1 package org.apache.tools.ant.taskdefs.optional.jmx; 2 3 52 53 import org.apache.tools.ant.BuildException; 54 import org.apache.tools.ant.types.optional.ContextType; 55 56 57 69 public abstract class AbstractManagementTask extends org.apache.tools.ant.Task { 70 71 private boolean failOnError = false; 72 73 private ContextType context = null; 74 75 public AbstractManagementTask() { 76 context = new ContextType(); 77 } 78 79 protected void setContext(ContextType context) { 80 this.context = context; 81 } 82 83 protected ContextType getContext() { 84 return context; 85 } 86 87 93 public void setServerType(String serverType) { 94 getContext().setServerType(serverType); 95 } 96 97 106 public void setProviderUrl(String providerUrl) { 107 getContext().setProviderUrl(providerUrl); 108 } 109 110 117 public void setJndiName(String jndiName) { 118 getContext().setJndiName(jndiName); 119 } 120 121 126 public void setUser(String user) { 127 getContext().setUser(user); 128 } 129 130 135 public void setPassword(String password) { 136 getContext().setPassword(password); 137 } 138 139 147 public void setFailOnError(boolean failOnError) { 148 this.failOnError = failOnError; 149 } 150 151 152 157 protected String getJndiName() { 158 return getContext().getJndiName(); 159 } 160 161 162 168 protected boolean getFailOnError() { 169 return failOnError; 170 } 171 172 177 protected String getProviderUrl() { 178 return getContext().getProviderUrl(); 179 } 180 181 protected String getUser() { 182 return getContext().getUser(); 183 } 184 185 protected String getPassword() { 186 return getContext().getPassword(); 187 } 188 189 public void setContextRef(org.apache.tools.ant.types.Reference ref) { 190 Object obj = ref.getReferencedObject(this.getProject()); 191 192 if (!(obj instanceof ContextType)) { 193 String msg = "'" + ref.getRefId() + "' doesn't denote a " + ContextType.DATA_TYPE_NAME + ". " + ref.getRefId() + " is a " + obj.getClass().getName(); 194 throw new BuildException(msg); 195 } 196 setContext((ContextType) obj); 197 } 198 199 200 } 201 202 | Popular Tags |