Examples of ICurrentInvocationID


Examples of org.ow2.util.auditreport.api.ICurrentInvocationID

        ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(getEasyBeansFactory().getContainer().getClassLoader());

        // Do some stuff on ID only if object is there, which means that audit
        // component is enabled and that this is an MDB JMS
        ICurrentInvocationID currentInvocationID = getMDBMessageEndPointFactory().getCurrentInvocationID();

        if (currentInvocationID != null && MessageListener.class.equals(this.listenerInterface)) {
            // Check if there is an ID in the message
            String auditIDString = null;
            try {
                auditIDString = ((Message) args[0]).getStringProperty(IAuditID.class.getName());
            } catch (JMSException e) {
                logger.error("Unable to get the ID in the JMS message", e);
            }
            if (auditIDString != null) {
                // Get the ID stored in this message
                AuditIDImpl callerID = new AuditIDImpl(auditIDString);

                // Add a new call
                AuditIDImpl newID = new AuditIDImpl();
                newID.generate();
                newID.setParentID(callerID.getLocalID());
                currentInvocationID.setAuditID(newID);

            } else {
                // New invocation is starting there
                currentInvocationID.init(null);
            }
        }

        // Create the bean invocation begin event.
        String methodEventProviderId = getMDBMessageEndPointFactory().getJ2EEManagedObjectId() + "/"
                + J2EEManagedObjectNamingHelper.getMethodSignature(method);
        EZBEventBeanInvocation event = getMDBMessageEndPointFactory().getInvocationEventBegin(methodEventProviderId, args);
        long number = event.getInvocationNumber();
        this.eventDispatcher.dispatch(event);
        EZBEventBeanInvocation endEvent = null;

        Method mdbMethod = null;
        // Bean is implementing the interface, keep the given method
        if (this.listenerInterface.isInstance(getEasyBeansMDB())) {
            mdbMethod = method;
        } else {
            // search the method with the same signature on the bean
            try {
                mdbMethod = getEasyBeansMDB().getClass().getMethod(method.getName(), method.getParameterTypes());
            } catch (SecurityException e) {
                throw new IllegalStateException("Cannot deliver the message", e);
            } catch (NoSuchMethodException e) {
                throw new IllegalStateException("Cannot deliver the message", e);
            }
        }



        // invoke by using reflection
        Object result = null;
        try {
            result = mdbMethod.invoke(getEasyBeansMDB(), args);
            endEvent = new EventBeanInvocationEnd(methodEventProviderId, number, null);
        } catch (IllegalArgumentException e) {
            logger.error("Cannot deliver the message", e);
            endEvent = new EventBeanInvocationError(methodEventProviderId, number, e);
            throw new IllegalStateException("Cannot deliver the message", e);
        } catch (IllegalAccessException e) {
            logger.error("Cannot deliver the message", e);
            endEvent = new EventBeanInvocationError(methodEventProviderId, number, e);
            throw new IllegalStateException("Cannot deliver the message", e);
        } catch (InvocationTargetException e) {
            endEvent = new EventBeanInvocationError(methodEventProviderId, number, e);
            logger.error("Cannot deliver the message", e.getTargetException());
            throw new IllegalStateException("Cannot deliver the message", e.getTargetException());
        } finally {
            // Reset classloader
            Thread.currentThread().setContextClassLoader(oldCL);
            if (currentInvocationID != null) {
                currentInvocationID.setAuditID(null);
            }
            if (endEvent != null) {
                this.eventDispatcher.dispatch(endEvent);
            }
        }
View Full Code Here

Examples of org.ow2.util.auditreport.api.ICurrentInvocationID

     * @param jClientRequestInfo jri the jrmp client info
     * @exception IOException if an exception occur with the ObjectOutput
     */
    public void send_request(final JClientRequestInfo jClientRequestInfo) throws IOException {
        // Get current ID
        ICurrentInvocationID currentInvocationID = CurrentInvocationID.getInstance();

        // Existing ID ?
        IAuditID localID = currentInvocationID.getAuditID();

        // If there is an ID, propagate it
        if (localID != null) {
            localID.increment();

View Full Code Here

Examples of org.ow2.util.auditreport.api.ICurrentInvocationID

        if (auditServiceContext != null) {
            // Gets Audit ID received by client
            IAuditID clientID = auditServiceContext.getAuditID();

            // Get current object
            ICurrentInvocationID currentInvocationID = CurrentInvocationID.getInstance();

            // If client ID is null, it will be seen as a new invocation
            currentInvocationID.init(clientID);
        }

    }
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.