Package org.jboss.as.ee.component

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


    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 {
View Full Code Here


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

    @Override
    public Object processInvocation(InterceptorContext interceptorContext) throws Exception {
        ComponentInstance componentInstance = interceptorContext.getPrivateData(ComponentInstance.class);
        Map<String, ExtendedEntityManager> entityManagers = null;
        if(componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY) == null) {
            // 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

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

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

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

    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ComponentClientInstance instance = context.getPrivateData(ComponentClientInstance.class);
        final Component component = context.getPrivateData(Component.class);
        final ComponentInstance componentInstance = component.createInstance();
        boolean ok = false;
        try {
            context.putPrivateData(ComponentInstance.class, componentInstance);
            instance.setViewInstanceData(ComponentInstance.class, componentInstance);
            final Object result = context.proceed();
            ok = true;
            return result;
        } finally {
            context.putPrivateData(ComponentInstance.class, null);
            if (! ok) {
                componentInstance.destroy();
                instance.setViewInstanceData(ComponentInstance.class, null);
            }
        }
    }
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 EeLogger.ROOT_LOGGER.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

                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

        return expectedType.cast(get());
    }

    public static EJBContextImpl getEjbContext() {
        final InterceptorContext context = get();
        final ComponentInstance component = context.getPrivateData(ComponentInstance.class);
        if(!(component instanceof EjbComponentInstance)) {
            throw MESSAGES.currentComponentNotAEjb(component);
        }
        return ((EjbComponentInstance)component).getEjbContext();
    }
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

    protected SFSBInvocationInterceptor() {
    }

    @Override
    public Object processInvocation(InterceptorContext context) throws Exception {
        ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class);
        if (componentInstance == null) {
            throw MESSAGES.notSetInInterceptorContext("componentInstance", context);
        }
        StatefulSessionComponentInstance sfsb = (StatefulSessionComponentInstance) componentInstance;
        SFSBContextHandleImpl sfsbContextHandle = new SFSBContextHandleImpl(sfsb);
View Full Code Here

    }

    @Override
    public Object processInvocation(InterceptorContext context) throws Exception {
        StatelessSessionComponent component = getComponent(context, StatelessSessionComponent.class);
        ComponentInstance instance = component.getPool().get();
        context.putPrivateData(ComponentInstance.class, instance);
        try {
            return context.proceed();
        }
        finally {
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.