public GridDialect newInstance()

in core/src/main/java/org/hibernate/ogm/dialect/impl/GridDialectInitiator.java [79:119]


		public GridDialect newInstance(Class<? extends GridDialect> clazz) {
			try {
				// FIXME not sure I like this constructor business. Argue with Sanne
				// to me that's blocking the doors for future enhancements (ie injecting more things)
				// an alternative is to pass the ServiceRegistry verbatim but I'm not sure that's enough either
				Constructor<?> injector = null;
				for ( Constructor<?> constructor : clazz.getConstructors() ) {
					Class<?>[] parameterTypes = constructor.getParameterTypes();
					if ( parameterTypes.length == 1 && DatastoreProvider.class.isAssignableFrom( parameterTypes[0] ) ) {
						injector = constructor;
						break;
					}
				}
				if ( injector == null ) {
					throw log.gridDialectHasNoProperConstructor( clazz );
				}
				GridDialect gridDialect = (GridDialect) injector.newInstance( datastore );

				if ( errorHandlerConfigured ) {
					gridDialect = new InvocationCollectingGridDialect( gridDialect, eventContext );
				}

				if ( GridDialects.hasFacet( gridDialect, BatchableGridDialect.class ) ||
						GridDialects.hasFacet( gridDialect, GroupingByEntityDialect.class ) ) {
					gridDialect = new BatchOperationsDelegator( gridDialect, eventContext );
				}

				log.useGridDialect( gridDialect.getClass() );
				if ( GridDialectLogger.activationNeeded() ) {
					gridDialect = new GridDialectLogger( gridDialect );
					log.info( "Grid dialect logs are active" );
				}
				else {
					log.info( "Grid dialect logs are disabled" );
				}
				return gridDialect;
			}
			catch ( Exception e ) {
				throw log.cannotInstantiateGridDialect( clazz, e );
			}
		}