001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.tools.server.rmi;
028:
029: import java.util.List;
030:
031: import org.cougaar.tools.server.ProcessDescription;
032: import org.cougaar.tools.server.RemoteFileSystem;
033: import org.cougaar.tools.server.RemoteHost;
034: import org.cougaar.tools.server.RemoteListenableConfig;
035: import org.cougaar.tools.server.RemoteProcess;
036: import org.cougaar.tools.server.RemoteProcessManager;
037:
038: /**
039: * This implementation of RemoteHost that communicates
040: * with a single "host:port" via RMI.
041: *
042: * @see RemoteHost
043: */
044: class RemoteHostStub implements RemoteHost {
045:
046: private RemoteHostDecl rhd;
047:
048: public RemoteHostStub(RemoteHostDecl rhd) {
049: this .rhd = rhd;
050: }
051:
052: public RemoteProcessManager getRemoteProcessManager()
053: throws Exception {
054: RemoteProcessManagerDecl rpmd = rhd.getRemoteProcessManager();
055: if (rpmd == null) {
056: return null;
057: }
058: RemoteProcessManager rpm = new RemoteProcessManagerStub(rpmd);
059: return rpm;
060: }
061:
062: public RemoteFileSystem getRemoteFileSystem() throws Exception {
063: RemoteFileSystemDecl rfsd = rhd.getRemoteFileSystem();
064: if (rfsd == null) {
065: return null;
066: }
067: RemoteFileSystem rfs = new RemoteFileSystemStub(rfsd);
068: return rfs;
069: }
070:
071: public RemoteProcess createRemoteProcess(ProcessDescription pd,
072: RemoteListenableConfig rlc) throws Exception {
073: return getRemoteProcessManager().createRemoteProcess(pd, rlc);
074: }
075:
076: public RemoteProcess getRemoteProcess(String procName)
077: throws Exception {
078: return getRemoteProcessManager().getRemoteProcess(procName);
079: }
080:
081: //
082: // delegate the rest:
083: //
084:
085: public long ping() throws Exception {
086: return rhd.ping();
087: }
088:
089: public int killRemoteProcess(String procName) throws Exception {
090: return rhd.killRemoteProcess(procName);
091: }
092:
093: public ProcessDescription getProcessDescription(String procName)
094: throws Exception {
095: return rhd.getProcessDescription(procName);
096: }
097:
098: public List listProcessDescriptions(String procGroup)
099: throws Exception {
100: return rhd.listProcessDescriptions(procGroup);
101: }
102:
103: public List listProcessDescriptions() throws Exception {
104: return rhd.listProcessDescriptions();
105: }
106: }
|