Package org.jboss.as.naming

Examples of org.jboss.as.naming.ExternalContextObjectFactory$LookupByStringContext


        final String moduleID = NamingBindingResourceDefinition.MODULE.resolveModelAttribute(context, model).asString();
        final String className = NamingBindingResourceDefinition.CLASS.resolveModelAttribute(context, model).asString();
        final ModelNode cacheNode = NamingBindingResourceDefinition.CACHE.resolveModelAttribute(context, model);
        boolean cache = cacheNode.isDefined() ? cacheNode.asBoolean() : false;

        final ObjectFactory objectFactoryClassInstance = new ExternalContextObjectFactory();

        final ServiceTarget serviceTarget = context.getServiceTarget();
        final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);

        final Hashtable<String, String> environment = getObjectFactoryEnvironment(context, model);
        environment.put(ExternalContextObjectFactory.CACHE_CONTEXT, Boolean.toString(cache));
        environment.put(ExternalContextObjectFactory.INITIAL_CONTEXT_CLASS, className);
        environment.put(ExternalContextObjectFactory.INITIAL_CONTEXT_MODULE, moduleID);

        final ExternalContextBinderService binderService = new ExternalContextBinderService(name, objectFactoryClassInstance);
        binderService.getManagedObjectInjector().inject(new ContextListAndJndiViewManagedReferenceFactory() {
            @Override
            public ManagedReference getReference() {
                try {
                    final Object value = objectFactoryClassInstance.getObjectInstance(name, null, null, environment);
                    return new ImmediateManagedReference(value);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            @Override
            public String getInstanceClassName() {
                return className;
            }

            @Override
            public String getJndiViewInstanceValue() {
                final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
                try {
                    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(objectFactoryClassInstance.getClass().getClassLoader());
                    return String.valueOf(getReference().getInstance());
                } finally {
                    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
                }
            }
View Full Code Here

TOP

Related Classes of org.jboss.as.naming.ExternalContextObjectFactory$LookupByStringContext

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.