Package org.jboss.as.naming

Examples of org.jboss.as.naming.ManagedReference


                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);
                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


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

                clientPostConstructInterceptor.processInvocation(context);
            } catch (Exception e) {
                // TODO: What is the best exception type to throw here?
                throw MESSAGES.componentViewConstructionFailure(e);
            }
            return new ManagedReference() {

                @Override
                public void release() {
                    try {
                        InterceptorContext interceptorContext = new InterceptorContext();
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();
            } else if(reference == null) {
                throw EeMessages.MESSAGES.managedReferenceWasNull(field);
            }
            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

    }

    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 {
            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

        webComponentInstantiatorMap.put(className,instantiator);
        serviceNames.addAll(instantiator.getServiceNames());
    }

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

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

    private Object instantiate(ComponentInstantiator instantiator) {
        ManagedReference reference =  instantiator.getReference();
        instanceMap.put(reference.getInstance(),reference);
        return reference.getInstance();
    }
View Full Code Here

                if (component == null) {
                    component = ((ServiceController<WebComponent>) serviceRegistry.getRequiredService(serviceName)).getValue();
                }
            }
        }
        return new ManagedReference() {

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

            @Override
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Object getInstance() {
        final ManagedReference managedReference = this.instanceReference.get();
        return managedReference.getInstance();
    }
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.