Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.PBKey


        persistor.writeToFile(repository, conRepository, fos);

        ConnectionRepository second = persistor.readConnectionRepository(filename);
        int connectionCount2 = second.getAllDescriptor().size();

        PBKey defaultKey = second.getStandardPBKeyForJcdAlias(TestHelper.DEF_JCD_ALIAS);
        assertNotNull(defaultKey);
        assertEquals(TestHelper.DEF_KEY, defaultKey);

        assertTrue(connectionCount2 > 0);
        assertEquals("read in persisted connection repository should have same number of classes",
View Full Code Here


        MetadataManager mm = MetadataManager.getInstance();
        ConnectionRepository cr = mm.readConnectionRepository(TEST_CONNECTION_DESCRIPTOR);
        mm.mergeConnectionRepository(cr);

        ConnectionRepository mergedCR = mm.connectionRepository();
        JdbcConnectionDescriptor jcd = mergedCR.getDescriptor(new PBKey("runtime"));
        assertNotNull("Runtime merge of ConnectionRepository failed", jcd);
    }
View Full Code Here

    /**
     * test to check PB create with PBKey
     */
    public void testLookupPB1()
    {
        PBKey key1 = new PBKey(TestHelper.DEF_JCD_ALIAS);
        PBKey key2 = new PBKey(TestHelper.DEF_JCD_ALIAS, TestHelper.DEF_USER, TestHelper.DEF_PASSWORD);
        PBKey key3 = new PBKey(TestHelper.FAR_AWAY_JCD_ALIAS);
        Query query = QueryFactory.newQuery(TEST_CLASS, new Criteria());

        PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(key1);
        broker.getCount(query);
        broker.close();
View Full Code Here

    /**
     * test to check PB create with PBKey
     */
    public void testLookupPB2()
    {
        PBKey key1 = new PBKey(TestHelper.DEF_JCD_ALIAS, "!!TestCase: This should fail!!", "nothing");
        Query query = QueryFactory.newQuery(TEST_CLASS, new Criteria());
        PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(key1);
        // hsql is not very strict in user handling
        try
        {
View Full Code Here

    }

    public void testReadConnectionDescriptor()
    {
        JdbcConnectionDescriptor jcd = MetadataManager.getInstance().connectionRepository().
                getDescriptor(new PBKey("testConnection", "a user", "a password"));
        /* descriptor snip

        <jdbc-connection-descriptor
        jcd-alias="testConnection"
        default-connection="false"
View Full Code Here

        invoker = new StoreEventInvoker(listeners, this);
        this.jcd = jcd;

        if (jcd != null)
        {
            pbKey = new PBKey(jcd);
        }
        else
        {
            pbKey = PersistenceBrokerFactory.getDefaultKey();
        }
View Full Code Here

        for (Iterator iterator = descriptors.iterator(); iterator.hasNext();)
        {
            descriptor = (JdbcConnectionDescriptor) iterator.next();
            if (descriptor.isDefaultConnection())
            {
                return new PBKey(descriptor.getJcdAlias(), descriptor.getUserName(), descriptor.getPassWord());
            }
        }
        log.info("No 'default-connection' attribute set in jdbc-connection-descriptors," +
                " thus it's currently not possible to use 'defaultPersistenceBroker()' " +
                " convenience method to lookup PersistenceBroker instances. But it's possible"+
View Full Code Here

        }
        if(user != null && passwd == null)
        {
            passwd = "";
        }
        PBKey key = new PBKey(dbName, user, passwd);
        return key;
    }
View Full Code Here

     */
    public static PBKey crossCheckPBKey(PBKey key)
    {
        if(key.getUser() == null)
        {
            PBKey defKey = MetadataManager.getInstance().connectionRepository().getStandardPBKeyForJcdAlias(key.getAlias());
            if(defKey != null)
            {
                return defKey;
            }
        }
View Full Code Here

     * @param validKey  This could be the {@link JdbcConnectionDescriptor}
     * itself, or the associated {@link JdbcConnectionDescriptor#getPBKey PBKey}.
     */
    public void removeDescriptor(Object validKey)
    {
        PBKey pbKey;
        if (validKey instanceof PBKey)
        {
            pbKey = (PBKey) validKey;
        }
        else if (validKey instanceof JdbcConnectionDescriptor)
        {
            pbKey = ((JdbcConnectionDescriptor) validKey).getPBKey();
        }
        else
        {
            throw new MetadataException("Could not remove descriptor, given object was no vaild key: " +
                    validKey);
        }
        Object removed = null;
        synchronized (jcdMap)
        {
            removed = jcdMap.remove(pbKey);
            jcdAliasToPBKeyMap.remove(pbKey.getAlias());
        }
        log.info("Remove descriptor: " + removed);
    }
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.PBKey

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.