public IntegratorServiceImpl( LinkedHashSet<Integrator> providedIntegrators, ClassLoaderService classLoaderService) { // register standard integrators. Envers and JPA, for example, need to be handled by discovery // because in // separate project/jars. addIntegrator(new BeanValidationIntegrator()); addIntegrator(new JaccIntegrator()); addIntegrator(new CollectionCacheInvalidator()); // register provided integrators for (Integrator integrator : providedIntegrators) { addIntegrator(integrator); } for (Integrator integrator : classLoaderService.loadJavaServices(Integrator.class)) { addIntegrator(integrator); } }
private static BasicTypeRegistry handleTypes(MetadataBuildingOptions options) { final ClassLoaderService classLoaderService = options.getServiceRegistry().getService(ClassLoaderService.class); // ultimately this needs to change a little bit to account for HHH-7792 final BasicTypeRegistry basicTypeRegistry = new BasicTypeRegistry(); final TypeContributions typeContributions = new TypeContributions() { public void contributeType(BasicType type) { basicTypeRegistry.register(type); } public void contributeType(BasicType type, String... keys) { basicTypeRegistry.register(type, keys); } public void contributeType(UserType type, String... keys) { basicTypeRegistry.register(type, keys); } public void contributeType(CompositeUserType type, String... keys) { basicTypeRegistry.register(type, keys); } }; // add Dialect contributed types final Dialect dialect = options.getServiceRegistry().getService(JdbcServices.class).getDialect(); dialect.contributeTypes(typeContributions, options.getServiceRegistry()); // add TypeContributor contributed types. for (TypeContributor contributor : classLoaderService.loadJavaServices(TypeContributor.class)) { contributor.contribute(typeContributions, options.getServiceRegistry()); } // add explicit application registered types for (BasicTypeRegistration basicTypeRegistration : options.getBasicTypeRegistrations()) { basicTypeRegistry.register( basicTypeRegistration.getBasicType(), basicTypeRegistration.getRegistrationKeys()); } return basicTypeRegistry; }
public MetadataBuilderImpl(MetadataSources sources, StandardServiceRegistry serviceRegistry) { this.sources = sources; this.options = new MetadataBuildingOptionsImpl(serviceRegistry); for (MetadataSourcesContributor contributor : sources .getServiceRegistry() .getService(ClassLoaderService.class) .loadJavaServices(MetadataSourcesContributor.class)) { contributor.contribute(sources); } // todo : not so sure this is needed anymore. // these should be set during the StandardServiceRegistryBuilder.configure call applyCfgXmlValues(serviceRegistry.getService(CfgXmlAccessService.class)); final ClassLoaderService classLoaderService = serviceRegistry.getService(ClassLoaderService.class); for (MetadataBuilderInitializer contributor : classLoaderService.loadJavaServices(MetadataBuilderInitializer.class)) { contributor.contribute(this, serviceRegistry); } }
/** * Builds the selector. * * @param classLoaderService The class loading service used to (attempt to) resolve any * un-registered strategy implementations. * @return The selector. */ public StrategySelector buildSelector(ClassLoaderService classLoaderService) { final StrategySelectorImpl strategySelector = new StrategySelectorImpl(classLoaderService); // build the baseline... addDialects(strategySelector); addJtaPlatforms(strategySelector); addTransactionFactories(strategySelector); addMultiTableBulkIdStrategies(strategySelector); // apply auto-discovered registrations for (AvailabilityAnnouncer announcer : classLoaderService.loadJavaServices(AvailabilityAnnouncer.class)) { for (Availability discoveredAvailability : announcer.getAvailabilities()) { applyFromAvailability(strategySelector, discoveredAvailability); } } // apply customizations for (Availability explicitAvailability : explicitAvailabilities) { applyFromAvailability(strategySelector, explicitAvailability); } return strategySelector; }