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.rmi.RemoteException;
030: import java.rmi.server.UnicastRemoteObject;
031: import java.util.List;
032:
033: import org.cougaar.tools.server.ProcessDescription;
034: import org.cougaar.tools.server.RemoteListenableConfig;
035: import org.cougaar.tools.server.RemoteProcess;
036: import org.cougaar.tools.server.RemoteProcessManager;
037:
038: /**
039: * Server implementation to create and control processes on a
040: * single host, plus basic file-system support.
041: */
042: class RemoteProcessManagerImpl extends UnicastRemoteObject implements
043: RemoteProcessManagerDecl {
044:
045: private final RemoteProcessManager rpm;
046:
047: public RemoteProcessManagerImpl(RemoteProcessManager rpm)
048: throws RemoteException {
049: this .rpm = rpm;
050: if (rpm == null) {
051: throw new NullPointerException();
052: }
053: }
054:
055: public RemoteProcessDecl createRemoteProcess(ProcessDescription pd,
056: RemoteListenableConfigWrapper rlcw) throws Exception {
057: // unwrap listener(s)
058: RemoteListenableConfig rlc = rlcw.toRemoteListenableConfig();
059: // create process
060: RemoteProcess rp = rpm.createRemoteProcess(pd, rlc);
061: if (rp == null) {
062: return null;
063: }
064: // wrap process
065: RemoteProcessDecl rpd = new RemoteProcessImpl(rp);
066: return rpd;
067: }
068:
069: public RemoteProcessDecl getRemoteProcess(String procName)
070: throws Exception {
071: RemoteProcess rp = rpm.getRemoteProcess(procName);
072: if (rp == null) {
073: return null;
074: }
075: // could cache this
076: RemoteProcessDecl rpd = new RemoteProcessImpl(rp);
077: return rpd;
078: }
079:
080: //
081: // delegate the rest:
082: //
083:
084: public int killRemoteProcess(String procName) throws Exception {
085: return rpm.killRemoteProcess(procName);
086: }
087:
088: public ProcessDescription getProcessDescription(String procName)
089: throws Exception {
090: return rpm.getProcessDescription(procName);
091: }
092:
093: public List listProcessDescriptions(String procGroup)
094: throws Exception {
095: return rpm.listProcessDescriptions(procGroup);
096: }
097:
098: public List listProcessDescriptions() throws Exception {
099: return rpm.listProcessDescriptions();
100: }
101: }
|