/** * Return a new configuration instance for this runtime. Configuration * data is maintained at the factory level and is available to all OpenJPA * components; therefore it is a good place to maintain shared resources * such as connection pools, etc. */ protected OpenJPAConfiguration newConfiguration() { return new OpenJPAConfigurationImpl(); }
public void instantiateAll() { super.instantiateAll(); getMetaDataRepositoryInstance(); getRemoteCommitEventManager(); getAuditorInstance(); cacheMarshallerPlugins.initialize(); if (isInitializeEagerly()) { getConnectionFactory(); getConnectionFactory2(); } }
public Log getConfigurationLog() { return getLog(LOG_RUNTIME); }
classResolverPlugin = addPlugin("ClassResolver", true); aliases = new String[] { "default", addValue(brokerFactoryPlugin); addValue(brokerPlugin); dataCacheManagerPlugin = addPlugin("DataCacheManager", true); aliases = new String[] { "default", DataCacheManagerImpl.class.getName(), }; dataCachePlugin = addPlugin("DataCache", false); aliases = new String[] { "false", null, dataCacheTimeout = addInt("DataCacheTimeout"); dataCacheTimeout.setDefault("-1"); dataCacheTimeout.set(-1); dataCacheTimeout.setDynamic(true); queryCachePlugin = addPlugin("QueryCache", true); aliases = new String[] { "true", ConcurrentQueryCache.class.getName(), dynamicDataStructs = addBoolean("DynamicDataStructs"); dynamicDataStructs.setDefault("false"); dynamicDataStructs.set(false);
conf.metaFactoryPlugin.setAlias(SPEC_JPA.getName(), PersistenceMetaDataFactory.class.getName()); conf.addValue(new EntityManagerFactoryValue()); conf.dataCacheMode = conf.addString(JPAProperties.CACHE_MODE); conf.dataCacheMode.setDefault(DataCacheMode.UNSPECIFIED.toString()); conf.dataCacheMode.set(DataCacheMode.UNSPECIFIED.toString());
conf.validationFactory = conf.addObject(JPAProperties.VALIDATE_FACTORY); conf.validator = conf.addObject("Validator"); conf.validationMode = conf.addString(JPAProperties.VALIDATE_MODE); conf.validationGroupPrePersist = conf.addString(JPAProperties.VALIDATE_PRE_PERSIST); conf.validationGroupPreUpdate = conf.addString(JPAProperties.VALIDATE_PRE_UPDATE); conf.validationGroupPreRemove = conf.addString(JPAProperties.VALIDATE_PRE_REMOVE);
public void setPersistenceEnvironmentInfo(OpenJPAConfiguration conf, PersistenceUnitInfo pui) { // OPENJPA-1460 Fix scope visibility of orm.xml when it is packaged in both ear file and war file if (conf instanceof OpenJPAConfigurationImpl) { Map<String, Object> peMap =((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment(); if (peMap == null) { peMap = new HashMap<String, Object>(); ((OpenJPAConfigurationImpl)conf).setPersistenceEnvironment(peMap); } peMap.put(AbstractCFMetaDataFactory.PERSISTENCE_UNIT_ROOT_URL, pui.getPersistenceUnitRootUrl()); peMap.put(AbstractCFMetaDataFactory.MAPPING_FILE_NAMES, pui.getMappingFileNames()); peMap.put(AbstractCFMetaDataFactory.JAR_FILE_URLS, pui.getJarFileUrls()); } }
public LifecycleEventManager getLifecycleEventManagerInstance() { LifecycleEventManager lem = null; if (!getCompatibilityInstance().isSingletonLifecycleEventManager() || (lem = (LifecycleEventManager)lifecycleEventManager.get()) == null) { lem = (LifecycleEventManager)lifecycleEventManager .instantiate(LifecycleEventManager.class, this); } return lem; }
/** * Create the connection factory if necessary. */ private DecoratingDataSource createConnectionFactory() { DataSource ds = (DataSource) connectionFactory.get(); if (ds != null) return setupConnectionFactory(ds, false); ds = (DataSource) super.getConnectionFactory(); // JNDI lookup if (ds == null) ds = DataSourceFactory.newDataSource(this, false); return setupConnectionFactory(ds, false); }
public Object getConnectionFactory2() { // override to configure data source if (dataSource2 == null) { // superclass will lookup from JNDI. DataSource ds = (DataSource) super.getConnectionFactory2(); if (ds == null) { // the driver name is always required, so if not specified, // then no connection factory 2 String driver = getConnection2DriverName(); if (!StringUtils.isEmpty(driver)) ds = DataSourceFactory.newDataSource(this, true); } if (ds != null) { DecoratingDataSource dds = setupConnectionFactory(ds, true); // before dict dataSource2 = DataSourceFactory.installDBDictionary (getDBDictionaryInstance(), dds, this, true); } } return dataSource2; }
Map peMap = null; if (conf instanceof OpenJPAConfigurationImpl) peMap = ((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment(); URL puUrl = peMap == null ? null : (URL) peMap.get(PERSISTENCE_UNIT_ROOT_URL); List<String> mappingFileNames =
@Override public boolean beforeConfigurationLoad(Configuration c) { if (!(c instanceof OpenJPAConfigurationImpl)) return false; OpenJPAConfigurationImpl conf = (OpenJPAConfigurationImpl) c; conf.metaFactoryPlugin.setAlias(ALIAS_EJB, PersistenceMetaDataFactory.class.getName()); conf.metaFactoryPlugin.setAlias(SPEC_JPA, PersistenceMetaDataFactory.class.getName()); conf.addValue(new EntityManagerFactoryValue()); return true; }
@Override public boolean beforeConfigurationLoad(Configuration config) { if (!(config instanceof OpenJPAConfiguration)) { return false; } final OpenJPAConfigurationImpl openJpaConfig = (OpenJPAConfigurationImpl) config; // Compass can make use of changed object IDs when receiving remote // commit events; reset the default setting to true. openJpaConfig.remoteProviderPlugin.setTransmitPersistedObjectIds(true); // In 0.x releases of OpenJPA, the BrokerFactoryEventManager does not exist. // This check will prevent us from triggering a NoSuchMethodError. if (!isReleasedVersion()) { openJpaConfig.getLog(OpenJPAConfiguration.LOG_RUNTIME).warn( "Compass cannot automatically install itself into pre-1.0 versions of OpenJPA. To complete " + "Compass installation, you must invoke CompassProductDerivation.installCompass()."); derivations.put(openJpaConfig, this); return false; } openJpaConfig.getBrokerFactoryEventManager().addListener(new BrokerFactoryListener() { public void afterBrokerFactoryCreate(BrokerFactoryEvent event) { installIntoFactory(event.getBrokerFactory()); } public void eventFired(BrokerFactoryEvent event) { if (event.getEventType() == BrokerFactoryEvent.BROKER_FACTORY_CREATED) afterBrokerFactoryCreate(event); } }); return false; }
classResolverPlugin = addPlugin("ClassResolver", true); aliases = new String[] { "default", "org.apache.openjpa.util.ClassResolverImpl", addValue(brokerFactoryPlugin); addValue(brokerPlugin); dataCacheManagerPlugin = addPlugin("DataCacheManager", true); aliases = new String[] { "default", DataCacheManagerImpl.class.getName(), }; cacheDistributionPolicyPlugin = addPlugin("CacheDistributionPolicy", true); aliases = new String[] { "default", "org.apache.openjpa.datacache.DefaultCacheDistributionPolicy", dataCachePlugin = addPlugin("DataCache", false); aliases = new String[] { "false", null, dataCacheTimeout = addInt("DataCacheTimeout"); dataCacheTimeout.setDefault("-1"); dataCacheTimeout.set(-1); dataCacheTimeout.setDynamic(true); queryCachePlugin = addPlugin("QueryCache", false); aliases = new String[] { "false", null,
conf.metaFactoryPlugin.setAlias(SPEC_JPA.getName(), PersistenceMetaDataFactory.class.getName()); conf.addValue(new EntityManagerFactoryValue()); conf.dataCacheMode = conf.addString(JPAProperties.CACHE_MODE); conf.dataCacheMode.setDefault(DataCacheMode.UNSPECIFIED.toString()); conf.dataCacheMode.set(DataCacheMode.UNSPECIFIED.toString());
conf.validationFactory = conf.addObject(JPAProperties.VALIDATE_FACTORY); conf.validator = conf.addObject("Validator"); conf.validationMode = conf.addString(JPAProperties.VALIDATE_MODE); conf.validationGroupPrePersist = conf.addString(JPAProperties.VALIDATE_PRE_PERSIST); conf.validationGroupPreUpdate = conf.addString(JPAProperties.VALIDATE_PRE_UPDATE); conf.validationGroupPreRemove = conf.addString(JPAProperties.VALIDATE_PRE_REMOVE);
public void setPersistenceEnvironmentInfo(OpenJPAConfiguration conf, PersistenceUnitInfo pui) { // OPENJPA-1460 Fix scope visibility of orm.xml when it is packaged in both ear file and war file if (conf instanceof OpenJPAConfigurationImpl) { Map<String, Object> peMap =((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment(); if (peMap == null) { peMap = new HashMap<String, Object>(); ((OpenJPAConfigurationImpl)conf).setPersistenceEnvironment(peMap); } peMap.put(AbstractCFMetaDataFactory.PERSISTENCE_UNIT_ROOT_URL, pui.getPersistenceUnitRootUrl()); peMap.put(AbstractCFMetaDataFactory.MAPPING_FILE_NAMES, pui.getMappingFileNames()); peMap.put(AbstractCFMetaDataFactory.JAR_FILE_URLS, pui.getJarFileUrls()); } }
public LifecycleEventManager getLifecycleEventManagerInstance() { LifecycleEventManager lem = null; if (!getCompatibilityInstance().isSingletonLifecycleEventManager() || (lem = (LifecycleEventManager)lifecycleEventManager.get()) == null) { lem = (LifecycleEventManager)lifecycleEventManager .instantiate(LifecycleEventManager.class, this); } return lem; }
/** * Create the connection factory if necessary. */ public DecoratingDataSource createConnectionFactory() { DataSource ds = (DataSource) connectionFactory.get(); Log log = getLog(LOG_JDBC); if (ds != null) { if (log.isTraceEnabled()) log.trace("createConnectionFactory: DataSource:" + ds); return setupConnectionFactory(ds, false); } if (log.isTraceEnabled()) log.trace("createConnectionFactory: connectionFactory not created yet, attempt JNDI lookup..."); ds = (DataSource) super.getConnectionFactory(); // JNDI lookup if (ds == null) { if (log.isTraceEnabled()) log.trace("createConnectionFactory: JNDI lookup failed, attempt DataSource properties..."); ds = DataSourceFactory.newDataSource(this, false); } if (log.isTraceEnabled()) log.trace("createConnectionFactory: DataSource="+ds); return setupConnectionFactory(ds, false); }
Object obj = super.getConnectionFactory2(); DataSource ds = null; if (obj != null) {