Package org.jboss.as.ee.component

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


            return null;
        }
        if(viewServices.containsKey(businessInterfaceType.getName())) {
            final ServiceController<?> serviceController = CurrentServiceRegistry.getServiceRegistry().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


            throw new NoSuchEJBException("Bean has been removed");
        }
        if (viewServices.containsKey(businessInterfaceType.getName())) {
            final ServiceController<?> serviceController = CurrentServiceRegistry.getServiceRegistry().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

        }
        //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

            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 Object processInvocation(InterceptorContext context) throws Exception {
        final Method invokedMethod = context.getMethod();
        final ComponentViewInstance componentViewInstance = context.getPrivateData(ComponentViewInstance.class);
        // For a lifecycle interception, the ComponentViewInstance (and the invoked business interface) will be null.
        // On a normal method invocation, the invoked business interface will be obtained from the ComponentViewInstance
        final Class<?> invokedBusinessInterface = componentViewInstance == null ? null : componentViewInstance.getViewClass();
        Object[] parameters = context.getParameters();
        SessionInvocationContext sessionInvocationContext = new CustomSessionInvocationContext(lifecycleCallback, context, invokedBusinessInterface, invokedMethod, parameters);
        context.putPrivateData(InvocationContext.class, sessionInvocationContext);
        CurrentInvocationContext.push(sessionInvocationContext);
        try {
View Full Code Here

        }


        @Override
        public Object processInvocation(InterceptorContext context) throws Exception {
            final ComponentViewInstance componentViewInstance = context.getPrivateData(ComponentViewInstance.class);
            if (componentViewInstance == null) {
                throw new IllegalStateException("ComponentViewInstance not available in interceptor context: " + context);
            }
            return "Proxy for view class: " + componentViewInstance.getViewClass().getName() + " of EJB: " + name;
        }
View Full Code Here

        if (viewInterface == null)
            throw new IllegalArgumentException("View interface is null");
        if (viewServices.containsKey(viewInterface.getName())) {
            final ServiceController<?> serviceController = CurrentServiceContainer.getServiceContainer().getRequiredService(viewServices.get(viewInterface.getName()));
            final ComponentView view = (ComponentView) serviceController.getValue();
            final ComponentViewInstance instance = view.createInstance(contextData);
            return viewInterface.cast(instance.createProxy());
        } else {
            throw new IllegalStateException("View of type " + viewInterface + " not found on bean " + this);
        }
    }
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 ComponentViewInstance componentViewInstance = getComponentViewInstance();
         final Method method = getEJBMethod(wsInvocation.getJavaMethod(), componentViewInstance.allowedMethods());
         final InterceptorContext context = new InterceptorContext();
         context.setMethod(method);
         context.setContextData(getWebServiceContext(wsInvocation).getMessageContext());
         context.setParameters(wsInvocation.getArgs());
         context.setTarget(componentViewInstance.createProxy());
         context.putPrivateData(Component.class, componentViewInstance.getComponent());
         context.putPrivateData(ComponentViewInstance.class, componentViewInstance);
         // invoke method
         final Object retObj = componentViewInstance.getEntryPoint(method).processInvocation(context);
         // set return value
         wsInvocation.setReturnValue(retObj);
      }
      catch (Throwable t) {
         log.error("Method invocation failed with exception: " + t.getMessage(), t);
View Full Code Here

        }


        @Override
        public Object processInvocation(InterceptorContext context) throws Exception {
            final ComponentViewInstance componentViewInstance = context.getPrivateData(ComponentViewInstance.class);
            if (componentViewInstance == null) {
                throw new IllegalStateException("ComponentViewInstance not available in interceptor context: " + context);
            }
            return "Proxy for view class: " + componentViewInstance.getViewClass().getName() + " of EJB: " + name;
        }
View Full Code Here

        final Component component = context.getPrivateData(Component.class);
        if (component instanceof EJBComponent == false) {
            throw new IllegalStateException("Unexpected component type: " + component.getClass() + " expected: " + EJBComponent.class);
        }
        final Method invokedMethod = context.getMethod();
        final ComponentViewInstance componentViewInstance = context.getPrivateData(ComponentViewInstance.class);
        final String viewClassOfInvokedMethod = componentViewInstance.getViewClass().getName();
        // shouldn't really happen if the interceptor was setup correctly. But let's be safe and do a check
        if (!this.viewClassName.equals(viewClassOfInvokedMethod) || !this.viewMethod.equals(invokedMethod)) {
            throw new IllegalStateException(this.getClass().getName() + " cannot handle method "
                    + invokedMethod + " of view class " + viewClassOfInvokedMethod + ".Expected view " +
                    "method to be " + viewMethod + " on view class " + viewClassName);
View Full Code Here

TOP

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

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.