Package org.apache.openejb

Examples of org.apache.openejb.DeploymentInfo$BusinessLocalBeanHome


        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;
                    }
                    case SINGLETON: {
                        handler = new SingletonEjbObjectHandler(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[interfaces.size()]), handler);
            } catch (IllegalAccessException iae) {
                throw new InternalErrorException("Could not create IVM proxy for " + interfce.getName() + " interface", iae);
            }
View Full Code Here


    private static class EntityState extends State {

        public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
            ThreadContext threadContext = ThreadContext.getThreadContext();
            DeploymentInfo di = threadContext.getDeploymentInfo();

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

            EjbObjectProxyHandler handler = new EntityEjbObjectHandler(di, threadContext.getPrimaryKey(), InterfaceType.EJB_LOCAL, new ArrayList<Class>());

            try {
                Class[] interfaces = new Class[]{di.getLocalInterface(), IntraVmProxy.class};
                return (EJBLocalObject) ProxyManager.newProxyInstance(interfaces, handler);
            } catch (IllegalAccessException iae) {
                throw new InternalErrorException("Could not create IVM proxy for " + di.getLocalInterface() + " 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(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

            } else {
                interfaces.add(ejb.getRemoteInterfaceClass());
            }

            ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
            DeploymentInfo deploymentInfo = containerSystem.getDeploymentInfo(ejb.getDeploymentID());

            return EjbHomeProxyHandler.createHomeProxy(deploymentInfo, interfaceType, interfaces);
        } catch (Exception e) {
            logger.error("ServerSideResolver.resolve() failed, falling back to ClientSideResolver: "+e.getClass().getName()+": "+e.getMessage(), e );
            return new EJBHomeProxyHandle.ClientSideResovler().resolve(handler);
View Full Code Here

            } else {
                interfaces.add(ejb.getRemoteInterfaceClass());
            }

            ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
            DeploymentInfo deploymentInfo = containerSystem.getDeploymentInfo(ejb.getDeploymentID());

            return EjbObjectProxyHandler.createProxy(deploymentInfo, handler.getPrimaryKey(), interfaceType, interfaces);
        } catch (Exception e) {
            logger.error("ServerSideResolver.resolve() failed, falling back to ClientSideResolver: "+e.getClass().getName()+": "+e.getMessage(), e );
            return new EJBObjectProxyHandle.ClientSideResovler().resolve(handler);
View Full Code Here

                return;
            }
        }

        ProxyInfo proxyInfo = handler.getProxyInfo();
        DeploymentInfo deployment = proxyInfo.getDeploymentInfo();
        String deploymentID = deployment.getDeploymentID().toString();

        updateServer(req, res, proxyInfo);

        switch(proxyInfo.getInterfaceType()){
            case EJB_HOME: {
                res.setResponseCode(ResponseCodes.JNDI_EJBHOME);
                EJBMetaDataImpl metaData = new EJBMetaDataImpl(deployment.getHomeInterface(),
                        deployment.getRemoteInterface(),
                        deployment.getPrimaryKeyClass(),
                        deployment.getComponentType().toString(),
                        deploymentID,
                        -1, null);
                res.setResult(metaData);
                break;
            }
            case EJB_LOCAL_HOME: {
                res.setResponseCode(ResponseCodes.JNDI_NAMING_EXCEPTION);
                NamingException namingException = new NamingException("Not remotable: '" + name + "'. EJBLocalHome interfaces are not remotable as per the EJB specification.");
                res.setResult(new ThrowableArtifact(namingException));
                break;
            }
            case BUSINESS_REMOTE: {
                res.setResponseCode(ResponseCodes.JNDI_BUSINESS_OBJECT);
                EJBMetaDataImpl metaData = new EJBMetaDataImpl(null,
                        null,
                        deployment.getPrimaryKeyClass(),
                        deployment.getComponentType().toString(),
                        deploymentID,
                        -1, proxyInfo.getInterfaces());
                metaData.setPrimaryKey(proxyInfo.getPrimaryKey());
                res.setResult(metaData);
                break;
            }
            case BUSINESS_LOCAL: {
                String property = SystemInstance.get().getProperty("openejb.remotable.businessLocals", "false");
                if (property.equalsIgnoreCase("true")) {
                    res.setResponseCode(ResponseCodes.JNDI_BUSINESS_OBJECT);
                    EJBMetaDataImpl metaData = new EJBMetaDataImpl(null,
                            null,
                            deployment.getPrimaryKeyClass(),
                            deployment.getComponentType().toString(),
                            deploymentID,
                            -1, proxyInfo.getInterfaces());
                    metaData.setPrimaryKey(proxyInfo.getPrimaryKey());
                    res.setResult(metaData);
                } else {
View Full Code Here

        /**
        service.put(Message.SCHEMA_VALIDATION_ENABLED,
                    service.getEnableSchemaValidationForAllPort());
                    **/

        DeploymentInfo deploymentInfo = (DeploymentInfo)bus.getExtension(DeploymentInfo.class);
        service.setInvoker(new EJBMethodInvoker(deploymentInfo));      
    }
View Full Code Here

                break;
            default:
                throw new IllegalArgumentException("Unknown component type: " + componentType);
        }

        DeploymentInfo deploymentInfo = proxyInfo.getDeploymentInfo();
        CORBAEJBMetaData ejbMetaData = new CORBAEJBMetaData(getEJBHome(proxyInfo),
                ejbType,
                deploymentInfo.getHomeInterface(),
                deploymentInfo.getRemoteInterface(),
                deploymentInfo.getPrimaryKeyClass());
        return ejbMetaData;
    }
View Full Code Here


    public void doStart() throws Exception {
        openEjbSystem.createEjbJar(ejbJarInfo, classLoader);
        for (String deploymentId: ejbs.keySet()) {
            DeploymentInfo deploymentInfo = openEjbSystem.getDeploymentInfo(deploymentId);
            GeronimoThreadContextListener.get().getEjbDeployment((CoreDeploymentInfo) deploymentInfo);
        }
    }
View Full Code Here

    }
    @RemoteMethod
    public List<EjbInformation> getDeploymentInfo(String containerId,
            String deploymentId, HttpServletRequest request) {
        Container container = containerSystem.getContainer(containerId);
        DeploymentInfo deploymentInfo = container
                .getDeploymentInfo(deploymentId);
        List<EjbInformation> informations = new ArrayList<EjbInformation>();
        EjbInformation information = new EjbInformation();
        information.setName(getLocalizedString(request, BUNDLE_NAME, BEANCLASSNAME_KEY));       
        information.setValue(deploymentInfo.getBeanClass().getName());
        informations.add(information);

        if (deploymentInfo.getBusinessLocalInterface() != null) {
            information = new EjbInformation();
            information.setName(getLocalizedString(request, BUNDLE_NAME, BLI_KEY));
            information.setValue(appendMultipleInterfaces(deploymentInfo
                    .getBusinessLocalInterfaces()));
            informations.add(information);
        }
        if (deploymentInfo.getBusinessRemoteInterface() != null) {
            information = new EjbInformation();
            information.setName(getLocalizedString(request, BUNDLE_NAME, BRI_KEY));
            information.setValue(appendMultipleInterfaces(deploymentInfo
                    .getBusinessRemoteInterfaces()));
            informations.add(information);
        }
        information = new EjbInformation();
        information.setName(getLocalizedString(request, BUNDLE_NAME, DEPLOYMENTID_KEY));
        information.setValue(deploymentId);
        informations.add(information);
        information = new EjbInformation();
        information.setName(getLocalizedString(request, BUNDLE_NAME, EJBNAME_KEY));
        information.setValue(deploymentInfo.getEjbName());
        informations.add(information);
        if (deploymentInfo.getHomeInterface() != null) {
            information = new EjbInformation();
            information.setValue(deploymentInfo.getHomeInterface().getName());
            information.setName(getLocalizedString(request, BUNDLE_NAME, EJBHOMEI_KEY));
            informations.add(information);
        }
        if (!container.getContainerType().equals(ContainerType.MESSAGE_DRIVEN)) {
            information = new EjbInformation();
            Class cls = null;
            try {
                cls = Class.forName("org.apache.openejb.assembler.classic.JndiBuilder$Bindings");
                Method method = cls.getMethod("getBindings");
                List<String> jndiNames = (List) method.invoke(deploymentInfo.get(cls));
                StringBuffer names = new StringBuffer();
                for (String jndiName : jndiNames) {
                    if (jndiName.startsWith("openejb/local/")) {
                        jndiName = jndiName.replaceFirst("openejb/local/", "");
                        names.append(jndiName).append(",");
                    }
                }
                information.setValue(names.substring(0, names.length() - 1));
            } catch (Exception e) {
                log.error("Exception when trying to get JNDI name", e);
            }
            information.setName(getLocalizedString(request, BUNDLE_NAME, JNDINAMES_KEY));
            informations.add(information);
        }
        if (deploymentInfo.getLocalHomeInterface() != null) {
            information = new EjbInformation();
            information.setName(getLocalizedString(request, BUNDLE_NAME, LHI_KEY));
            information.setValue(deploymentInfo.getLocalHomeInterface()
                    .getName());
            informations.add(information);
        }

        if (deploymentInfo.getLocalInterface() != null) {
            information = new EjbInformation();
            information.setName(getLocalizedString(request, BUNDLE_NAME, LI_KEY));
            information.setValue(deploymentInfo.getLocalInterface().getName());
            informations.add(information);
        }

        if (deploymentInfo.getRemoteInterface() != null) {
            information = new EjbInformation();
            information.setName(getLocalizedString(request, BUNDLE_NAME, RI_KEY));
            information.setValue(deploymentInfo.getRemoteInterface().getName());
            informations.add(information);
        }

        if (deploymentInfo.getPrimaryKeyClass() != null) {
            information = new EjbInformation();
            information.setName(getLocalizedString(request, BUNDLE_NAME, PKC_KEY));
            information.setValue(deploymentInfo.getPrimaryKeyClass().getName());
            informations.add(information);
        }

        if (deploymentInfo.getPrimaryKeyField() != null) {
            information = new EjbInformation();
            information.setName(getLocalizedString(request, BUNDLE_NAME, PKF_KEY));
            information.setValue(deploymentInfo.getPrimaryKeyField());
            informations.add(information);
        }

        if (deploymentInfo.getServiceEndpointInterface() != null) {
            information = new EjbInformation();
            information.setName(getLocalizedString(request, BUNDLE_NAME, SEI_KEY));
            information.setValue(deploymentInfo.getServiceEndpointInterface()
                    .getName());
            informations.add(information);
        }

        return informations;
View Full Code Here

TOP

Related Classes of org.apache.openejb.DeploymentInfo$BusinessLocalBeanHome

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.