List of usage examples for javax.persistence.spi PersistenceUnitInfo getPersistenceProviderClassName
public String getPersistenceProviderClassName();
From source file:org.apache.openjpa.persistence.PersistenceProductDerivation.java
/** * Return whether the given persistence unit uses an OpenJPA provider. *//*from w w w . j a v a 2 s .c o m*/ private static boolean isOpenJPAPersistenceProvider(PersistenceUnitInfo pinfo, ClassLoader loader) { String provider = pinfo.getPersistenceProviderClassName(); if (StringUtils.isEmpty(provider) || PersistenceProviderImpl.class.getName().equals(provider)) return true; if (loader == null) loader = (ClassLoader) AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction()); try { if (PersistenceProviderImpl.class.isAssignableFrom(Class.forName(provider, false, loader))) return true; } catch (Throwable t) { log(_loc.get("unloadable-provider", provider, t).getMessage()); return false; } return false; }
From source file:org.apache.openjpa.persistence.PersistenceProductDerivation.java
/** * Warn the user that we could only find an unrecognized persistence * provider.//from w w w.j a va 2 s .c o m */ private static void warnUnknownProvider(PersistenceUnitInfo pinfo) { log(_loc.get("unrecognized-provider", pinfo.getPersistenceProviderClassName()).getMessage()); }
From source file:org.kie.server.services.jbpm.JbpmKieServerExtension.java
protected EntityManagerFactory build(Map<String, String> properties) { try {// w ww . j av a 2 s . co m InitialContext ctx = new InitialContext(); InputStream inputStream = PersistenceUnitInfoLoader.class.getResourceAsStream(PERSISTENCE_XML_LOCATION); PersistenceUnitInfo info = PersistenceUnitInfoLoader.load(inputStream, ctx, this.getClass().getClassLoader()); // prepare persistence unit root location URL root = PersistenceUnitInfoLoader.class.getResource(PERSISTENCE_XML_LOCATION); String jarLocation = root.toExternalForm().split("!")[0].replace(PERSISTENCE_XML_LOCATION, ""); try { ((PersistenceUnitInfoImpl) info).setPersistenceUnitRootUrl(new URL(jarLocation)); } catch (Exception e) { // in case setting URL to jar file location only fails, fallback to complete URL ((PersistenceUnitInfoImpl) info).setPersistenceUnitRootUrl(root); } // Need to explicitly set jtaDataSource here, its value is fetched in Hibernate logger before configuration ((PersistenceUnitInfoImpl) info).setJtaDataSource(properties.get("javax.persistence.jtaDataSource")); List<PersistenceProvider> persistenceProviders = PersistenceProviderResolverHolder .getPersistenceProviderResolver().getPersistenceProviders(); PersistenceProvider selectedProvider = null; if (persistenceProviders != null) { for (PersistenceProvider provider : persistenceProviders) { if (provider.getClass().getName().equals(info.getPersistenceProviderClassName())) { selectedProvider = provider; break; } } } return selectedProvider.createContainerEntityManagerFactory(info, properties); } catch (Exception e) { throw new RuntimeException("Unable to create EntityManagerFactory due to " + e.getMessage(), e); } }