Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.PBFactoryException


    protected PersistenceBroker wrapRequestedBrokerInstance(PersistenceBroker broker)
    {
        // all PB instance should be of this type
        if (!(broker instanceof PersistenceBrokerSyncImpl))
        {
            throw new PBFactoryException("Expect instance of " + PersistenceBrokerSyncImpl.class
                    + ", found " + broker.getClass());
        }
        /*
        Before we return the PB handle, we jump into the running JTA tx
        */
        PersistenceBrokerSyncImpl pb = (PersistenceBrokerSyncImpl) broker;
        try
        {
            // search for an active tx
            Transaction tx = searchForValidTx();
            if (tx != null)
            {
                txRegistry.register(tx, pb);
                try
                {
                    pb.internBegin();
                }
                catch (Exception e)
                {
                    /*
                    if something going wrong with pb-tx, we rollback the
                    whole JTA tx
                    */
                    log.error("Unexpected exception when start intern pb-tx", e);
                    try
                    {
                        tx.setRollbackOnly();
                    }
                    catch (Throwable ignore)
                    {
                    }
                    throw new PBFactoryException("Unexpected exception when start intern pb-tx", e);
                }
            }
        }
        catch (Exception e)
        {
            if(e instanceof PBFactoryException)
            {
                throw (PBFactoryException) e;
            }
            else
            {
                throw new PBFactoryException("Error while try to participate in JTA transaction", e);
            }
        }
        return new PersistenceBrokerSyncHandle(pb);
    }
View Full Code Here


        if (tx != null)
        {
            int status = tx.getStatus();
            if (status != Status.STATUS_ACTIVE && status != Status.STATUS_NO_TRANSACTION)
            {
                throw new PBFactoryException("Transaction synchronization failed - wrong" +
                        " status of external JTA tx. Expected was an 'active' or 'no transaction'"
                        + ", found status is '" + getStatusFlagAsString(status) + "'");
            }
        }
        return tx;
View Full Code Here

        void add(PersistenceBrokerSyncImpl syncObj)
        {
            if (isLocked)
            {
                throw new PBFactoryException("Can't associate object with JTA transaction, because tx-completion started");
            }
            syncMap.put(syncObj.getPBKey(), (Synchronization) syncObj);
        }
View Full Code Here

            isClosed = true;
            // discard association of PB instances and jta-tx
            txRegistry.removeTxBox(jtaTx);
            if (failures)
            {
                throw new PBFactoryException("Unexpected error occured while performing" +
                        " Synchronization#afterCompletion method");
            }
        }
View Full Code Here

                }
            }
            isLocked = true;
            if (failures)
            {
                throw new PBFactoryException("Unexpected error occured while performing" +
                        " Synchronization#beforeCompletion method");
            }
        }
View Full Code Here

TOP

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

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.