Examples of IEventDispatcher


Examples of org.ow2.util.event.api.IEventDispatcher

        if (eventComponent == null) {
            throw new EZBContainerException("Event component is required !");
        }

        // Create/Start/Register a new event dispatcher
        IEventDispatcher eventDispatcher = eventComponent.createEventDispatcher();
        eventDispatcher.start();

        // The topic is common for all EZBContainer and Factory
        eventComponent.getEventService().registerDispatcher(Embedded.NAMING_EXTENSION_POINT,
                                                            eventDispatcher);

        logger.debug("EventService instance {0}", eventComponent.getEventService());

        // Wrap in a try/finally block to be able to stop/unregister the dispatcher afterall
        try {
            this.ejbJarInfo = new EJBJarInfo();
            // bind session beans
            EjbJarArchiveMetadata ejbMetadata = this.deployment.getEjbJarArchiveMetadata();
            if (ejbMetadata != null) {
                List<String> beanNames = this.deployment.getEjbJarArchiveMetadata().getBeanNames();
                for (String beanName : beanNames) {
                    for (EasyBeansEjbJarClassMetadata classAnnotationMetadata : this.deployment.getEjbJarArchiveMetadata()
                            .getClassesForBean(beanName)) {
                        Factory<?, ?> factory = null;
                        if (classAnnotationMetadata.isSession()) {
                            factory = createSessionBeanFactory(classAnnotationMetadata);
                        } else if (classAnnotationMetadata.isMdb()) {
                            factory = createMessageDrivenBeanFactory(classAnnotationMetadata);
                        }

                        // Post-Configure the created factories.
                        if (factory != null) {

                            // Adds more runtime info
                            IBeanInfo beanInfo = factory.getBeanInfo();

                            // EJB Name
                            beanInfo.setName(classAnnotationMetadata.getJCommonBean().getName());

                            // Adds security info.
                            beanInfo.setSecurityInfo(SecurityInfoHelper.getSecurityInfo(classAnnotationMetadata));

                            // Adds Business method info.
                            beanInfo.setBusinessMethodsInfo(BusinessMethodsInfoHelper.getMethods(classAnnotationMetadata));

                            // Cluster config
                            beanInfo.setCluster(classAnnotationMetadata.getCluster());

                            // Set invocation context factor

                            if (Boolean.getBoolean("easybeans.dynamicinterceptors")) {
                              factory.setInvocationContextFactory(new EasyBeansInvocationContextFactory(classAnnotationMetadata,
                                   this.classLoader));
                            }
                            // Sets the bean info
                            this.ejbJarInfo.addBeanInfo(beanInfo);

                            // Build java: Context
                            Context javaContext;
                            try {
                                javaContext = JavaContextHelper.build(classAnnotationMetadata, factory, eventDispatcher);
                            } catch (JavaContextHelperException e) {
                                throw new EZBContainerException("Cannot build environment", e);
                            }

                            // Set java: context
                            factory.setJavaContext(javaContext);

                            // Add Management
                            try {
                                MBeansHelper.getInstance().registerMBean(factory);
                            } catch (MBeansException me) {
                                throw new EZBContainerException("Cannot register the factory MBean", me);
                            }

                            // Pool config
                            poolConfiguration(factory, classAnnotationMetadata);

                            // Init factory
                            try {
                                factory.init();
                            } catch (FactoryException e) {
                                throw new EZBContainerException("Cannot initialize the factory.", e);
                            }

                            // Add the factory to the managed factories
                            this.factories.put(beanName, factory);

                        }
                    }
                }
                //Register clustered beans if necessary.
                eventDispatcher.dispatch(new EventLifeCycleClusteredBean(Embedded.NAMING_EXTENSION_POINT,
                        EZBClusteredBeanEvent.STARTING, this.bindingReferences));

                // Bind references only once
                bindReferences();

                // Permission Manager.
                try {
                    this.permissionManager = new PermissionManager(getArchive().getURL(), this.ejbJarInfo);
                    // translate metadata into permission
                    this.permissionManager.translateMetadata();
                    // commit
                    this.permissionManager.commit();
                } catch (PermissionManagerException e) {
                    throw new EZBContainerException("Cannot create permission manager", e);
                } catch (ArchiveException e) {
                    throw new EZBContainerException("Cannot create permission manager", e);
                }

            }
        } finally {
            eventDispatcher.stop();
            eventComponent.getEventService().unregisterDispatcher(Embedded.NAMING_EXTENSION_POINT);
        }
    }
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.