Package org.jboss.as.naming

Examples of org.jboss.as.naming.ManagedReference


    @Override
    public Object processInvocation(final InterceptorContext interceptorContext) throws Exception {
        final WSComponent wsComponent = (WSComponent)interceptorContext.getPrivateData(Component.class);
        BasicComponentInstance pojoComponentInstance = null;
        if (interceptorContext.getPrivateData(ManagedReference.class) != null) {
           ManagedReference reference = interceptorContext.getPrivateData(ManagedReference.class);
           pojoComponentInstance = (BasicComponentInstance)wsComponent.createInstance(reference.getInstance());
        } else {
           pojoComponentInstance = wsComponent.getComponentInstance();
        }
        interceptorContext.putPrivateData(ComponentInstance.class, pojoComponentInstance);
        return interceptorContext.proceed();
View Full Code Here


    /**
     * {@inheritDoc}
     */
    public Object getInstance() {
        ManagedReference managedReference = (ManagedReference) getInstanceData(INSTANCE_KEY);
        if(managedReference == null) {
            //can happen if around construct chain returns null
            return null;
        }
        return managedReference.getInstance();
    }
View Full Code Here

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

        }
    }

    public ManagedReference initializeInstance(final Object instance) {
        setupComponent();
        return new ManagedReference() {

            private final ComponentInstance componentInstance = component.createInstance(instance);
            private boolean destroyed;

            @Override
View Full Code Here

        // will not be used, but if instance factory is not set then components must have default constructor, which is not a
        // requirement for MBeans
        configuration.setInstanceFactory(new ComponentFactory() {
                    @Override
                    public ManagedReference create(final InterceptorContext context) {
                        return new ManagedReference() {
                            @Override
                            public void release() {

                            }
View Full Code Here

                target = ((ManagedReference) componentInstance.getInstanceData(targetKey)).getInstance();
                if (target == null) {
                    throw EeLogger.ROOT_LOGGER.injectionTargetNotFound();
                }
            }
            final ManagedReference reference = factory.getReference();
            if (reference == null && optional) {
                return context.proceed();
            } else if(reference == null) {
                throw EeLogger.ROOT_LOGGER.managedReferenceWasNull(field);
            }
            boolean ok = false;
            try {
                componentInstance.setInstanceData(valueContextKey, reference);
                field.set(target, reference.getInstance());
                Object result = context.proceed();
                ok = true;
                return result;
            } finally {
                if (!ok) {
                    componentInstance.setInstanceData(valueContextKey, null);
                    reference.release();
                }
            }
        }
View Full Code Here

        this.contextKey = contextKey;
    }

    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class);
        final ManagedReference existing = (ManagedReference) componentInstance.getInstanceData(contextKey);
        if (existing == null) {
            final ManagedReference reference = componentFactory.create(context);
            boolean ok = false;
            try {
                componentInstance.setInstanceData(contextKey, reference);
                if (setTarget) {
                    context.setTarget(reference.getInstance());
                }
                Object result = context.proceed();
                ok = true;
                return result;
            } finally {
                if (!ok) {
                    reference.release();
                    componentInstance.setInstanceData(contextKey, reference);
                }
            }
        } else {
            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 getInstance() {
        final ManagedReference managedReference = this.instanceReference.get();
        return managedReference.getInstance();
    }
View Full Code Here

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