public SearchableCacheConfiguration(Class<?>[] classArray, Properties properties, EmbeddedCacheManager uninitializedCacheManager, ComponentRegistry cr) { this.providedServices = initializeProvidedServices(uninitializedCacheManager, cr); if (properties == null) { this.properties = new Properties(); } else { this.properties = augment(properties); } classes = new HashMap<>(); for (Class<?> c : classArray) { String classname = c.getName(); classes.put(classname, c); } if (hasAffinity) { ErrorHandler configuredErrorHandler = ErrorHandlerFactory.createErrorHandler(this); this.properties.put(Environment.ERROR_HANDLER, new AffinityErrorHandler(configuredErrorHandler)); } //deal with programmatic mapping: searchMapping = SearchMappingHelper.extractSearchMapping(this); //if we have a SearchMapping then we can predict at least those entities specified in the mapping //and avoid further SearchFactory rebuilds triggered by new entity discovery during cache events if (searchMapping != null) { Set<Class<?>> mappedEntities = searchMapping.getMappedEntities(); for (Class<?> entity : mappedEntities) { classes.put(entity.getName(), entity); } } }
/** * @param searchConfiguration The configuration that may specify an ErrorHandler * @return ErrorHandler specified in the {@link SearchConfiguration} or the default one in case not specified. */ public static ErrorHandler createErrorHandler(SearchConfiguration searchConfiguration) { Object configuredErrorHandler = searchConfiguration.getProperties().get( Environment.ERROR_HANDLER ); if ( configuredErrorHandler == null ) { return getDefault(); } if ( configuredErrorHandler instanceof String ) { return createErrorHandlerFromString( (String) configuredErrorHandler, searchConfiguration.getClassLoaderService() ); } else if ( configuredErrorHandler instanceof ErrorHandler ) { return (ErrorHandler) configuredErrorHandler; } else { throw LoggerFactory.make( MethodHandles.lookup() ).unsupportedErrorHandlerConfigurationValueType( configuredErrorHandler.getClass() ); } }
private static ErrorHandler createErrorHandlerFromString( String errorHandlerClassName, ClassLoaderService classLoaderService) { if ( StringHelper.isEmpty( errorHandlerClassName ) || ErrorHandler.LOG.equals( errorHandlerClassName.trim() ) ) { return getDefault(); } else { Class<?> errorHandlerClass = classLoaderService.classForName( errorHandlerClassName ); return ClassLoaderHelper.instanceFromClass( ErrorHandler.class, errorHandlerClass, "Error Handler" ); } }
private static ErrorHandler createErrorHandlerFromString( String errorHandlerClassName, ClassLoaderService classLoaderService) { if ( StringHelper.isEmpty( errorHandlerClassName ) || ErrorHandler.LOG.equals( errorHandlerClassName.trim() ) ) { return getDefault(); } else { Class<?> errorHandlerClass = classLoaderService.classForName( errorHandlerClassName ); return ClassLoaderHelper.instanceFromClass( ErrorHandler.class, errorHandlerClass, "Error Handler" ); } }
ErrorHandler configuredErrorHandler = ErrorHandlerFactory.createErrorHandler(this); this.properties.put(Environment.ERROR_HANDLER, new AffinityErrorHandler(configuredErrorHandler));
/** * @param searchConfiguration The configuration that may specify an ErrorHandler * @return ErrorHandler specified in the {@link SearchConfiguration} or the default one in case not specified. */ public static ErrorHandler createErrorHandler(SearchConfiguration searchConfiguration) { Object configuredErrorHandler = searchConfiguration.getProperties().get( Environment.ERROR_HANDLER ); if ( configuredErrorHandler == null ) { return getDefault(); } if ( configuredErrorHandler instanceof String ) { return createErrorHandlerFromString( (String) configuredErrorHandler, searchConfiguration.getClassLoaderService() ); } else if ( configuredErrorHandler instanceof ErrorHandler ) { return (ErrorHandler) configuredErrorHandler; } else { throw LoggerFactory.make().unsupportedErrorHandlerConfigurationValueType( configuredErrorHandler.getClass() ); } }
private void createCleanFactoryState(SearchConfiguration cfg, BuildContext buildContext) { if ( rootFactory == null ) { //set the mutable structure of factory state rootFactory = new MutableSearchFactory(); factoryState.setDocumentBuildersIndexedEntities( IndexedTypeMaps.concurrentHashMap() ); factoryState.setDocumentBuildersContainedEntities( IndexedTypeMaps.concurrentHashMap() ); factoryState.setConfiguredTypeHierarchy( new TypeHierarchy() ); factoryState.setIndexedTypeHierarchy( new TypeHierarchy() ); factoryState.setConfigurationProperties( cfg.getProperties() ); factoryState.setServiceManager( new StandardServiceManager( cfg, buildContext, Environment.DEFAULT_SERVICES_MAP ) ); factoryState.setAllIndexesManager( new IndexManagerHolder() ); factoryState.setErrorHandler( ErrorHandlerFactory.createErrorHandler( cfg ) ); factoryState.setInstanceInitializer( cfg.getInstanceInitializer() ); factoryState.setTimingSource( new DefaultTimingSource() ); factoryState.setIndexMetadataComplete( cfg.isIndexMetadataComplete() ); factoryState.setTransactionManagerExpected( cfg.isTransactionManagerExpected() ); factoryState.setDeleteByTermEnforced( cfg.isDeleteByTermEnforced() ); factoryState.setIdProvidedImplicit( cfg.isIdProvidedImplicit() ); factoryState.setMultitenancyEnabled( cfg.isMultitenancyEnabled() ); } }
private void createCleanFactoryState(SearchConfiguration cfg, BuildContext buildContext) { if ( rootFactory == null ) { //set the mutable structure of factory state rootFactory = new MutableSearchFactory(); factoryState.setDocumentBuildersIndexedEntities( IndexedTypeMaps.concurrentHashMap() ); factoryState.setDocumentBuildersContainedEntities( IndexedTypeMaps.concurrentHashMap() ); factoryState.setConfiguredTypeHierarchy( new TypeHierarchy() ); factoryState.setIndexedTypeHierarchy( new TypeHierarchy() ); factoryState.setConfigurationProperties( cfg.getProperties() ); factoryState.setServiceManager( new StandardServiceManager( cfg, buildContext, Environment.DEFAULT_SERVICES_MAP ) ); factoryState.setAllIndexesManager( new IndexManagerHolder() ); factoryState.setErrorHandler( ErrorHandlerFactory.createErrorHandler( cfg ) ); factoryState.setInstanceInitializer( cfg.getInstanceInitializer() ); factoryState.setTimingSource( new DefaultTimingSource() ); factoryState.setIndexMetadataComplete( cfg.isIndexMetadataComplete() ); factoryState.setTransactionManagerExpected( cfg.isTransactionManagerExpected() ); factoryState.setDeleteByTermEnforced( cfg.isDeleteByTermEnforced() ); factoryState.setIdProvidedImplicit( cfg.isIdProvidedImplicit() ); factoryState.setMultitenancyEnabled( cfg.isMultitenancyEnabled() ); } }