Package org.jboss.as.naming

Examples of org.jboss.as.naming.ManagedReference


    public static final InterceptorFactory FACTORY = new ImmediateInterceptorFactory(new SFSBInvocationInterceptor());

    @Override
    public Object processInvocation(InterceptorContext context) throws Exception {
        final ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class);
        ManagedReference entityManagerRef = (ManagedReference) componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY);
        if(entityManagerRef != null) {
            Map<String, ExtendedEntityManager> entityManagers = (Map<String, ExtendedEntityManager>) entityManagerRef.getInstance();
            SFSBCallStack.pushCall(entityManagers);
        }
        try {
            return context.proceed();   // call the next interceptor or target
        } finally {
View Full Code Here


            // Get all of the extended persistence contexts in use by the bean (some of which may of been inherited from
            // other beans).
            entityManagers = new HashMap<String, ExtendedEntityManager>();
            componentInstance.setInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY, new ImmediateManagedReference(entityManagers));
        } else {
            ManagedReference entityManagerRef = (ManagedReference) componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY);
            entityManagers = (Map<String, ExtendedEntityManager>)entityManagerRef.getInstance();
        }
        final List<ExtendedEntityManager> ems = CreatedEntityManagers.getDeferredEntityManagers();
        for (ExtendedEntityManager e : ems) {
            entityManagers.put(e.getScopedPuName(), e);
        }
View Full Code Here

    }

    @Override
    public ResourceReference<T> createResource() {
        try {
            final ManagedReference instance = view.createInstance();
            return new ManagedReferenceToResourceReferenceAdapter<T>(instance);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

    public Object processInvocation(InterceptorContext interceptorContext) throws Exception {
        final ComponentInstance componentInstance = interceptorContext.getPrivateData(ComponentInstance.class);
        try {
            return interceptorContext.proceed();
        } finally {
            ManagedReference entityManagerRef = (ManagedReference) componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY);
            if(entityManagerRef != null) {
                Map<String, ExtendedEntityManager> entityManagers = (Map<String, ExtendedEntityManager>) entityManagerRef.getInstance();
                for(Map.Entry<String, ExtendedEntityManager> entry : entityManagers.entrySet()) {
                    // close all extended persistence contexts that are referenced by the bean being destroyed
                    entry.getValue().refCountedClose();
                }
            }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ManagedReference reference = (ManagedReference) context.getPrivateData(ComponentInstance.class).getInstanceData(contextKey);
        final Object instance = reference.getInstance();
        try {
            final Method method = this.method;
            if (withContext) {
                final Method oldMethod = context.getMethod();
                try {
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ManagedReference reference = (ManagedReference) context.getPrivateData(ComponentInstance.class).getInstanceData(contextKey);
        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

                @Override
                public void inject(final ServerEnvironment serverEnvironment) throws InjectionException {
                    instanceNameService.getManagedObjectInjector().inject(new ManagedReferenceFactory() {
                        @Override
                        public ManagedReference getReference() {
                            return new ManagedReference() {
                                @Override
                                public void release() {

                                }
View Full Code Here

         Component component = componentView.getComponent();
         //for spring integration and @FactoryType is annotated we don't need to go into ee's interceptors
         if(wsInvocation.getInvocationContext().getTargetBean() != null
                 && (endpoint.getProperty("SpringBus") != null)
                 || wsInvocation.getInvocationContext().getProperty("forceTargetBean") != null) {
             this.reference = new ManagedReference() {
                 public void release() {
                 }

                 public Object getInstance() {
                     return wsInvocation.getInvocationContext().getTargetBean();
View Full Code Here

                target = ((ManagedReference) componentInstance.getInstanceData(targetKey)).getInstance();
                if (target == null) {
                    throw EeLogger.ROOT_LOGGER.injectionTargetNotFound();
                }
            }
            ManagedReference reference = factory.getReference();
            if (reference == null && optional) {
                return context.proceed();
            }
            boolean ok = false;
            try {
                componentInstance.setInstanceData(valueKey, 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) {
                    componentInstance.setInstanceData(valueKey, null);
                    reference.release();
                }
            }
        }
View Full Code Here

                context.putPrivateData(entry.getKey(), entry.getValue());
            }
            clientPostConstructInterceptor.processInvocation(context);
            instance.constructionComplete();

            return new ManagedReference() {

                @Override
                public void release() {
                    try {
                        InterceptorContext interceptorContext = new InterceptorContext();
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.