当前位置: 首页>>代码示例>>Java>>正文


Java PersistenceBroker.close方法代码示例

本文整理汇总了Java中org.apache.ojb.broker.PersistenceBroker.close方法的典型用法代码示例。如果您正苦于以下问题:Java PersistenceBroker.close方法的具体用法?Java PersistenceBroker.close怎么用?Java PersistenceBroker.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ojb.broker.PersistenceBroker的用法示例。


在下文中一共展示了PersistenceBroker.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertNewArticles

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * A performance optimized insert-method implementation,
 * used to test performance.
 */
public void insertNewArticles(PerfArticle[] arr) throws Exception
{
    PersistenceBroker broker = null;
    try
    {
        broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        broker.serviceConnectionManager().setBatchMode(true);
        broker.beginTransaction();
        for (int i = 0; i < arr.length; i++)
        {
            broker.store(arr[i], ObjectModification.INSERT);
        }
        broker.commitTransaction();
    }
    finally
    {
        if (broker != null) broker.close();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:24,代码来源:OJBPerfTest.java

示例2: insertNewArticlesStress

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * A resource cumbering insert-method implementation,
 * this was used to test implementation.
 */
public void insertNewArticlesStress(PerfArticle[] arr) throws Exception
{
    for (int i = 0; i < arr.length; i++)
    {
        PersistenceBroker broker = null;
        try
        {
            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
            broker.beginTransaction();
            broker.store(arr[i]);
            broker.commitTransaction();
        }
        finally
        {
            if (broker != null) broker.close();
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:OJBPerfTest.java

示例3: ojbChangeReferenceSetting

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * Allows to do a global change of object/collection reference settings. When the test
 * is tear down the old settings will be restored. Be careful when override setUp/tearDown method, don't
 * forget the "super call", else this method couldn't work properly.
 *
 * @param clazz
 * @param referenceField
 * @param autoRetrieve
 * @param autoUpdate
 * @param autoDelete
 * @param useProxy
 */
public void ojbChangeReferenceSetting(Class clazz, String referenceField, boolean autoRetrieve, int autoUpdate, int autoDelete, boolean useProxy)
{
    if(referenceHelper == null)
    {
        referenceHelper = new MetadataHelper();
    }
    PersistenceBroker temp = PersistenceBrokerFactory.defaultPersistenceBroker();
    try
    {
        referenceHelper.changeReferenceSetting(temp, clazz, referenceField, autoRetrieve, autoUpdate, autoDelete, useProxy);
    }
    finally
    {
        if(temp != null)
        {
            temp.close();
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:32,代码来源:OJBTestCase.java

示例4: updateArticles

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
public void updateArticles(PerfArticle[] arr) throws Exception
{
    PersistenceBroker broker = null;
    try
    {
        broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        broker.serviceConnectionManager().setBatchMode(true);
        broker.beginTransaction();
        for (int i = 0; i < arr.length; i++)
        {
            broker.store(arr[i], ObjectModification.UPDATE);
            // broker.store(arr[i]);
        }
        broker.commitTransaction();
    }
    finally
    {
        if (broker != null) broker.close();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:21,代码来源:OJBPerfTest.java

示例5: testSimpleObjectCacheFunctions

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * Check base caching functions of some cache implementations.
 *
 * @throws Exception
 */
public void testSimpleObjectCacheFunctions() throws Exception
{
    for (int i = 0; i < objectCacheImpls.length; i++)
    {
        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        try
        {
            ObjectCache cache = (ObjectCache) ClassHelper.newInstance(
                        objectCacheImpls[i],
                        new Class[] {PersistenceBroker.class,Properties.class},
                        new Object[] {broker, null});
            checkBaseFunctions(broker, cache);
        }
        finally
        {
            if (broker != null) broker.close();
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:25,代码来源:ObjectCacheTest.java

示例6: deleteArticlesStress

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * A resource cumbering delete-method implementation,
 * used to test implementation
 */
public void deleteArticlesStress(PerfArticle[] arr) throws Exception
{
    for (int i = 0; i < arr.length; i++)
    {
        PersistenceBroker broker = null;
        try
        {
            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
            broker.beginTransaction();
            broker.delete(arr[i]);
            broker.commitTransaction();
        }
        finally
        {
            if (broker != null) broker.close();
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:OJBPerfTest.java

示例7: deleteArticles

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * A performance optimized delete-method implementation,
 * used to test performance
 */
public void deleteArticles(PerfArticle[] arr) throws Exception
{
    PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
    try
    {
        broker.serviceConnectionManager().setBatchMode(true);
        broker.beginTransaction();
        for (int i = 0; i < arr.length; i++)
        {
            broker.delete(arr[i]);
        }
        broker.commitTransaction();
    }
    finally
    {
        if (broker != null) broker.close();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:OJBPerfTest.java

示例8: testDatabaseSequenceGeneration

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * This test only works, when using
 * {@link org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl}
 * for sequence generation.
 */
public void testDatabaseSequenceGeneration() throws Exception
{
    PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
    SequenceManager sm = SequenceManagerFactory.getSequenceManager(broker);
    if (!(sm instanceof SequenceManagerNextValImpl))
    {
        System.out.println("This test only works for SeqMan implementations using "
                + SequenceManagerNextValImpl.class + " Skip test case.");
        broker.close();
        return;
    }
    int count = 0;
    FieldDescriptor idFld = broker.getClassDescriptor(
            Repository.SMDatabaseSequence.class).getAutoIncrementFields()[0];
    for (int i = 0; i < 10; i++)
    {
        Integer val = (Integer) sm.getUniqueValue(idFld);
        count += val.intValue();
        System.err.println("count " + count);
    }
    assertFalse("No keys generated", count == 0);
    broker.close();
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:29,代码来源:SequenceManagerTest.java

示例9: getArticles

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * @ejb:interface-method
 */
public Collection getArticles(String articleName)
{
    PersistenceBroker broker = getBroker();
    Collection result;
    try
    {
        Criteria criteria = new Criteria();
        if (articleName != null) criteria.addEqualTo("name", articleName);
        Query q = new QueryByCriteria(ArticleVO.class, criteria);
        result = broker.getCollectionByQuery(q);
    }
    finally
    {
        if (broker != null) broker.close();
    }
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:21,代码来源:ArticleManagerPBBean.java

示例10: doKeyAnalysing

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
private void doKeyAnalysing(Class classOne, Class classTwo) throws SequenceManagerException
{
    PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
    FieldDescriptor fieldOne = broker.getClassDescriptor(classOne).getAutoIncrementFields()[0];
    FieldDescriptor fieldTwo = broker.getClassDescriptor(classOne).getAutoIncrementFields()[0];

    List listOne = createKeyList(broker, fieldOne, numberOfKeys);
    List listTwo = createKeyList(broker, fieldTwo, numberOfKeys);
    for (int i = 0; i < listOne.size(); i++)
    {
        if (listTwo.contains(listOne.get(i)))
        {
            fail("\nFound double generated key " + listOne.get(i) +
                    " when generate keys for \n" + classOne + " with autoincrement field " + fieldOne +
                    " and \n" + classTwo + " with autoincrement field " + fieldTwo);
        }
    }
    broker.close();
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:20,代码来源:SequenceManagerTest.java

示例11: selectClassDescriptor

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
protected ClassDescriptor selectClassDescriptor(Map row) throws PersistenceBrokerException {
    String[] key = new String[column.length];

    for (int i = 0; i < column.length; i++) {
        key[i] = (String) row.get(column[i]);
    }

    Class clazz = null;

    if (key != null) {
        clazz = chooseClass(key);
    }
    if (clazz == null) {
        return getClassDescriptor();
    }

    PersistenceBroker broker = null;
    try {
        broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        ClassDescriptor result = broker.getClassDescriptor(clazz);
        broker.close();
        if (result == null) {
            return getClassDescriptor();
        }
        else {
            return result;
        }
    }
    catch (PersistenceBrokerException e) {
        broker.close();
        throw e;
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:34,代码来源:PolymorphicMultiColumnDiscriminator.java

示例12: releaseBroker

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * Release the broker instance.
 */
protected synchronized void releaseBroker(PersistenceBroker broker)
{
    /*
    arminw:
    only close the broker instance if we get
    it from the PBF, do nothing if we obtain it from
    PBThreadMapping
    */
    if (broker != null && _needsClose)
    {
        _needsClose = false;
        broker.close();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:18,代码来源:CollectionProxyDefaultImpl.java

示例13: testMassStoreOfObjects

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
public void testMassStoreOfObjects()
{
    int outerLoops = 10;
    int innerLoops = 30;
    String name = "Name_" + System.currentTimeMillis();

    Repository.SMKey key = null;
    for (int i = outerLoops - 1; i >= 0; i--)
    {
        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        try
        {
            broker.beginTransaction();
            for (int j = innerLoops - 1; j >= 0; j--)
            {
                key = new Repository.SMKey();
                key.setName(name);
                broker.store(key);
            }
            broker.commitTransaction();
        }
        finally
        {
            if(broker != null) broker.close();
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:28,代码来源:SequenceManagerTest.java

示例14: getDBObjectCountWithNewPB

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
protected int getDBObjectCountWithNewPB(Class target) throws Exception
{
    PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
    Criteria c = new Criteria();
    Query q = new QueryByCriteria(target, c);
    int count = broker.getCount(q);
    broker.close();
    return count;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:10,代码来源:ODMGRollbackTest.java

示例15: getCount

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * Return the count of all objects found
 * for given class.
 */
public int getCount(Class target)
{
    PersistenceBroker broker = getBroker();
    int result;
    try
    {
        result = broker.getCount(new QueryByCriteria(target));
    }
    finally
    {
        if (broker != null) broker.close();
    }
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:19,代码来源:PBBaseBeanImpl.java


注:本文中的org.apache.ojb.broker.PersistenceBroker.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。