Package org.apache.geronimo.transaction

Examples of org.apache.geronimo.transaction.InstanceContext


            infos.remove(connectionInfo);
        }
    }

    public void setEnvironment(ConnectionInfo connectionInfo, String key) {
        InstanceContext currentInstanceContext = (InstanceContext) currentInstanceContexts.get();
        if (currentInstanceContext != null) {
            Set unshareableResources = currentInstanceContext.getUnshareableResources();
            boolean unshareable = unshareableResources.contains(key);
            connectionInfo.setUnshareable(unshareable);
            Set applicationManagedSecurityResources = currentInstanceContext.getApplicationManagedSecurityResources();
            boolean applicationManagedSecurity = applicationManagedSecurityResources.contains(key);
            connectionInfo.setApplicationManagedSecurity(applicationManagedSecurity);
        }
    }
View Full Code Here


    public void invoke(Request request, Response response) throws IOException,
            ServletException {

        try {
            InstanceContext oldContext = trackedConnectionAssociator
                    .enter(new DefaultInstanceContext(unshareableResources,
                            applicationManagedSecurityResources));

            // Pass this request on to the next valve in our pipeline
            getNext().invoke(request, response);
View Full Code Here

        key2 = null;
    }

    public void testSimpleComponentContextLifecyle() throws Exception {
        DefaultInstanceContext componentContext = new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources);
        InstanceContext oldInstanceContext = connectionTrackingCoordinator.enter(componentContext);
        assertNull("Expected old instance context to be null", oldInstanceContext);
        //give the context a ConnectionInfo
        ConnectionInfo connectionInfo = newConnectionInfo();
        connectionTrackingCoordinator.handleObtained(key1, connectionInfo);
        connectionTrackingCoordinator.exit(oldInstanceContext);
View Full Code Here

        return ci;
    }

    public void testNestedComponentContextLifecyle() throws Exception {
        DefaultInstanceContext componentContext1 = new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources);
        InstanceContext oldInstanceContext1 = connectionTrackingCoordinator.enter(componentContext1);
        assertNull("Expected old component context to be null", oldInstanceContext1);
        //give the context a ConnectionInfo
        ConnectionInfo connectionInfo1 = newConnectionInfo();
        connectionTrackingCoordinator.handleObtained(key1, connectionInfo1);

        //Simulate calling another component
        DefaultInstanceContext componentContext2 = new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources);
        InstanceContext oldInstanceContext2 = connectionTrackingCoordinator.enter(componentContext2);
        assertTrue("Expected returned component context to be componentContext1", oldInstanceContext2 == componentContext1);
        //give the context a ConnectionInfo
        ConnectionInfo connectionInfo2 = newConnectionInfo();
        connectionTrackingCoordinator.handleObtained(key2, connectionInfo2);
View Full Code Here

        TransactionContext transactionContext = transactionContextManager.getContext();
        if (transactionContext == null) {
            transactionContextManager.newUnspecifiedTransactionContext();
        }
        try {
            InstanceContext oldInstanceContext = trackedConnectionAssociator.enter(newInstanceContext);
            try {
                return next.invoke(newInstanceContext);
            } finally {
                trackedConnectionAssociator.exit(oldInstanceContext);
            }
View Full Code Here

        associatedContexts.remove(context.getContainerId(), context.getId());
        context.unassociate();
    }

    public final void unassociate(Object containerId, Object id) throws Throwable {
        InstanceContext context = (InstanceContext) associatedContexts.remove(containerId, id);
        if (context != null) {
            context.unassociate();
        }
    }
View Full Code Here

    }

    protected final void unassociateAll() {
        ArrayList toFlush = getAssociatedContexts();
        for (Iterator i = toFlush.iterator(); i.hasNext();) {
            InstanceContext context = (InstanceContext) i.next();
            try {
                context.unassociate();
            } catch (Throwable throwable) {
                log.warn("Error while unassociating instance from transaction context: " + context, throwable);
            }
        }
    }
View Full Code Here

        if (context.getId() != null) {
            associate(context);
            dirtyContexts.put(context.getContainerId(), context.getId(), context);
        }
        context.enter();
        InstanceContext caller = currentContext;
        currentContext = context;
        return caller;
    }
View Full Code Here

    public final void flushState() throws Throwable {
        while (dirtyContexts.isEmpty() == false) {
            ArrayList toFlush = new ArrayList(dirtyContexts.values());
            dirtyContexts.clear();
            for (Iterator i = toFlush.iterator(); i.hasNext();) {
                InstanceContext context = (InstanceContext) i.next();
                if (!context.isDead()) {
                    context.flush();
                }
            }
        }
        if (currentContext != null && currentContext.getId() != null) {
            dirtyContexts.put(currentContext.getContainerId(), currentContext.getId(), currentContext);
View Full Code Here

    private void beforeCommit() throws Throwable {
        // @todo allow for enrollment during pre-commit
        ArrayList toFlush = getAssociatedContexts();
        for (Iterator i = toFlush.iterator(); i.hasNext();) {
            InstanceContext context = (InstanceContext) i.next();
            if (!context.isDead()) {
                context.beforeCommit();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.transaction.InstanceContext

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.