1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.tools.ant.taskdefs.optional.j2ee;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.types.Path;
/**
* An Ant wrapper task for the weblogic.deploy tool. This is used
* to hot-deploy J2EE applications to a running WebLogic server.
* This is <b>not</b> the same as creating the application
* archive. This task assumes the archive (EAR, JAR, or WAR) file
* has been assembled and is supplied as the "source" attribute.
* <p>
*
* In the end, this task assembles the commadline parameters and
* runs the weblogic.deploy tool in a seperate JVM.
*
*@see org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool
*@see org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool
*@see org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy
*/
public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements HotDeploymentTool {
/**
* Description of the Field
*/
protected static final String DEFAULT_ORB = "RMI";
/**
* The classname of the tool to run *
*/
private static final String JONAS_DEPLOY_CLASS_NAME = "org.objectweb.jonas.adm.JonasAdmin";
/**
* All the valid actions that weblogic.deploy permits *
*/
private static final String[] VALID_ACTIONS
= {ACTION_DELETE, ACTION_DEPLOY, ACTION_LIST, ACTION_UNDEPLOY, ACTION_UPDATE};
/**
* Description of the Field
*/
private File jonasroot;
/**
* Description of the Field
*/
private String orb = null;
/**
* Description of the Field
*/
private String davidHost;
/**
* Description of the Field
*/
private int davidPort;
/**
* Set the host for the David ORB; required if
* ORB==david.
*
*@param inValue The new davidhost value
*/
public void setDavidhost(final String inValue) {
davidHost = inValue;
}
/**
* Set the port for the David ORB; required if
* ORB==david.
*
*@param inValue The new davidport value
*/
public void setDavidport(final int inValue) {
davidPort = inValue;
}
/**
* set the jonas root directory (-Dinstall.root=). This
* element is required.
*
*@param inValue The new jonasroot value
*/
public void setJonasroot(final File inValue) {
jonasroot = inValue;
}
/**
*
* Choose your ORB : RMI, JEREMIE, DAVID, ...; optional.
* If omitted, it defaults
* to the one present in classpath. The corresponding JOnAS JAR is
* automatically added to the classpath. If your orb is DAVID (RMI/IIOP) you must
* specify davidhost and davidport properties.
*
*@param inValue RMI, JEREMIE, DAVID,...
*/
public void setOrb(final String inValue) {
orb = inValue;
}
/**
* gets the classpath field.
*
*@return A Path representing the "classpath" attribute.
*/
public Path getClasspath() {
Path aClassPath = super.getClasspath();
if (aClassPath == null) {
aClassPath = new Path(getTask().getProject());
}
if (orb != null) {
String aOrbJar = new File(jonasroot, "lib/" + orb + "_jonas.jar").toString();
String aConfigDir = new File(jonasroot, "config/").toString();
Path aJOnASOrbPath = new Path(aClassPath.getProject(),
aOrbJar + File.pathSeparator + aConfigDir);
aClassPath.append(aJOnASOrbPath);
}
return aClassPath;
}
/**
* Validates the passed in attributes. <p>
*
* The rules are:
* <ol>
* <li> If action is "deploy" or "update" the "application"
* and "source" attributes must be supplied.
* <li> If action is "delete" or "undeploy" the
* "application" attribute must be supplied.
*
*@exception BuildException Description
* of Exception
*/
public void validateAttributes() throws BuildException {
// super.validateAttributes(); // don't want to call this method
Java java = getJava();
String action = getTask().getAction();
if (action == null) {
throw new BuildException("The \"action\" attribute must be set");
}
if (!isActionValid()) {
throw new BuildException("Invalid action \"" + action + "\" passed");
}
if (getClassName() == null) {
setClassName(JONAS_DEPLOY_CLASS_NAME);
}
if (jonasroot == null || jonasroot.isDirectory()) {
java.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
java.createJvmarg().setValue("-Djava.security.policy=" + jonasroot
+ "/config/java.policy");
if ("DAVID".equals(orb)) {
java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBClass"
+ "=org.objectweb.david.libs.binding.orbs.iiop.IIOPORB");
java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBSingletonClass="
+ "org.objectweb.david.libs.binding.orbs.ORBSingletonClass");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.StubClass="
+ "org.objectweb.david.libs.stub_factories.rmi.StubDelegate");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.PortableRemoteObjectClass="
+ "org.objectweb.david.libs.binding.rmi.ORBPortableRemoteObjectDelegate");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.UtilClass="
+ "org.objectweb.david.libs.helpers.RMIUtilDelegate");
java.createJvmarg().setValue("-Ddavid.CosNaming.default_method=0");
java.createJvmarg().setValue("-Ddavid.rmi.ValueHandlerClass="
+ "com.sun.corba.se.internal.io.ValueHandlerImpl");
if (davidHost != null) {
java.createJvmarg().setValue("-Ddavid.CosNaming.default_host="
+ davidHost);
}
if (davidPort != 0) {
java.createJvmarg().setValue("-Ddavid.CosNaming.default_port="
+ davidPort);
}
}
}
if (getServer() != null) {
java.createArg().setLine("-n " + getServer());
}
if (action.equals(ACTION_DEPLOY)
|| action.equals(ACTION_UPDATE)
|| action.equals("redeploy")) {
java.createArg().setLine("-a " + getTask().getSource());
} else if (action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) {
java.createArg().setLine("-r " + getTask().getSource());
} else if (action.equals(ACTION_LIST)) {
java.createArg().setValue("-l");
}
}
/**
* Determines if the action supplied is valid. <p>
*
* Valid actions are contained in the static array
* VALID_ACTIONS
*
*@return true if the action attribute is valid, false if
* not.
*/
protected boolean isActionValid() {
boolean valid = false;
String action = getTask().getAction();
for (int i = 0; i < VALID_ACTIONS.length; i++) {
if (action.equals(VALID_ACTIONS[i])) {
valid = true;
break;
}
}
return valid;
}
}
|