Examples of EnvEntry


Examples of org.apache.openejb.jee.EnvEntry

        logger.debug("context path = " + path);
        webModule.setHost(standardContext.getHostname());
        // Add all Tomcat env entries to context so they can be overriden by the env.properties file
        NamingResources naming = standardContext.getNamingResources();
        for (ContextEnvironment environment : naming.findEnvironments()) {
            EnvEntry envEntry = webApp.getEnvEntryMap().get(environment.getName());
            if (envEntry == null) {
                envEntry = new EnvEntry();
                envEntry.setName(environment.getName());
                webApp.getEnvEntry().add(envEntry);
            }

            envEntry.setEnvEntryValue(environment.getValue());
            envEntry.setEnvEntryType(environment.getType());
        }

        // remove all jndi entries where there is a configured Tomcat resource or resource-link
        for (ContextResource resource : naming.findResources()) {
            String name = resource.getName();
View Full Code Here

Examples of org.apache.openejb.jee.EnvEntry

        // ApplicationClient META-INF/env-entries.properties
        for (ClientModule module : appModule.getClientModules()) {
            if (module.getApplicationClient() == null) continue;
            for (Map.Entry<String, String> entry : getEnvEntries(module).entrySet()) {
                EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
                apply(module.getApplicationClient(), envEntry, "AppClient");
            }
        }

        // WebModule META-INF/env-entries.properties
        for (WebModule webModule : appModule.getWebModules()) {
            deploy(webModule);
        }

        // Resource Adapters do not have an ENC

        // EjbJar META-INF/env-entries.properties
        for (EjbModule module : appModule.getEjbModules()) {
            for (Map.Entry<String, String> entry : getEnvEntries(module).entrySet()) {
                EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());

                // To override a specific ejb only
                // the following format is used:
                // <ejb-name>.name = value
                if (envEntry.getName().contains(".")) {
                    String name = envEntry.getName();
                    String ejbName = name.substring(0,name.indexOf('.'));
                    name = name.substring(name.indexOf('.')+1);
                    EnterpriseBean bean = module.getEjbJar().getEnterpriseBean(ejbName);
                    if (bean != null){
                        // Set the new property name without the <ejb-name>. prefix
                        envEntry.setName(name);
                        apply(bean, envEntry, bean.getEjbName());
                        continue;
                    }
                }
View Full Code Here

Examples of org.apache.openejb.jee.EnvEntry

        return appModule;
    }

    public WebModule deploy(WebModule webModule) {
        for (Map.Entry<String, String> entry : getEnvEntries(webModule).entrySet()) {
            EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
            apply(webModule.getWebApp(), envEntry, "WebApp");
        }
        return webModule;
    }
View Full Code Here

Examples of org.apache.openejb.jee.EnvEntry

        }
        return webModule;
    }

    private void apply(JndiConsumer bean, EnvEntry newEntry, String componentName) {
        EnvEntry entry = bean.getEnvEntryMap().get(newEntry.getName());
        if(entry == null){
            entry = bean.getEnvEntryMap().get("java:comp/env/" + newEntry.getName());
        }
        if (entry != null){
            if (SystemInstance.get().getOptions().get("envprops.override", false)) {
                log.debug("envprops.override", componentName, entry.getName(), entry.getEnvEntryValue(), newEntry.getEnvEntryValue());
                entry.setEnvEntryValue(newEntry.getEnvEntryValue());
            }
            return;
        }

        // Must not be an override, just add the new entry
View Full Code Here

Examples of org.apache.openejb.jee.EnvEntry

        Bundle bundle = module.getEarContext().getDeploymentBundle();
        XmlObject[] gerEnvEntryUntyped = plan == null ? NO_REFS : plan.selectChildren(GER_ENV_ENTRY_QNAME_SET);
        Map<String, String> envEntryMap = mapEnvEntries(gerEnvEntryUntyped);
        for (Map.Entry<String, EnvEntry> entry : specDD.getEnvEntryMap().entrySet()) {
            String name = entry.getKey();
            EnvEntry envEntry = entry.getValue();

            if (lookupJndiContextMap(module, name) != null) {
                // some other builder handled this entry already
                addInjections(normalize(name), ReferenceType.ENV_ENTRY, envEntry.getInjectionTarget(), NamingBuilder.INJECTION_KEY.get(sharedContext));
                continue;
            }

            String type = getStringValue(envEntry.getEnvEntryType());

            Object value = null;

            String strValueOverride = envEntryMap.remove(name);
            String strValue = null;
            if (strValueOverride == null) {
                strValue = envEntry.getEnvEntryValue();
                String lookupName = getStringValue(envEntry.getLookupName());
                if (strValue != null && lookupName != null) {
                    throw new DeploymentException("You must specify an environment entry value or lookup name but not both. Component: " + module.toString() + ", name: " + name + ", env-entry-value: " + strValue + ", lookup-name: " + lookupName + "");
                }
                if (lookupName != null) {
                    //TODO better circular reference checking
                    if (lookupName.equals(getJndiName(name))) {
                        throw new DeploymentException("env-entry lookup name refers to itself");
                    }
                    value = new JndiReference(lookupName);
                }
            } else {
                strValue = strValueOverride;
            }

            type = inferAndCheckType(module, bundle, envEntry.getInjectionTarget(), name, type);


            if (value == null) {
                if (strValue == null) {
                    if ("org.apache.geronimo.kernel.Kernel".equals(type)) {
                        value = new KernelReference();
                    }
                } else {
                    Class<?> typeClass;
                    try {
                        typeClass = bundle.loadClass(type);
                    } catch (ClassNotFoundException e) {
                        throw new DeploymentException("Could not env-entry type class " + type, e);
                    }
                    try {
                        if (String.class.equals(typeClass)) {
                            value = strValue;
                        } else if (Character.class.equals(typeClass)) {
                            if (strValue.length() == 1) {
                                value = strValue.charAt(0);
                            } else {
                                log.warn("invalid character value: {} for name {}", strValue, name);
                                value = ' ';
                            }
                        } else if (Boolean.class.equals(typeClass)) {
                            value = Boolean.valueOf(strValue);
                        } else if (Byte.class.equals(typeClass)) {
                            value = Byte.valueOf(strValue);
                        } else if (Short.class.equals(typeClass)) {
                            value = Short.valueOf(strValue);
                        } else if (Integer.class.equals(typeClass)) {
                            value = Integer.valueOf(strValue);
                        } else if (Long.class.equals(typeClass)) {
                            value = Long.valueOf(strValue);
                        } else if (Float.class.equals(typeClass)) {
                            value = Float.valueOf(strValue);
                        } else if (Double.class.equals(typeClass)) {
                            value = Double.valueOf(strValue);
                        } else if (Class.class.equals(typeClass)) {
                            value = new ClassReference(strValue);
                        } else if (typeClass.isEnum()) {
                            value = Enum.valueOf(typeClass.asSubclass(Enum.class), strValue);
                        } else {
                            throw new DeploymentException("Unrecognized env-entry type: " + type);
                        }
                    } catch (NumberFormatException e) {
                        throw new DeploymentException("Invalid env-entry value for name: " + name, e);
                    }
                }
            }

            // perform resource injection only if there is a value specified
            // see Java EE 5 spec, section EE.5.4.1.3
            if (value != null) {
                put(name, value, ReferenceType.ENV_ENTRY, module.getJndiContext(), envEntry.getInjectionTarget(), sharedContext);
            } else if(isSharableJndiNamespace(name)) {
                //Even the value is configured, while it is belong to those shareable namespace, it is still to be added to the injection list
                addInjections(normalize(name), ReferenceType.ENV_ENTRY, envEntry.getInjectionTarget(), NamingBuilder.INJECTION_KEY.get(sharedContext));
            }
        }

        if (!envEntryMap.isEmpty()) {
            throw new DeploymentException("Unknown env-entry elements in geronimo plan: " + envEntryMap);
View Full Code Here

Examples of org.apache.openejb.jee.EnvEntry

            String resourceName = getResourceName(annotation, method, field);
            Class resourceType = getResourceTypeClass(annotation, method, field);
            if (knownEnvironmentEntries.contains(resourceType.getName()) || resourceType.isEnum()) {
                log.debug("addResource(): <env-entry> found");

                EnvEntry envEntry = annotatedApp.getEnvEntryMap().get(getJndiName(resourceName));

                if (envEntry == null) {
                    try {

                        log.debug("addResource(): Does not exist in DD: " + resourceName);

                        // Doesn't exist in deployment descriptor -- add new
                        envEntry = new EnvEntry();

                        //------------------------------------------------------------------------------
                        // <env-entry> required elements:
                        //------------------------------------------------------------------------------

                        // env-entry-name
                        envEntry.setEnvEntryName(resourceName);

                        if (!resourceType.equals(Object.class)) {
                            // env-entry-type
                            envEntry.setEnvEntryType(deprimitivize(resourceType).getCanonicalName());
                        }

                        //------------------------------------------------------------------------------
                        // <env-entry> optional elements:
                        //------------------------------------------------------------------------------

                        // mappedName
                        String mappdedNameAnnotation = annotation.mappedName();
                        if (!mappdedNameAnnotation.equals("")) {
                            envEntry.setMappedName(mappdedNameAnnotation);
                        }

                        // description
                        String descriptionAnnotation = annotation.description();
                        if (!descriptionAnnotation.equals("")) {
                            envEntry.setDescriptions(new Text[] {new Text(null, descriptionAnnotation)});
                        }

                        // lookup
                        String lookup = annotation.lookup();
                        if (!lookup.equals("")) {
                            envEntry.setLookupName(lookup);
                        }
                        annotatedApp.getEnvEntry().add(envEntry);
                    }
                    catch (Exception anyException) {
                        log.debug("ResourceAnnotationHelper: Exception caught while processing <env-entry>");
                    }
                }

                if (method != null || field != null) {
                    Set<InjectionTarget> targets = envEntry.getInjectionTarget();
                    if (!hasTarget(method, field, targets)) {
                        envEntry.getInjectionTarget().add(configureInjectionTarget(method, field));
                    }
                }

                return true;
            }
View Full Code Here

Examples of org.apache.openejb.jee.EnvEntry

            if (mergeItem != null) {
                if (mergeItem.isFromWebFragment()) {
                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("env-entry", envEntryName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
                } else if (mergeItem.isFromWebXml() && !isEnvEntryInjectTargetsConfiguredInInitialWebXML(envEntryName, mergeContext)) {
                    //Merge InjectTarget
                    EnvEntry envEntry = (EnvEntry) mergeItem.getValue();
                    for (InjectionTarget injectTarget : srcEnvEntry.getInjectionTarget()) {
                        String envEntryInjectTargetKey = createEnvEntryInjectTargetKey(envEntryName, injectTarget.getInjectionTargetClass(), injectTarget
                                .getInjectionTargetName());
                        if (!mergeContext.containsAttribute(envEntryInjectTargetKey)) {
                            envEntry.getInjectionTarget().add(injectTarget);
                            mergeContext.setAttribute(envEntryInjectTargetKey, Boolean.TRUE);
                        }
                    }
                }
            } else {
View Full Code Here

Examples of org.apache.openejb.jee.EnvEntry

    public AppModule deploy(AppModule appModule) throws OpenEJBException {

        // ApplicationClient META-INF/env-entries.properties
        for (ClientModule module : appModule.getClientModules()) {
            for (Map.Entry<String, String> entry : getEnvEntries(module).entrySet()) {
                EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
                apply(module.getApplicationClient(), envEntry, "AppClient");
            }
        }

        // WebModule META-INF/env-entries.properties
        for (WebModule webModule : appModule.getWebModules()) {
            for (Map.Entry<String, String> entry : getEnvEntries(webModule).entrySet()) {
                EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
                apply(webModule.getWebApp(), envEntry, "WebApp");
            }
        }

        // Resource Adapters do not have an ENC

        // EjbJar META-INF/env-entries.properties
        for (EjbModule module : appModule.getEjbModules()) {
            for (Map.Entry<String, String> entry : getEnvEntries(module).entrySet()) {
                EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());

                // To override a specific ejb only
                // the following format is used:
                // <ejb-name>.name = value
                if (envEntry.getName().contains(".")) {
                    String name = envEntry.getName();
                    String ejbName = name.substring(0,name.indexOf('.'));
                    name = name.substring(name.indexOf('.')+1);
                    EnterpriseBean bean = module.getEjbJar().getEnterpriseBean(ejbName);
                    if (bean != null){
                        // Set the new property name without the <ejb-name>. prefix
                        envEntry.setName(name);
                        apply(bean, envEntry, bean.getEjbName());
                        continue;
                    }
                }
View Full Code Here

Examples of org.apache.openejb.jee.EnvEntry

                     *
                     * Add an env-entry via @Resource if 'lookup' attribute is set.
                     */
                    final String lookupName = getLookupName(resource);
                    if (!lookupName.equals("")) {
                        final EnvEntry envEntry = new EnvEntry();
                        envEntry.setName(refName);
                        consumer.getEnvEntry().add(envEntry);

                        envEntry.setLookupName(lookupName);

                        reference = envEntry;
                    } else if (isShareableJNDINamespace(refName)) {
                        final EnvEntry envEntry = new EnvEntry();
                        envEntry.setName(refName);
                        consumer.getEnvEntry().add(envEntry);
                        reference = envEntry;
                    } else {

                        final String shortName = normalize(member.getName());
                        reference = consumer.getEnvEntryMap().get(shortName);

                        if (reference == null) {
                            final EnvEntry envEntry = new EnvEntry();
                            envEntry.setName(refName);
                            consumer.getEnvEntry().add(envEntry);
                            reference = envEntry;
                        }

//                        /*
 
View Full Code Here

Examples of org.apache.openejb.jee.EnvEntry

        System.out.println("context path = " + path);
        webModule.setHost(standardContext.getHostname());
        // Add all Tomcat env entries to context so they can be overriden by the env.properties file
        NamingResources naming = standardContext.getNamingResources();
        for (ContextEnvironment environment : naming.findEnvironments()) {
            EnvEntry envEntry = webApp.getEnvEntryMap().get(environment.getName());
            if (envEntry == null) {
                envEntry = new EnvEntry();
                envEntry.setName(environment.getName());
                webApp.getEnvEntry().add(envEntry);
            }

            envEntry.setEnvEntryValue(environment.getValue());
            envEntry.setEnvEntryType(environment.getType());
        }

        // remove all jndi entries where there is a configured Tomcat resource or resource-link
        for (ContextResource resource : naming.findResources()) {
            String name = resource.getName();
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.