Package org.ow2.util.auditreport.api

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


        List<EZBJNDIBeanData> jndiDataList = null;
        try {
            jndiDataList = getJNDIResolver().getEJBJNDINames(interfaceName, beanName);
        } catch (RemoteException re) {
            // No Remote JNDI resolver, so throw first exception
            throw new ArchiveInjectionException("Unable to get JNDI Name for '" + interfaceName + "'/'" + beanName + "'", re);
        }

        // Data is here, check if it is empty or not
        if (jndiDataList.size() == 0) {
            throw new ArchiveInjectionException("Unable to get JNDI Name for '" + interfaceName + "'/'" + beanName
                    + "', no data was found on the remote side.");
        } else if (jndiDataList.size() > 1) {
            // too many entries
            logger.warn("There may be a problem for bean '" + interfaceName + "'/'" + beanName + "', too many answers : '"
                    + jndiDataList + "'. Using the first entry");
View Full Code Here


        // Create classloader with these URLs
        URL[] arrayURLs = urls.toArray(new URL[urls.size()]);

        // Child of the EAR classloader with RARs
        ClassLoader ejbClassLoader = new EasyBeansClassLoader(arrayURLs, earClassLoader);

        // Get Persistence unit manager
        PersistenceUnitManager persistenceUnitManager = getPersistenceUnitManager(earDeployable, ejbClassLoader);

        // Get Extra libraries
View Full Code Here

            if (this.warService == null) {
                logger.warn("There are WAR files in the EAR ''{0}'' but the 'web' service is not available", earDeployable);
            } else {

                // Build context for sending parameters
                Context ctx = new ContextImpl(earURL.toExternalForm());
                try {
                    ctx.rebind("earURL", earURL);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the EAR URL parameter '" + earURL + "'", e);
                }
                // Get URLS of the wars and context-root
                List<URL> urls = new LinkedList<URL>();
                List<String> ctxRoots = new LinkedList<String>();
                for (WARDeployable warDeployable : wars) {

                    // URL
                    URL url = null;
                    try {
                        url = warDeployable.getArchive().getURL();
                    } catch (ArchiveException e) {
                        throw new DeployerException("Cannot get the URL for the archive '" + warDeployable.getArchive() + "'",
                                e);
                    }
                    urls.add(url);

                    // Context-root
                    ctxRoots.add(warDeployable.getContextRoot());

                }
                try {
                    ctx.rebind("urls", urls.toArray(new URL[urls.size()]));
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the urls parameter '" + urls + "'", e);
                }

                // Bind the parent classloader of the web application
                try {
                    ctx.rebind("parentClassLoader", parentClassLoader);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the parentClassLoader parameter '" + parentClassLoader + "'", e);
                }

                // Bind the earClassLoader of the web application
                try {
                    ctx.rebind("earClassLoader", earClassLoader);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the earClassLoader parameter '" + earClassLoader + "'", e);
                }

                // No alt-dd yet, give an empty array
                try {
                    ctx.rebind("altDDs", new URL[urls.size()]);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the altDDs parameter.'", e);
                }

                // Build context roots
                try {
                    ctx.rebind("contextRoots", ctxRoots.toArray(new String[ctxRoots.size()]));
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the contextRoots parameter '" + urls + "'", e);
                }

                try {
View Full Code Here

        List<RARDeployable> rars = earDeployable.getRARDeployables();
        if (rars.size() > 0) {
            if (this.rarService == null) {
                logger.warn("There are RAR files in the EAR ''{0}'' but the resource service is not available", earDeployable);
            } else {
                Context ctx = new ContextImpl(earURL.toExternalForm());
                try {
                    ctx.rebind("earUrl", earURL);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the EAR URL parameter '" + earURL + "'", e);
                }
                List<URL> urls = new ArrayList<URL>();
                for (RARDeployable rarDeployable : rars) {
                    try {
                        urls.add(rarDeployable.getArchive().getURL());
                    } catch (ArchiveException e) {
                        throw new DeployerException("Cannot get the URL for the archive '" + rarDeployable.getArchive() + "'",
                                e);
                    }
                }
                try {
                    ctx.rebind("urls", urls.toArray(new URL[urls.size()]));
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the urls parameter '" + urls + "'", e);
                }
                try {
                    ctx.rebind("earClassLoader", earClassLoader);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the earClassLoader parameter '" + earClassLoader + "'", e);
                }
                try {
                    ctx.rebind("altDDs", new URL[urls.size()]);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the altDDs parameter.'", e);
                }

                try {
View Full Code Here

                    }
                }


                // Deploy EJB 2.1 on JOnAS service
                Context ctx = new ContextImpl(earURL.toExternalForm());
                try {
                    ctx.rebind("earUrl", earURL);
                    ctx.rebind("earRootUrl", earURL);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the EAR URL parameter '" + earURL + "'", e);
                }

                try {
                    ctx.rebind("jarURLs", urls.toArray(new URL[urls.size()]));
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the urls parameter '" + urls + "'", e);
                }
                try {
                    ctx.rebind("earClassLoader", earClassLoader);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the earClassLoader parameter '" + earClassLoader + "'", e);
                }

                // Bind the EJB classloader
                try {
                    ctx.rebind("ejbClassLoader", ejbClassLoader);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the ejbClassLoader parameter '" + ejbClassLoader + "'", e);
                }

                // Role names
                try {
                    ctx.rebind("roleNames", new String[0]);
                } catch (NamingException e) {
                    throw new DeployerException("Cannot add the altDDs parameter.'", e);
                }

                try {
View Full Code Here

        // Child of the EAR classloader with RARs
        ClassLoader ejbClassLoader = new EasyBeansClassLoader(arrayURLs, earClassLoader);

        // Get Persistence unit manager
        PersistenceUnitManager persistenceUnitManager = getPersistenceUnitManager(earDeployable, ejbClassLoader);

        // Get Extra libraries
        List<IArchive> libArchives = getLibArchives(earDeployable);

View Full Code Here

        for (EJBDeployable ejb : ejb3s) {
            containers.add(getEmbedded().createContainer(ejb));
        }

        // Create Resolver for EAR
        EZBApplicationJNDIResolver applicationJNDIResolver = new ApplicationJNDIResolver();

        // Create EasyBeans injection Holder
        InjectionHolder ejbInjectionHolder = new InjectionHolder();
        ejbInjectionHolder.setPersistenceUnitManager(persistenceUnitManager);
        ejbInjectionHolder.setJNDIResolver(applicationJNDIResolver);


        // Configure containers
        for (EZBContainer container : containers) {
            // Set the classloader that needs to be used
            container.setClassLoader(ejbClassLoader);

            // Set application name
            container.setApplicationName(earDeployable.getModuleName());

            // Add persistence context found
            container.setPersistenceUnitManager(persistenceUnitManager);

            // Add the metadata
            container.setExtraArchives(libArchives);

            // set parent JNDI Resolver
            EZBContainerJNDIResolver containerJNDIResolver = container.getConfiguration().getContainerJNDIResolver();
            containerJNDIResolver.setApplicationJNDIResolver(applicationJNDIResolver);

            // Add child on application JNDI Resolver
            applicationJNDIResolver.addContainerJNDIResolver(containerJNDIResolver);


            // Resolve container
            try {
                container.resolve();
View Full Code Here

            logger.warn("There may be a problem for bean '" + interfaceName + "'/'" + beanName + "', too many answers : '"
                    + jndiDataList + "'. Using the first entry");
        }

        // Only one item found, so get JNDI Name from this object
        EZBJNDIBeanData jndiData = jndiDataList.get(0);
        // Update JNDI name
        jndiName = jndiData.getName();
        if (logger.isDebugEnabled()) {
            logger.debug("Found JNDI Name '" + jndiName + "' for '" + interfaceName + "'/'" + beanName + "', answers : '"
                    + jndiDataList + "'.");
        }
View Full Code Here

            logger.warn("There may be a problem for message destination '" + messageDestinationName + "', too many answers : '"
                    + jndiDataList + "'. Using the first entry");
        }

        // Only one item found, so get JNDI Name from this object
        EZBJNDIData jndiData = jndiDataList.get(0);
        // Update JNDI name
        jndiName = jndiData.getName();
        if (logger.isDebugEnabled()) {
            logger.debug("Found JNDI Name '" + jndiName + "' for message destination '" + messageDestinationName
                    + "', answers : '" + jndiDataList + "'.");
        }
View Full Code Here

        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

TOP

Related Classes of org.ow2.util.auditreport.api.ICurrentInvocationID

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.