Package org.ow2.easybeans.injection.JNDILookupHelper

Examples of org.ow2.easybeans.injection.JNDILookupHelper.JndiType


        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


            Thread.currentThread().setContextClassLoader(old);
            this.classLoader = null;
        }
        // Dispatch lifecycle event.
        this.dispatcher.dispatch(new EventContainerStopped(this.j2eeManagedObjectId, getArchive(), this.configuration));
        this.dispatcher.dispatch(new EventLifeCycleStopped(this.j2eeManagedObjectId));

        // Unregister from statistic component.
        EZBStatisticComponent statisticComponent = getComponent(EZBStatisticComponent.class);
        if (statisticComponent != null) {
            statisticComponent.unregisterJ2EEManagedObject(this);
View Full Code Here

                    jAnnotationResource.setType(EJBCONTEXT);

                    bindResource(jAnnotationResource, mv);

                } else if (isEnvEntry(typeInterface)) { // Env-Entry
                    JndiType type = JAVA_COMP_ENV;
                    // Lookup name exists ?
                    if (lookupName == null) {
                        lookupName = jAnnotationResource.getName();
                    }
                    if (lookupName.startsWith("java:")) {
                        type = JAVA;
                    }


                    callAttributeJndi(lookupName, typeInterface, mv, fieldMetaData,
                            this.classAnnotationMetadata.getClassName(), type);
                } else if (USERTRANSACTION_ITF.equals(itfName)) {
                    callAttributeJndi("UserTransaction", typeInterface, mv, fieldMetaData,
                            this.classAnnotationMetadata.getClassName(), JAVA_COMP);
                    callBindAttributeJndi(jAnnotationResource.getName(), "java:comp/UserTransaction", mv, fieldMetaData);
                } else if (URL_ITF.equals(itfName)) {
                    // Bind object in java:comp/env
                    callBindLookupURLRef(jAnnotationResource.getName(), mappedName, mv);

                    // Set attribute
                    callAttributeJndi(jAnnotationResource.getName(), typeInterface, mv, fieldMetaData,
                            this.classAnnotationMetadata.getClassName(), JAVA_COMP_ENV);
                } else if (TIMERSERVICE_ITF.equals(itfName)) {
                    // Needs to get timerservice with the bean's context.
                    //this.fieldtimerService = getEasyBeansContext().getInternalTimerService();
                    mv.visitVarInsn(ALOAD, 0);
                    addCallGetEasyBeansContext(mv, null);
                    mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(EZBEJBContext.class), "getInternalTimerService",
                    "()Ljavax/ejb/TimerService;");
                    mv.visitFieldInsn(PUTFIELD, this.classAnnotationMetadata.getClassName(), fieldMetaData.getFieldName(),
                            "Ljavax/ejb/TimerService;");
                    callBindAttributeJndi(jAnnotationResource.getName(), "java:comp/TimerService", mv, fieldMetaData);
                } else if (ORB_ITF.equals(itfName)) {
                    callAttributeJndi("ORB", typeInterface, mv, fieldMetaData,
                            this.classAnnotationMetadata.getClassName(), JAVA_COMP);
                    callBindAttributeJndi(jAnnotationResource.getName(), "java:comp/ORB", mv, fieldMetaData);
                } else if (lookupName != null && !lookupName.equals("")) {
                    JndiType type = REGISTRY;
                    // Lookup name ?
                    if (lookupName.startsWith("java:")) {
                        type = JAVA;
                    }
                    callAttributeJndi(lookupName, typeInterface, mv, fieldMetaData,
View Full Code Here

                }

                // Env-Entry
                if (isEnvEntry(typeInterface)) {

                    JndiType type = JAVA_COMP_ENV;
                    // Lookup name exists ?
                    if (lookupName == null) {
                        lookupName = jAnnotationResource.getName();
                    }
                    if (lookupName.startsWith("java:")) {
                        type = JAVA;
                    }


                    callMethodJndiEnv(lookupName, typeInterface, mv, methodMetaData,
                            this.classAnnotationMetadata.getClassName(), type);
                } else if (USERTRANSACTION_ITF.equals(itfName)) {
                    callMethodJndiEnv("UserTransaction", typeInterface, mv, methodMetaData,
                            this.classAnnotationMetadata.getClassName(), JAVA_COMP);
                    callBindLookupJndiRef(jAnnotationResource.getName(), "java:comp/UserTransaction", mv);
                } else if (TIMERSERVICE_ITF.equals(itfName)) {
                    // add call to : setterMethod(getEasyBeansContext().getInternalTimerService());
                    mv.visitVarInsn(ALOAD, 0);
                    addCallGetEasyBeansContext(mv, null);
                    mv.visitMethodInsn(INVOKEINTERFACE, "org/ow2/easybeans/api/container/EZBEJBContext",
                            "getInternalTimerService", "()Ljavax/ejb/TimerService;");
                    mv.visitMethodInsn(INVOKEVIRTUAL, this.classAnnotationMetadata.getClassName(), methodMetaData.getMethodName(),
                            "(Ljavax/ejb/TimerService;)V");
                    callBindLookupJndiRef(jAnnotationResource.getName(), "java:comp/TimerService", mv);
                } else if (SESSION_CONTEXT.equals(itfName)) {
                    // add call to : setterMethod(getEasyBeansContext());
                    mv.visitVarInsn(ALOAD, 0);
                    addCallGetEasyBeansContext(mv, "javax/ejb/SessionContext");
                    mv.visitMethodInsn(INVOKEVIRTUAL, this.classAnnotationMetadata.getClassName(), methodMetaData.getMethodName(),
                            "(Ljavax/ejb/SessionContext;)V");

                    // Define the type (if missing)
                    jAnnotationResource.setType(SESSION_CONTEXT);
                    bindResource(jAnnotationResource, mv);
                } else if (MESSAGEDRIVEN_CONTEXT.equals(itfName)) {
                    // add call to : setterMethod(getEasyBeansContext());
                    mv.visitVarInsn(ALOAD, 0);
                    addCallGetEasyBeansContext(mv, "javax/ejb/MessageDrivenContext");
                    mv.visitMethodInsn(INVOKEVIRTUAL, this.classAnnotationMetadata.getClassName(), methodMetaData.getMethodName(),
                            "(Ljavax/ejb/MessageDrivenContext;)V");

                    // Define the type (if missing)
                    jAnnotationResource.setType(MESSAGEDRIVEN_CONTEXT);
                    bindResource(jAnnotationResource, mv);
                } else if (EJBCONTEXT.equals(itfName)) {
                    // add call to : setterMethod(getEasyBeansContext());
                    mv.visitVarInsn(ALOAD, 0);
                    addCallGetEasyBeansContext(mv, "javax/ejb/EJBContext");
                    mv.visitMethodInsn(INVOKEVIRTUAL, this.classAnnotationMetadata.getClassName(), methodMetaData.getMethodName(),
                            "(Ljavax/ejb/EJBContext;)V");

                    // Define the type (if missing)
                    jAnnotationResource.setType(EJBCONTEXT);
                    bindResource(jAnnotationResource, mv);
                } else if (ORB_ITF.equals(itfName)) {
                    callMethodJndiEnv("ORB", typeInterface, mv, methodMetaData,
                            this.classAnnotationMetadata.getClassName(), JAVA_COMP);
                    callBindLookupJndiRef(jAnnotationResource.getName(), "java:comp/ORB", mv);
                } else if (URL_ITF.equals(itfName)) {
                    // Bind object in java:comp/env
                    callBindLookupURLRef(jAnnotationResource.getName(), mappedName, mv);

                    // Get JNDI value from registry and call setter method
                    callMethodJndiEnv(jAnnotationResource.getName(), typeInterface, mv, methodMetaData,
                        this.classAnnotationMetadata.getClassName(), JAVA_COMP_ENV);
                } else if (lookupName != null && !lookupName.equals("")) {
                    JndiType type = REGISTRY;
                    // Lookup name ?
                    if (lookupName.startsWith("java:")) {
                        type = JAVA;
                    }
                    callMethodJndiEnv(lookupName, typeInterface, mv, methodMetaData,
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

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

        // Set value
View Full Code Here

            // Set value
            try {
                method.invoke(instance, value);
            } catch (IllegalAccessException e) {
                throw new ArchiveInjectionException("Cannot set given value on the method '" + jMethod + "'.", e);
            } catch (IllegalArgumentException e) {
                throw new ArchiveInjectionException("Cannot set given value on the method '" + jMethod + "'.", e);
            } catch (InvocationTargetException e) {
                throw new ArchiveInjectionException("Cannot set given value on the method '" + jMethod + "'.", e);
            }
        } finally {
            // set back accessible attribute
            method.setAccessible(accessible);
        }
View Full Code Here

TOP

Related Classes of org.ow2.easybeans.injection.JNDILookupHelper.JndiType

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.