Package org.apache.openejb.server.stream

Examples of org.apache.openejb.server.stream.CountingOutputStream


        try {
            RequestInfos.initRequestInfo(socket);

            in = new CountingInputStream(socket.getInputStream());
            out = new CountingOutputStream(socket.getOutputStream());

            //TODO: if ssl change to https
            final URI socketURI = new URI("http://" + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort());
            processRequest(socketURI, in, out);
View Full Code Here


                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();
View Full Code Here

    }

    private void logRequestResponse(final JNDIRequest req, final JNDIResponse res) {
        final RequestInfos.RequestInfo info = RequestInfos.info();
        final CountingInputStream cis = info.getInputStream();
        final CountingOutputStream cos = info.getOutputStream();

        logger.debug("JNDI REQUEST: " + req + " (size = " + (null != cis ? cis.getCount() : 0)
            + "b, remote-ip =" + info.ip
            + ") -- RESPONSE: " + res + " (size = " + (null != cos ? cos.getCount() : 0) + "b)");
    }
View Full Code Here

        try {
            RequestInfos.initRequestInfo(socket);

            in = new CountingInputStream(socket.getInputStream());
            out = new CountingOutputStream(socket.getOutputStream());

            //TODO: if ssl change to https
            final URI socketURI = new URI("http://" + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort());
            processRequest(socketURI, in, out);
View Full Code Here

    }

    private void logRequestResponse(final JNDIRequest req, final JNDIResponse res) {
        final RequestInfos.RequestInfo info = RequestInfos.info();
        final CountingInputStream cis = info.getInputStream();
        final CountingOutputStream cos = info.getOutputStream();

        logger.debug("JNDI REQUEST: " + req + " (size = " + (null != cis ? cis.getCount() : 0)
            + "b, remote-ip =" + info.ip
            + ") -- RESPONSE: " + res + " (size = " + (null != cos ? cos.getCount() : 0) + "b)");
    }
View Full Code Here

                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();
View Full Code Here

        try {
            RequestInfos.initRequestInfo(socket);

            in = new CountingInputStream(socket.getInputStream());
            out = new CountingOutputStream(socket.getOutputStream());

            //TODO: if ssl change to https
            final URI socketURI = new URI("http://" + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort());
            processRequest(socketURI, in, out);
View Full Code Here

        try {
            RequestInfos.initRequestInfo(socket);

            in = new CountingInputStream(socket.getInputStream());
            out = new CountingOutputStream(socket.getOutputStream());

            //TODO: if ssl change to https
            final URI socketURI = new URI("http://" + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort());
            processRequest(socketURI, in, out);
View Full Code Here

    }

    private void logRequestResponse(final JNDIRequest req, final JNDIResponse res) {
        final RequestInfos.RequestInfo info = RequestInfos.info();
        final CountingInputStream cis = info.getInputStream();
        final CountingOutputStream cos = info.getOutputStream();

        logger.debug("JNDI REQUEST: " + req + " (size = " + (null != cis ? cis.getCount() : 0)
                     + "b, remote-ip =" + info.ip
                     + ") -- RESPONSE: " + res + " (size = " + (null != cos ? cos.getCount() : 0) + "b)");
    }
View Full Code Here

                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();
View Full Code Here

TOP

Related Classes of org.apache.openejb.server.stream.CountingOutputStream

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.