Package org.ow2.easybeans.event.naming

Examples of org.ow2.easybeans.event.naming.JavaContextNamingEvent


        if (auditComponent != null) {
            auditComponent.registerJ2EEManagedObject(this);
        }

        // Dispatch life cycle event.
        this.dispatcher.dispatch(new EventLifeCycleStarting(this.j2eeManagedObjectId));

        // Gets URL of the archive
        final URL url;
        try {
            url = getArchive().getURL();
View Full Code Here


     * Process the event.
     * @param event the given event
     */
    public void handle(final IEvent event) {

        JavaContextNamingEvent cne = (JavaContextNamingEvent) event;
        Factory<?, ?> easyBeansFactory = cne.getFactory();
        Context javaCtx = cne.getJavaContext();
        Context compCtx = null;
        try {
            compCtx = (Context) javaCtx.lookup("comp");
        } catch (NamingException e) {
            throwException(cne, new IllegalStateException("Cannot get java:comp object", e));
View Full Code Here

     * @return <code>true</code> if the proposed event is of the expected type
     */
    @Override
    public boolean accept(final IEvent event) {
        if (event instanceof JavaContextNamingEvent) {
            JavaContextNamingEvent namingEvent = (JavaContextNamingEvent) event;

            // source/event-provider-id attribute is used to filter the destination
            if ("java:".equals(namingEvent.getEventProviderId())) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

     * Process the event.
     * @param event the event
     */
    public void handle(final IEvent event) {

        JavaContextNamingEvent javaContextNamingEvent = (JavaContextNamingEvent) event;
        String beanName = javaContextNamingEvent.getFactory().getBeanInfo().getName();

        Context javaContext = javaContextNamingEvent.getJavaContext();
        Context javaCompEnvCtx = null;
        try {
            javaCompEnvCtx = (Context) javaContext.lookup("comp/env");
        } catch (NamingException e) {
            throwException(javaContextNamingEvent, new IllegalStateException("Cannot lookup java:comp/env element.", e));
        }

        Context javaModuleCtx = null;
        try {
            javaModuleCtx = (Context) javaContext.lookup("module");
        } catch (NamingException e) {
            throwException(javaContextNamingEvent, new IllegalStateException("Cannot lookup java:module element.", e));
        }

        Context javaAppCtx = null;
        try {
            javaAppCtx = (Context) javaContext.lookup("app");
        } catch (NamingException e) {
            throwException(javaContextNamingEvent, new IllegalStateException("Cannot lookup java:app element.", e));
        }

        Context javaGlobalCtx = null;
        try {
            javaGlobalCtx = (Context) javaContext.lookup("app");
        } catch (NamingException e) {
            throwException(javaContextNamingEvent, new IllegalStateException("Cannot lookup java:app element.", e));
        }

        for (IEnvEntry envEntry : javaContextNamingEvent.getBeanMetadata().getEnvEntryCollection()) {
            String name = envEntry.getName();
            Object value = getEnvEntryValue(envEntry, javaContextNamingEvent);
            // if null, no entry in java:comp/env as specified chapter 15.4.1
            if (value != null) {

View Full Code Here

     * @param event tested event
     * @return <code>true</code> if the proposed event is of the expected type
     */
    public boolean accept(final IEvent event) {
        if (event instanceof JavaContextNamingEvent) {
            JavaContextNamingEvent namingEvent = (JavaContextNamingEvent) event;

            // source/event-provider-id attribute is used to filter the destination
            if ("java:".equals(namingEvent.getEventProviderId())) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

        } catch (NamingException e) {
            throw new IllegalStateException("Cannot build a new environment", e);
        }

        // Send event for java: filling
        JavaContextNamingEvent event = new JavaContextNamingEvent("java:", javaCtx, easyBeansFactory, bean);
        dispatcher.dispatch(event);

        // Check if synchronous listeners have thrown some exceptions
        if (!event.getThrowables().isEmpty()) {
            throw new JavaContextHelperException("Cannot fill java:",
                                                 event.getThrowables().get(0));
        }

        return javaCtx;
    }
View Full Code Here

        // Get Deployable
        IDeployable<?> deployable = null;
        try {
            deployable = DeployableHelper.getDeployable(this.archive);
        } catch (DeployableHelperException e) {
            throw new ArchiveInjectionException("Unable to get a deployable on archive '" + this.archive + "'.", e);
        }

        // Client Archive ?
        if (CARDeployable.class.isInstance(deployable)) {
            // Create metadata
            ICarDeployableMetadata carDeployableMetadata = null;
            try {
                carDeployableMetadata = new CarDeployableMetadataFactory().createDeployableMetadata(CARDeployable.class
                        .cast(deployable), classLoader);
            } catch (DeployableMetadataException e) {
                throw new ArchiveInjectionException("Unable to get metadata on archive '" + this.archive + "'.", e);
            }

            // Use only common part
            this.metadataCollection = carDeployableMetadata.getCarClassMetadataCollection();
        } else {
View Full Code Here

        for (ICommonMethodMetadata<?, ?, ?> postConstructMethodMetadata : postConstructMethods) {
            Method postConstructMethod = null;
            try {
                postConstructMethod = clazz.getDeclaredMethod(postConstructMethodMetadata.getJMethod().getName());
            } catch (NoSuchMethodException e) {
                throw new ArchiveInjectionException("Cannot invoke postconstruct method", e);
            }

            boolean accessible = postConstructMethod.isAccessible();
            try {
                postConstructMethod.setAccessible(true);
                postConstructMethod.invoke(instance);
            } catch (IllegalAccessException e) {
                throw new ArchiveInjectionException("Cannot invoke postconstruct method", e);
            } catch (InvocationTargetException e) {
                throw new ArchiveInjectionException("Cannot invoke postconstruct method", e);
            } finally {
                postConstructMethod.setAccessible(accessible);
            }
        }
View Full Code Here

            // OK, now that JNDI name is here, get value
            try {
                value = new InitialContext().lookup(jndiName);
            } catch (NamingException e) {
                throw new ArchiveInjectionException("Cannot get object with JNDI Name '" + jndiName + "' for ejb '" + ejb
                        + "'.", e);
            }
        }

        // Set value
View Full Code Here

        // No value, needs to find it
        if (value == null) {
            try {
                value = new InitialContext().lookup(name);
            } catch (NamingException e) {
                throw new ArchiveInjectionException("Cannot get object with JNDI Name '" + name + "' for Resource '"
                        + jJavaxPersistenceUnit + "'.", e);
            }
        }

        // Set value
View Full Code Here

TOP

Related Classes of org.ow2.easybeans.event.naming.JavaContextNamingEvent

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.