Package org.apache.openejb

Examples of org.apache.openejb.DeploymentInfo


        public Object getBusinessObject(Class interfce) {
            if (interfce == null) throw new IllegalStateException("Interface argument cannot me null.");

            ThreadContext threadContext = ThreadContext.getThreadContext();
            DeploymentInfo di = threadContext.getDeploymentInfo();


            InterfaceType interfaceType = di.getInterfaceType(interfce);

            if (interfaceType == null){
                throw new IllegalStateException("Component has no such interface: " + interfce.getName());
            }

            if (!interfaceType.isBusiness()) {
                throw new IllegalStateException("Interface is not a business interface for this bean: " + interfce.getName());
            }

            try {
                EjbObjectProxyHandler handler;
                switch(di.getComponentType()){
                    case STATEFUL: {
                        handler = new StatefulEjbObjectHandler(di, threadContext.getPrimaryKey(), interfaceType, new ArrayList<Class>());
                        break;
                    }
                    case STATELESS: {
                        handler = new StatelessEjbObjectHandler(di, threadContext.getPrimaryKey(), interfaceType, new ArrayList<Class>());
                        break;
                    }
                    default: throw new IllegalStateException("Bean is not a session bean: "+di.getComponentType());
                }

                List<Class> interfaces = new ArrayList<Class>();
                interfaces.addAll(di.getInterfaces(interfaceType));
                interfaces.add(IntraVmProxy.class);
                return ProxyManager.newProxyInstance(interfaces.toArray(new Class[]{}), handler);
            } catch (IllegalAccessException iae) {
                throw new InternalErrorException("Could not create IVM proxy for " + interfce.getName() + " interface", iae);
            }
View Full Code Here


            }
        }

        public EJBObject getEJBObject() throws IllegalStateException {
            ThreadContext threadContext = ThreadContext.getThreadContext();
            DeploymentInfo di = threadContext.getDeploymentInfo();

            if (di.getRemoteInterface() == null) {
                throw new IllegalStateException("EJB " + di.getDeploymentID() + " does not have a remote interface");
            }

            EjbObjectProxyHandler handler = new EntityEjbObjectHandler(((RpcContainer) di.getContainer()).getDeploymentInfo(di.getDeploymentID()), threadContext.getPrimaryKey(), InterfaceType.EJB_OBJECT, new ArrayList<Class>());
            try {
                Class[] interfaces = new Class[]{di.getRemoteInterface(), IntraVmProxy.class};
                return (EJBObject) ProxyManager.newProxyInstance(interfaces, handler);
            } catch (IllegalAccessException iae) {
                throw new InternalErrorException("Could not create IVM proxy for " + di.getRemoteInterface() + " interface", iae);
            }
        }
View Full Code Here

        assert this.location != null : "null location received";
               
        String beanClassName = ejbDeploymentContext.getBeanClass().getName();   
        Context context = ejbDeploymentContext.getComponentContext();       
        ClassLoader classLoader = ejbDeploymentContext.getClassLoader();
        DeploymentInfo deploymnetInfo = ejbDeploymentContext.getDeploymentInfo();
       
        this.container =
            new EJBWebServiceContainer(portInfo, beanClassName, classLoader,
                                       context, configurationBaseUrl, deploymnetInfo);
        this.container.init();
View Full Code Here

        return (EJBLocalObject) newProxy;
    }

    public Object getBusinessObject(Class interfce) {
        ThreadContext threadContext = ThreadContext.getThreadContext();
        DeploymentInfo di = threadContext.getDeploymentInfo();

        InterfaceType interfaceType;
        if (di.getBusinessLocalInterface() != null && di.getBusinessLocalInterface().getName().equals(interfce.getName())) {
            interfaceType = InterfaceType.BUSINESS_LOCAL;
        } else if (di.getBusinessRemoteInterface() != null && di.getBusinessRemoteInterface().getName().equals(interfce.getName())) {
            interfaceType = InterfaceType.BUSINESS_REMOTE;
        } else {
            throw new IllegalArgumentException("Component has no such interface " + interfce.getName());
        }

        Object newProxy;
        try {
            EjbObjectProxyHandler handler = newEjbObjectHandler((RpcContainer) di.getContainer(), threadContext.getPrimaryKey(), di.getDeploymentID(), interfaceType);
            Class[] interfaces = new Class[]{interfce, IntraVmProxy.class};
            newProxy = ProxyManager.newProxyInstance(interfaces, handler);
        } catch (IllegalAccessException iae) {
            throw new InternalErrorException("Could not create IVM proxy for " + interfce.getName() + " interface", iae);
        }
View Full Code Here

        assembler.createApplication(ejbJar);

        ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);

        DeploymentInfo deploymentInfo = containerSystem.getDeploymentInfo("EchoBean");

        assertNotNull(deploymentInfo);

        assertEquals("ServiceEndpointInterface", EchoServiceEndpoint.class, deploymentInfo.getServiceEndpointInterface());


        // OK, Now let's fake a web serivce invocation coming from any random
        // web service provider.  The web serivce provider needs supply
        // the MessageContext and an interceptor to do the marshalling as
        // the arguments of the standard container.invoke signature.

        // So let's create a fake message context.
        MessageContext messageContext = new FakeMessageContext();

        // Now let's create a fake interceptor as would be supplied by the
        // web service provider.  Instead of writing "fake" marshalling
        // code that would pull the arguments from the soap message, we'll
        // just give it the argument values directly.
        Object webServiceProviderInterceptor = new FakeWebServiceProviderInterceptor("Hello world");

        // Ok, now we have the two arguments expected on a JAX-RPC Web Service
        // invocation as per the OpenEJB-specific agreement between OpenEJB
        // and the Web Service Provider
        Object[] args = new Object[]{messageContext, webServiceProviderInterceptor};

        // Let's grab the container as the Web Service Provider would do and
        // perform an invocation
        RpcContainer container = (RpcContainer) deploymentInfo.getContainer();

        Method echoMethod = EchoServiceEndpoint.class.getMethod("echo", String.class);

        String value = (String) container.invoke("EchoBean", echoMethod.getDeclaringClass(), echoMethod, args, null);
View Full Code Here

            return deploymentInfo;
        }
        else if (deploymentId != null)
        {
            ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
            DeploymentInfo deploymentInfo = containerSystem.getDeploymentInfo(deploymentId);
            return deploymentInfo;
        }
        return null;
    }
View Full Code Here

        if (intf == null)
        {
            throw new NullPointerException("intf is null");  
        }

        DeploymentInfo deploymentInfo = getDeploymentInfo();
        if (deploymentInfo == null)
        {
            throw new IllegalStateException("DeploymentInfo or DeploymentID must be set before EJB can be retrieved");
        }

        // this is the pattern for the internal jndi name
        String jndiName = "java:openejb/Deployment/" + JndiBuilder.format(deploymentInfo.getDeploymentID(), getInterface().getName());

        // perform the lookup against the jndi context in the container
        // system
        ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
        Object proxy = containerSystem.getJNDIContext().lookup(jndiName);
View Full Code Here

        if (!isSessionBean(clazz))
        {
            throw new IllegalArgumentException("Given class is not an session bean class");
        }

        DeploymentInfo info = null;
        SessionBeanType type = SessionBeanType.STATELESS;

        if (isStatelessBean(clazz))
        {
            info = this.statelessBeans.get(clazz);
View Full Code Here

        if (!isSessionBean(clazz))
        {
            throw new IllegalArgumentException("Given class is not an session bean class");
        }

        DeploymentInfo info = null;
        SessionBeanType type = SessionBeanType.STATELESS;

        if (isStatelessBean(clazz))
        {
            info = this.statelessBeans.get(clazz);
View Full Code Here

    {
        T instance = null;
       
        ContainerSystem containerSystem =  SystemInstance.get().getComponent(ContainerSystem.class);
        Context jndiContext = containerSystem.getJNDIContext();
        DeploymentInfo deploymentInfo = this.getDeploymentInfo();
        try
        {
            if(iface != null)
            {
                InterfaceType type = deploymentInfo.getInterfaceType(iface);
                if(!type.equals(InterfaceType.BUSINESS_LOCAL))
                {
                    throw new IllegalArgumentException("Interface type is not legal business local interface for session bean class : " + getReturnType().getName());
                }  
            }   
            else
            {
                iface = this.deploymentInfo.getBusinessLocalInterface();
            }
           
        String jndiName = "java:openejb/Deployment/" + JndiBuilder.format(deploymentInfo.getDeploymentID(), this.iface.getName());
        instance = (T)this.iface.cast(jndiContext.lookup(jndiName));                            
           
        }
        catch(NamingException e)
        {
View Full Code Here

TOP

Related Classes of org.apache.openejb.DeploymentInfo

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.