Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.PBFactoryException


        {
            txMan = TransactionManagerFactoryFactory.instance().getTransactionManager();
        }
        catch (TransactionManagerFactoryException e)
        {
            throw new PBFactoryException("Can't instantiate TransactionManager of managed environment", e);
        }
        txRegistry = new TxRegistry();
    }
View Full Code Here


            // search for an active tx
            tx = searchForValidTx();
        }
        catch (SystemException e)
        {
            throw new PBFactoryException("Can't create PB instance, failure while lookup" +
                    " running JTA transaction",e);
        }
        PersistenceBrokerSyncImpl obtainedBroker = null;
        PersistenceBrokerSyncHandle result;
        if (tx != null)
View Full Code Here

    protected PersistenceBrokerInternal wrapRequestedBrokerInstance(PersistenceBrokerInternal 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(), 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

            }
            catch (Exception ignore)
            {
                //ignore it
            }
            throw new PBFactoryException("Borrow broker from pool failed, using PBKey " + pbKey, e);
        }
        return broker;
    }
View Full Code Here

        {
            MetadataManager.getInstance().setDefaultPBKey(key);
        }
        catch (Exception e)
        {
            throw new PBFactoryException(e);
        }
    }
View Full Code Here

    /**
     * For internal use! This method creates real new PB instances
     */
    protected PersistenceBrokerInternal createNewBrokerInstance(PBKey key) throws PBFactoryException
    {
        if (key == null) throw new PBFactoryException("Could not create new broker with PBkey argument 'null'");
        // check if the given key really exists
        if (MetadataManager.getInstance().connectionRepository().getDescriptor(key) == null)
        {
            throw new PBFactoryException("Given PBKey " + key + " does not match in metadata configuration");
        }
        if (log.isEnabledFor(Logger.INFO))
        {
            // only count created instances when INFO-Log-Level
            log.info("Create new PB instance for PBKey " + key +
                    ", already created persistence broker instances: " + instanceCount);
            // useful for testing
            ++this.instanceCount;
        }

        PersistenceBrokerInternal instance = null;
        Class[] types = {PBKey.class, PersistenceBrokerFactoryIF.class};
        Object[] args = {key, this};
        try
        {
            instance = (PersistenceBrokerInternal) ClassHelper.newInstance(implementationClass, types, args);
            OjbConfigurator.getInstance().configure(instance);
            instance = (PersistenceBrokerInternal) InterceptorFactory.getInstance().createInterceptorFor(instance);
        }
        catch (Exception e)
        {
            log.error("Creation of a new PB instance failed", e);
            throw new PBFactoryException("Creation of a new PB instance failed", e);
        }
        return instance;
    }
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.