001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028: package com.caucho.j2ee.deployclient;
029:
030: import javax.enterprise.deploy.shared.StateType;
031: import javax.enterprise.deploy.spi.TargetModuleID;
032: import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException;
033: import javax.enterprise.deploy.spi.status.ClientConfiguration;
034: import javax.enterprise.deploy.spi.status.DeploymentStatus;
035: import javax.enterprise.deploy.spi.status.ProgressListener;
036: import javax.enterprise.deploy.spi.status.ProgressObject;
037: import java.util.logging.Level;
038: import java.util.logging.Logger;
039:
040: /**
041: * Status of the progress.
042: */
043: public class ProgressObjectImpl implements ProgressObject,
044: java.io.Serializable {
045: private static final Logger log = Logger
046: .getLogger(ProgressObjectImpl.class.getName());
047:
048: private TargetModuleID[] _targetModuleIDs;
049: private final DeploymentStatusImpl _status = new DeploymentStatusImpl();
050:
051: ProgressObjectImpl() {
052: }
053:
054: public ProgressObjectImpl(TargetModuleID[] targetModuleIDs) {
055: _targetModuleIDs = targetModuleIDs;
056: }
057:
058: /**
059: * Returns the status.
060: */
061: public DeploymentStatus getDeploymentStatus() {
062: if (_status != null)
063: return _status;
064: else
065: return new DeploymentStatusImpl();
066: }
067:
068: /**
069: * Returns the target ids.
070: */
071: public TargetModuleID[] getResultTargetModuleIDs() {
072: return _targetModuleIDs;
073: }
074:
075: /**
076: * Returns the client configuration.
077: */
078: public ClientConfiguration getClientConfiguration(TargetModuleID id) {
079: throw new UnsupportedOperationException();
080: }
081:
082: /**
083: * Returns true if cancel is supported.
084: */
085: public boolean isCancelSupported() {
086: return false;
087: }
088:
089: /**
090: * Cancels the operation.
091: */
092: public void cancel() throws OperationUnsupportedException {
093: throw new UnsupportedOperationException();
094: }
095:
096: /**
097: * Returns true if stop is supported.
098: */
099: public boolean isStopSupported() {
100: return false;
101: }
102:
103: /**
104: * Stops the operation.
105: */
106: public void stop() throws OperationUnsupportedException {
107: throw new UnsupportedOperationException();
108: }
109:
110: /**
111: * Adds a listener.
112: */
113: public void addProgressListener(ProgressListener listener) {
114: }
115:
116: /**
117: * Removes a listener.
118: */
119: public void removeProgressListener(ProgressListener listener) {
120: }
121:
122: /**
123: * Change to the failed state.
124: */
125: public void failed(String message) {
126: if (log.isLoggable(Level.FINEST))
127: log.log(Level.FINEST, "failed " + message);
128:
129: _status.setState(StateType.FAILED);
130: _status.setMessage(message);
131: }
132:
133: /**
134: * Change to the running state.
135: */
136: public void completed(String message) {
137: _status.setState(StateType.COMPLETED);
138: _status.setMessage(message);
139: }
140:
141: public String toString() {
142: return "ProgressObjectImpl[" + _status + "]";
143: }
144: }
|