Examples of EasyBeansMDB


Examples of org.ow2.easybeans.api.bean.EasyBeansMDB

     * Creates an instance.
     * @throws CreatePoolItemException if instance cannot be created.
     * @return the created instance.
     */
    public EasyBeansMDB createPoolItem() throws CreatePoolItemException {
        EasyBeansMDB instance = null;
        try {
            instance = getBeanClass().newInstance();
        } catch (InstantiationException e) {
            throw new CreatePoolItemException(WAITING_TIME_BEFORE_CREATION, "Cannot create a new instance", e);
        } catch (IllegalAccessException e) {
            throw new CreatePoolItemException(WAITING_TIME_BEFORE_CREATION, "Cannot create a new instance", e);
        } catch (Error e) {
            logger.error("Unable to create a new instance of the class ''{0}''", getBeanClass().getName(), e);
            // null as factory is broken
            throw new CreatePoolItemException(null, "Cannot create a new instance", e);
        }

        // Set the factory
        instance.setEasyBeansFactory(this);
        instance.setEasyBeansInvocationContextFactory(getInvocationContextFactory());

        // Init the MDB context
        EasyBeansMDBContext mdbContext = new EasyBeansMDBContext(this);
        instance.setEasyBeansContext(mdbContext);

        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(getContainer().getClassLoader());
        try {
            // Call injection
            try {
                injectResources(instance);
            } catch (PoolException e) {
                throw new CreatePoolItemException(WAITING_TIME_BEFORE_CREATION, "Cannot inject resource in the instance", e);
            }


            // post construct callback
            instance.postConstructEasyBeansLifeCycle();
        } finally {
            Thread.currentThread().setContextClassLoader(oldClassLoader);
        }

        return instance;
View Full Code Here

Examples of org.ow2.easybeans.api.bean.EasyBeansMDB

     *         message endpoint. Subsequent attempts to create a message
     *         endpoint might succeed.
     */
    public EZBMessageEndPoint createInternalEndpoint(final XAResource xaResource) throws UnavailableException {
        // get an instance of MDB
        EasyBeansMDB easyBeansMDB = null;
        try {
            easyBeansMDB = getPool().get();
        } catch (PoolException e) {
            throw new UnavailableException("Cannot get instance in the pool", e);
        }

        // Build a wrapper around this mdb instance
        MDBListenerEndpointInvocationHandler handler = new MDBListenerEndpointInvocationHandler(this, easyBeansMDB,
                this.listenerInterface);
        EZBMessageEndPoint proxy = (EZBMessageEndPoint) Proxy.newProxyInstance(getContainer().getClassLoader(), new Class[] {
                this.listenerInterface, EZBMessageEndPoint.class}, handler);

        // Set XAResource of the message endpoint.
        easyBeansMDB.setXaResource(xaResource);

        return proxy;
    }
View Full Code Here

Examples of org.ow2.easybeans.api.bean.EasyBeansMDB

        }


        // Get XA Resource
        Object target = invocationContext.getTarget();
        EasyBeansMDB mdbInstance = null;
        XAResource xaResource = null;
        if (target instanceof EasyBeansMDB) {
            mdbInstance = (EasyBeansMDB) target;
            if (mdbInstance != null) {
                xaResource = mdbInstance.getXaResource();
            }
        }

        // Enlist XA Resource
        if (xaResource != null) {
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.