ee/src/main/java/org/jboss/as/ee/component/LookupInjectionSource.java
public void getResourceValue(final ResolutionContext resolutionContext, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) {
        final String applicationName = resolutionContext.getApplicationName();
        final String moduleName = resolutionContext.getModuleName();
        final String componentName = resolutionContext.getComponentName();
        final boolean compUsesModule = resolutionContext.isCompUsesModule();
        final String scheme = org.jboss.as.naming.InitialContext.getURLScheme(lookupName);
        if (scheme == null) {
            // relative name, build absolute name and setup normal lookup injection
            if (componentName != null && !compUsesModule) {
                ContextNames.bindInfoFor(applicationName, moduleName, componentName, "java:comp/env/" + lookupName)
                        .setupLookupInjection(serviceBuilder, injector, phaseContext.getDeploymentUnit(), optional);
            } else if (compUsesModule) {
                ContextNames.bindInfoFor(applicationName, moduleName, componentName, "java:module/env/" + lookupName)
                        .setupLookupInjection(serviceBuilder, injector, phaseContext.getDeploymentUnit(), optional);
            } else {
                ContextNames.bindInfoFor(applicationName, moduleName, componentName, "java:jboss/env/" + lookupName)
                        .setupLookupInjection(serviceBuilder, injector, phaseContext.getDeploymentUnit(), optional);
            }
        } else {
            if (scheme.equals("java")) {
                // an absolute java name, setup normal lookup injection
                if (compUsesModule && lookupName.startsWith("java:comp/")) {
                    // switch "comp" with "module"
                    ContextNames.bindInfoFor(applicationName, moduleName, componentName, "java:module/" + lookupName.substring(10))
                            .setupLookupInjection(serviceBuilder, injector, phaseContext.getDeploymentUnit(), optional);
                } else {
                    ContextNames.bindInfoFor(applicationName, moduleName, componentName, lookupName)
                            .setupLookupInjection(serviceBuilder, injector, phaseContext.getDeploymentUnit(), optional);
                }
            } else {
                // an absolute non java name
                final ManagedReferenceFactory managedReferenceFactory;
                if (URL_SCHEMES.contains(scheme)) {
                    // a Java EE Standard Resource Manager Connection Factory for URLs, using lookup to define value of URL, inject factory that creates URL instances
                    managedReferenceFactory = new ManagedReferenceFactory() {
                        @Override
                        public ManagedReference getReference() {
                            try {
                                return new ImmediateManagedReference(new URL(lookupName));
                            } catch (MalformedURLException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    };
                } else {
                    // lookup for a non java jndi resource, inject factory which does a true jndi lookup
                    managedReferenceFactory = new ManagedReferenceFactory() {
                        @Override
                        public ManagedReference getReference() {
                            try {
                                return new ImmediateManagedReference(new InitialContext().lookup(lookupName));
                            } catch (NamingException e) {
                                EeLogger.ROOT_LOGGER.tracef(e, "failed to lookup %s", lookupName);
                                return null;
                            }
                        }
                    };
                }
                injector.inject(managedReferenceFactory);
            }
        }
    }
public void getResourceValue(final ResolutionContext resolutionContext, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) {
        final String applicationName = resolutionContext.getApplicationName();
        final String moduleName = resolutionContext.getModuleName();
        final String componentName = resolutionContext.getComponentName();
        final boolean compUsesModule = resolutionContext.isCompUsesModule();
        final String scheme = org.jboss.as.naming.InitialContext.getURLScheme(lookupName);
        if (scheme == null) {
            // relative name, build absolute name and setup normal lookup injection
            if (componentName != null && !compUsesModule) {
                ContextNames.bindInfoFor(applicationName, moduleName, componentName, "java:comp/env/" + lookupName)
                        .setupLookupInjection(serviceBuilder, injector, phaseContext.getDeploymentUnit(), optional);
            } else if (compUsesModule) {
                ContextNames.bindInfoFor(applicationName, moduleName, componentName, "java:module/env/" + lookupName)
                        .setupLookupInjection(serviceBuilder, injector, phaseContext.getDeploymentUnit(), optional);
            } else {
                ContextNames.bindInfoFor(applicationName, moduleName, componentName, "java:jboss/env/" + lookupName)
                        .setupLookupInjection(serviceBuilder, injector, phaseContext.getDeploymentUnit(), optional);
            }
        } else {
            if (scheme.equals("java")) {
                // an absolute java name, setup normal lookup injection
                if (compUsesModule && lookupName.startsWith("java:comp/")) {
                    // switch "comp" with "module"
                    ContextNames.bindInfoFor(applicationName, moduleName, componentName, "java:module/" + lookupName.substring(10))
                            .setupLookupInjection(serviceBuilder, injector, phaseContext.getDeploymentUnit(), optional);
                } else {
                    ContextNames.bindInfoFor(applicationName, moduleName, componentName, lookupName)
                            .setupLookupInjection(serviceBuilder, injector, phaseContext.getDeploymentUnit(), optional);
                }
            } else {
                // an absolute non java name
                final ManagedReferenceFactory managedReferenceFactory;
                if (URL_SCHEMES.contains(scheme)) {
                    // a Java EE Standard Resource Manager Connection Factory for URLs, using lookup to define value of URL, inject factory that creates URL instances
                    managedReferenceFactory = new ManagedReferenceFactory() {
                        @Override
                        public ManagedReference getReference() {
                            try {
                                return new ImmediateManagedReference(new URL(lookupName));
                            } catch (MalformedURLException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    };
                } else {
                    // lookup for a non java jndi resource, inject factory which does a true jndi lookup
                    managedReferenceFactory = new ManagedReferenceFactory() {
                        @Override
                        public ManagedReference getReference() {
                            try {
                                return new ImmediateManagedReference(new InitialContext().lookup(lookupName));
                            } catch (NamingException e) {
                                EeLogger.ROOT_LOGGER.tracef(e, "failed to lookup %s", lookupName);
                                return null;
                            }
                        }
                    };
                }
                injector.inject(managedReferenceFactory);
            }
        }
    }
public void getResourceValue ( final ResolutionContext resolutionContext , final ServiceBuilder < ? > serviceBuilder , final DeploymentPhaseContext phaseContext , final Injector < ManagedReferenceFactory > injector ) { final String applicationName = resolutionContext . getApplicationName ( ) ; final String moduleName = resolutionContext . getModuleName ( ) ; final String componentName = resolutionContext . getComponentName ( ) ; final boolean compUsesModule = resolutionContext . isCompUsesModule ( ) ; final String scheme = org . jboss . as . naming . InitialContext . getURLScheme ( lookupName ) ; if ( scheme == null ) { // relative name, build absolute name and setup normal lookup injection if ( componentName != null && ! compUsesModule ) { ContextNames . bindInfoFor ( applicationName , moduleName , componentName , "java:comp/env/" + lookupName ) . setupLookupInjection ( serviceBuilder , injector , phaseContext . getDeploymentUnit ( ) , optional ) ; } else if ( compUsesModule ) { ContextNames . bindInfoFor ( applicationName , moduleName , componentName , "java:module/env/" + lookupName ) . setupLookupInjection ( serviceBuilder , injector , phaseContext . getDeploymentUnit ( ) , optional ) ; } else { ContextNames . bindInfoFor ( applicationName , moduleName , componentName , "java:jboss/env/" + lookupName ) . setupLookupInjection ( serviceBuilder , injector , phaseContext . getDeploymentUnit ( ) , optional ) ; } } else { if ( scheme . equals ( "java" ) ) { // an absolute java name, setup normal lookup injection if ( compUsesModule && lookupName . startsWith ( "java:comp/" ) ) { // switch "comp" with "module" ContextNames . bindInfoFor ( applicationName , moduleName , componentName , "java:module/" + lookupName . substring ( 10 ) ) . setupLookupInjection ( serviceBuilder , injector , phaseContext . getDeploymentUnit ( ) , optional ) ; } else { ContextNames . bindInfoFor ( applicationName , moduleName , componentName , lookupName ) . setupLookupInjection ( serviceBuilder , injector , phaseContext . getDeploymentUnit ( ) , optional ) ; } } else { // an absolute non java name final ManagedReferenceFactory managedReferenceFactory ; if ( URL_SCHEMES . contains ( scheme ) ) { // a Java EE Standard Resource Manager Connection Factory for URLs, using lookup to define value of URL, inject factory that creates URL instances managedReferenceFactory = new ManagedReferenceFactory ( ) { @ Override public ManagedReference getReference ( ) { try { return new ImmediateManagedReference ( new URL ( lookupName ) ) ; } catch ( MalformedURLException e ) { throw new RuntimeException ( e ) ; } } } ; } else { // lookup for a non java jndi resource, inject factory which does a true jndi lookup managedReferenceFactory = new ManagedReferenceFactory ( ) { @ Override public ManagedReference getReference ( ) { try { return new ImmediateManagedReference ( new InitialContext ( ) . lookup ( lookupName ) ) ; } catch ( NamingException e ) { EeLogger . ROOT_LOGGER . tracef ( e , "failed to lookup %s" , lookupName ) ; return null ; } } } ; } injector . inject ( managedReferenceFactory ) ; } } }
{@inheritDoc}
{