private boolean isBeanValidationApiAvailable(ClassLoaderService classLoaderService) { try { classLoaderService.classForName( BV_CHECK_CLASS ); return true; } catch (Exception e) { return false; } }
@Override public URL locateResource(String resourceName) { return classLoaderService.locateResource( resourceName ); }
for ( JtaPlatformProvider provider : classLoaderService.loadJavaServices( JtaPlatformProvider.class ) ) { final JtaPlatform providedPlatform = provider.getProvidedJtaPlatform(); log.tracef( "Located JtaPlatformProvider [%s] provided JtaPlaform : %s", provider, providedPlatform ); classLoaderService.classForName( WildFlyStandAloneJtaPlatform.WILDFLY_TM_CLASS_NAME ); classLoaderService.classForName( WildFlyStandAloneJtaPlatform.WILDFLY_UT_CLASS_NAME ); classLoaderService.classForName( JBossStandAloneJtaPlatform.JBOSS_TM_CLASS_NAME ); classLoaderService.classForName( JBossStandAloneJtaPlatform.JBOSS_UT_CLASS_NAME ); classLoaderService.classForName( AtomikosJtaPlatform.TM_CLASS_NAME ); return new AtomikosJtaPlatform(); classLoaderService.classForName( BitronixJtaPlatform.TM_CLASS_NAME ); return new BitronixJtaPlatform(); classLoaderService.classForName( JOnASJtaPlatform.TM_CLASS_NAME ); return new JOnASJtaPlatform(); classLoaderService.classForName( JOTMJtaPlatform.TM_CLASS_NAME ); return new JOTMJtaPlatform(); classLoaderService.classForName(WebSphereLibertyJtaPlatform.TMF_CLASS_NAME); return new WebSphereLibertyJtaPlatform(); : WebSphereJtaPlatform.WebSphereEnvironment.values() ) { try { Class accessClass = classLoaderService.classForName( webSphereEnvironment.getTmAccessClassName() ); return new WebSphereJtaPlatform( accessClass, webSphereEnvironment );
final URL url = classLoaderService.locateResource( name ); if ( url == null ) { throw new MappingException( classLoaderService.<AttributeConverter>classForName( classDescriptor.getName() ) final URL classFileUrl = classLoaderService.locateResource( classFileName ); if ( classFileUrl != null ) { managedResources.addAnnotatedClassName( unresolvedListedClassName ); final URL packageInfoFileUrl = classLoaderService.locateResource( packageInfoFileName ); if ( packageInfoFileUrl != null ) { managedResources.addAnnotatedPackageName( unresolvedListedClassName );
private void applyServiceContributors() { final Iterable<ServiceContributor> serviceContributors = bootstrapServiceRegistry.getService( ClassLoaderService.class ) .loadJavaServices( ServiceContributor.class ); for ( ServiceContributor serviceContributor : serviceContributors ) { serviceContributor.contribute( this ); } }
private InputStream resolveInLocalNamespace(String path) { try { return classLoaderService.locateResourceStream( path ); } catch ( Throwable t ) { return null; } }
public XMLHelper(ClassLoaderService classLoaderService) { this.documentFactory = classLoaderService.workWithClassLoader( new ClassLoaderService.Work<DocumentFactory>() { @Override public DocumentFactory doWork(ClassLoader classLoader) { final ClassLoader originalTccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( classLoader ); return DocumentFactory.getInstance(); } finally { Thread.currentThread().setContextClassLoader( originalTccl ); } } } ); }
final URL url = classLoaderService.locateResource( name ); if ( url == null ) { throw new MappingException( classLoaderService.classForName( classDescriptor.getName() ), bootstrapContext.getClassmateContext() final URL classFileUrl = classLoaderService.locateResource( classFileName ); if ( classFileUrl != null ) { managedResources.addAnnotatedClassName( unresolvedListedClassName ); final URL packageInfoFileUrl = classLoaderService.locateResource( packageInfoFileName ); if ( packageInfoFileUrl != null ) { managedResources.addAnnotatedPackageName( unresolvedListedClassName );
/** * In case a custom {@link MetadataBuilderFactory} creates a custom builder, return that one, otherwise the default * builder. */ private MetadataBuilder getCustomBuilderOrDefault(MetadataBuilderImpl defaultBuilder) { final ClassLoaderService cls = serviceRegistry.getService( ClassLoaderService.class ); final java.util.Collection<MetadataBuilderFactory> discoveredBuilderFactories = cls.loadJavaServices( MetadataBuilderFactory.class ); MetadataBuilder builder = null; List<String> activeFactoryNames = null; for ( MetadataBuilderFactory discoveredBuilderFactory : discoveredBuilderFactories ) { final MetadataBuilder returnedBuilder = discoveredBuilderFactory.getMetadataBuilder( this, defaultBuilder ); if ( returnedBuilder != null ) { if ( activeFactoryNames == null ) { activeFactoryNames = new ArrayList<>(); } activeFactoryNames.add( discoveredBuilderFactory.getClass().getName() ); builder = returnedBuilder; } } if ( activeFactoryNames != null && activeFactoryNames.size() > 1 ) { throw new HibernateException( "Multiple active MetadataBuilder definitions were discovered : " + String.join(", ", activeFactoryNames) ); } return builder != null ? builder : defaultBuilder; }
private Reader getConfigStreamReader(String resource) { return new InputStreamReader( classLoaderService.locateResourceStream( resource ) ); }
public XMLHelper(ClassLoaderService classLoaderService) { this.documentFactory = classLoaderService.workWithClassLoader( new ClassLoaderService.Work<DocumentFactory>() { @Override public DocumentFactory doWork(ClassLoader classLoader) { final ClassLoader originalTccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( classLoader ); return DocumentFactory.getInstance(); } finally { Thread.currentThread().setContextClassLoader( originalTccl ); } } } ); }
public static Class cdiBeanManagerClass(ClassLoaderService classLoaderService) throws ClassLoadingException { return classLoaderService.classForName( "javax.enterprise.inject.spi.BeanManager" ); }
for ( JtaPlatformProvider provider : classLoaderService.loadJavaServices( JtaPlatformProvider.class ) ) { final JtaPlatform providedPlatform = provider.getProvidedJtaPlatform(); log.tracef( "Located JtaPlatformProvider [%s] provided JtaPlaform : %s", provider, providedPlatform ); classLoaderService.classForName( WildFlyStandAloneJtaPlatform.WILDFLY_TM_CLASS_NAME ); classLoaderService.classForName( WildFlyStandAloneJtaPlatform.WILDFLY_UT_CLASS_NAME ); classLoaderService.classForName( JBossStandAloneJtaPlatform.JBOSS_TM_CLASS_NAME ); classLoaderService.classForName( JBossStandAloneJtaPlatform.JBOSS_UT_CLASS_NAME ); classLoaderService.classForName( AtomikosJtaPlatform.TM_CLASS_NAME ); return new AtomikosJtaPlatform(); classLoaderService.classForName( BitronixJtaPlatform.TM_CLASS_NAME ); return new BitronixJtaPlatform(); classLoaderService.classForName( JOnASJtaPlatform.TM_CLASS_NAME ); return new JOnASJtaPlatform(); classLoaderService.classForName( JOTMJtaPlatform.TM_CLASS_NAME ); return new JOTMJtaPlatform(); classLoaderService.classForName(WebSphereLibertyJtaPlatform.TMF_CLASS_NAME); return new WebSphereLibertyJtaPlatform(); : WebSphereJtaPlatform.WebSphereEnvironment.values() ) { try { Class accessClass = classLoaderService.classForName( webSphereEnvironment.getTmAccessClassName() ); return new WebSphereJtaPlatform( accessClass, webSphereEnvironment );
private ScriptSourceInput interpretLegacyImportScriptSetting( String resourceName, ClassLoaderService classLoaderService, String charsetName) { try { final URL resourceUrl = classLoaderService.locateResource( resourceName ); if ( resourceUrl == null ) { return ScriptSourceInputNonExistentImpl.INSTANCE; } else { return new ScriptSourceInputFromUrl( resourceUrl, charsetName ); } } catch (Exception e) { throw new SchemaManagementException( "Error resolving legacy import resource : " + resourceName, e ); } }
@Override public SessionFactoryBuilder getSessionFactoryBuilder() { final SessionFactoryBuilderImpl defaultBuilder = new SessionFactoryBuilderImpl( this, bootstrapContext ); final ClassLoaderService cls = metadataBuildingOptions.getServiceRegistry().getService( ClassLoaderService.class ); final java.util.Collection<SessionFactoryBuilderFactory> discoveredBuilderFactories = cls.loadJavaServices( SessionFactoryBuilderFactory.class ); SessionFactoryBuilder builder = null; List<String> activeFactoryNames = null; for ( SessionFactoryBuilderFactory discoveredBuilderFactory : discoveredBuilderFactories ) { final SessionFactoryBuilder returnedBuilder = discoveredBuilderFactory.getSessionFactoryBuilder( this, defaultBuilder ); if ( returnedBuilder != null ) { if ( activeFactoryNames == null ) { activeFactoryNames = new ArrayList<>(); } activeFactoryNames.add( discoveredBuilderFactory.getClass().getName() ); builder = returnedBuilder; } } if ( activeFactoryNames != null && activeFactoryNames.size() > 1 ) { throw new HibernateException( "Multiple active SessionFactoryBuilderFactory definitions were discovered : " + String.join(", ", activeFactoryNames) ); } if ( builder != null ) { return builder; } return defaultBuilder; }
private Properties getConfigProperties(String resource) { try { Properties properties = new Properties(); properties.load( classLoaderService.locateResourceStream( resource ) ); return properties; } catch (IOException e) { throw new HibernateException( "Unable to load properties from specified config file: " + resource, e ); } }
public static ConfigurationBuilderHolder loadConfiguration(ServiceRegistry registry, String config) { ClassLoaderService.Work<ConfigurationBuilderHolder> work = classLoader -> { ClassLoader infinispanClassLoader = InfinispanProperties.class.getClassLoader(); try (InputStream input = lookupFile(config, classLoader, infinispanClassLoader)) { return parse(input, infinispanClassLoader); } catch (IOException e) { throw LOGGER.unableToCreateCacheManager(e); } }; return registry.getService(ClassLoaderService.class).workWithClassLoader(work); }
private Class loadTypeSafeActivatorClass(ClassLoaderService classLoaderService) { try { return classLoaderService.classForName( ACTIVATOR_CLASS_NAME ); } catch (Exception e) { throw new HibernateException( "Unable to load TypeSafeActivator class", e ); } }
expect( mockClassLoaderService.classForName( "javax.persistence.Id" ) ) .andReturn( Object.class ) .anyTimes(); expect( mockClassLoaderService.classForName( "javax.persistence.EmbeddedId" ) ) .andReturn( Object.class ) .anyTimes(); expect( mockClassLoaderService.loadJavaServices( LuceneQueryTranslator.class ) ) .andReturn( Collections.<LuceneQueryTranslator>emptySet() ); expect( mockClassLoaderService.loadJavaServices( IndexManagerTypeSpecificBridgeProvider.class ) ) .andReturn( Collections.<IndexManagerTypeSpecificBridgeProvider>emptySet() ); expect( mockClassLoaderService.loadJavaServices( BridgeProvider.class ) ) .andReturn( Collections.<BridgeProvider>emptySet() ); expect( mockClassLoaderService.classForName( startsWith( "java.time" ) ) ) .andThrow( new ClassLoadingException( "Called by JavaTimeBridgeProvider; we assume the classes in java.time are not on the ORM class loader" ) ) .anyTimes();
private Schema resolveLocalSchema(String schemaName, String schemaLanguage) { URL url = classLoaderService.locateResource( schemaName ); if ( url == null ) { throw new XsdException( "Unable to locate schema [" + schemaName + "] via classpath", schemaName );