Package org.jboss.as.ee.component

Examples of org.jboss.as.ee.component.ComponentInstance


    public ManagedBeanDestroyInterceptor(final AtomicReference<ComponentInstance> componentInstanceReference) {
        this.componentInstanceReference = componentInstanceReference;
    }

    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ComponentInstance componentInstance = componentInstanceReference.get();
        context.putPrivateData(ComponentInstance.class, componentInstance);
        try {
            return context.proceed();
        } finally {
            context.putPrivateData(ComponentInstance.class, null);
            componentInstance.destroy();
        }
    }
View Full Code Here


    }

    public Object processInvocation(final InterceptorContext context) throws Exception {
        final AtomicReference<ComponentInstance> componentInstanceReference = this.componentInstanceReference;
        final Component component = context.getPrivateData(Component.class);
        final ComponentInstance componentInstance = component.createInstance();
        boolean ok = false;
        try {
            context.putPrivateData(ComponentInstance.class, componentInstance);
            componentInstanceReference.set(componentInstance);
            final Object result = context.proceed();
            ok = true;
            return result;
        } finally {
            context.putPrivateData(ComponentInstance.class, null);
            if (! ok) {
                componentInstance.destroy();
                componentInstanceReference.set(null);
            }
        }
    }
View Full Code Here

                    // only POJO endpoints have to be initialized. EJB3 endpoints are handled by the EJB3 subsystem.
                    final ServiceName endpointComponentName = getEndpointComponentServiceName();
                    final ServiceController<BasicComponent> endpointController = getComponentController(endpointComponentName);
                    if (endpointController != null) {
                        final BasicComponent endpointComponent = endpointController.getValue();
                        final ComponentInstance endpointComponentInstance = endpointComponent.createInstance(delegate.getInstance(className).getValue());
                        final Object endpointInstance = endpointComponentInstance.getInstance();
                        // mark reference as initialized because JBoss server initialized it
                        final Reference endpointReference = ReferenceFactory.newInitializedReference(endpointInstance);
                        return cacheAndGet(endpointReference);
                    }
                }
            } else {
                // handle JAXWS handler instantiation
                final ServiceName handlerComponentName = getHandlerComponentServiceName(className);
                final ServiceController<BasicComponent> handlerComponentController = getComponentController(handlerComponentName);
                if (handlerComponentController != null) {
                    // we support initialization only on non system JAXWS handlers
                    final BasicComponent handlerComponent = handlerComponentController.getValue();
                    final ComponentInstance handlerComponentInstance = handlerComponent.createInstance(delegate.getInstance(className).getValue());
                    final Object handlerInstance = handlerComponentInstance.getInstance();
                    // mark reference as initialized because JBoss server initialized it
                    final Reference handlerReference = ReferenceFactory.newInitializedReference(handlerInstance);
                    return cacheAndGet(handlerReference);
                }
            }
View Full Code Here

    public ComponentDispatcherInterceptor(final Method componentMethod) {
        this.componentMethod = componentMethod;
    }

    public Object processInvocation(final InterceptorContext context) throws Exception {
        ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class);
        if (componentInstance == null) {
            throw MESSAGES.noComponentInstance();
        }
        Method oldMethod = context.getMethod();
        try {
            context.setMethod(componentMethod);
            context.setTarget(componentInstance.getInstance());
            return componentInstance.getInterceptor(componentMethod).processInvocation(context);
        } finally {
            context.setMethod(oldMethod);
            context.setTarget(null);
        }
    }
View Full Code Here

    public static EJBContextImpl getEjbContext() {
        final InterceptorContext context = get();
        if(context == null) {
            throw MESSAGES.noEjbContextAvailable();
        }
        final ComponentInstance component = context.getPrivateData(ComponentInstance.class);
        if(!(component instanceof EjbComponentInstance)) {
            throw MESSAGES.currentComponentNotAEjb(component);
        }
        return ((EjbComponentInstance)component).getEjbContext();
    }
View Full Code Here

    }

    @Override
    public Object processInvocation(InterceptorContext interceptorContext) throws Exception {
        SingletonComponent singletonComponent = getComponent(interceptorContext, SingletonComponent.class);
        ComponentInstance singletonComponentInstance = singletonComponent.getComponentInstance();
        if (singletonComponentInstance == null) {
            throw MESSAGES.componentInstanceNotAvailable(interceptorContext);
        }
        interceptorContext.putPrivateData(ComponentInstance.class, singletonComponentInstance);
        return interceptorContext.proceed();
View Full Code Here

        final InterceptorContext context = CurrentInvocationContext.get();

        if (context == null) {
            return null;
        }
        final ComponentInstance instance = context.getPrivateData(ComponentInstance.class);
        if (instance instanceof EntityBeanComponentInstance) {
            return ((EntityBeanComponentInstance) instance).getPrimaryKey();
        }
        return null;
    }
View Full Code Here

    @Override
    public Object processInvocation(InterceptorContext context) throws Exception {
        final EJBComponent component = getComponent(context, EJBComponent.class);
        // create the instance
        final ComponentInstance componentInstance = component.createInstance();
        context.putPrivateData(ComponentInstance.class, componentInstance);
        //if this is set to true we do not invoke instance.destroy
        //as we are not allowed to invoke pre-destroy callbacks
        boolean discard = false;
        try {
            return context.proceed();
        } catch (Exception ex) {
            final EJBComponent ejbComponent = component;
            // Detect app exception
            if (ejbComponent.getApplicationException(ex.getClass(), context.getMethod()) != null) {
                // it's an application exception, just throw it back.
                throw ex;
            }
            if (ex instanceof ConcurrentAccessTimeoutException || ex instanceof ConcurrentAccessException) {
                throw ex;
            }
            if (ex instanceof RuntimeException || ex instanceof RemoteException) {
                discard = true;
            }
            throw ex;
        } catch (final Error e) {
            discard = true;
            throw e;
        } catch (final Throwable t) {
            discard = true;
            throw new RuntimeException(t);
        } finally {
            // destroy the instance
            if (!discard) {
                componentInstance.destroy();
            }
        }
    }
View Full Code Here

    public ManagedBeanDestroyInterceptor(final AtomicReference<ComponentInstance> componentInstanceReference) {
        this.componentInstanceReference = componentInstanceReference;
    }

    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ComponentInstance componentInstance = componentInstanceReference.get();
        context.putPrivateData(ComponentInstance.class, componentInstance);
        try {
            return context.proceed();
        } finally {
            context.putPrivateData(ComponentInstance.class, null);
            componentInstance.destroy();
        }
    }
View Full Code Here

    }

    public Object processInvocation(final InterceptorContext context) throws Exception {
        final AtomicReference<ComponentInstance> componentInstanceReference = this.componentInstanceReference;
        final Component component = context.getPrivateData(Component.class);
        final ComponentInstance componentInstance = component.createInstance();
        boolean ok = false;
        try {
            context.putPrivateData(ComponentInstance.class, componentInstance);
            componentInstanceReference.set(componentInstance);
            final Object result = context.proceed();
            ok = true;
            return result;
        } finally {
            context.putPrivateData(ComponentInstance.class, null);
            if (! ok) {
                componentInstance.destroy();
                componentInstanceReference.set(null);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.ee.component.ComponentInstance

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.