Package org.jboss.as.naming

Examples of org.jboss.as.naming.ManagedReference


        this.managedReferenceFactory = managedReferenceFactory;
    }

    @Override
    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ManagedReference managedReference = targetReference.get();
        if (managedReference instanceof WeldManagedReference) {
            final WeldManagedReference reference = (WeldManagedReference) managedReference;
            reference.getInjectionTarget().inject(targetReference.get().getInstance(), reference.getContext());
            //now inject the interceptors
            for (final Map.Entry<Class<?>, AtomicReference<ManagedReference>> entry : interceptors.entrySet()) {
                final ManagedReference instance = entry.getValue().get();
                if (instance != null) {
                    reference.injectInterceptor(entry.getKey(), instance.getInstance());
                }
            }
        } else if(managedReferenceFactory != null){
            //this component was not created by the managed reference factory, this can happen in the case of JSF managed beans
            final ManagedReference newReference = managedReferenceFactory.injectExistingReference(managedReference);
            targetReference.set(newReference);
        }
        return context.proceed();
    }
View Full Code Here


        }
        final Object instance = existing.getInstance();

        injectionTarget.inject(instance, ctx);

        return new ManagedReference() {
            @Override
            public void release() {
                try {
                    existing.release();
                } finally {
View Full Code Here

        /**
         * {@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

                target = targetReference.get().getInstance();
                if (target == null) {
                    throw MESSAGES.injectionTargetNotFound();
                }
            }
            final ManagedReference reference = factory.getReference();
            if (reference == null && optional) {
                return context.proceed();
            }
            boolean ok = false;
            try {
                valueReference.set(reference);
                field.set(target, reference.getInstance());
                Object result = context.proceed();
                ok = true;
                return result;
            } finally {
                if (!ok) {
                    valueReference.set(null);
                    reference.release();
                }
            }
        }
View Full Code Here

        /**
         * {@inheritDoc}
         */
        public Object processInvocation(final InterceptorContext context) throws Exception {
            final ManagedReference reference = instanceRef.get();
            final Object instance = reference.getInstance();
            try {
                final Method method = this.method;
                if (withContext) {
                    final Method oldMethod = context.getMethod();
                    try {
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

            this.componentInstantiator = componentInstantiator;
            this.referenceReference = referenceReference;
        }

        public Object processInvocation(final InterceptorContext context) throws Exception {
            final ManagedReference existing = referenceReference.get();
            if (existing == null) {
                final ManagedReference reference = componentInstantiator.getReference();
                boolean ok = false;
                try {
                    referenceReference.set(reference);
                    context.setTarget(reference.getInstance());
                    Object result = context.proceed();
                    ok = true;
                    return result;
                } finally {
                    context.setTarget(null);
                    if (!ok) {
                        reference.release();
                        referenceReference.set(null);
                    }
                }
            } else {
                return context.proceed();
View Full Code Here

                target = targetReference.get().getInstance();
                if (target == null) {
                    throw MESSAGES.injectionTargetNotFound();
                }
            }
            ManagedReference reference = factory.getReference();
            if (reference == null && optional) {
                return context.proceed();
            }
            boolean ok = false;
            try {
                valueReference.set(reference);
                final InvocationType invocationType = context.getPrivateData(InvocationType.class);
                try {
                    context.putPrivateData(InvocationType.class, InvocationType.DEPENDENCY_INJECTION);
                    method.invoke(target, reference.getInstance());
                } finally {
                    context.putPrivateData(InvocationType.class, invocationType);
                }
                Object result = context.proceed();
                ok = true;
                return result;
            } finally {
                if (!ok) {
                    valueReference.set(null);
                    reference.release();
                }
            }
        }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Object getInstance() {
        final ManagedReference managedReference = this.instanceReference.get();
        return managedReference.getInstance();
    }
View Full Code Here

     * {@inheritDoc}
     */
    public final void destroy() {
        if (doneUpdater.compareAndSet(this, 0, 1)) try {
            preDestroy();
            final ManagedReference reference = instanceReference.get();
            if (reference != null) {
                final InterceptorContext interceptorContext = prepareInterceptorContext();
                interceptorContext.setTarget(reference.getInstance());
                interceptorContext.putPrivateData(InvocationType.class, InvocationType.PRE_DESTROY);
                preDestroy.processInvocation(interceptorContext);
            }
        } catch (Exception e) {
            ROOT_LOGGER.componentDestroyFailure(e, this);
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.