Package org.apache.openejb.client

Examples of org.apache.openejb.client.EJBRequest$Body


    sourceDesc.getSources().add(source);
    fileDesc.setSourceDesc(sourceDesc);   
    meiHead.setFileDesc(fileDesc)
    mei.setMeiHead(meiHead);
    Music music = new Music();
    Body body = new Body();
    Mdiv mdiv = new Mdiv();
    Score score = new Score();
    ScoreDef scoreDef = createScoreDef(stavesCount);
    score.getGapsAndSbsAndCorrs().add(scoreDef);
    Section section = new Section();
    Measure measureFirst = new Measure();
    Staff staffFirst = new Staff();
    Layer layerFirst = new Layer();
    staffFirst.getSbsAndSymbolsAndOrigs().add(layerFirst);
    measureFirst.getAnnotsAndSlursAndTupletSpen().add(staffFirst);
    for (int stavesIter = 1; stavesIter < stavesCount; stavesIter++) {
      Staff staff = new Staff();
      Layer layer = new Layer();
      staff.getSbsAndSymbolsAndOrigs().add(layer);
      measureFirst.getAnnotsAndSlursAndTupletSpen().add(staff);
    }
    section.getUnclearsAndSbsAndApps().add(measureFirst);

    for (int measureIter = 1; measureIter < measureCount; measureIter++) {
      Measure measure = new Measure();
      for (int stavesIter = 0; stavesIter < stavesCount; stavesIter++) {
        Staff staff = new Staff();
        Layer layer = new Layer();
        staff.getSbsAndSymbolsAndOrigs().add(layer);
        measure.getAnnotsAndSlursAndTupletSpen().add(staff);
      }
      section.getUnclearsAndSbsAndApps().add(measure);
    }
    score.getGapsAndSbsAndCorrs().add(section);
    mdiv.setScore(score);
    body.getMdivs().add(mdiv);
    music.setBody(body);
    mei.setMusic(music);
    mei.setId(DEFAULT_MEI_TREE);
    return mei;
  }
View Full Code Here


        // Setup the client proxy replacement to replace
        // the proxies with the IntraVM proxy implementations
        EJBHomeProxyHandle.resolver.set(SERVER_SIDE_RESOLVER);
        EJBObjectProxyHandle.resolver.set(SERVER_SIDE_RESOLVER);

        EJBRequest req = new EJBRequest();
        EJBResponse res = new EJBResponse();

        try {
            req.readExternal(in);
        } catch (Throwable t) {
            replyWithFatalError(out, t, "Error caught during request processing");
            return;
        }

        CallContext call = null;
        DeploymentInfo di = null;
        RpcContainer c = null;

        try {
            di = this.daemon.getDeployment(req);
        } catch (RemoteException e) {
            replyWithFatalError
                    (out, e, "No such deployment");
            return;
            /*
                logger.warn( req + "No such deployment: "+e.getMessage());
                res.setResponse( EJB_SYS_EXCEPTION, e);
                res.writeExternal( out );
                return;
            */
        } catch (Throwable t) {
            replyWithFatalError
                    (out, t, "Unkown error occured while retrieving deployment");
            return;
        }

        //  Need to set this for deserialization of the body
        ClassLoader classLoader = di.getBeanClass().getClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);

        try {
            req.getBody().readExternal(in);
        } catch (Throwable t) {
            replyWithFatalError(out, t, "Error caught during request processing");
            return;
        }

        try {
            call = CallContext.getCallContext();
            call.setEJBRequest(req);
            call.setDeploymentInfo(di);
        } catch (Throwable t) {
            replyWithFatalError(out, t, "Unable to set the thread context for this request");
            return;
        }

        try {
            SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
            securityService.associate(req.getClientIdentity());
        } catch (Throwable t) {
            replyWithFatalError(out, t, "Security system failed to associate thread with the thread");
            return;
        }

        try {
            switch (req.getRequestMethod()) {
            // Remote interface methods
                case RequestMethodConstants.EJB_OBJECT_BUSINESS_METHOD:
                    doEjbObject_BUSINESS_METHOD(req, res);
                    break;

View Full Code Here

        // Setup the client proxy replacement to replace
        // the proxies with the IntraVM proxy implementations
        EJBHomeProxyHandle.resolver.set(SERVER_SIDE_RESOLVER);
        EJBObjectProxyHandle.resolver.set(SERVER_SIDE_RESOLVER);

        final EJBRequest req = new EJBRequest();
        final EJBResponse res = new EJBResponse();

        res.start(EJBResponse.Time.TOTAL);

        try {
            req.readExternal(in);
        } catch (Throwable t) {
            replyWithFatalError(out, t, "Bad request");
            return;
        }

        final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
        try {
            final Object clientIdentity = req.getClientIdentity();
            if (clientIdentity != null) {//noinspection unchecked
                securityService.associate(clientIdentity);
            }
        } catch (Throwable t) {
            replyWithFatalError(out, t, "Client identity is not valid: " + req);
            return;
        }

        final CallContext call;
        final BeanContext di;

        try {
            di = this.daemon.getDeployment(req);
        } catch (RemoteException e) {
            replyWithFatalError(out, e, "No such deployment");
            return;
            /*
                logger.warn( req + "No such deployment: "+e.getMessage());
                res.setResponse( EJB_SYS_EXCEPTION, e);
                res.writeExternal( out );
                return;
            */
        } catch (Throwable t) {
            replyWithFatalError(out, t, "Unkown error occured while retrieving deployment");
            return;
        }

        //  Need to set this for deserialization of the body
        final ClassLoader classLoader = di.getBeanClass().getClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);

        try {
            res.start(EJBResponse.Time.DESERIALIZATION);

            req.getBody().readExternal(in);

            res.stop(EJBResponse.Time.DESERIALIZATION);
        } catch (Throwable t) {
            replyWithFatalError(out, t, "Error caught during request processing");
            return;
        }

        try {
            call = CallContext.getCallContext();
            call.setEJBRequest(req);
            call.setBeanContext(di);
        } catch (Throwable t) {
            replyWithFatalError(out, t, "Unable to set the thread context for this request");
            return;
        }

        res.start(EJBResponse.Time.CONTAINER);
        boolean respond = true;
        try {
            switch (req.getRequestMethod()) {
                // Remote interface methods
                case EJB_OBJECT_BUSINESS_METHOD:
                    doEjbObject_BUSINESS_METHOD(req, res);
                    updateServer(req, res);
                    break;
View Full Code Here

    }

    @Test
    public void testGetDeploymentEJBRequest() throws RemoteException {
        EJBMetaDataImpl ejbMetadataWithId = new EJBMetaDataImpl(null, null, null, null, null, 1, InterfaceType.BUSINESS_REMOTE, null, null);
        EJBRequest request = new EJBRequest(null, ejbMetadataWithId, method, null, null);
        BeanContext info = deploymentIndex.getDeployment(request);
        assert beanContext.equals(info);
        assert request.getDeploymentId().equals(info.getDeploymentID());
    }
View Full Code Here

    @Test(expected = RemoteException.class)
    public void testGetDeploymentEJBRequestRemoteException() throws RemoteException {
        // 0 causes DeploymentIndex to move further
        EJBMetaDataImpl ejbMetadata = new EJBMetaDataImpl(null, null, null, null, null, 0, InterfaceType.BUSINESS_REMOTE, null, null);
        EJBRequest request = new EJBRequest(null, ejbMetadata, method, null, null);
        deploymentIndex.getDeployment(request);
    }
View Full Code Here

    }

    @Test
    public void testGetDeploymentEJBRequest() throws RemoteException {
        EJBMetaDataImpl ejbMetadataWithId = new EJBMetaDataImpl(null, null, null, null, null, 1, null);
        EJBRequest request = new EJBRequest(0, ejbMetadataWithId, method, null, null);
        DeploymentInfo info = deploymentIndex.getDeployment(request);
        assert deploymentInfo.equals(info);
        assert request.getDeploymentId().equals(info.getDeploymentID());
    }
View Full Code Here

    @Test(expected = RemoteException.class)
    public void testGetDeploymentEJBRequestRemoteException() throws RemoteException {
        // 0 causes DeploymentIndex to move further
        EJBMetaDataImpl ejbMetadata = new EJBMetaDataImpl(null, null, null, null, null, 0, null);
        EJBRequest request = new EJBRequest(0, ejbMetadata, method, null, null);
        deploymentIndex.getDeployment(request);
    }
View Full Code Here

        // Setup the client proxy replacement to replace
        // the proxies with the IntraVM proxy implementations
        EJBHomeProxyHandle.resolver.set(SERVER_SIDE_RESOLVER);
        EJBObjectProxyHandle.resolver.set(SERVER_SIDE_RESOLVER);

        final EJBRequest req = new EJBRequest();
        req.setMetaData(metaData);
        byte version = req.getVersion();

        final EJBResponse res = new EJBResponse();
        res.setMetaData(metaData);
        res.start(EJBResponse.Time.TOTAL);
        res.setRequest(req);

        try {
            req.readExternal(in);
        } catch (Throwable t) {
            return setResponseError(res, version, t, "Bad request");
        }

        final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
        boolean failed = false;
        final CallContext call;

        try {
            try {
                final Object clientIdentity = req.getClientIdentity();
                if (clientIdentity != null) {//noinspection unchecked
                    securityService.associate(clientIdentity);
                }
            } catch (LoginException t) {
                failed = true;
                return setResponseError(res, version, t, "Client identity is not valid - " + req);
            }

            final BeanContext di;

            try {
                di = this.daemon.getDeployment(req);
            } catch (RemoteException e) {
                failed = true;
                return setResponseError(res, version, e, "No such deployment");
            } catch (Throwable t) {
                failed = true;
                return setResponseError(res, version, t, "Unkown error occured while retrieving deployment: " + req);
            }

            try {

                //Need to set this for deserialization of the body - Will always be reset by EjbDaemon
                final ClassLoader classLoader = di.getBeanClass().getClassLoader();
                Thread.currentThread().setContextClassLoader(classLoader);

                res.start(EJBResponse.Time.DESERIALIZATION);

                req.getBody().readExternal(in);

                //Client version retrieved from body
                version = req.getVersion();

                res.stop(EJBResponse.Time.DESERIALIZATION);
            } catch (Throwable t) {
                failed = true;
                return setResponseError(res, version, t, "Error caught during request body deserialization: " + req);
            }

            try {
                call = CallContext.getCallContext();
                call.setEJBRequest(req);
                call.setBeanContext(di);
            } catch (Throwable t) {
                failed = true;
                return setResponseError(res, version, t, "Unable to set the thread call context for this request: " + req);
            }

        } finally {
            if (failed) {
                securityService.disassociate();
            }
        }

        res.start(EJBResponse.Time.CONTAINER);

        Object securityToken = null;
        try {
            final JNDIContext.AuthenticationInfo authentication = req.getBody().getAuthentication();
            if (authentication != null) {
                try {
                    securityToken = securityService.login(authentication.getRealm(), authentication.getUser(), new String(authentication.getPassword()));
                } catch (final Throwable t) {
                    res.setResponse(req.getVersion(), ResponseCodes.AUTH_DENIED, t);
                }
            }

            if (res.getResponseCode() != ResponseCodes.AUTH_DENIED) {
                switch (req.getRequestMethod()) {
                    // Remote interface methods
                    case EJB_OBJECT_BUSINESS_METHOD:
                        doEjbObject_BUSINESS_METHOD(req, res);
                        updateServer(req, res);
                        break;

                    // Home interface methods
                    case EJB_HOME_CREATE:
                        doEjbHome_CREATE(req, res);
                        updateServer(req, res);
                        break;

                    // Home interface methods
                    case EJB_HOME_METHOD:
                        doEjbHome_METHOD(req, res);
                        updateServer(req, res);
                        break;

                    case EJB_HOME_FIND:
                        doEjbHome_FIND(req, res);
                        updateServer(req, res);
                        break;

                    // javax.ejb.EJBObject methods
                    case EJB_OBJECT_GET_EJB_HOME:
                        doEjbObject_GET_EJB_HOME(req, res);
                        updateServer(req, res);
                        break;

                    case EJB_OBJECT_GET_HANDLE:
                        doEjbObject_GET_HANDLE(req, res);
                        updateServer(req, res);
                        break;

                    case EJB_OBJECT_GET_PRIMARY_KEY:
                        doEjbObject_GET_PRIMARY_KEY(req, res);
                        updateServer(req, res);
                        break;

                    case EJB_OBJECT_IS_IDENTICAL:
                        doEjbObject_IS_IDENTICAL(req, res);
                        updateServer(req, res);
                        break;

                    case EJB_OBJECT_REMOVE:
                        doEjbObject_REMOVE(req, res);
                        break;

                    // javax.ejb.EJBHome methods
                    case EJB_HOME_GET_EJB_META_DATA:
                        doEjbHome_GET_EJB_META_DATA(req, res);
                        updateServer(req, res);
                        break;

                    case EJB_HOME_GET_HOME_HANDLE:
                        doEjbHome_GET_HOME_HANDLE(req, res);
                        updateServer(req, res);
                        break;

                    case EJB_HOME_REMOVE_BY_HANDLE:
                        doEjbHome_REMOVE_BY_HANDLE(req, res);
                        break;

                    case EJB_HOME_REMOVE_BY_PKEY:
                        doEjbHome_REMOVE_BY_PKEY(req, res);
                        break;

                    case FUTURE_CANCEL:
                        doFUTURE_CANCEL_METHOD(req, res);
                        break;

                    default:
                        throw new org.apache.openejb.SystemException("Unexpected request method: " + req.getRequestMethod());
                }
            }

        } catch (org.apache.openejb.InvalidateReferenceException e) {
            res.setResponse(version, ResponseCodes.EJB_SYS_EXCEPTION, new ThrowableArtifact(e.getRootCause()));
View Full Code Here

    }

    @Test
    public void testGetDeploymentEJBRequest() throws RemoteException {
        EJBMetaDataImpl ejbMetadataWithId = new EJBMetaDataImpl(null, null, null, null, null, 1, InterfaceType.BUSINESS_REMOTE, null, null);
        EJBRequest request = new EJBRequest(0, ejbMetadataWithId, method, null, null);
        BeanContext info = deploymentIndex.getDeployment(request);
        assert beanContext.equals(info);
        assert request.getDeploymentId().equals(info.getDeploymentID());
    }
View Full Code Here

    @Test(expected = RemoteException.class)
    public void testGetDeploymentEJBRequestRemoteException() throws RemoteException {
        // 0 causes DeploymentIndex to move further
        EJBMetaDataImpl ejbMetadata = new EJBMetaDataImpl(null, null, null, null, null, 0, InterfaceType.BUSINESS_REMOTE, null, null);
        EJBRequest request = new EJBRequest(0, ejbMetadata, method, null, null);
        deploymentIndex.getDeployment(request);
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.client.EJBRequest$Body

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.