/** * Construct properties with given parent. Application and domain class loaders will be * initialized to the ones of the parent. * * @param parent Parent properties. */ protected AbstractProperties(final AbstractProperties parent) { _applicationClassLoader = parent.getApplicationClassLoader(); _domainClassLoader = parent.getDomainClassLoader(); _parent = parent; }
/** * Construct an instance of CacheFactoryRegistry that uses given properties * to get required configuration properties. * * @param properties The properties. */ public CacheFactoryRegistry(final AbstractProperties properties) { Object[] objects = properties.getObjectArray( CPAProperties.CACHE_FACTORIES, properties.getApplicationClassLoader()); for (int i = 0; i < objects.length; i++) { CacheFactory factory = (CacheFactory) objects[i]; _cacheFactories.put(factory.getCacheType(), factory); } }
/** * Create a new registry instance of key generator factories. The registry will be initialized * with all key generator factories specified through <b>KEYGENERATOR_FACTORIES</b> property * of given properties. * * @param properties The properties to use. */ public KeyGeneratorFactoryRegistry(final AbstractProperties properties) { Object[] objects = properties.getObjectArray( CPAProperties.KEYGENERATOR_FACTORIES, properties.getApplicationClassLoader()); for (int i = 0; i < objects.length; i++) { KeyGeneratorFactory factory = (KeyGeneratorFactory) objects[i]; _factories.put(factory.getKeyGeneratorName(), factory); } }
/** * Load the {@link TxSynchronizable} implementations from the * properties file, if not loaded before. */ protected void loadSynchronizables() { if (_synchronizables == null) { _synchronizables = new ArrayList<TxSynchronizable>(); AbstractProperties properties = CPAProperties.getInstance(); Object[] objects = properties.getObjectArray( CPAProperties.TX_SYNCHRONIZABLE, properties.getApplicationClassLoader()); if (objects != null) { for (int i = 0; i < objects.length; i++) { TxSynchronizable sync = (TxSynchronizable) objects[i]; _synchronizables.add(sync); } } if (_synchronizables.size() == 0) { _synchronizables = null; } } }
/** * Construct an instance of TransactionManagerFactoryRegistry that loads the * {@link TransactionManagerFactory} implementations specified in the given * properties. * * @param properties The properties. */ public TransactionManagerFactoryRegistry(final AbstractProperties properties) { ClassLoader loader = properties.getApplicationClassLoader(); Object[] objects = properties.getObjectArray( CPAProperties.TRANSACTION_MANAGER_FACTORIES, loader); for (int i = 0; i < objects.length; i++) { TransactionManagerFactory factory = (TransactionManagerFactory) objects[i]; _factories.put(factory.getName(), factory); } }
/** * Load the factories from the properties file, if not loaded before. */ private static synchronized void load() { if (_factories == null) { _factories = new Hashtable<String, PersistenceFactory>(); AbstractProperties properties = CPAProperties.getInstance(); Object[] objects = properties.getObjectArray( CPAProperties.PERSISTENCE_FACTORIES, properties.getApplicationClassLoader()); for (int i = 0; i < objects.length; i++) { PersistenceFactory factory = (PersistenceFactory) objects[i]; _factories.put(factory.getFactoryName(), factory); } } }
/** * Create a new registry instance of type convertors. The registry will be initialized * with all type convertors specified through <b>TYPE_CONVERTORS</b> property of given * properties. The properties get also passed to the type converters for them to * get any required property. * * @param properties The properties to use. */ public TypeConvertorRegistry(final AbstractProperties properties) { Object[] objects = properties.getObjectArray( CPAProperties.TYPE_CONVERTORS, properties.getApplicationClassLoader()); for (int i = 0; i < objects.length; i++) { TypeConvertor convertor = (TypeConvertor) objects[i]; convertor.configure(properties); putConvertor(convertor.fromType(), convertor.toType(), convertor); } }