001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)JbiShutdownServiceAssemblyTask.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.ui.ant;
030:
031: import org.apache.tools.ant.BuildException;
032:
033: /** This class is an ant task for shutting down the service assembly.
034: *
035: * @author Sun Microsystems, Inc.
036: */
037: public class JbiShutdownServiceAssemblyTask extends JbiTargetTask {
038: /**
039: * success msg key
040: */
041: private static final String PARTIAL_SUCCESS_STATUS_KEY = "jbi.ui.ant.shutdown.sasm.partial.success";
042:
043: /**
044: * success msg key
045: */
046: private static final String SUCCESS_STATUS_KEY = "jbi.ui.ant.shutdown.sasm.successful";
047: /**
048: * failure msg key
049: */
050: private static final String FAILED_STATUS_KEY = "jbi.ui.ant.shutdown.sasm.failed";
051:
052: /** Holds value of property ServiceAssemblyName. */
053: private String mServiceAssemblyName;
054:
055: /**
056: * Holds value of property force.
057: */
058: private boolean mForce = false;
059:
060: /**
061: * Getter for property forced.
062: * @return Value of property forced.
063: */
064: public boolean isForce() {
065:
066: return this .mForce;
067: }
068:
069: /**
070: * Setter for property forced.
071: * @param force New value of property forced.
072: */
073: public void setForce(boolean force) {
074:
075: this .mForce = force;
076: }
077:
078: /** Getter for property name.
079: * @return Value of property name.
080: *
081: */
082: public String getName() {
083: return this .mServiceAssemblyName;
084: }
085:
086: /**
087: * Setter for property name.
088: * @param name service assembly name
089: */
090: public void setName(String name) {
091: this .mServiceAssemblyName = name;
092: }
093:
094: /** executes the shutdown sevice assembly task. Ant Task framework calls this method to
095: * excute the task.
096: * @throws BuildException if error or exception occurs.
097: */
098: public void executeTask() throws BuildException {
099:
100: String saName = getValidServiceAssemblyName(getName());
101: String target = getValidTarget();
102: boolean force = isForce();
103: String result = null;
104: try {
105: result = this .getJBIAdminCommands()
106: .shutdownServiceAssembly(saName, force, target);
107: } catch (Exception ex) {
108: processTaskException(ex);
109: }
110:
111: processTaskResult(result);
112:
113: }
114:
115: /**
116: * returns i18n key. tasks implement this method.
117: * @return i18n key for the success status
118: */
119: protected String getTaskFailedStatusI18NKey() {
120: return FAILED_STATUS_KEY;
121: }
122:
123: /**
124: * returns i18n key. tasks implement this method.
125: * @return i18n key for the failed status
126: */
127: protected String getTaskSuccessStatusI18NKey() {
128: return SUCCESS_STATUS_KEY;
129: }
130:
131: /**
132: * return i18n key for the partial success
133: * @return i18n key for the partial success
134: */
135: protected String getTaskPartialSuccessStatusI18NKey() {
136: return PARTIAL_SUCCESS_STATUS_KEY;
137: }
138:
139: }
|