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: * @(#)JbiShutdownComponentTask.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 engine or binding component.
034: *
035: * @author Sun Microsystems, Inc.
036: */
037: public class JbiShutdownComponentTask extends JbiTargetTask {
038: /**
039: * success msg key
040: */
041: private static final String SUCCESS_STATUS_KEY = "jbi.ui.ant.shutdown.successful";
042: /**
043: * failure msg key
044: */
045: private static final String FAILED_STATUS_KEY = "jbi.ui.ant.shutdown.failed";
046:
047: /**
048: * Holds value of property force.
049: */
050: private boolean mForce = false;
051:
052: /** Holds value of property componentName. */
053: private String mComponentName;
054:
055: /** Getter for property componentName.
056: * @return Value of property componentName.
057: *
058: */
059: public String getName() {
060: return this .mComponentName;
061: }
062:
063: /**
064: * Setter for property componentName.
065: * @param name component name.
066: */
067: public void setName(String name) {
068: this .mComponentName = name;
069: }
070:
071: /** executes the shutdown component task. Ant Task framework calls this method to
072: * excute the task.
073: * @throws BuildException if error or exception occurs.
074: */
075: public void executeTask() throws BuildException {
076: String compName = getValidComponentName(getName());
077: String target = getValidTarget();
078: boolean force = isForce();
079: try {
080: String result;
081:
082: result = this .getJBIAdminCommands().shutdownComponent(
083: compName, force, target);
084:
085: printTaskSuccess(result);
086:
087: } catch (Exception ex) {
088: // throwTaskBuildException(ex);
089: processTaskException(ex);
090: }
091:
092: }
093:
094: /**
095: * returns i18n key. tasks implement this method.
096: * @return i18n key for the success status
097: */
098: protected String getTaskFailedStatusI18NKey() {
099: return FAILED_STATUS_KEY;
100: }
101:
102: /**
103: * returns i18n key. tasks implement this method.
104: * @return i18n key for the failed status
105: */
106: protected String getTaskSuccessStatusI18NKey() {
107: return SUCCESS_STATUS_KEY;
108: }
109:
110: /**
111: * Getter for property forced.
112: * @return Value of property forced.
113: */
114: public boolean isForce() {
115:
116: return this .mForce;
117: }
118:
119: /**
120: * Setter for property forced.
121: * @param force New value of property forced.
122: */
123: public void setForce(boolean force) {
124:
125: this.mForce = force;
126: }
127:
128: }
|