Package org.ow2.easybeans.api.bean.lifecycle

Examples of org.ow2.easybeans.api.bean.lifecycle.EasyBeansSLSBLifeCycle


            } catch (Exception e) {
                this.logger.error("Cannot configure Carol to use CMI", e);
                throw new EZBComponentException("Cannot configure Carol to use CMI", e);
            }

            ClusterViewManagerFactory clusterViewManagerFactory = ClusterViewManagerFactory.getFactory();

            // Start the manager
            try {
                this.clusterViewManager = (ServerClusterViewManager) clusterViewManagerFactory.create();
            } catch (Exception e) {
                this.logger.error("Cannot retrieve the CMI Server", e);
                throw new EZBComponentException("Cannot retrieve the CMI Server", e);
            }
            if (this.clusterViewManager != null
                    && this.clusterViewManager.getState().equals(ClusterViewManager.State.STOPPED)) {
                if (this.eventComponent != null) {
                    List<Component> components =
                        clusterViewManagerFactory.getConfig().getComponents().getComponents();
                    if (components != null) {
                        for (Component cmiEventComponent : components) {
                            if (org.ow2.cmi.component.event.EventComponent.class.isAssignableFrom(cmiEventComponent.getClass())) {
                                ((org.ow2.cmi.component.event.EventComponent) cmiEventComponent).setEventService(
                                        this.eventComponent.getEventService());
View Full Code Here


            return EASYBEANS_ROOT;
        } else if (EZBContainer.class.isAssignableFrom(clazz)) {
            // The object is an EJB container.

            EZBContainer container = (EZBContainer) instance;

            // Get the archive name (remove all character before the last slash/antislash).
            String archiveName = container.getName().replaceAll("(.*[/\\\\])", "");

            // Compute the application id.
            return EASYBEANS_ROOT + "/" + container.getApplicationName() + "/" + archiveName;
        } else if (Factory.class.isAssignableFrom(clazz)) {
            // The object is a bean factory.

            Factory<?, ?> factory = (Factory<?, ?>) instance;
            EZBContainer container = factory.getContainer();

            // Get the archive name (remove all character before the last slash/antislash).
            String archiveName = container.getName().replaceAll("(.*[/\\\\])", "");

            // Get the bean class name (remove all character before the last point).
            String factoryName = factory.getClassName().replaceAll("(.*\\.)", "");

            // Compute the bean id.
            return EASYBEANS_ROOT + "/" + container.getApplicationName() + "/" + archiveName + "/" + factoryName;
        } else {
            throw new java.lang.IllegalArgumentException("Name is not define for argument of type " + instance.getClass());
        }
    }
View Full Code Here

     * Test the stateless bean callbacks.
     */
    @Test
    public void testStatelessBeanCallbacks() {
        assertEquals(0, statelessBean.getCounter());
        EasyBeansSLSBLifeCycle lifeCycle = getSLSBLifeCycle();

        // postConstruct should increment the counter
        lifeCycle.postConstructEasyBeansLifeCycle();
        assertEquals(1, statelessBean.getCounter());

        // preDestroy should decrement counter
        lifeCycle.preDestroyEasyBeansLifeCycle();
        assertEquals(0, statelessBean.getCounter());
    }
View Full Code Here

     * Test the postConstruct on stateless bean.
     */
    @Test
    public void testStatelessPostConstruct() {
        assertFalse(statelessBean.isPostConstructCalled());
        EasyBeansSLSBLifeCycle lifeCycle = getSLSBLifeCycle();
        lifeCycle.postConstructEasyBeansLifeCycle();

        assertTrue(statelessBean.isPostConstructCalled());
    }
View Full Code Here

     * Test the preDestroy on stateless bean.
     */
    @Test
    public void testStatelessPreDestroy() {
        assertFalse(statelessBean.isPreDestroyCalled());
        EasyBeansSLSBLifeCycle lifeCycle = getSLSBLifeCycle();
        lifeCycle.preDestroyEasyBeansLifeCycle();

        assertTrue(statelessBean.isPreDestroyCalled());
    }
View Full Code Here

     * Test the postConstruct on stateless bean.
     */
    @Test
    public void testStateless2PostConstruct() {
        assertFalse(statelessBean2.isPostConstructCalled());
        EasyBeansSLSBLifeCycle lifeCycle = getSLSB2LifeCycle();
        lifeCycle.postConstructEasyBeansLifeCycle();

        assertTrue(statelessBean2.isPostConstructCalled());
    }
View Full Code Here

     * Test the preDestroy on stateless bean.
     */
    @Test
    public void testStateless2PreDestroy() {
        assertFalse(statelessBean2.isPreDestroyCalled());
        EasyBeansSLSBLifeCycle lifeCycle = getSLSB2LifeCycle();
        lifeCycle.preDestroyEasyBeansLifeCycle();

        assertTrue(statelessBean2.isPreDestroyCalled());
    }
View Full Code Here

     */
    @Test
    public void testStateless3() {
        assertEquals(0, statelessBean3.getCounter());

        EasyBeansSLSBLifeCycle lifeCycle = getSLSB3LifeCycle();

        // postConstruct should increment the counter
        lifeCycle.postConstructEasyBeansLifeCycle();
        assertEquals(1, statelessBean3.getCounter());

        // preDestroy should decrement the counter
        lifeCycle.preDestroyEasyBeansLifeCycle();
        assertEquals(0, statelessBean3.getCounter());
    }
View Full Code Here

    @Test
    public void testInheritanceBeanLifeCycleStateless() {
        assertEquals(0, statelessBean.getCounter());
        assertEquals(0, statelessBean.getSuperLifeCycleCounter());

        EasyBeansSLSBLifeCycle lifeCycle = getSLSBLifeCycle();

        // postConstruct should increment the counter
        lifeCycle.postConstructEasyBeansLifeCycle();
        assertEquals(1, statelessBean.getCounter());
        // and the counter of the super class
        assertEquals(1, statelessBean.getSuperLifeCycleCounter());

        // preDestroy should decrement the counter
        lifeCycle.preDestroyEasyBeansLifeCycle();
        assertEquals(0, statelessBean.getCounter());
        assertEquals(0, statelessBean.getSuperLifeCycleCounter());
    }
View Full Code Here

                    throw new EZBComponentException("Cannot start the CMI Server", e);
                }
            }
        }
        // register the listener.
        EZBEventListener eventListener = new CmiEventListener();
        this.eventComponent.registerEventListener(eventListener);

        this.logger.debug("The CMI configuration extension has been added.");
    }
View Full Code Here

TOP

Related Classes of org.ow2.easybeans.api.bean.lifecycle.EasyBeansSLSBLifeCycle

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.