Package org.rhq.enterprise.communications.command.impl.stream

Examples of org.rhq.enterprise.communications.command.impl.stream.RemoteOutputStreamCommandResponse


        String method_name = invocation.getMethodName();
        Object[] params = invocation.getParameters();
        String[] signature = invocation.getSignature();
        Class<?>[] class_signature = new Class[signature.length];

        RemoteOutputStreamCommandResponse response;

        try {
            // get the stream that the command wants to access
            Long stream_id = remote_command.getStreamId();
            OutputStream the_stream;

            synchronized (m_lock) {
                the_stream = m_remotedOutputStreams.get(stream_id);

                if (the_stream == null) {
                    throw new IllegalArgumentException(LOG.getMsgString(CommI18NResourceKeys.INVALID_OUTSTREAM_ID,
                        stream_id, remote_command));
                }

                setLastAccess(stream_id, System.currentTimeMillis());
            }

            LOG.debug(CommI18NResourceKeys.INVOKING_OUTSTREAM_FROM_REMOTE_CLIENT, stream_id, method_name);

            // use reflection to make the call
            for (int x = 0; x < signature.length; x++) {
                class_signature[x] = ClassUtil.getClassFromTypeName(signature[x]);
            }

            Method method = OutputStream.class.getMethod(method_name, class_signature);
            Object results = method.invoke(the_stream, params);

            response = new RemoteOutputStreamCommandResponse(remote_command, results);

            // if the client has asked to close the stream, then we will ask that this service be deregistered as soon as possible
            // once the stream is closed, a client should not request anything else from our service (obviously, there is nothing else
            // this service can provide since the stream is now useless)
            if ("close".equals(method_name)) {
                setLastAccess(stream_id, 0L);
            }
        } catch (Exception e) {
            LOG.warn(e, CommI18NResourceKeys.FAILED_TO_INVOKE_OUTSTREAM_METHOD, method_name, remote_command);
            response = new RemoteOutputStreamCommandResponse(remote_command, e);
        }

        return response;
    }
View Full Code Here


        if (m_sender == null) {
            throw new RemoteIOException(LOG.getMsgString(CommI18NResourceKeys.REMOTE_OUTPUT_STREAM_HAS_NO_SENDER,
                m_streamId, m_serverEndpoint));
        }

        RemoteOutputStreamCommandResponse response;
        RemoteOutputStreamCommand cmd = new RemoteOutputStreamCommand();

        cmd.setNameBasedInvocation(new NameBasedInvocation(method, args));
        cmd.setStreamId(m_streamId);

        try {
            response = new RemoteOutputStreamCommandResponse(m_sender.sendSynch(cmd));
        } catch (Exception e) {
            throw new RemoteIOException(e);
        }

        if (!response.isSuccessful()) {
            throw new RemoteIOException(response.getException());
        }

        return response.getResults();
    }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.communications.command.impl.stream.RemoteOutputStreamCommandResponse

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.