Package org.jboss.as.ee.component

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


    public static MethodIntf of(final InterceptorContext invocation) {
        //for timer invocations there is no view, so the methodInf is attached directly
        //to the context. Otherwise we retrive it from the invoked view
        MethodIntf methodIntf = invocation.getPrivateData(MethodIntf.class);
        if (methodIntf == null) {
            final ComponentView componentView = invocation.getPrivateData(ComponentView.class);
            if (componentView != null) {
                methodIntf = componentView.getPrivateData(MethodIntf.class);
            } else {
                methodIntf = MethodIntf.BEAN;
            }
        }
        return methodIntf;
View Full Code Here


            } else if (viewService.size() > 1) {
                throw new RuntimeException("More than 1 ejb found for @Ejb reference " + ejb);
            }
            final ViewDescription viewDescription = viewService.iterator().next();
            final ServiceController<?> controller = serviceRegistry.getRequiredService(viewDescription.getServiceName());
            final ComponentView view = (ComponentView) controller.getValue();
            return view.createInstance().getInstance();
        }
    }
View Full Code Here

    @SuppressWarnings({"unchecked"})
    public synchronized <S> S getBusinessObject(Class<S> businessInterfaceType) {
        //TODO: this should be cached
        if (viewServices.containsKey(businessInterfaceType.getName())) {
            final ServiceController<?> serviceController = CurrentServiceContainer.getServiceContainer().getRequiredService(viewServices.get(businessInterfaceType.getName()));
            final ComponentView view = (ComponentView) serviceController.getValue();
            return(S) view.createInstance().getInstance();
        } else {
            throw new IllegalArgumentException("View of type " + businessInterfaceType + " not found on bean ");
        }
    }
View Full Code Here

        if (isRemoved()) {
            throw new NoSuchEJBException("Bean has been removed");
        }
        if (viewServices.containsKey(businessInterfaceType.getName())) {
            final ServiceController<?> serviceController = CurrentServiceContainer.getServiceContainer().getRequiredService(viewServices.get(businessInterfaceType.getName()));
            final ComponentView view = (ComponentView) serviceController.getValue();
            return (S) view.createInstance(Collections.<Object, Object>singletonMap(SessionID.SESSION_ID_KEY, id)).getInstance();
        } else {
            throw new IllegalStateException("View of type " + businessInterfaceType + " not found on bean " + ejbComponent);
        }
    }
View Full Code Here

   public void invoke(final Endpoint endpoint, final Invocation wsInvocation) throws Exception {
      try {
         // prepare for invocation
         onBeforeInvocation(wsInvocation);
         // prepare invocation data
         final ComponentView componentView = getComponentView();
         final Method method = getEJBMethod(wsInvocation.getJavaMethod(), componentView.getViewMethods());
         final InterceptorContext context = new InterceptorContext();
         prepareForInvocation(context, wsInvocation);
         context.setMethod(method);
         context.setParameters(wsInvocation.getArgs());
         context.setTarget(reference.getInstance());
         context.putPrivateData(Component.class, componentView.getComponent());
         context.putPrivateData(ComponentView.class, componentView);
          // invoke method
         final Object retObj = componentView.invoke(context);
         // set return value
         wsInvocation.setReturnValue(retObj);
      }
      catch (Throwable t) {
         log.error(MESSAGES.methodInvocationFailed(t.getLocalizedMessage()), t);
View Full Code Here

        return getComponent().getEJBObject(invocation);
    }

    public Class<?> getInvokedBusinessInterface() throws IllegalStateException {
        final InterceptorContext invocation = CurrentInvocationContext.get();
        final ComponentView view = invocation.getPrivateData(ComponentView.class);
        if (view.getViewClass().equals(getComponent().getEjbObjectType()) || view.getViewClass().equals(getComponent().getEjbLocalObjectType())) {
            throw MESSAGES.cannotCall("getInvokedBusinessInterface", "EjbObject", "EJBLocalObject");
        }
        return view.getViewClass();
    }
View Full Code Here

            } else if (viewService.size() > 1) {
                throw new RuntimeException("More than 1 ejb found for @Ejb reference " + ejb);
            }
            final ViewDescription viewDescription = viewService.iterator().next();
            final ServiceController<?> controller = serviceRegistry.getRequiredService(viewDescription.getServiceName());
            final ComponentView view = (ComponentView) controller.getValue();
            return view.createInstance().createProxy();
        }
    }
View Full Code Here

            return null;
        }
        //TODO: this should be cached
        if (viewServices.containsKey(businessInterfaceType.getName())) {
            final ServiceController<?> serviceController = CurrentServiceContainer.getServiceContainer().getRequiredService(viewServices.get(businessInterfaceType.getName()));
            final ComponentView view = (ComponentView) serviceController.getValue();
            final ComponentViewInstance instance = view.createInstance();
            return (S) instance.createProxy();
        } else {
            throw new IllegalArgumentException("View of type " + businessInterfaceType + " not found on bean ");
        }
    }
View Full Code Here

        if (isRemoved()) {
            throw new NoSuchEJBException("Bean has been removed");
        }
        if (viewServices.containsKey(businessInterfaceType.getName())) {
            final ServiceController<?> serviceController = CurrentServiceContainer.getServiceContainer().getRequiredService(viewServices.get(businessInterfaceType.getName()));
            final ComponentView view = (ComponentView) serviceController.getValue();
            final ComponentViewInstance instance = view.createInstance(Collections.<Object, Object>singletonMap(StatefulSessionComponent.SESSION_ATTACH_KEY, id));
            return (S) instance.createProxy();
        } else {
            throw new IllegalStateException("View of type " + businessInterfaceType + " not found on bean " + getComponent());
        }
    }
View Full Code Here

        }
    }

    @Override
    public <T> T getBusinessObject(SessionContext ctx, Class<T> businessInterface) throws IllegalStateException {
        final ComponentView view = getComponentView(businessInterface);
        if (view == null)
            throw new IllegalStateException("Stateful bean " + getComponentName() + " does not have a view " + businessInterface);
        // see SessionBeanComponentInstance
        Serializable sessionId = ((SessionBeanComponentInstance.SessionBeanComponentInstanceContext) ctx).getId();
        Object proxy = view.getViewForInstance(sessionId);
        return businessInterface.cast(proxy);
    }
View Full Code Here

TOP

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

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.