Package org.castor.core.util

Examples of org.castor.core.util.AbstractProperties


    public void testGetCache() throws CacheAcquireException {
        Logger logger = Logger.getLogger(CacheFactoryRegistry.class);
        Level level = logger.getLevel();
       
        AbstractProperties properties = CPAProperties.newInstance();
        _registry = new CacheFactoryRegistry(properties);
       
        Cache cache = null;
       
        if (DISABLE_LOGGING) { logger.setLevel(Level.FATAL); }
View Full Code Here


            StringTokenizer tokenizer;
            Class           infoClass;
            Method          method;

            allInfo = new Vector();
            AbstractProperties properties = XMLProperties.newInstance();
            tokenizer = new StringTokenizer(properties.getString(XMLProperties.COLLECTION_HANDLERS_FOR_JAVA_11_OR_12, ""), ", ");
// Joachim 2007-09-01 old local configuration is dead!
//            LocalConfiguration config = LocalConfiguration.getInstance();
//            tokenizer = new StringTokenizer( config.getProperty( "org.exolab.castor.mapping.collections", "" ), ", " );
            while ( tokenizer.hasMoreTokens() ) {
                try {
View Full Code Here

        assertEquals("org.castor.transactionmanager.Factories",
                CPAProperties.TRANSACTION_MANAGER_FACTORIES);
       
        Object temp = new TransactionManagerFactoryDummy();
       
        AbstractProperties properties = CPAProperties.newInstance();
        Object mem = properties.getObject(CPAProperties.TRANSACTION_MANAGER_FACTORIES);
        properties.put(CPAProperties.TRANSACTION_MANAGER_FACTORIES,
                "org.castor.transactionmanager.LocalTransactionManagerFactory, "
                + TransactionManagerFactoryDummy.class.getName());
       
        TransactionManagerFactoryRegistry registry;
        registry = new TransactionManagerFactoryRegistry(properties);
       
        String[] names = registry.getTransactionManagerFactoryNames();
        assertEquals(2, names.length);
        assertTrue("local".equals(names[0]) || "local".equals(names[1]));
        assertTrue("dummy".equals(names[0]) || "dummy".equals(names[1]));
       
        TransactionManagerFactory factory = null;
        try {
            factory = registry.getTransactionManagerFactory("unknown");
            fail("A TransactionManagerAcquireException without cause "
               + "should have been thrown.");
        } catch (TransactionManagerAcquireException ex) {
            assertNull(factory);
        }

        try {
            factory = registry.getTransactionManagerFactory("dummy");
            assertTrue(factory instanceof TransactionManagerFactoryDummy);
        } catch (TransactionManagerAcquireException ex) {
            fail("Unexpected TransactionManagerAcquireException.");
        }
       
        properties.put(CPAProperties.TRANSACTION_MANAGER_FACTORIES, mem);

        logger.setLevel(level);
    }
View Full Code Here

        if (DISABLE_LOGGING) { logger.setLevel(Level.FATAL); }

        assertEquals("org.castor.transactionmanager.InitializeAtRegistration",
                CPAProperties.TRANSACTION_MANAGER_INIT);
       
        AbstractProperties properties = CPAProperties.getInstance();
        String memF = properties.getString(CPAProperties.TRANSACTION_MANAGER_FACTORIES, null);
        String memI = properties.getString(CPAProperties.TRANSACTION_MANAGER_INIT, null);
        properties.put(CPAProperties.TRANSACTION_MANAGER_FACTORIES,
                TransactionManagerFactoryDummy.class.getName());
        properties.put(CPAProperties.TRANSACTION_MANAGER_INIT,
                Boolean.FALSE.toString());
       
        TransactionManagerRegistry tmr = new TransactionManagerRegistry(properties);
        String[] managers = tmr.getTransactionManagerNames();
        assertEquals(0, managers.length);
       
        TransactionManager manager = new TransactionManagerDummy();
        try {
            tmr.registerTransactionManager("m1", manager);
        } catch (TransactionManagerAcquireException ex) {
            fail("Unexpected TransactionManagerAcquireException.");
        }
       
        managers = tmr.getTransactionManagerNames();
        assertEquals(1, managers.length);
        assertEquals("m1", managers[0]);

        try {
            assertTrue(manager == tmr.getTransactionManager("m1"));
        } catch (TransactionManagerAcquireException ex) {
            fail("Unexpected TransactionManagerAcquireException.");
        }

        try {
            tmr.registerTransactionManager("m1", new TransactionManagerDummy());
            fail("A TransactionManagerAcquireException without cause "
                    + "should have been thrown.");
        } catch (TransactionManagerAcquireException ex) {
            assertNull(ex.getCause());
        }
       
        managers = tmr.getTransactionManagerNames();
        assertEquals(1, managers.length);
        assertEquals("m1", managers[0]);

        try {
            assertTrue(manager == tmr.getTransactionManager("m1"));
        } catch (TransactionManagerAcquireException ex) {
            fail("Unexpected TransactionManagerAcquireException.");
        }

        tmr.deregisterTransactionManager("m1");
        managers = tmr.getTransactionManagerNames();
        assertEquals(0, managers.length);
       
        try {
            tmr.registerTransactionManager("m2", "dummy", null);
        } catch (TransactionManagerAcquireException ex) {
            fail("Unexpected TransactionManagerAcquireException.");
        }
       
        managers = tmr.getTransactionManagerNames();
        assertEquals(1, managers.length);
        assertEquals("m2", managers[0]);

        WebSphereMock.init(new TransactionManagerDummy());
        try {
            manager = tmr.getTransactionManager("m2");
            assertTrue(manager instanceof TransactionManagerDummy);
        } catch (TransactionManagerAcquireException ex) {
            fail("Unexpected TransactionManagerAcquireException.");
        }

        try {
            tmr.getTransactionManager("m3");
            fail("A TransactionManagerAcquireException without cause "
                    + "should have been thrown.");
        } catch (TransactionManagerAcquireException ex) {
            assertNull(ex.getCause());
        }

        tmr.deregisterTransactionManager("m2");
        managers = tmr.getTransactionManagerNames();
        assertEquals(0, managers.length);
       
        properties.put(CPAProperties.TRANSACTION_MANAGER_INIT, memI);
        properties.put(CPAProperties.TRANSACTION_MANAGER_FACTORIES, memF);

        logger.setLevel(level);
    }
View Full Code Here

     */
    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);
                }
View Full Code Here

     * @param loader A Custom {@link ClassLoader} instance.
     */
    public JDOMappingLoader(final ClassLoader loader) {
        super(loader);

        AbstractProperties properties = CPAProperties.getInstance();
        _typeConvertorRegistry = new TypeConvertorRegistry(properties);
    }
View Full Code Here

     */
    private static synchronized void load() {
        if (_factories == null) {
            _factories = new Hashtable();

            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);
            }
        }
View Full Code Here

     * user.
     *
     * @return Properties instance for Castor XML module.
     */
    public static AbstractProperties newInstance() {
        AbstractProperties core = new CoreProperties();
        AbstractProperties xml = new XMLProperties(core);
        AbstractProperties castor = new CastorProperties(xml);
        return castor;
    }
View Full Code Here

     * @param app Classloader to be used for all classes of Castor and its required libraries.
     * @param domain Classloader to be used for all domain objects.
     * @return Properties instance for Castor XML modul.
     */
    public static AbstractProperties newInstance(final ClassLoader app, final ClassLoader domain) {
        AbstractProperties core = new CoreProperties(app, domain);
        AbstractProperties xml = new XMLProperties(core);
        AbstractProperties castor = new CastorProperties(xml);
        return castor;
    }
View Full Code Here

        _database = database;
    }
   
    private TypeConvertorRegistry getTypeConvertorRegistry() {
        if (_typeConvertorRegistry == null) {
            AbstractProperties properties = CPAProperties.getInstance();
            _typeConvertorRegistry = new TypeConvertorRegistry(properties);
        }
        return _typeConvertorRegistry;
    }
View Full Code Here

TOP

Related Classes of org.castor.core.util.AbstractProperties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.