Examples of IJAnnotationResource


Examples of org.ow2.util.ee.metadata.common.api.struct.IJAnnotationResource

            // inject field
            injectEJB(jejb, sharedMetadata, clazz, instance);
        }

        // Inject Resources
        IJAnnotationResource jAnnotationResource = sharedMetadata.getJAnnotationResource();
        if (jAnnotationResource != null) {
            // Update interface name
            jAnnotationResource.setType(getInterfaceName(sharedMetadata));

            // inject field
            injectResource(jAnnotationResource, sharedMetadata, clazz, instance);
        }
View Full Code Here

Examples of org.ow2.util.ee.metadata.common.api.struct.IJAnnotationResource

            for (IJAnnotationResource jAnnotationResource : jAnnotationResources) {
                bindResource(jAnnotationResource, mv);
            }
        }
        // @Resource annotation
        IJAnnotationResource jAnnotationResource = this.classAnnotationMetadata.getJAnnotationResource();
        if (jAnnotationResource != null) {
            bindResource(jAnnotationResource, mv);
        }

    }
View Full Code Here

Examples of org.ow2.util.ee.metadata.common.api.struct.IJAnnotationResource


            }

            // @Resource annotation
            IJAnnotationResource jAnnotationResource = fieldMetaData.getJAnnotationResource();
            if (jAnnotationResource != null) {

                // Set default name if not present.
                jAnnotationResource.setName(getJndiName(jAnnotationResource.getName(), fieldMetaData));


                // Update annotation value with data set on the class
                updateAnnotationResource(jAnnotationResource);

                // Get Mapped Name / lookup Name
                String mappedName = jAnnotationResource.getMappedName();
                String lookupName = jAnnotationResource.getLookup();

                // Use MessageDestinationLink if present !
                String messageDestinationLink = jAnnotationResource.getMessageDestinationLink();
                if (messageDestinationLink != null) {
                    try {
                        mappedName = this.containerJNDIResolver.getMessageDestinationJNDIUniqueName(messageDestinationLink);
                    } catch (EZBJNDIResolverException e) {
                        throw new IllegalStateException("No JNDI name found when analyzing @Resource annotation '"
                                + jAnnotationResource + "' for the class '" + this.classAnnotationMetadata.getClassName()
                                + "'.", e);
                    }
                }

                // validate
                validateAccessFieldAnnotation(fieldMetaData);

                if (SESSION_CONTEXT.equals(itfName)) {
                    logger.debug("Add injection for @Resource on attribute {0} of class {1} for the type {2}",
                            fieldMetaData.getFieldName(), this.classAnnotationMetadata.getClassName(), itfName);

                    // this.attribute = getEasyBeansContext();
                    mv.visitVarInsn(ALOAD, 0);
                    addCallGetEasyBeansContext(mv, "javax/ejb/SessionContext");
                    mv.visitFieldInsn(PUTFIELD, this.classAnnotationMetadata.getClassName(), fieldMetaData.getFieldName(),
                            "Ljavax/ejb/SessionContext;");
                    // Define the type (if missing)
                    jAnnotationResource.setType(SESSION_CONTEXT);

                    bindResource(jAnnotationResource, mv);
                } else if (MESSAGEDRIVEN_CONTEXT.equals(itfName)) {
                    logger.debug("Add injection for @Resource on attribute {0} of class {1} for the type {2}",
                            fieldMetaData.getFieldName(), this.classAnnotationMetadata.getClassName(), itfName);

                    // this.attribute = getEasyBeansContext();
                    mv.visitVarInsn(ALOAD, 0);
                    addCallGetEasyBeansContext(mv, "javax/ejb/MessageDrivenContext");
                    mv.visitFieldInsn(PUTFIELD, this.classAnnotationMetadata.getClassName(), fieldMetaData.getFieldName(),
                            "Ljavax/ejb/MessageDrivenContext;");
                    // Define the type (if missing)
                    jAnnotationResource.setType(MESSAGEDRIVEN_CONTEXT);

                    bindResource(jAnnotationResource, mv);

                } else if (EJBCONTEXT.equals(itfName)) {
                    logger.debug("Add injection for @Resource on attribute {0} of class {1} for the type {2}",
                            fieldMetaData.getFieldName(), this.classAnnotationMetadata.getClassName(), itfName);

                    // this.attribute = getEasyBeansContext();
                    mv.visitVarInsn(ALOAD, 0);
                    addCallGetEasyBeansContext(mv, "javax/ejb/EJBContext");
                    mv.visitFieldInsn(PUTFIELD, this.classAnnotationMetadata.getClassName(), fieldMetaData.getFieldName(),
                            "Ljavax/ejb/EJBContext;");
                    // Define the type (if missing)
                    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,
                            this.classAnnotationMetadata.getClassName(), type);
                } else if (mappedName != null && !mappedName.equals("")) {
                        callAttributeJndi(mappedName, typeInterface, mv, fieldMetaData,
                                this.classAnnotationMetadata.getClassName(), REGISTRY);
                        callBindAttributeJndi(jAnnotationResource.getName(), mappedName, mv, fieldMetaData);
                    }

            }

            // @WebServiceRef annotation
View Full Code Here

Examples of org.ow2.util.ee.metadata.common.api.struct.IJAnnotationResource

     * @param jAnnotationResource the resource to update
     */
    private void updateAnnotationResource(final IJAnnotationResource jAnnotationResource) {
        // Search if no resource was defined on the class.
        List<IJAnnotationResource> classResources = null;
        IJAnnotationResource resClass = this.classAnnotationMetadata.getJAnnotationResource();
        if (resClass != null) {
            classResources = new ArrayList<IJAnnotationResource>();
            classResources.add(resClass);
        } else {
            classResources = this.classAnnotationMetadata.getJAnnotationResources();
View Full Code Here

Examples of org.ow2.util.ee.metadata.common.api.struct.IJAnnotationResource

            // Ignore inherited methods (managed by super class)
            if (methodMetaData.isInherited()) {
                continue;
            }

            IJAnnotationResource jAnnotationResource = methodMetaData.getJAnnotationResource();
            // &#64;Resource annotation
            if (jAnnotationResource != null) {
                Type typeInterface = validateSetterMethod(methodMetaData);
                String itfName = typeInterface.getClassName();

                // Set default name if not present.
                jAnnotationResource.setName(getJndiName(jAnnotationResource.getName(), methodMetaData));

                // Update annotation value with data set on the class
                updateAnnotationResource(jAnnotationResource);

                // Get lookup / Mapped Name
                String lookupName = jAnnotationResource.getLookup();
                String mappedName = jAnnotationResource.getMappedName();

                // Use MessageDestinationLink if present !
                String messageDestinationLink = jAnnotationResource.getMessageDestinationLink();
                if (messageDestinationLink != null) {
                    try {
                        mappedName = this.containerJNDIResolver.getMessageDestinationJNDIUniqueName(messageDestinationLink);
                    } catch (EZBJNDIResolverException e) {
                        throw new IllegalStateException("No JNDI name found when analyzing @Resource annotation '"
                                + jAnnotationResource + "' for the class '" + this.classAnnotationMetadata.getClassName()
                                + "'.", e);
                    }
                }

                // 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,
                            this.classAnnotationMetadata.getClassName(), type);
                } else if (mappedName != null && !mappedName.equals("")) {
                    // Get JNDI value from registry and call setter method
                    callMethodJndiEnv(mappedName, typeInterface, mv, methodMetaData,
                            this.classAnnotationMetadata.getClassName(), REGISTRY);
                    // Then bind attribute in ENC
                    callBindLookupJndiRef(jAnnotationResource.getName(), mappedName, mv);
                }
            }

            // &#64;EJB annotation
            IJEjbEJB jEjb = methodMetaData.getJEjbEJB();
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.