I tried to do deploy/undeploy from code also.
Currently I create ant script to run command line to deploy/undeploy/etc.
<target name="deploy">
<echo message="Deploying ${module.name} at instance port ${rmi.port}" />
<java jar="bin/deployer.jar" fork="true">
<arg value="--port"/>
<arg value="${rmi.port}"/>
<arg value="--user"/>
<arg value="${user}"/>
<arg value="--password"/>
<arg value="${password}"/>
<arg value="deploy"/>
<arg value="${module.name}.war"/>
</java>
</target>
Then I trigger that ant task from code.
public void deployModule(String rmiPort, String moduleName, String user,
String password) {
Map<String, String> param = new HashMap<String, String>();
param.put("rmi.port",rmiPort);
param.put("module.name",moduleName);
param.put("user",user);
param.put("password",password);
antWrapper.callAnt("deploy",true,param);
}
AntWrapper.java
public void callAnt(String target, boolean showOutput,Map<String,
String> param){
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
...
p.fireBuildStarted();
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(target);
This one call gbean method directly using JMX:
gbeanObjName = new
ObjectName("geronimo:ServiceModule=org.apache.geronimo.framework/plugin/2.1.3/car,J2EEServer=geronimo,name=PluginInstaller,j2eeType=GBean");
Object [] paramsStartInstall = new Object[] {carFile, null, false, null,
null};
String [] signatureStartInstall = new String[] {"java.io.File",
"java.lang.String" , "boolean", "java.lang.String", "java.lang.String"};
returnObj = mbServerConn.invoke(gbeanObjName, "install-plugin", params,
signature);
Thanks,
Ricky
djencks wrote:
>
>
> On Jan 14, 2009, at 3:29 PM, Ricky Ignatius wrote:
>
>>
>> Hi,
>> I try to do same thing.
>> Currently I use ant to run command line, and call those ant task
>> from java.
>> For install-plugin, I unable to do that using ant so I use JMX to call
>> plugin gbean directly.
>>
>> It's work so far, is there any bteer way to do that?
>
> I'm a little bit confused about what you want. The original request
> was for advice on how to call some gbean methods from within the
> geronimo vm. We also have a lot of gshell commands that call these
> gbean methods from another vm running gshell, and of course there are
> lot of maven plugins that let you do this stuff. You mention ant
> repeatedly.... do you want some way to call these methods from ant?
> Or from another vm? JMX should certainly work but you should be able
> to write some simpler client code if you use gbean proxies as the
> gshell code does.
>
> Ant tasks should be pretty easy to write also, I think no one here
> uses ant much so it hasn't been a priority. If you would like to try
> we can give you some advice and if you could contribute them that
> would be great!
>
> thanks
> david jencks
>
>>
>>
>> Thanks,
>>
>> Ricky
>>
>>
>> djencks wrote:
>>>
>>>
>>> On Aug 27, 2007, at 12:56 AM, Stefan Schulze Frielinghaus wrote:
>>>
>>>> I would like to have the functionality of the command line tool
>>>> "java -jar deployer.jar --user system --password manager
>>>> {deploy,undeploy} <tool>.jar" in a GBean. So I could programmatic
>>>> load and unload other GBeans via a GBean.
>
>
--
View this message in context:
http://www.nabble.com/deploy-and-undeploy-a-gbean-tp12317449s134p21468560.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.