Package org.jboss.as.naming

Examples of org.jboss.as.naming.ManagedReference


    public ComponentEntry createClient(final Class<?> viewClass) {
        final ComponentView view = views.get(viewClass);
        if (view == null) {
            throw new IllegalArgumentException("Non-existent view " + viewClass + " requested");
        }
        final ManagedReference managedReference = view.getReference();
        final Method[] methods = view.getProxyFactory().getCachedMethods();
        final IdentityHashMap<Method, Interceptor> interceptorMap = new IdentityHashMap<Method, Interceptor>();
        final SimpleInterceptorFactoryContext interceptorFactoryContext = new SimpleInterceptorFactoryContext();
        for (Method method : methods) {
            final InterceptorFactory interceptorFactory = interceptorFactoryMap.get(method);
            if (interceptorFactory != null) {
                interceptorMap.put(method, interceptorFactory.create(interceptorFactoryContext));
            }
        }
        final Set<Method> allowedMethods = Collections.unmodifiableSet(interceptorFactoryMap.keySet());
        return new ComponentEntry() {
            public Component getComponent() {
                return AbstractComponent.this;
            }

            public Class<?> getViewClass() {
                return viewClass;
            }

            public Collection<Method> allowedMethods() {
                return allowedMethods;
            }

            public Interceptor getEntryPoint(final Method method) throws IllegalArgumentException {
                Interceptor interceptor = interceptorMap.get(method);
                if (interceptor == null) {
                    throw new IllegalArgumentException("No entry point found for " + method);
                }
                return interceptor;
            }

            public boolean isAsynchronous(final Method method) throws IllegalArgumentException {
                if (! interceptorMap.containsKey(method)) {
                    throw new IllegalArgumentException("No entry point found for " + method);
                }
                return false;
            }

            public void destroy() {
                managedReference.release();
            }
        };
    }
View Full Code Here


    public ComponentConfiguration createConfiguration(final ClassIndex classIndex, final ClassLoader moduleClassLoder) {
        final ComponentConfiguration configuration =  super.createConfiguration(classIndex, moduleClassLoder);
        configuration.setInstanceFactory(new ManagedReferenceFactory() {
            @Override
            public ManagedReference getReference() {
                return new ManagedReference() {
                    @Override
                    public void release() {

                    }
View Full Code Here

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

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

        // Annnotations ? return newInstance(clazz.newInstance(), clazz);
        return clazz.newInstance();
    }

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

        try {
            proxy = proxyFactory.newInstance(new CmpEntityBeanInvocationHandler(component.getValue()));
        } catch (Exception e) {
            throw new RuntimeException("Failed to create proxy instance for: " + beanClass, e);
        }
        return new ManagedReference() {
            public void release() {
            }

            public Object getInstance() {
                return proxy;
View Full Code Here

    }

    @Override
    public ManagedReference getReference() {
        setupComponent();
        return new ManagedReference() {

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

            @Override
View Full Code Here

    }

    @Override
    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

        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

            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

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.