Package org.apache.geronimo.transaction

Examples of org.apache.geronimo.transaction.InstanceContext


    private void afterCommit(boolean status) throws Throwable {
        Throwable firstThrowable = null;
        ArrayList toFlush = getAssociatedContexts();
        for (Iterator i = toFlush.iterator(); i.hasNext();) {
            InstanceContext context = (InstanceContext) i.next();
            if (!context.isDead()) {
                try {
                    context.afterCommit(status);
                } catch (Throwable e) {
                    if (firstThrowable == null) {
                        firstThrowable = e;
                    }
                }
View Full Code Here


     * @see #exitContext(InstanceContext)
     */
    public Object invoke(MethodInvocation invocation) throws Throwable {
        Set unshareableResources = new HashSet();
        Set applicationManagedSecurityResources = new HashSet();
        InstanceContext context = associator.enter(
                new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources));
        Object returnValue = invocation.proceed();
        associator.exit(context);
        return returnValue;
    }
View Full Code Here

    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {
        // Enter in the transactionnal context
        Set unshareableResources = new HashSet();
        Set applicationManagedSecurityResources = new HashSet();
        InstanceContext oldContext =
                enterContext(unshareableResources, applicationManagedSecurityResources);

        // Proceed with chain
        chain.doFilter(request, response);
View Full Code Here

     * the client.
     */
    private InstanceContext enterContext(Set unshareableResources,
                                         Set applicationManagedSecurityResources) {
        try {
            InstanceContext oldContext =
                    associator.enter(new DefaultInstanceContext(
                            unshareableResources, applicationManagedSecurityResources));
            if (logger.isDebugEnabled()) {
                logger.info("Geronimo transaction context set.");
            }
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

    private final ThreadLocal currentInstanceContexts = new ThreadLocal();

    public InstanceContext enter(InstanceContext newInstanceContext)
            throws ResourceException {
        InstanceContext oldInstanceContext = (InstanceContext) currentInstanceContexts.get();
        currentInstanceContexts.set(newInstanceContext);
        notifyConnections(newInstanceContext);
        return oldInstanceContext;
    }
View Full Code Here

            mcci.enter(connections);
        }
    }

    public void newTransaction() throws ResourceException {
        InstanceContext oldInstanceContext = (InstanceContext) currentInstanceContexts.get();
        notifyConnections(oldInstanceContext);
    }
View Full Code Here

        notifyConnections(oldInstanceContext);
    }

    public void exit(InstanceContext reenteringInstanceContext)
            throws ResourceException {
        InstanceContext oldInstanceContext = (InstanceContext) currentInstanceContexts.get();
        Map resources = oldInstanceContext.getConnectionManagerMap();
        for (Iterator i = resources.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();
            ConnectionTrackingInterceptor mcci =
                    (ConnectionTrackingInterceptor) entry.getKey();
            Set connections = (Set) entry.getValue();
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.