Package org.jboss.as.naming

Examples of org.jboss.as.naming.ManagedReference


        this.instanceRef = instanceRef;
    }

    /** {@inheritDoc} */
    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ManagedReference reference = instanceRef.get();
        final Object instance = reference.getInstance();
        try {
            return method.invoke(instance, context.getParameters());
        } catch (IllegalAccessException e) {
            final IllegalAccessError n = new IllegalAccessError(e.getMessage());
            n.setStackTrace(e.getStackTrace());
View Full Code Here


    public Object processInvocation(final InterceptorContext context) throws Exception {
        Object target = targetReference.get().getInstance();
        if (target == null) {
            throw new IllegalStateException("No injection target found");
        }
        ManagedReference reference = factory.getReference();
        boolean ok = false;
        try {
            valueReference.set(reference);
            method.invoke(target, reference.getInstance());
            Object result = context.proceed();
            ok = true;
            return result;
        } finally {
            if (!ok) {
                valueReference.set(null);
                reference.release();
            }
        }
    }
View Full Code Here

     */
    public Object processInvocation(final InterceptorContext context) throws Exception {
        try {
            return context.proceed();
        } finally {
            final ManagedReference managedReference = referenceReference.getAndSet(null);
            if (managedReference != null) {
                managedReference.release();
            }
        }
    }
View Full Code Here

            @Override
            public ManagedReference getReference() {
                try {
                    final Object value = new InitialContext().lookup(lookup);

                    return new ManagedReference() {
                        @Override
                        public void release() {

                        }
View Full Code Here

    public ComponentConfiguration createConfiguration(final ClassIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
        final ComponentConfiguration configuration =  super.createConfiguration(classIndex, moduleClassLoader, moduleLoader);
        configuration.setInstanceFactory(new ComponentFactory() {
            @Override
            public ManagedReference create(final InterceptorContext context) {
                return new ManagedReference() {
                    @Override
                    public void release() {

                    }
View Full Code Here

                        ConcurrentReferenceHashMap.ReferenceType.WEAK, EnumSet.of(ConcurrentReferenceHashMap.Option.IDENTITY_COMPARISONS));
    }


    public void destroyInstance(Object instance) {
        final ManagedReference reference = instanceMap.remove(instance);
        if (reference != null) {
            reference.release();
        }
    }
View Full Code Here

        return newInstance(classloader.loadClass(className));
    }

    public Object newInstance(Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException {
        final ManagedReferenceFactory factory = componentRegistry.createInstanceFactory(clazz);
        ManagedReference reference = factory.getReference();
        if (reference != null) {
            instanceMap.put(reference.getInstance(), reference);
            return reference.getInstance();
        }
        return clazz.newInstance();
    }
View Full Code Here

        }
        return clazz.newInstance();
    }

    public void newInstance(Object arg0) throws IllegalAccessException, InvocationTargetException, NamingException {
        final ManagedReference reference = componentRegistry.createInstance(arg0);
        if (reference != null) {
            instanceMap.put(arg0, reference);
        }
    }
View Full Code Here

    }

    protected <T> T createViewInstanceProxy(final Class<T> viewInterface, final Map<Object, Object> contextData, final ServiceName serviceName) {
        final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(serviceName);
        final ComponentView view = (ComponentView) serviceController.getValue();
        final ManagedReference instance;
        try {
            if(WildFlySecurityManager.isChecking()) {
                instance = WildFlySecurityManager.doUnchecked(new PrivilegedExceptionAction<ManagedReference>() {
                    @Override
                    public ManagedReference run() throws Exception {
                        return view.createInstance(contextData);
                    }
                });
            } else {
                instance = view.createInstance(contextData);
            }
        } catch (Exception e) {
            //TODO: do we need to let the exception propagate here?
            throw new RuntimeException(e);
        }
        return viewInterface.cast(instance.getInstance());
    }
View Full Code Here

            final ConstructedValue interceptorInstanceValue = new ConstructedValue(interceptorConstructor, Collections.<Value<?>>emptyList());
            // we *don't* create multiple instances of the container-interceptor class, but we just reuse a single instance and it's *not*
            // tied to the EJB component instance lifecycle.
            final CachedValue cachedInterceptorInstanceValue = new CachedValue(interceptorInstanceValue);
            // ultimately create the managed reference which is backed by the CachedValue
            final ManagedReference interceptorInstanceRef = new ValueManagedReference(cachedInterceptorInstanceValue);
            // return the ContainerInterceptorMethodInterceptorFactory which is responsible for creating an Interceptor
            // which can invoke the container-interceptor's around-invoke/around-timeout methods
            return new ContainerInterceptorMethodInterceptorFactory(interceptorInstanceRef, method);
        }
View Full Code Here

TOP

Related Classes of org.jboss.as.naming.ManagedReference

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.