Package org.apache.openejb.client

Examples of org.apache.openejb.client.ProtocolMetaData


        }
    }

    public void service(final InputStream rawIn, final OutputStream rawOut) throws IOException {

        final ProtocolMetaData clientProtocol = new ProtocolMetaData();

        ObjectInputStream ois = null;
        ObjectOutputStream oos = null;
        RequestType requestType = null;
        byte requestTypeByte = RequestType.NOP_REQUEST.getCode();

        try {

            final RequestInfos.RequestInfo info = RequestInfos.info();
            info.setInputStream(new CountingInputStream(rawIn));

            // Read client Protocol Version
            final CountingInputStream cis = info.getInputStream();
            clientProtocol.readExternal(cis);
            ois = new EjbObjectInputStream(cis);

            // Read ServerMetaData
            final ServerMetaData serverMetaData = new ServerMetaData();
            serverMetaData.readExternal(ois);
            ClientObjectFactory.serverMetaData.set(serverMetaData);

            // Read request type
            requestTypeByte = ois.readByte();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            ClusterResponse clusterResponse = null;

            if (requestType == RequestType.CLUSTER_REQUEST) {
                clusterResponse = clusterHandler.processRequest(ois, clientProtocol);

                //Check for immediate failure
                final Throwable failure = clusterResponse.getFailure();
                if (null != clusterResponse && null != failure) {

                    clusterHandler.getLogger().debug("Failed to write to ClusterResponse", failure);

                    try {
                        info.setOutputStream(new CountingOutputStream(rawOut));
                        oos = new ObjectOutputStream(info.getOutputStream());
                        clusterResponse.setMetaData(clientProtocol);
                        clusterResponse.writeExternal(oos);
                        oos.flush();
                    } catch (IOException ie) {
                        final String m = "Failed to write to ClusterResponse: " + ie.getMessage();
                        clusterHandler.getLogger().error(m, ie);
                        throw Exceptions.newIOException(m, ie);
                    }

                    throw failure;
                }
            }

            requestTypeByte = ois.readByte();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            final Response response;
            switch (requestType) {
                case EJB_REQUEST:
                    response = processEjbRequest(ois, clientProtocol);
                    break;
                case JNDI_REQUEST:
                    response = processJndiRequest(ois, clientProtocol);
                    break;
                case AUTH_REQUEST:
                    response = processAuthRequest(ois, clientProtocol);
                    break;
                default:
                    logger.error("\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unknown request type " + requestType);
                    return;
            }

            try {
                info.setOutputStream(new CountingOutputStream(rawOut));

                final CountingOutputStream cos = info.getOutputStream();

                //Let client know we are using the requested protocol to respond
                clientProtocol.writeExternal(cos);
                cos.flush();

                oos = new ObjectOutputStream(cos);
                clusterHandler.processResponse(clusterResponse, oos, clientProtocol);
                oos.flush();

            } finally {
                switch (requestType) {
                    case EJB_REQUEST:
                        processEjbResponse(response, oos, clientProtocol);
                        break;
                    case JNDI_REQUEST:
                        processJndiResponse(response, oos, clientProtocol);
                        break;
                    case AUTH_REQUEST:
                        processAuthResponse(response, oos, clientProtocol);
                        break;
                    default:
                        //Should never get here...
                        logger.error("\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unknown response type " + requestType);
                }
            }

        } catch (IllegalArgumentException iae) {
            final String msg = "\"" + clientProtocol.getSpec() + "\" FAIL \"Unknown request type " + requestTypeByte;
            if (logger.isDebugEnabled()) {
                logger.debug(msg, iae);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (SecurityException e) {
            final String msg = "\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Security error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (Throwable e) {
            final String msg = "\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unexpected error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
View Full Code Here


            }
        }
    }

    public void service(InputStream in, OutputStream out) throws IOException {
        ProtocolMetaData protocolMetaData = new ProtocolMetaData();
        String requestTypeName = null;

        ObjectInputStream ois = null;
        ObjectOutputStream oos = null;

        try {

            protocolMetaData.readExternal(in);

            PROTOCOL_VERSION.writeExternal(out);

            byte requestType = (byte) in.read();

            if (requestType == -1) {
                return;
            }

            ois = new EjbObjectInputStream(in);
            oos = new ObjectOutputStream(out);

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            switch (requestType) {
                case RequestMethodConstants.EJB_REQUEST:
                    requestTypeName = "EJB_REQUEST";
                    processEjbRequest(ois, oos);
                    break;
                case RequestMethodConstants.JNDI_REQUEST:
                    requestTypeName = "JNDI_REQUEST";
                    processJndiRequest(ois, oos);
                    break;
                case RequestMethodConstants.AUTH_REQUEST:
                    requestTypeName = "AUTH_REQUEST";
                    processAuthRequest(ois, oos);
                    break;
                default:
                    requestTypeName = requestType+" (UNKNOWN)";
                    logger.error("\"" + requestTypeName + " " + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type " + requestType);

            }
        } catch (SecurityException e) {
            logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \"Security error - "+e.getMessage()+"\"",e);
        } catch (Throwable e) {
            logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \"Unexpected error - "+e.getMessage()+"\"",e);
        } finally {
            try {
                if (oos != null) {
                    oos.flush();
                    oos.close();
                } else if (out != null) {
                    out.flush();
                    out.close();
                }
            } catch (Throwable t) {
                logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \""+t.getMessage()+"\"");
            }
        }
    }
View Full Code Here

        }
    }

    public void service(final InputStream rawIn, final OutputStream rawOut) throws IOException {

        final ProtocolMetaData clientProtocol = new ProtocolMetaData();

        ObjectInputStream ois = null;
        ObjectOutputStream oos = null;
        RequestType requestType = null;
        byte requestTypeByte = RequestType.NOP_REQUEST.getCode();

        try {

            final RequestInfos.RequestInfo info = RequestInfos.info();
            info.setInputStream(new CountingInputStream(rawIn));

            // Read client Protocol Version
            final CountingInputStream cis = info.getInputStream();
            clientProtocol.readExternal(cis);
            ois = new EjbObjectInputStream(cis);

            // Read ServerMetaData
            final ServerMetaData serverMetaData = new ServerMetaData();
            serverMetaData.readExternal(ois);
            ClientObjectFactory.serverMetaData.set(serverMetaData);

            // Read request type
            requestTypeByte = ois.readByte();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            ClusterResponse clusterResponse = null;

            if (requestType == RequestType.CLUSTER_REQUEST) {
                clusterResponse = clusterHandler.processRequest(ois, clientProtocol);

                //Check for immediate failure
                final Throwable failure = clusterResponse.getFailure();
                if (null != clusterResponse && null != failure) {

                    clusterHandler.getLogger().debug("Failed to write to ClusterResponse", failure);

                    try {
                        info.setOutputStream(new CountingOutputStream(rawOut));
                        oos = new ObjectOutputStream(info.getOutputStream());
                        clusterResponse.setMetaData(clientProtocol);
                        clusterResponse.writeExternal(oos);
                        oos.flush();
                    } catch (final IOException ie) {
                        final String m = "Failed to write to ClusterResponse: " + ie.getMessage();
                        clusterHandler.getLogger().error(m, ie);
                        throw Exceptions.newIOException(m, ie);
                    }

                    throw failure;
                }
            }

            requestTypeByte = ois.readByte();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            final Response response;
            switch (requestType) {
                case EJB_REQUEST:
                    response = processEjbRequest(ois, clientProtocol);
                    break;
                case JNDI_REQUEST:
                    response = processJndiRequest(ois, clientProtocol);
                    break;
                case AUTH_REQUEST:
                    response = processAuthRequest(ois, clientProtocol);
                    break;
                default:
                    logger.error("\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unknown request type " + requestType);
                    return;
            }

            try {
                info.setOutputStream(new CountingOutputStream(rawOut));

                final CountingOutputStream cos = info.getOutputStream();

                //Let client know we are using the requested protocol to respond
                clientProtocol.writeExternal(cos);
                cos.flush();

                oos = new ObjectOutputStream(cos);
                clusterHandler.processResponse(clusterResponse, oos, clientProtocol);
                oos.flush();

            } finally {
                switch (requestType) {
                    case EJB_REQUEST:
                        processEjbResponse(response, oos, clientProtocol);
                        break;
                    case JNDI_REQUEST:
                        processJndiResponse(response, oos, clientProtocol);
                        break;
                    case AUTH_REQUEST:
                        processAuthResponse(response, oos, clientProtocol);
                        break;
                    default:
                        //Should never get here...
                        logger.error("\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unknown response type " + requestType);
                }
            }

        } catch (final IllegalArgumentException iae) {
            final String msg = "\"" + clientProtocol.getSpec() + "\" FAIL \"Unknown request type " + requestTypeByte;
            if (logger.isDebugEnabled()) {
                logger.debug(msg, iae);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (final SecurityException e) {
            final String msg = "\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Security error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (final Throwable e) {
            final String msg = "\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unexpected error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
View Full Code Here

            }
        }
    }

    public void service(InputStream in, OutputStream out) throws IOException {
        ProtocolMetaData protocolMetaData = new ProtocolMetaData();
        String requestTypeName = null;

        ObjectInputStream ois = null;
        ObjectOutputStream oos = null;

        try {

            protocolMetaData.readExternal(in);

            PROTOCOL_VERSION.writeExternal(out);

            byte requestType = (byte) in.read();

            if (requestType == -1) {
                return;
            }

            ois = new EjbObjectInputStream(in);
            oos = new ObjectOutputStream(out);

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            switch (requestType) {
                case RequestMethodConstants.EJB_REQUEST:
                    requestTypeName = "EJB_REQUEST";
                    processEjbRequest(ois, oos);
                    break;
                case RequestMethodConstants.JNDI_REQUEST:
                    requestTypeName = "JNDI_REQUEST";
                    processJndiRequest(ois, oos);
                    break;
                case RequestMethodConstants.AUTH_REQUEST:
                    requestTypeName = "AUTH_REQUEST";
                    processAuthRequest(ois, oos);
                    break;
                default:
                    requestTypeName = requestType+" (UNKNOWN)";
                    logger.error("\"" + requestTypeName + " " + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type " + requestType);

            }
        } catch (SecurityException e) {
            logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \"Security error - "+e.getMessage()+"\"",e);
        } catch (Throwable e) {
            logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \"Unexpected error - "+e.getMessage()+"\"",e);
        } finally {
            try {
                if (oos != null) {
                    oos.flush();
                    oos.close();
                } else if (out != null) {
                    out.flush();
                    out.close();
                }
            } catch (Throwable t) {
                logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \""+t.getMessage()+"\"");
            }
        }
    }
View Full Code Here

            }
        }
    }

    public void service(InputStream in, OutputStream out) throws IOException {
        ProtocolMetaData protocolMetaData = new ProtocolMetaData();
        String requestTypeName = null;

        ObjectInputStream ois = null;
        ObjectOutputStream oos = null;

        try {

            protocolMetaData.readExternal(in);

            PROTOCOL_VERSION.writeExternal(out);

            byte requestType = (byte) in.read();

            if (requestType == -1) {
                return;
            }

            ois = new EjbObjectInputStream(in);
            oos = new ObjectOutputStream(out);

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            switch (requestType) {
                case RequestMethodConstants.EJB_REQUEST:
                    requestTypeName = "EJB_REQUEST";
                    processEjbRequest(ois, oos);
                    break;
                case RequestMethodConstants.JNDI_REQUEST:
                    requestTypeName = "JNDI_REQUEST";
                    processJndiRequest(ois, oos);
                    break;
                case RequestMethodConstants.AUTH_REQUEST:
                    requestTypeName = "AUTH_REQUEST";
                    processAuthRequest(ois, oos);
                    break;
                default:
                    requestTypeName = requestType+" (UNKNOWN)";
                    logger.error("\"" + requestTypeName + " " + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type " + requestType);

            }
        } catch (SecurityException e) {
            logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \"Security error - "+e.getMessage()+"\"",e);
        } catch (Throwable e) {
            logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \"Unexpected error - "+e.getMessage()+"\"",e);
        } finally {
            try {
                if (oos != null) {
                    oos.flush();
                    oos.close();
                } else if (out != null) {
                    out.flush();
                    out.close();
                }
            } catch (Throwable t) {
                logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \""+t.getMessage()+"\"");
            }
        }
    }
View Full Code Here

            }
        }
    }

    public void service(InputStream in, OutputStream out) throws IOException {
        ProtocolMetaData protocolMetaData = new ProtocolMetaData();
        String requestTypeName = null;

        ObjectInputStream ois = null;
        ObjectOutputStream oos = null;

        try {

            // Read Protocol Version
            protocolMetaData.readExternal(in);

            PROTOCOL_VERSION.writeExternal(out);

            ois = new EjbObjectInputStream(in);
            oos = new ObjectOutputStream(out);

            // Read ServerMetaData
            ServerMetaData serverMetaData = new ServerMetaData();
            serverMetaData.readExternal(ois);
            ClientObjectFactory.serverMetaData.set(serverMetaData);

            // Read request type
            byte requestType = (byte) ois.read();

            if (requestType == -1) {
                return;
            }

            if (requestType == RequestMethodConstants.CLUSTER_REQUEST){
                processClusterRequest(ois, oos);
            }

            requestType = (byte) ois.read();

            if (requestType == -1) {
                return;
            }


            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            switch (requestType) {
                case RequestMethodConstants.EJB_REQUEST:
                    requestTypeName = "EJB_REQUEST";
                    processEjbRequest(ois, oos);
                    break;
                case RequestMethodConstants.JNDI_REQUEST:
                    requestTypeName = "JNDI_REQUEST";
                    processJndiRequest(ois, oos);
                    break;
                case RequestMethodConstants.AUTH_REQUEST:
                    requestTypeName = "AUTH_REQUEST";
                    processAuthRequest(ois, oos);
                    break;
                default:
                    requestTypeName = requestType+" (UNKNOWN)";
                    logger.error("\"" + requestTypeName + " " + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type " + requestType);

            }
        } catch (SecurityException e) {
            logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \"Security error - "+e.getMessage()+"\"",e);
        } catch (Throwable e) {
            logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \"Unexpected error - "+e.getMessage()+"\"",e);
        } finally {
            ClientObjectFactory.serverMetaData.remove();
            try {
                if (oos != null) {
                    oos.flush();
                    oos.close();
                } else if (out != null) {
                    out.flush();
                    out.close();
                }
            } catch (Throwable t) {
                logger.error("\""+requestTypeName +" "+ protocolMetaData.getSpec() + "\" FAIL \""+t.getMessage()+"\"");
            }
        }
    }
View Full Code Here

        }
    }

    public void service(final InputStream rawIn, final OutputStream rawOut) throws IOException {

        final ProtocolMetaData clientProtocol = new ProtocolMetaData();

        ObjectInputStream ois = null;
        ObjectOutputStream oos = null;
        RequestType requestType = null;
        byte requestTypeByte = RequestType.NOP_REQUEST.getCode();

        try {

            final RequestInfos.RequestInfo info = RequestInfos.info();
            info.setInputStream(new CountingInputStream(rawIn));

            // Read client Protocol Version
            final CountingInputStream cis = info.getInputStream();
            clientProtocol.readExternal(cis);
            ois = new EjbObjectInputStream(cis);

            // Read ServerMetaData
            final ServerMetaData serverMetaData = new ServerMetaData();
            serverMetaData.readExternal(ois);
            ClientObjectFactory.serverMetaData.set(serverMetaData);

            // Read request type
            requestTypeByte = ois.readByte();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            ClusterResponse clusterResponse = null;

            if (requestType == RequestType.CLUSTER_REQUEST) {
                clusterResponse = clusterHandler.processRequest(ois, clientProtocol);

                //Check for immediate failure
                final Throwable failure = clusterResponse.getFailure();
                if (null != clusterResponse && null != failure) {

                    clusterHandler.getLogger().debug("Failed to write to ClusterResponse", failure);

                    try {
                        info.setOutputStream(new CountingOutputStream(rawOut));
                        oos = new ObjectOutputStream(info.getOutputStream());
                        clusterResponse.setMetaData(clientProtocol);
                        clusterResponse.writeExternal(oos);
                        oos.flush();
                    } catch (IOException ie) {
                        final String m = "Failed to write to ClusterResponse: " + ie.getMessage();
                        clusterHandler.getLogger().error(m, ie);
                        throw Exceptions.newIOException(m, ie);
                    }

                    throw failure;
                }
            }

            requestTypeByte = ois.readByte();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            final Response response;
            switch (requestType) {
                case EJB_REQUEST:
                    response = processEjbRequest(ois, clientProtocol);
                    break;
                case JNDI_REQUEST:
                    response = processJndiRequest(ois, clientProtocol);
                    break;
                case AUTH_REQUEST:
                    response = processAuthRequest(ois, clientProtocol);
                    break;
                default:
                    logger.error("\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unknown request type " + requestType);
                    return;
            }

            try {
                info.setOutputStream(new CountingOutputStream(rawOut));

                final CountingOutputStream cos = info.getOutputStream();

                //Let client know we are using the requested protocol to respond
                clientProtocol.writeExternal(cos);
                cos.flush();

                oos = new ObjectOutputStream(cos);
                clusterHandler.processResponse(clusterResponse, oos, clientProtocol);
                oos.flush();

            } finally {
                switch (requestType) {
                    case EJB_REQUEST:
                        processEjbResponse(response, oos, clientProtocol);
                        break;
                    case JNDI_REQUEST:
                        processJndiResponse(response, oos, clientProtocol);
                        break;
                    case AUTH_REQUEST:
                        processAuthResponse(response, oos, clientProtocol);
                        break;
                    default:
                        //Should never get here...
                        logger.error("\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unknown response type " + requestType);
                }
            }

        } catch (IllegalArgumentException iae) {
            final String msg = "\"" + clientProtocol.getSpec() + "\" FAIL \"Unknown request type " + requestTypeByte;
            if (logger.isDebugEnabled()) {
                logger.debug(msg, iae);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (SecurityException e) {
            final String msg = "\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Security error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (Throwable e) {
            final String msg = "\"" + requestType + " " + clientProtocol.getSpec() + "\" FAIL \"Unexpected error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
View Full Code Here

            }
        }
    }

    public void service(final InputStream in, final OutputStream out) throws IOException {
        final ProtocolMetaData protocolMetaData = new ProtocolMetaData();

        ObjectInputStream ois = null;
        ObjectOutputStream oos = null;
        RequestType requestType = null;
        byte requestTypeByte = RequestType.NOP_REQUEST.getCode();

        try {

            // Read Protocol Version
            protocolMetaData.readExternal(in);
            PROTOCOL_VERSION.writeExternal(out);

            ois = new EjbObjectInputStream(in);
            oos = new ObjectOutputStream(out);

            // Read ServerMetaData
            final ServerMetaData serverMetaData = new ServerMetaData();
            serverMetaData.readExternal(ois);
            ClientObjectFactory.serverMetaData.set(serverMetaData);

            // Read request type
            requestTypeByte = (byte) ois.read();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            if (requestType == RequestType.CLUSTER_REQUEST) {
                processClusterRequest(ois, oos);
            }

            requestTypeByte = (byte) ois.read();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            switch (requestType) {
                case EJB_REQUEST:
                    processEjbRequest(ois, oos);
                    break;
                case JNDI_REQUEST:
                    processJndiRequest(ois, oos);
                    break;
                case AUTH_REQUEST:
                    processAuthRequest(ois, oos);
                    break;
                default:
                    logger.error("\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type " + requestType);
                    break;
            }
        } catch (IllegalArgumentException iae) {
            final String msg = "\"" + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type " + requestTypeByte;
            if (logger.isDebugEnabled()) {
                logger.debug(msg, iae);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (SecurityException e) {
            final String msg = "\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL \"Security error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (Throwable e) {
            final String msg = "\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL \"Unexpected error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
View Full Code Here

            }
        }
    }

    public void service(InputStream in, OutputStream out) throws IOException {
        ProtocolMetaData protocolMetaData = new ProtocolMetaData();

        ObjectInputStream ois = null;
        ObjectOutputStream oos = null;
        RequestType requestType = null;
        byte requestTypeByte = RequestType.NOP_REQUEST.getCode();

        try {

            // Read Protocol Version
            protocolMetaData.readExternal(in);
            PROTOCOL_VERSION.writeExternal(out);

            ois = new EjbObjectInputStream(in);
            oos = new ObjectOutputStream(out);

            // Read ServerMetaData
            final ServerMetaData serverMetaData = new ServerMetaData();
            serverMetaData.readExternal(ois);
            ClientObjectFactory.serverMetaData.set(serverMetaData);

            // Read request type
            requestTypeByte = (byte) ois.read();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            if (requestType == RequestType.CLUSTER_REQUEST) {
                processClusterRequest(ois, oos);
            }

            requestTypeByte = (byte) ois.read();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            switch (requestType) {
                case EJB_REQUEST:
                    processEjbRequest(ois, oos);
                    break;
                case JNDI_REQUEST:
                    processJndiRequest(ois, oos);
                    break;
                case AUTH_REQUEST:
                    processAuthRequest(ois, oos);
                    break;
                default:
                    logger.error("\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type " + requestType);
                    break;
            }
        } catch (IllegalArgumentException iae) {
            final String msg = "\"" + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type " + requestTypeByte;
            if (logger.isDebugEnabled()) {
                logger.debug(msg, iae);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (SecurityException e) {
            final String msg = "\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL \"Security error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (Throwable e) {
            final String msg = "\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL \"Unexpected error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
View Full Code Here

            }
        }
    }

    public void service(InputStream in, OutputStream out) throws IOException {
        ProtocolMetaData protocolMetaData = new ProtocolMetaData();

        ObjectInputStream ois = null;
        ObjectOutputStream oos = null;
        RequestType requestType = null;
        byte requestTypeByte = RequestType.NOP_REQUEST.getCode();

        try {

            // Read Protocol Version
            protocolMetaData.readExternal(in);
            PROTOCOL_VERSION.writeExternal(out);

            ois = new EjbObjectInputStream(in);
            oos = new ObjectOutputStream(out);

            // Read ServerMetaData
            final ServerMetaData serverMetaData = new ServerMetaData();
            serverMetaData.readExternal(ois);
            ClientObjectFactory.serverMetaData.set(serverMetaData);

            // Read request type
            requestTypeByte = (byte) ois.read();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            if (requestType == RequestType.CLUSTER_REQUEST) {
                processClusterRequest(ois, oos);
            }

            requestTypeByte = (byte) ois.read();
            requestType = RequestType.valueOf(requestTypeByte);

            if (requestType == RequestType.NOP_REQUEST) {
                return;
            }

            // Exceptions should not be thrown from these methods
            // They should handle their own exceptions and clean
            // things up with the client accordingly.
            switch (requestType) {
                case EJB_REQUEST:
                    processEjbRequest(ois, oos);
                    break;
                case JNDI_REQUEST:
                    processJndiRequest(ois, oos);
                    break;
                case AUTH_REQUEST:
                    processAuthRequest(ois, oos);
                    break;
                default:
                    logger.error("\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type " + requestType);
                    break;
            }
        } catch (IllegalArgumentException iae) {
            final String msg = "\"" + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type " + requestTypeByte;
            if (logger.isDebugEnabled()) {
                logger.debug(msg, iae);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (SecurityException e) {
            final String msg = "\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL \"Security error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
        } catch (Throwable e) {
            final String msg = "\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL \"Unexpected error - " + e.getMessage() + "\"";
            if (logger.isDebugEnabled()) {
                logger.debug(msg, e);
            } else {
                logger.warning(msg + " - Debug for StackTrace");
            }
View Full Code Here

TOP

Related Classes of org.apache.openejb.client.ProtocolMetaData

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.