-
1. Re: Multiple Databases - Hot deployment of *-ds.xml and *.pa
bill.burke Nov 21, 2005 2:52 PM (in response to holgercasties)You can tell the MainDeployer through an MBean invocation to deploy any archive you want immediately. This is how our junit tests work in JBoss.
-
2. Re: Multiple Databases - Hot deployment of *-ds.xml and *.pa
holgercasties Nov 22, 2005 5:28 AM (in response to holgercasties)Hi Bill.
Thanx a lot for your prompt response.
My problem is that I don't know how to achieve that.
How can I get an appropriate MainDeployer?
And how can I invoke this one through Mbean invocation?
How have I to submit my par file to be deployed?
A useful code sequence would help very much.
Holger -
3. Re: Multiple Databases - Hot deployment of *-ds.xml and *.pa
holgercasties Nov 28, 2005 4:47 AM (in response to holgercasties)Hi.
After looking through several forums I found some answers relating to my questions:
An MBeanServer may be got in the following way:MBeanServerConnection mBeanServerConn = (MBeanServerConnection)ctx.lookup("jmx/invoker/RMIAdaptor");
A MainDeployer could be retrieved via:ObjectName mainDeployer = new ObjectName(MainDeployer.OBJECT_NAME.getCanonicalName());
Now I can use the MBeanServer.invoke method to invoke some MainDeployer methods like "listDeployers()".
But I am not able to invoke the "deploy()" method in this way!
What do I have to do?
How can I deploy my par file?
Holger -
4. Re: Multiple Databases - Hot deployment of *-ds.xml and *.pa
holgercasties Nov 29, 2005 7:07 AM (in response to holgercasties)Hi.
I code the following to achieve hot deployment of 'postgres-ds.xml':// Get MBean server connection MBeanServerConnection mBeanServerConn = (MBeanServerConnection)ctx.lookup("jmx/invoker/RMIAdaptor"); // Get MainDeployer ObjectName mainDeployer = MainDeployer.OBJECT_NAME; // Set params for method invocation: Object[] args = { dsFile }; // fully-qualified path to *-ds.xml file String[] sig = { "java.lang.String" }; // Invoke the 'deploy' method mBeanServerConn.invoke(mainDeployer, "deploy", args, sig);
But the xml file above WILL NOT be hot-deployed!
What is missing in my code sequence?
Or is there anything else to do, to achieve hot deployment?
Holger -
5. Re: Multiple Databases - Hot deployment of *-ds.xml and *.pa
holgercasties Nov 29, 2005 7:15 AM (in response to holgercasties)Relating to my last post:
The *-ds.xml file will be hot-deployed but not immediately as wanted!
The changes will be detected after the 'ScanPeriod' time!
But that's too late! -
6. Re: Multiple Databases - Hot deployment of *-ds.xml and *.pa
holgercasties Dec 2, 2005 7:13 AM (in response to holgercasties)Hi.
I think I found an acceptable solution to my problem.
Here is the running code:/** * This method enforces an immediate hot deployment of the submitted file. * At first, the file will be deployed by the MainDeployer through * MBeanServerConnection invocation. * The second step is to invoke the DeploymentScanner's scan() method to achieve * an immediate detection of the changes. * * @param deployFile * Name of the file to be deployed (fully-qualified path name) * * @throws IOException * @throws ReflectionException * @throws MBeanException * @throws InstanceNotFoundException * @throws NullPointerException * @throws MalformedObjectNameException */ private void hotDeploy(String deployFile) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException, MalformedObjectNameException, NullPointerException { // Initialize the necessary services once: if (mBeanServerConn == null) { // Get MBeanServerConnection mBeanServerConn = (MBeanServerConnection) sessionContext.lookup("jmx/invoker/RMIAdaptor"); // Get MainDeployer mainDeployer = MainDeployer.OBJECT_NAME; // Get DeploymentScanner deploymentScanner = new ObjectName("jboss.deployment:type=DeploymentScanner,flavor=URL"); } { // Deploy submitted file: // Set params for method invocation: Object[] params = { deployFile }; String[] signatures = { "java.lang.String" }; // Invoke the deploy() method of 'mainDeployer' mBeanServerConn.invoke(mainDeployer, "deploy", params, signatures); } { // Enforce immediate scanning of deployment: // Set params for method invocation: Object[] params = {}; String[] signatures = {}; // Invoke the scan() method of 'deploymentScanner' mBeanServerConn.invoke(deploymentScanner, "scan", params, signatures); } }
Holger