-
1. Re: Ordering of .ear subdeployments
starksm64 Mar 1, 2006 2:20 PM (in response to dimitris)Or more generally the Comparator to use. If the Comparator setting is null this could mean do not sort. If there is no Comparator setting, use the MainDeployer infoSorter.
-
2. Re: Ordering of .ear subdeployments
dimitris Mar 1, 2006 4:16 PM (in response to dimitris)To be backwards compatible, I think we'd need 2 new DeploymentInfo fields:
boolean sortedSubDeployments = false // default
Comparator comparator = null; // default
The MainDeployer would check sortedSubDeployments and if false, it would use either its own, or the DeploymentInfo provided comparator (if not null) to sort them.
(An optimization could be to store back the result and turn the flag to true, to avoid sorting them 5 times during the lifecycle of a deployment ???)
If the sortedSubDeployments is true, it would do nothing.
Interesed subdeployers (like the EARDeployer) would set the flag to true, or provide their custom comparator. -
3. Re: Ordering of .ear subdeployments
starksm64 Mar 1, 2006 4:28 PM (in response to dimitris)I was thinking of using the DeploymentInfo.context map with a "comparator" key. If you want these as explicit fields then your right that two fields are needed.
-
4. Re: Ordering of .ear subdeployments
vickyk Jun 30, 2006 7:11 AM (in response to dimitris)I was thinking of using the DeploymentInfo.context map with a "comparator" key. If you want these as explicit fields then your right that two fields are needed.
I don?t think providing the explicit information regarding the deployment sorter in the DeploymentInfo will be helpful , I can think of the use case doing this.
Anyway Can I make the changes in the following files?
1) DeploymentInfo .java , will add two fields as specified by the Dimitiris , yes we go for explicit information .
2) MainDeployer.java , here I will have to do the optimization for the 5 times sorting
3) EARDeployer.java , here I will have to set the flag indicating that the sorting has been done .
Regards
Vicky -
5. Re: Ordering of .ear subdeployments
starksm64 Jun 30, 2006 11:28 AM (in response to dimitris)Sounds ok, but we need testcases for both the suffix based odering and the application.xml based ordering that validate deployments are started in the expected order in both cases.
-
6. Re: Ordering of .ear subdeployments
vickyk Jul 17, 2006 7:00 AM (in response to dimitris)Ok I am planning to create the junit test case for this, do we need to discuss that here too ?
I am planning to have a separate unit test case , have a new folder in the testsuite/foedeployer .
I will have an sample EAR containing ejb, utility and war.
The test case should create the EAR from the source and verify if the deployment is done as per the ordering specified in the application.xml . We will have few more applicaiton.xml files with different ordering.
Regards
Vicky -
7. Re: Ordering of .ear subdeployments
vickyk Jul 20, 2006 8:30 AM (in response to dimitris)Any inputs here :)
Regards
Vicky -
8. Re: Ordering of .ear subdeployments
dimitris Jul 20, 2006 8:48 AM (in response to dimitris)Sounds ok.
-
9. Re: Ordering of .ear subdeployments
vickyk Jul 26, 2006 10:35 AM (in response to dimitris)The changes seems to be working fine, I have done it on the local system.
Can we put this in the head?
Also I am in process of investigating the deplorers folder of the test suite , it contains some of the sample ears which I feel could be used for preparing the junit test suite .
I may write a separate JUnit test cases class as JBAS2904EARDeploymentUnitTestCase.java.
Would this be ok?
Regards
Vicky -
10. Re: Ordering of .ear subdeployments
starksm64 Jul 26, 2006 11:51 AM (in response to dimitris)The deployers in head are going to be rewritten very soon, starting as soon as the svn migration is done. You can put it into head to have it under source control, but this needs to be migrated to a jboss-4.0.x release to be available.
The notion of deployment ordering needs to be revisted in the deployer rewrite. -
11. Re: Ordering of .ear subdeployments
vickyk Jul 27, 2006 6:12 AM (in response to dimitris)I have been in a process of writing a test case for the change but there seems to be some more changes to be made if we need the automated test case . Here are my analysis
1) The DeploymentInfo needs to have a field as
public ArrayList actualEarlierDeployements ;
which will be set during the initi of the MainDeployer
2) The init of the MainDeployer have
// Changes for the JBAB-2904
ArrayList actualEarlierSortedSubs = new ArrayList(deployment.subDeployments);
Collections.sort(actualEarlierSortedSubs, infoSorter);
deployment.actualEarlierDeployements = actualEarlierSortedSubs;
boolean isSorted = deployment.getSortedSubDeployments();
if(!isSorted){
Collections.sort(sortedSubs, infoSorter);
}
// Changes for the JBAB-2904
3) The additional actualEarlierDeployements from the DeploymentInfo can be used in the UnitTest to see the variation in the ordering .
If we dont keep the UnitTest then we dont need to make the changes in the DeploymentInfo object .
Here is the UnitTest Code I have been in process of writing/* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.deployers.ear.jbas2904; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.StringTokenizer; import java.net.JarURLConnection; import java.net.URL; import java.io.InputStream; import java.io.File; import java.io.FileInputStream; import junit.framework.Test; import junit.framework.TestSuite; import org.jboss.deployment.DeploymentInfo; import org.jboss.deployment.EARDeployer; import org.jboss.test.deployers.AbstractDeploymentTest; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.jboss.metadata.XmlFileLoader; /** * A test that tests the JBAB2904 * * build compile-classes-only * build -Dtest=org.jboss.test.deployers.ear.jbas2904.EARDeploymentUnitTestCase one-test * @author <a href="vicky.kak@jboss.com">Vicky Kak</a> * @version $Revision: 1.0 $ */ public class EARDeploymentUnitTestCase extends AbstractDeploymentTest { public EARDeploymentUnitTestCase(String test) { super(test); } public static Test suite() throws Exception { return getDeploySetup(EARDeploymentUnitTestCase.class, ear1Deployment); } public void testEARDeployment() throws Exception{ //Expected Deployment Ordering DeploymentInfo topInfo = assertDeployed(ear1Deployment); ArrayList expectedList = new ArrayList(); String urltoread = (topInfo.url).toString(); URL applicationUrl = new URL("jar:"+urltoread+"!/META-INF/application.xml"); JarURLConnection jarConnection = (JarURLConnection)applicationUrl.openConnection(); InputStream is = jarConnection.getInputStream(); System.out.println("Expected Ordering ------->"); expectedList = getExpectedDeployedModules(is,"application.xml"); is.close(); applicationUrl = new URL("jar:"+urltoread+"!/META-INF/jboss-app.xml"); jarConnection = (JarURLConnection)applicationUrl.openConnection(); is = jarConnection.getInputStream(); ArrayList expectedList1 = getExpectedDeployedModules(is,"jboss-app.xml"); expectedList.addAll(expectedList1); is.close(); Object expectedModules[] = expectedList.toArray(); //Actual Results //Set subDeployments = topInfo.subDeployments; ArrayList subDeployments = topInfo.actualEarlierDeployements; //System.out.println("subDeployments : "+subDeployments.size()); System.out.println("Actual Ordering -------->"); ArrayList deployedModuleNames = new ArrayList(subDeployments.size()); int index = 0; if (subDeployments != null ) { //for (Iterator i = subDeployments.iterator(); i.hasNext(); ) for(int count = 0;count<subDeployments.size();count++) { //DeploymentInfo child = (DeploymentInfo) i.next(); DeploymentInfo child = (DeploymentInfo)subDeployments.get(count); URL url = child.url; String moduleName = getModuleDeployed(url.toString()); deployedModuleNames.add(moduleName); System.out.println(getModuleDeployed(url.toString())); //assertEquals(((String)expectedModules[index]),moduleName); index++; } } } private String getModuleDeployed(String tempUrl){ StringTokenizer st = new StringTokenizer(tempUrl,"/"); String moduleName = ""; while (st.hasMoreTokens()) { moduleName = st.nextToken(); //System.out.println(moduleName); } return moduleName; } private ArrayList getExpectedDeployedModules(InputStream in,String xmlDDFileName) throws Exception{ XmlFileLoader xfl = new XmlFileLoader(false); Element application = xfl.getDocument(in, xmlDDFileName).getDocumentElement(); NodeList jeemoduleList = application.getElementsByTagName("module"); int jeemoduleListCount = jeemoduleList.getLength(); ArrayList list = new ArrayList(jeemoduleListCount); //System.out.println(" jeemoduleListCount :"+jeemoduleListCount); for(int count=0;count<jeemoduleListCount;count++) { Node node = jeemoduleList.item(count); if(node.getNodeType()== Node.ELEMENT_NODE) { String module = node.getNodeValue(); Element mod = (Element) node; NodeList jeeNodeList = mod.getElementsByTagName("java"); //System.out.println("Modules are >>>>-->"+jeeNodeList.getLength()); int nodescount = jeeNodeList.getLength(); if(nodescount==0) { jeeNodeList = mod.getElementsByTagName("ejb"); nodescount = jeeNodeList.getLength(); } if(nodescount==0) { jeeNodeList = mod.getElementsByTagName("web-uri"); nodescount = jeeNodeList.getLength(); } if(nodescount==0) { jeeNodeList = mod.getElementsByTagName("connector"); nodescount = jeeNodeList.getLength(); } if(nodescount==0) { jeeNodeList = mod.getElementsByTagName("service"); nodescount = jeeNodeList.getLength(); } Node checkNode = jeeNodeList.item(0); if(checkNode!=null){ String nodeName = checkNode.getFirstChild().getNodeValue(); System.out.println(nodeName); list.add(nodeName); } } } return list; } }
Any inputs here ?
Regards
Vicky -
12. Re: Ordering of .ear subdeployments
vickyk Jul 27, 2006 6:15 AM (in response to dimitris)If we still need the UnitTest then I will refractor the UnitTest code , the reading of the deployment descriptor using the JARConnector will go ....
Please let me know , I don?t personally find it better to bloat the DeploymentInfo Object with one of the fields which will only be used for testing .
Regards
Vicky -
13. Re: Ordering of .ear subdeployments
dimitris Jul 27, 2006 6:19 AM (in response to dimitris)Don't put extra fields in DeploymentInfo just for testing!
-
14. Re: Ordering of .ear subdeployments
vickyk Jul 27, 2006 6:30 AM (in response to dimitris)So can we then leave the UnitTest class .....
It seems to be working fine with the changes what have been discussed out here .