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: * @(#)JbiTargetTask.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 com.sun.jbi.ui.client.ConnectionType;
032: import com.sun.jbi.ui.client.JBIAdminCommandsClientFactory;
033: import com.sun.jbi.ui.client.JMXConnectionProperties;
034: import com.sun.jbi.ui.common.I18NBundle;
035: import com.sun.jbi.ui.common.JBIAdminCommands;
036: import com.sun.jbi.ui.common.JBIManagementMessage;
037: import com.sun.jbi.ui.common.JBIRemoteException;
038: import com.sun.jbi.ui.common.JBIResultXmlBuilder;
039: import com.sun.jbi.ui.common.JMXConnectionException;
040: import com.sun.jbi.ui.common.JBIManagementMessage.JBIManagementMessageException;
041: import java.util.Properties;
042: import java.io.IOException;
043: import org.apache.tools.ant.BuildException;
044: import org.apache.tools.ant.Project;
045: import org.apache.tools.ant.Task;
046:
047: import java.io.FileInputStream;
048: import java.io.File;
049:
050: /** This class extends from the <@link JbiJmxTask> to add target attribute to the task.
051: * Jbi tasks that required the target attribute in addition to the jmx connection attributes
052: * will extends from this task. Jbi Tasks that don't need target attribute can directly
053: * extend from JbiJmxTask.
054: *
055: * @author Sun Microsystems, Inc.
056: */
057:
058: public abstract class JbiTargetTask extends JbiJmxTask {
059: /** server target */
060: public static final String TARGET_SERVER = "server";
061: /** domain target */
062: public static final String TARGET_DOMAIN = "domain";
063:
064: /** Holds value of property Target. */
065: private String mTarget = TARGET_SERVER;
066:
067: /** Getter for property target.
068: * @return Value for Property target.
069: */
070: public String getTarget() {
071: return this .mTarget;
072: }
073:
074: /** Setter for property target.
075: * @param target New value of property target.
076: */
077: public void setTarget(String target) {
078: this .mTarget = target;
079: }
080:
081: protected void validateTarget(String target) throws BuildException {
082: if (target != null && target.length() > 0
083: && target.trim().length() == 0) {
084: throwTaskBuildException(
085: "jbi.ui.ant.task.error.invalid.target", target);
086: }
087: }
088:
089: public String getValidTarget() throws BuildException {
090: String target = getTarget();
091: validateTarget(target);
092:
093: if (target == null || target.length() == 0) {
094: target = TARGET_SERVER;
095: }
096: return target;
097: }
098:
099: protected void logDebugConnectionAttributes() {
100: super .logDebugConnectionAttributes();
101: logDebug("target=" + this.getTarget());
102: }
103:
104: }
|