Examples of OTMKit


Examples of org.apache.ojb.otm.OTMKit

    }

    public void waitForTx(Transaction tx)
        throws LockingException
    {
        OTMKit kit = tx.getKit();
        LockWaitStrategy waitStrategy = kit.getLockWaitStrategy();
        waitStrategy.waitForLock(this, tx);
    }
View Full Code Here

Examples of org.apache.ojb.otm.OTMKit

    {
        ContextEntry entry;
        LockManager lockManager;
        Swizzling swizzlingStrategy;
        IndirectionHandler handler = null;
        OTMKit kit = _tx.getKit();
        // Are we building object's relations for the userObject in the transaction?
        // Otherwise we just get data from the "userObject" and put it into
        // the previously loaded/created object in the transaction
        boolean buildingObject = false;
        boolean lazySwizzle = false;

        if (lock == LockType.NO_LOCK)
        {
            return null;
        }

        entry = (ContextEntry) _objects.get(oid);

        if (userObject == null)
        {
            // invalidating object...
            _original.remove(oid);
            _checkpointed.remove(oid);
            if (entry != null)
            {
                entry.userObject = null;
                entry.cacheObject = null;
            }
            return entry;
        }

        lockManager = LockManager.getInstance();
        swizzlingStrategy = kit.getSwizzlingStrategy();

        handler = ProxyHelper.getIndirectionHandler(userObject);
        if ((handler != null) && handler.alreadyMaterialized())
        {
            userObject = handler.getRealSubject();
            handler = null;
        }

        if ((entry == null) || (entry.userObject == null))
        {
            // first insertion of the userObject into editing context
            Object swizzledObject = swizzlingStrategy.swizzle(userObject, null, _pb, this);
            entry = new ContextEntry(swizzledObject);
            if (entry.handler != null)
            {
                ObjectCopyStrategy copyStrategy = _tx.getKit().getCopyStrategy(oid);
                entry.cacheObject = copyStrategy.copy(userObject, _pb);
                // Assume that object exists, otherwise were the proxy came from?
                _objects.put(oid, entry);
                lockManager.ensureLock(oid, _tx, lock, _pb); // lock after _objects.put to avoid hanged locks
                entry.handler.addListener(this);
            }
            else
            {
                Object origCacheObj = _pb.getObjectByIdentity(oid);

                if ((origCacheObj == null) && !canCreate)
                {
                    // we don't create the objects by reachability
                    throw new IllegalStateException("Related object is neither persistent, nor otm-depentent: " + oid);
                }
                if (origCacheObj != null)
                {
                    entry.cacheObject = origCacheObj;
                }
                buildingObject = true;
                _objects.put(oid, entry);
                lockManager.ensureLock(oid, _tx, lock, _pb); // lock after _objects.put to avoid hanged locks

                if (userObject != null)
                {
                    if ((origCacheObj == null) && canCreate)
                    {
                        ObjectCopyStrategy copyStrategy = _tx.getKit().getCopyStrategy(oid);
                        entry.cacheObject = copyStrategy.copy(userObject, _pb);
                        entry.state = State.PERSISTENT_NEW;
                        if (kit.isEagerInsert(userObject)
                                || hasBidirectionalAssociation(userObject.getClass()))
                        {
                            _pb.store(entry.cacheObject, entry.state);
                            entry.state = State.PERSISTENT_CLEAN;
                            origCacheObj = entry.cacheObject;
View Full Code Here

Examples of org.apache.ojb.otm.OTMKit

     *
     * @param product The product to store
     */
    public static void storeProduct(Product product) throws LockingException
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;

        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            tx.begin();

            conn.makePersistent(product);

View Full Code Here

Examples of org.apache.ojb.otm.OTMKit

     *
     * @param product The product to remove
     */
    public static void removeProduct(Product product) throws LockingException
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;

        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            tx.begin();

            conn.deletePersistent(product);

View Full Code Here

Examples of org.apache.ojb.otm.OTMKit

     * @param query The query to perform
     * @return The iterator
     */
    public Iterator findByCriteria(Query query)
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;
        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            tx.begin();

            Iterator results = conn.getIteratorByQuery(query);

View Full Code Here

Examples of org.apache.ojb.otm.OTMKit

     * @param lock  The type of lock to be applied to the objects
     * @return The iterator
     */
    public Iterator findByCriteriaWithLock(Query query, int lock)
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;
        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            tx.begin();

            Iterator results = conn.getIteratorByQuery(query, lock);

View Full Code Here

Examples of org.apache.ojb.otm.OTMKit

     * @param queryParams Parameter values for the query
     * @return The iterator
     */
    public Iterator findByOQL(String query, Object[] queryParams) throws Exception
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;

        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            OQLQuery oql = conn.newOQLQuery();

            oql.create(query);

View Full Code Here

Examples of org.apache.ojb.otm.OTMKit

     * @param lock  The type of lock to be applied to the objects
     * @return The iterator
     */
    public Iterator moreRealisticQueryByCriteria(Query query, int lock)
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;
        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            boolean auto = !tx.isInProgress();

            if (auto)
            {
View Full Code Here

Examples of org.apache.ojb.otm.OTMKit

    /**
     * Sample method that renames all product with a specific name.
     */
    public void renameWidgetExample()
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;

        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            tx.begin();

            Product sample = new Product();

View Full Code Here

Examples of org.apache.ojb.otm.OTMKit

     *
     * @param product The product to store
     */
    public static void storeProduct(Product product) throws LockingException
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;

        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            tx.begin();

            conn.makePersistent(product);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.