geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis AxisGbean.java AxisGeronimoUtils.java DependancyEJBManager.java WebServiceContainer.java WebServiceDeployer.java
Date Wed, 11 Aug 2004 13:27:18 GMT
dims        2004/08/11 06:27:18

  Modified:    modules/axis/src/test/org/apache/geronimo/axis
                        AbstractTestCase.java
                        AdminClientDeploymentTest.java AxisGBeanTest.java
                        DynamicEJBDeploymentTest.java EchoHeadersTest.java
                        EWSTest.java JettyServiceWrapper.java
                        TestServer.java WebServiceDeploymentTest.java
                        WebServiceTest.java
               modules/axis/src/java/org/apache/geronimo/axis
                        AxisGbean.java AxisGeronimoUtils.java
                        DependancyEJBManager.java WebServiceContainer.java
                        WebServiceDeployer.java
  Added:       modules/axis/src/test/org/apache/geronimo/axis
                        ClassLoadingTest.java
                        ComplexTypeWebServiceTest.java
  Log:
  Patch from Srinath:
  ===================================================
  with the new patch fix the class loading stuff. Now this complete geronimo
  supports for the Simple type web serivices. The WebServiceTest now has
  code to do the actual web service invocation tests.
  
  There is a class loading problem for the Complex type web services in the
  openejb service invocation. I add a test case to cover this but exclude
  it.
  
  I need to check it in the new openEJB cvs and get help from the open ejb
  ppl if there is a problem.
  Thanks
  --Srinath
  =======================================================
  
  Revision  Changes    Path
  1.2       +2 -2      incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/AbstractTestCase.java
  
  Index: AbstractTestCase.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/AbstractTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractTestCase.java	22 Jul 2004 14:57:49 -0000	1.1
  +++ AbstractTestCase.java	11 Aug 2004 13:27:14 -0000	1.2
  @@ -16,9 +16,9 @@
    
   package org.apache.geronimo.axis;
   
  -import junit.framework.TestCase;
  -
   import java.io.File;
  +
  +import junit.framework.TestCase;
   
   /**
    * Abstract base class for test cases.
  
  
  
  1.4       +48 -33    incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/AdminClientDeploymentTest.java
  
  Index: AdminClientDeploymentTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/AdminClientDeploymentTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AdminClientDeploymentTest.java	31 Jul 2004 15:48:54 -0000	1.3
  +++ AdminClientDeploymentTest.java	11 Aug 2004 13:27:14 -0000	1.4
  @@ -15,29 +15,23 @@
    */
   package org.apache.geronimo.axis;
   
  +import java.io.BufferedReader;
   import java.io.File;
   import java.io.InputStream;
  -import java.io.PrintWriter;
  +import java.io.InputStreamReader;
  +import java.net.HttpURLConnection;
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.net.URLClassLoader;
   
   import javax.management.ObjectName;
   
  -import org.apache.axis.AxisEngine;
  -import org.apache.axis.MessageContext;
   import org.apache.axis.client.AdminClient;
   import org.apache.axis.client.Call;
  -import org.apache.axis.deployment.wsdd.WSDDDeployment;
  -import org.apache.axis.deployment.wsdd.WSDDDocument;
  -//import org.apache.axis.encoding.SerializationContextImpl;
  -import org.apache.axis.server.AxisServer;
  -import org.apache.axis.utils.Admin;
  -import org.apache.axis.utils.XMLUtils;
  +import org.apache.axis.utils.ClassUtils;
   import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2ee;
   import org.apache.geronimo.gbean.jmx.GBeanMBean;
   import org.apache.geronimo.kernel.Kernel;
  -import org.w3c.dom.Document;
   /**
    * <p>This test case shows the possible two ways of add a entry to the Axis 
    * server-config.wsdd Deployment Discrypter.</p>
  @@ -55,42 +49,63 @@
       public AdminClientDeploymentTest(String testName) {
           super(testName);
       }
  -
  -	public void XtestDeployWithAdminClientStatically() throws Exception{
  -//		URLClassLoader cl = new  URLClassLoader(new URL[]{jarFile.toURL()});
  -//		InputStream deplydd = cl.getResourceAsStream("deploy.wsdd");
  -//		assertNotNull(deplydd);
  +//I leave it like this .. this feature is not used now. 
  +    public void XtestDeployWithAdminClientStatically() throws Exception{
  +//      URLClassLoader cl = new  URLClassLoader(new URL[]{jarFile.toURL()});
  +//      InputStream deplydd = cl.getResourceAsStream("deploy.wsdd");
  +//      assertNotNull(deplydd);
   //
  -//		Admin admin = new Admin();
  -//		InputStream wsddconf = getClass().getClassLoader().getResourceAsStream("org/apache/axis/server/server-config.wsdd");
  -//		assertNotNull(wsddconf);
  -//		WSDDDocument wsddDoc = new WSDDDocument(XMLUtils.newDocument(wsddconf));
  -//		WSDDDeployment deployment = wsddDoc.getDeployment();
  -//		AxisEngine engine = new AxisServer(deployment);
  -//		engine.setShouldSaveConfig(true);
  -//		engine.init();
  -//		MessageContext msgContext = new MessageContext(engine);
  +//      Admin admin = new Admin();
  +//      InputStream wsddconf = getClass().getClassLoader().getResourceAsStream("org/apache/axis/server/server-config.wsdd");
  +//      assertNotNull(wsddconf);
  +//      WSDDDocument wsddDoc = new WSDDDocument(XMLUtils.newDocument(wsddconf));
  +//      WSDDDeployment deployment = wsddDoc.getDeployment();
  +//      AxisEngine engine = new AxisServer(deployment);
  +//      engine.setShouldSaveConfig(true);
  +//      engine.init();
  +//      MessageContext msgContext = new MessageContext(engine);
   //
  -//		Document doc = XMLUtils.newDocument(deplydd);
  -//		Document result = admin.process(msgContext, doc.getDocumentElement());
  -//		System.out.println(XMLUtils.DocumentToString(result));
  -//		PrintWriter w = new PrintWriter(System.out);
  -//		deployment.writeToContext(new SerializationContextImpl(w));
  -//		w.close();
  -   	}
  +//      Document doc = XMLUtils.newDocument(deplydd);
  +//      Document result = admin.process(msgContext, doc.getDocumentElement());
  +//      System.out.println(XMLUtils.DocumentToString(result));
  +//      PrintWriter w = new PrintWriter(System.out);
  +//      deployment.writeToContext(new SerializationContextImpl(w));
  +//      w.close();
  +    }
  +
       public void testDeployWithAdminClientDinamically() throws Exception{
           URLClassLoader cl = new  URLClassLoader(new URL[]{jarFile.toURL()});
           InputStream deplydd = cl.getResourceAsStream("deploy.wsdd");
           assertNotNull(deplydd);  
   
  +        ClassLoader parentClassLoder = ClassUtils.getDefaultClassLoader();
  +        ClassUtils.setDefaultClassLoader(cl);
           AdminClient adminClient = new AdminClient();
  +        
           URL requestUrl = new URL("http://localhost:"
  -             +AxisGeronimoConstants.AXIS_SERVICE_PORT
  -             +"/axis/services/AdminService");
  +             + AxisGeronimoConstants.AXIS_SERVICE_PORT
  +             + "/axis/services/AdminService");
           Call call = adminClient.getCall();
           call.setTargetEndpointAddress(requestUrl);
           String result = adminClient.process(null,deplydd);
           System.out.println(result);
  +        
  +        URL wsdlrequestUrl = new URL("http://localhost:"
  +                     +AxisGeronimoConstants.AXIS_SERVICE_PORT
  +                    
  +                     +"/axis/services/echoPort?wsdl");
  +                    //+"/axis/services/AdminService?wsdl");
  +        
  +        HttpURLConnection connection = (HttpURLConnection)wsdlrequestUrl.openConnection();
  +        BufferedReader reader = new BufferedReader(
  +                new InputStreamReader(connection.getInputStream()));
  +        connection.getResponseCode();
  +        String line = reader.readLine();
  +        while (line != null) {
  +            System.out.println(line);
  +            line = reader.readLine();
  +        }
  +
       }
   
   
  
  
  
  1.4       +5 -4      incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/AxisGBeanTest.java
  
  Index: AxisGBeanTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/AxisGBeanTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AxisGBeanTest.java	28 Jul 2004 14:24:50 -0000	1.3
  +++ AxisGBeanTest.java	11 Aug 2004 13:27:14 -0000	1.4
  @@ -15,15 +15,16 @@
    */
   package org.apache.geronimo.axis;
   
  -import org.apache.geronimo.gbean.jmx.GBeanMBean;
  -import org.apache.geronimo.kernel.Kernel;
  -
  -import javax.management.ObjectName;
   import java.io.BufferedReader;
   import java.io.InputStreamReader;
   import java.net.HttpURLConnection;
   import java.net.URL;
   import java.net.URLClassLoader;
  +
  +import javax.management.ObjectName;
  +
  +import org.apache.geronimo.gbean.jmx.GBeanMBean;
  +import org.apache.geronimo.kernel.Kernel;
   /**
    * <p> This test case start the AxisGbean and test retiving the index.html of the 
    * Axis Service</p>   
  
  
  
  1.4       +12 -11    incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/DynamicEJBDeploymentTest.java
  
  Index: DynamicEJBDeploymentTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/DynamicEJBDeploymentTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DynamicEJBDeploymentTest.java	6 Aug 2004 22:44:36 -0000	1.3
  +++ DynamicEJBDeploymentTest.java	11 Aug 2004 13:27:14 -0000	1.4
  @@ -16,11 +16,20 @@
   
   package org.apache.geronimo.axis;
   
  +import java.io.File;
  +import java.io.FileInputStream;
  +import java.net.URL;
  +import java.net.URLClassLoader;
  +import java.util.Collections;
  +import java.util.HashSet;
  +import java.util.Set;
  +
  +import javax.management.ObjectName;
  +
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
   import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2ee;
   import org.apache.geronimo.gbean.jmx.GBeanMBean;
   import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
  -import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
   import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl;
   import org.apache.geronimo.kernel.Kernel;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
  @@ -31,15 +40,6 @@
   import org.apache.xmlbeans.XmlObject;
   import org.openejb.deployment.OpenEJBModuleBuilder;
   
  -import javax.management.ObjectName;
  -import java.io.File;
  -import java.io.FileInputStream;
  -import java.net.URL;
  -import java.net.URLClassLoader;
  -import java.util.Collections;
  -import java.util.HashSet;
  -import java.util.Set;
  -
   /**
    * <p>This test case show the infomation about openEJB that we assumed. And the
    * simmlier code code is used in the real code. As the OpenEJB is developing and 
  @@ -105,7 +105,7 @@
   
   	}
   	public void testEJBJarDeploy() throws Exception {
  -		OpenEJBModuleBuilder moduleBuilder = new OpenEJBModuleBuilder(kernel);
  +        OpenEJBModuleBuilder moduleBuilder = new OpenEJBModuleBuilder(kernel);
   	
   		File earFile =  new File(outDir + "/echo-ewsimpl.jar");
   		if(!earFile.exists()){
  @@ -169,3 +169,4 @@
   
   
   }
  +
  
  
  
  1.3       +9 -8      incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/EchoHeadersTest.java
  
  Index: EchoHeadersTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/EchoHeadersTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EchoHeadersTest.java	22 Jul 2004 14:57:49 -0000	1.2
  +++ EchoHeadersTest.java	11 Aug 2004 13:27:14 -0000	1.3
  @@ -15,11 +15,8 @@
    */
   package org.apache.geronimo.axis;
   
  -import org.apache.axis.AxisEngine;
  -import org.apache.axis.client.Call;
  -import org.apache.axis.client.Service;
  -import org.apache.geronimo.gbean.jmx.GBeanMBean;
  -import org.apache.geronimo.kernel.Kernel;
  +import java.net.URL;
  +import java.net.URLClassLoader;
   
   import javax.management.ObjectName;
   import javax.xml.messaging.URLEndpoint;
  @@ -32,8 +29,12 @@
   import javax.xml.soap.SOAPElement;
   import javax.xml.soap.SOAPEnvelope;
   import javax.xml.soap.SOAPMessage;
  -import java.net.URL;
  -import java.net.URLClassLoader;
  +
  +import org.apache.axis.AxisEngine;
  +import org.apache.axis.client.Call;
  +import org.apache.axis.client.Service;
  +import org.apache.geronimo.gbean.jmx.GBeanMBean;
  +import org.apache.geronimo.kernel.Kernel;
   
   
   public class EchoHeadersTest extends AbstractTestCase {
  @@ -108,7 +109,7 @@
       }
   
       public void testFrenchAccents2() throws Exception {
  -        runtest("Une chaîne avec des caractères accentués");
  +        runtest("Une cha?ne avec des caract?res accentu?s");
       }
   
       public void testGermanUmlauts() throws Exception {
  
  
  
  1.3       +2 -2      incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/EWSTest.java
  
  Index: EWSTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/EWSTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EWSTest.java	28 Jul 2004 14:24:50 -0000	1.2
  +++ EWSTest.java	11 Aug 2004 13:27:14 -0000	1.3
  @@ -15,9 +15,9 @@
    */
   package org.apache.geronimo.axis;
   
  -import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2ee;
  -
   import java.io.File;
  +
  +import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2ee;
   /**
    * <p>This test case represents the code generation with the EWS module. 
    * This test case needed the $JAVA_HOME/lib.tools.jar at the classapth.</p>
  
  
  
  1.3       +8 -7      incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/JettyServiceWrapper.java
  
  Index: JettyServiceWrapper.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/JettyServiceWrapper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JettyServiceWrapper.java	28 Jul 2004 14:24:50 -0000	1.2
  +++ JettyServiceWrapper.java	11 Aug 2004 13:27:14 -0000	1.3
  @@ -16,6 +16,14 @@
   
   package org.apache.geronimo.axis;
   
  +import java.util.Collections;
  +import java.util.HashSet;
  +import java.util.Set;
  +
  +import javax.management.MBeanServer;
  +import javax.management.MalformedObjectNameException;
  +import javax.management.ObjectName;
  +
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
   import org.apache.geronimo.gbean.jmx.GBeanMBean;
   import org.apache.geronimo.jetty.JettyContainerImpl;
  @@ -23,13 +31,6 @@
   import org.apache.geronimo.kernel.Kernel;
   import org.apache.geronimo.transaction.GeronimoTransactionManager;
   import org.apache.geronimo.transaction.context.TransactionContextManager;
  -
  -import javax.management.MBeanServer;
  -import javax.management.MalformedObjectNameException;
  -import javax.management.ObjectName;
  -import java.util.Collections;
  -import java.util.HashSet;
  -import java.util.Set;
   
   /**
    * <p>This class wrap the Jetty service, This is a test utility only</p>
  
  
  
  1.4       +22 -9     incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/TestServer.java
  
  Index: TestServer.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/TestServer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestServer.java	28 Jul 2004 14:24:50 -0000	1.3
  +++ TestServer.java	11 Aug 2004 13:27:14 -0000	1.4
  @@ -17,12 +17,13 @@
   
   package org.apache.geronimo.axis;
   
  -import org.apache.geronimo.gbean.jmx.GBeanMBean;
  -import org.apache.geronimo.kernel.Kernel;
  -
  -import javax.management.ObjectName;
   import java.net.URL;
   import java.net.URLClassLoader;
  +
  +import javax.management.ObjectName;
  +
  +import org.apache.geronimo.gbean.jmx.GBeanMBean;
  +import org.apache.geronimo.kernel.Kernel;
   /**
    * <p>Simple stanalone Axis Service started via a GBean. This is a test utility only</p>  
    * @author hemapani@opensource.lk
  @@ -37,23 +38,35 @@
           name = new ObjectName("test:name=AxisGBean");
           kernel = new Kernel("test.kernel", "test");
           kernel.boot();
  -
  -		jettyService = new JettyServiceWrapper(kernel);
  -		jettyService.doStart();
  +    }
  +    
  +    public void start()throws Exception{
  +        jettyService = new JettyServiceWrapper(kernel);
  +        jettyService.doStart();
   
           ClassLoader cl = getClass().getClassLoader();
           ClassLoader myCl = new URLClassLoader(new URL[0], cl);
           GBeanMBean gbean = new GBeanMBean(AxisGbean.getGBeanInfo(), myCl);
           gbean.setAttribute("Name", "Test");
  +
           kernel.loadGBean(name, gbean);
           kernel.startGBean(name);
  -        System.in.read();
  +    }
  +    
  +    public void stop()throws Exception{
           System.out.println("Shutting down the kernel");
           kernel.stopGBean(name);
           kernel.unloadGBean(name);
           
  -		jettyService.doStop();
  +        jettyService.doStop();
           kernel.shutdown();
  +    }
  +    
  +    public static void main(String[] args)throws Exception{
  +        TestServer test = new TestServer();
  +        test.start();
  +        System.in.read();
  +        test.stop();
       }
   
   }
  
  
  
  1.3       +53 -15    incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/WebServiceDeploymentTest.java
  
  Index: WebServiceDeploymentTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/WebServiceDeploymentTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebServiceDeploymentTest.java	28 Jul 2004 14:24:50 -0000	1.2
  +++ WebServiceDeploymentTest.java	11 Aug 2004 13:27:14 -0000	1.3
  @@ -16,30 +16,27 @@
   
   package org.apache.geronimo.axis;
   
  -import org.apache.geronimo.kernel.Kernel;
  -
   import java.io.File;
  +import java.net.URL;
  +import java.net.URLClassLoader;
  +
  +import javax.management.ObjectName;
  +
  +import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2ee;
  +import org.apache.geronimo.gbean.jmx.GBeanMBean;
  +import org.apache.geronimo.kernel.Kernel;
   
   public class WebServiceDeploymentTest extends AbstractTestCase{
   	private Kernel kernel;
  +    private ObjectName name;
  +    private JettyServiceWrapper jettyService;
  +    private File jarFile;
  +
   	public WebServiceDeploymentTest(String name){
   		super(name);
   	}
   
  -	protected void setUp() throws Exception {
  -		kernel = new Kernel("test.kernel", "test");
  -		kernel.boot();
  -		File file = new File(tempDir);
  -		file.getParentFile().mkdirs();
  -	}
   
  -	protected void tearDown() throws Exception {
  -		kernel.shutdown();
  -		File file = new File(tempDir);
  -        AxisGeronimoUtils.delete(file);
  -        file = new File(AxisGeronimoConstants.AXIS_CONFIG_STORE);
  -		AxisGeronimoUtils.delete(file);
  -	}
       
       public void testDeployEJB() throws Exception{
   		WebServiceDeployer deployer 
  @@ -48,4 +45,45 @@
   				null,
   				"ws/apache/axis/test2");
       }
  +    
  +    protected void setUp() throws Exception {
  +        new File(outDir).mkdirs();
  +        name = new ObjectName("test:name=AxisGBean");
  +        kernel = new Kernel("test.kernel", "test");
  +        kernel.boot();
  +        jettyService = new JettyServiceWrapper(kernel);
  +        jettyService.doStart();
  +        ClassLoader cl = getClass().getClassLoader();
  +        ClassLoader myCl = new URLClassLoader(new URL[0], cl);
  +        GBeanMBean gbean = new GBeanMBean(AxisGbean.getGBeanInfo(), myCl);
  +        gbean.setAttribute("Name", "Test");
  +        kernel.loadGBean(name, gbean);
  +        kernel.startGBean(name);
  +        
  +        jarFile =  new File(outDir + "/echo-ewsimpl.jar");
  +        if(!jarFile.exists()){
  +            GeronimoWsDeployContext deployContext =
  +                 new GeronimoWsDeployContext(
  +                     getTestFile("target/samples/echo.jar"),
  +                     outDir);
  +            Ws4J2ee ws4j2ee = new Ws4J2ee(deployContext, null);
  +                    ws4j2ee.generate();
  +        }
  +        File file = new File(tempDir);
  +        file.getParentFile().mkdirs();
  +
  +    }
  +
  +    protected void tearDown() throws Exception {
  +        kernel.stopGBean(name);
  +        kernel.unloadGBean(name);
  +        jettyService.doStop();
  +        kernel.shutdown();
  +        File file = new File(tempDir);
  +        AxisGeronimoUtils.delete(file);
  +        file = new File(AxisGeronimoConstants.AXIS_CONFIG_STORE);
  +        AxisGeronimoUtils.delete(file);
  +
  +    }
  +
   }
  
  
  
  1.3       +91 -10    incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/WebServiceTest.java
  
  Index: WebServiceTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/WebServiceTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebServiceTest.java	28 Jul 2004 14:24:50 -0000	1.2
  +++ WebServiceTest.java	11 Aug 2004 13:27:14 -0000	1.3
  @@ -16,15 +16,20 @@
   package org.apache.geronimo.axis;
   
   
  -import org.apache.geronimo.gbean.jmx.GBeanMBean;
  -import org.apache.geronimo.kernel.Kernel;
  -
  -import javax.management.ObjectName;
  +import java.io.BufferedReader;
   import java.io.File;
  +import java.io.InputStreamReader;
  +import java.lang.reflect.Method;
  +import java.net.HttpURLConnection;
   import java.net.URL;
   import java.net.URLClassLoader;
   import java.util.Arrays;
   
  +import javax.management.ObjectName;
  +
  +import org.apache.geronimo.gbean.jmx.GBeanMBean;
  +import org.apache.geronimo.kernel.Kernel;
  +
   public class WebServiceTest extends AbstractTestCase {
       private ObjectName axisname;
       private ObjectName deployGbeanName;
  @@ -59,17 +64,23 @@
   //        GBeanMBean deploygbean =
   //            new GBeanMBean(WebServiceDeployerGbean.getGBeanInfo(), myCl);
     
  -      GBeanMBean deploygbean =
  +        //axis gbean        
  +        GBeanMBean axisgbean = new GBeanMBean(AxisGbean.getGBeanInfo(), myCl);
  +        kernel.loadGBean(axisname, axisgbean);
  +        kernel.startGBean(axisname);
  +
  +        GBeanMBean deploygbean =
             new GBeanMBean(WebServiceDeployerGbean.getGBeanInfo(), cl);
           kernel.loadGBean(deployGbeanName, deploygbean);
           kernel.startGBean(deployGbeanName);
           System.out.println(
               kernel.getMBeanServer().getAttribute(deployGbeanName, "state"));
  +        File jarfile = new File(getTestFile("target/generated/samples/echo-ewsimpl.jar"));    
           kernel.getMBeanServer().invoke(
               deployGbeanName,
               "deployEWSModule",
               new Object[] {
  -                getTestFile("target/generated/samples/echo-ewsimpl.jar"),
  +                jarfile.getAbsolutePath(),
                   null,
                   "ws/apache/axis/echo" },
               new String[] {
  @@ -79,10 +90,22 @@
           kernel.stopGBean(deployGbeanName);
           kernel.unloadGBean(deployGbeanName);
   
  -        //axis gbean        
  -        GBeanMBean axisgbean = new GBeanMBean(AxisGbean.getGBeanInfo(), myCl);
  -        kernel.loadGBean(axisname, axisgbean);
  -        kernel.startGBean(axisname);
  +        //let us try to brows the WSDL of the service
  +        URL wsdlrequestUrl = new URL("http://localhost:"
  +                     +AxisGeronimoConstants.AXIS_SERVICE_PORT
  +                     +"/axis/services/echoPort?wsdl");
  +                    //+"/axis/services/AdminService?wsdl");
  +        
  +        HttpURLConnection connection = (HttpURLConnection)wsdlrequestUrl.openConnection();
  +        BufferedReader reader = new BufferedReader(
  +                new InputStreamReader(connection.getInputStream()));
  +        connection.getResponseCode();
  +        String line = reader.readLine();
  +        while (line != null) {
  +            System.out.println(line);
  +            line = reader.readLine();
  +        }
  +
   
           //invoke the ejb just in the same way it is invoked by the webservice 
           String msg = "Hi Hello";
  @@ -161,6 +184,64 @@
                   new Class[] { byte[].class },
                   new Object[] { byteVal });
           assertTrue(Arrays.equals(byteVal,byteValreturn));
  +
  +
  +
  +
  +//        
  +//        //check the real web service invocations 
  +        ClassLoader ocl = Thread.currentThread().getContextClassLoader();
  +        URLClassLoader jarclassloder = new URLClassLoader(new URL[]{jarfile.toURL()});
  +        Thread.currentThread().setContextClassLoader(jarclassloder);
  +        
  +        
  +        
  +        Class echoLoacaterClass =  Class.forName("org.apache.ws.echosample.EchoServiceLocator",true,jarclassloder);
  +        Object echoLoacater = echoLoacaterClass.newInstance();
  +        Method getportMethod = echoLoacaterClass.getMethod("getechoPort",new Class[]{URL.class});
  +        
  +        URL serviceURL = new URL("http://localhost:"
  +                +AxisGeronimoConstants.AXIS_SERVICE_PORT
  +               // + 5679
  +                +"/axis/services/echoPort");
  +        Object echoPort = getportMethod.invoke(echoLoacater,new Object[]{serviceURL});        
  +        Class echoClass = echoPort.getClass();
  +        
  +        Method echoStringMethod = echoClass.getMethod("echoString",new Class[]{String.class});
  +        String val = "Hi";
  +        assertEquals(val,echoStringMethod.invoke(echoPort,new Object[]{val}));
  +        
  +        Class structClass = Class.forName("org.apache.ws.echosample.EchoStruct",true,jarclassloder);
  +        Method echostuctMethod = echoClass.getMethod("echoStruct",new Class[]{structClass});
  +        Object structval = structClass.newInstance();
  +        
  +//        //try invoke from this class
  +//        ContainerIndex index = ContainerIndex.getInstance();
  +//        int length = index.length();
  +//        System.out.println("number of continers "+length);
  +//        for(int i = 0;i<length;i++){
  +//            EJBContainer contianer = index.getContainer(i);
  +//            if(contianer!= null){
  +//                String name = contianer.getEJBName();
  +//                System.out.println("found the ejb "+name);
  +//                if("echo".equals(name)){
  +//                    EJBHome statelessHome = contianer.getEJBHome();
  +//                    Object stateless = statelessHome.getClass().getMethod("create", null).invoke(statelessHome, null);
  +//                    Method[] methods = stateless.getClass().getMethods();
  +//                    
  +//                    for(int j = 0;j< methods.length;j++){
  +//                        if(methods[j].getName().equals("echoStruct")){
  +//                                Class[] classes = methods[j].getParameterTypes();
  +//                                System.out.println(classes[0]);
  +//                                methods[j].invoke(stateless, new Object[]{null});
  +//                                methods[j].invoke(stateless, new Object[]{classes[0].newInstance()});
  +//                        }
  +//                    }
  +//                }
  +//            }
  +//        }                                                    
  +        Thread.currentThread().setContextClassLoader(ocl); 
  +         
           kernel.stopGBean(axisname);
           kernel.unloadGBean(axisname);
   
  
  
  
  1.1                  incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/ClassLoadingTest.java
  
  Index: ClassLoadingTest.java
  ===================================================================
  /*
   * Copyright 2001-2004 The Apache Software Foundation.
   * 
   * Licensed 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.geronimo.axis;
  
  import java.io.File;
  import java.net.URL;
  import java.net.URLClassLoader;
  
  import org.apache.axis.utils.ClassUtils;
  
  /**
   * @author hemapani@opensource.lk
   */
  public class ClassLoadingTest extends AbstractTestCase{
      /**
       * @param testName
       */
      public ClassLoadingTest(String testName) {
          super(testName);
      }
  
      public void testClassLoading() throws Exception{
          ClassLoader cl = Thread.currentThread().getContextClassLoader();
          Class class0 = Class.forName("org.apache.axis.utils.tcpmon",true,cl);
  
          File jarfile = new File(getTestFile("target/generated/samples/echo-ewsimpl.jar"));
          
          ClassLoader cl1 = new URLClassLoader(new URL[]{jarfile.toURL()},cl);
          ClassLoader cl2 = new URLClassLoader(new URL[]{jarfile.toURL()},cl);
          
          Class class1 = Class.forName("org.apache.ws.echosample.EchoStruct",true,cl1);
          Class class2 = Class.forName("org.apache.ws.echosample.EchoStruct",true,cl2);
          Class class3 = Class.forName("org.apache.ws.echosample.EchoStruct",true,cl1);
          Class class4 = Class.forName("org.apache.axis.utils.tcpmon",true,cl1);
          
          assertNotSame(class1,class2);
          assertSame(class1,class3);
          assertSame(class0,class4);
          
          String className = "org.apache.ws.echosample.EchoPortSoapBindingImpl"; 
          ClassUtils.setClassLoader(className,cl1);
          ClassUtils.forName(className);
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/axis/src/test/org/apache/geronimo/axis/ComplexTypeWebServiceTest.java
  
  Index: ComplexTypeWebServiceTest.java
  ===================================================================
  /*
   * Copyright 2001-2004 The Apache Software Foundation.
   * 
   * Licensed 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.geronimo.axis;
  
  
  import java.io.File;
  import java.lang.reflect.Method;
  import java.net.URL;
  import java.net.URLClassLoader;
  
  import javax.management.ObjectName;
  
  import org.apache.axis.utils.ClassUtils;
  import org.apache.geronimo.gbean.jmx.GBeanMBean;
  import org.apache.geronimo.kernel.Kernel;
  
  public class ComplexTypeWebServiceTest extends AbstractTestCase {
      private ObjectName axisname;
      private ObjectName deployGbeanName;
      private Kernel kernel;
      private JettyServiceWrapper jettyService;
  
      /**
       * @param testName
       */
      public ComplexTypeWebServiceTest(String testName) {
          super(testName);
      }
  
      public void testLoad() throws Exception {
          ClassLoader cl = Thread.currentThread().getContextClassLoader();
  		ClassLoader myCl =   new URLClassLoader(new URL[]{}, cl);
    
          //axis gbean        
          GBeanMBean axisgbean = new GBeanMBean(AxisGbean.getGBeanInfo(), myCl);
          kernel.loadGBean(axisname, axisgbean);
          kernel.startGBean(axisname);
  
          GBeanMBean deploygbean =
            new GBeanMBean(WebServiceDeployerGbean.getGBeanInfo(), cl);
          kernel.loadGBean(deployGbeanName, deploygbean);
          kernel.startGBean(deployGbeanName);
          System.out.println(
              kernel.getMBeanServer().getAttribute(deployGbeanName, "state"));
          File jarfile = new File(getTestFile("target/generated/samples/echo-ewsimpl.jar"));    
          kernel.getMBeanServer().invoke(
              deployGbeanName,
              "deployEWSModule",
              new Object[] {
                  jarfile.getAbsolutePath(),
                  null,
                  "ws/apache/axis/echo" },
              new String[] {
                  String.class.getName(),
                  String.class.getName(),
                  String.class.getName()});
          kernel.stopGBean(deployGbeanName);
          kernel.unloadGBean(deployGbeanName);
  
  //      //try invoke from this java
  //          ContainerIndex index = ContainerIndex.getInstance();
  //          int length = index.length();
  //          System.out.println("number of continers "+length);
  //          for(int i = 0;i<length;i++){
  //              EJBContainer contianer = index.getContainer(i);
  //              if(contianer!= null){
  //                  String name = contianer.getEJBName();
  //                  System.out.println("found the ejb "+name);
  //                  if("echo".equals(name)){
  //                      EJBHome statelessHome = contianer.getEJBHome();
  //                      Object stateless = statelessHome.getClass().getMethod("create", null).invoke(statelessHome, null);
  //                      Method[] methods = stateless.getClass().getMethods();
  //                        
  //                      for(int j = 0;j< methods.length;j++){
  //                          if(methods[j].getName().equals("echoStruct")){
  //                                  Class[] classes = methods[j].getParameterTypes();
  //                                  System.out.println(classes[0]);
  //                                  methods[j].invoke(stateless, new Object[]{null});
  //                                  methods[j].invoke(stateless, new Object[]{classes[0].newInstance()});
  //                          }
  //                      }
  //                  }
  //              }
  //          }                                                    
  
          //check the real web service invocations 
  //        ClassLoader ocl = Thread.currentThread().getContextClassLoader();
  //        URLClassLoader jarclassloder = new URLClassLoader(new URL[]{jarfile.toURL()});
  //        Thread.currentThread().setContextClassLoader(jarclassloder);
          
  //        Class echoLoacaterClass =  Class.forName("org.apache.ws.echosample.EchoServiceLocator",true,jarclassloder);
  //        Class structClass = Class.forName("org.apache.ws.echosample.EchoStruct",true,jarclassloder);
            Class echoLoacaterClass =  ClassUtils.forName("org.apache.ws.echosample.EchoServiceLocator");
            Class structClass = ClassUtils.forName("org.apache.ws.echosample.EchoStruct");
  
  
          Object echoLoacater = echoLoacaterClass.newInstance();
          Method getportMethod = echoLoacaterClass.getMethod("getechoPort",new Class[]{URL.class});
          
          URL serviceURL = new URL("http://localhost:"
                  +AxisGeronimoConstants.AXIS_SERVICE_PORT
                 // + 5679
                  +"/axis/services/echoPort");
          Object echoPort = getportMethod.invoke(echoLoacater,new Object[]{serviceURL});        
          Class echoClass = echoPort.getClass();
          
          Method echostuctMethod = echoClass.getMethod("echoStruct",new Class[]{structClass});
          Object structval = structClass.newInstance();
          
          Object structret = echostuctMethod.invoke(echoPort,new Object[]{null});
          structret = echostuctMethod.invoke(echoPort,new Object[]{structval});
          assertEquals(structval,structret);
          //Thread.currentThread().setContextClassLoader(ocl); 
           
          kernel.stopGBean(axisname);
          kernel.unloadGBean(axisname);
      }
  
      protected void setUp() throws Exception {
  		File file = new File(AxisGeronimoConstants.AXIS_CONFIG_STORE);
          axisname = new ObjectName("test:name=AxisGBean");
          deployGbeanName = new ObjectName("test:name=WebServiceDeployerGbean");
          kernel = new Kernel("test.kernel", "test");
          kernel.boot();
          jettyService = new JettyServiceWrapper(kernel);
          jettyService.doStart();
          AxisGeronimoUtils.delete(file);
          file.getParentFile().mkdirs();
      }
  
      protected void tearDown() throws Exception {
          jettyService.doStop();
          kernel.shutdown();
          File file = new File(AxisGeronimoConstants.AXIS_CONFIG_STORE);
          AxisGeronimoUtils.delete(file);
      }
  
  }
  
  
  
  1.4       +2 -2      incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis/AxisGbean.java
  
  Index: AxisGbean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis/AxisGbean.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AxisGbean.java	28 Jul 2004 14:24:48 -0000	1.3
  +++ AxisGbean.java	11 Aug 2004 13:27:15 -0000	1.4
  @@ -16,14 +16,14 @@
   
   package org.apache.geronimo.axis;
   
  +import javax.management.ObjectName;
  +
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoFactory;
   import org.apache.geronimo.gbean.GBeanLifecycle;
   import org.apache.geronimo.gbean.WaitingException;
   import org.apache.geronimo.kernel.Kernel;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
  -
  -import javax.management.ObjectName;
   
   /**
    * Class AxisGbean
  
  
  
  1.3       +53 -13    incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis/AxisGeronimoUtils.java
  
  Index: AxisGeronimoUtils.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis/AxisGeronimoUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AxisGeronimoUtils.java	28 Jul 2004 14:24:48 -0000	1.2
  +++ AxisGeronimoUtils.java	11 Aug 2004 13:27:15 -0000	1.3
  @@ -17,6 +17,10 @@
   
   import java.io.File;
   import java.lang.reflect.Method;
  +import java.util.ArrayList;
  +import java.util.Enumeration;
  +import java.util.zip.ZipEntry;
  +import java.util.zip.ZipFile;
   
   import javax.ejb.EJBHome;
   import javax.management.ObjectName;
  @@ -25,7 +29,6 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.geronimo.deployment.DeploymentException;
  -import org.apache.geronimo.ews.ws4j2ee.wsutils.GeronimoUtils;
   import org.apache.geronimo.gbean.jmx.GBeanMBean;
   import org.apache.geronimo.kernel.Kernel;
   import org.openejb.ContainerIndex;
  @@ -36,7 +39,7 @@
    */
   public class AxisGeronimoUtils {
       
  -    public static final Log log = LogFactory.getLog(GeronimoUtils.class);
  +    public static final Log log = LogFactory.getLog(AxisGeronimoUtils.class);
       public static Object invokeEJB(
           String ejbName,
           String methodName,
  @@ -55,27 +58,48 @@
                           if(ejbName.equals(name)){
                               EJBHome statelessHome = contianer.getEJBHome();
                               Object stateless = statelessHome.getClass().getMethod("create", null).invoke(statelessHome, null);
  -                            if(parmClasses!= null){
  -                                Object obj = stateless.getClass().getMethod(methodName,parmClasses).invoke(stateless, parameters);
  -                                return obj; 
  -                            }else{
  -                                Method[] methods = stateless.getClass().getMethods();
  -                                for(int j = 0;i< methods.length;j++){
  -                                    if(methods[j].getName().equals(methodName)){
  +                            Method[] methods = stateless.getClass().getMethods();
  +                            for(int j = 0;j< methods.length;j++){
  +                                if(methods[j].getName().equals(methodName)){
  +                                    try{
                                           return methods[j].invoke(stateless, parameters);
  +                                    }catch(Exception e){
  +                                        Class[] classes = methods[j].getParameterTypes();
  +                                        System.out.print(methodName+"("); 
  +                                        if(parameters == null || classes== null){
  +                                            System.out.println("both or one is null");
  +                                        }else{
  +                                            if(parameters.length != classes.length)
  +                                                System.out.println("parameter length do not match expected parametes");
  +                                            for(int k = 0;k<classes.length;k++){
  +                                                Object obj = parameters[k];
  +                                                Class theClass = classes[k];
  +                                                if(theClass != obj.getClass()){
  +                                                    System.out.println("calsses are differant");
  +                                                }
  +                                                System.out.println("ejb class loader "+theClass.getClassLoader());                                                        
  +                                                System.out.println("parameter class loader = "+obj.getClass().getClassLoader());
  +                                            }
  +                                        }
  +                                        throw e;                         
                                       }
  +
                                   }
  -                                throw new NoSuchMethodException(methodName+" not found");
                               }
  -                        }                   
  +                            throw new NoSuchMethodException(methodName+" not found");
  +                        }           
                       }else{
                           System.out.println("Continer is null");
                           log.debug("Continer is null");
                       }
                   }
                   throw new AxisFault("Dependancy ejb "+ejbName+" not found ");
  -            } catch (Exception e) {
  -                throw AxisFault.makeFault(e);
  +            } catch (Throwable e) {
  +                e.printStackTrace();
  +                if(e instanceof Exception)
  +                    throw AxisFault.makeFault((Exception)e);
  +                else
  +                    throw AxisFault.makeFault(new Exception(e));    
               } 
       
       }
  @@ -133,5 +157,21 @@
               }
               file.delete();
           }
  +    }
  +    
  +    public static ArrayList getClassFileList(ZipFile file){
  +        ArrayList list = new ArrayList();
  +        if(file != null){
  +            Enumeration entires = file.entries();
  +            while(entires.hasMoreElements()){
  +                ZipEntry zipe = (ZipEntry)entires.nextElement();
  +                String name = zipe.getName();
  +                if(name.endsWith(".class")){
  +                    int index = name.lastIndexOf('.');
  +                    list.add(name.substring(0,index).replace('/','.'));
  +               } 
  +           }
  +        }
  +        return list;    
       }
   }
  
  
  
  1.3       +42 -32    incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis/DependancyEJBManager.java
  
  Index: DependancyEJBManager.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis/DependancyEJBManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DependancyEJBManager.java	28 Jul 2004 14:24:48 -0000	1.2
  +++ DependancyEJBManager.java	11 Aug 2004 13:27:16 -0000	1.3
  @@ -20,10 +20,8 @@
   import java.io.InputStream;
   import java.io.ObjectInputStream;
   import java.util.Collections;
  -import java.util.Enumeration;
   import java.util.HashMap;
   import java.util.HashSet;
  -import java.util.Hashtable;
   import java.util.Map;
   import java.util.Set;
   import java.util.Vector;
  @@ -31,6 +29,7 @@
   import javax.management.MalformedObjectNameException;
   import javax.management.ObjectName;
   
  +import org.apache.axis.utils.ClassUtils;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.geronimo.connector.ActivationSpecWrapper;
  @@ -105,7 +104,7 @@
       /**
        * Field dependedEJBs
        */
  -    private Vector dependedEJBs;
  +    private static Vector dependedEJBs;
   
       /**
        * Field kernel
  @@ -117,11 +116,17 @@
        *
        * @param kernel
        */
  -    public DependancyEJBManager(Kernel kernel) {
  +    public DependancyEJBManager(Kernel kernel) throws MalformedObjectNameException, DeploymentException{
           this.kernel = kernel;
           configStore = new File(AxisGeronimoConstants.AXIS_CONFIG_STORE);
           log.debug("configuration Store is "+configStore.getAbsolutePath());
           dependedEJBs = new Vector();
  +        //start the J2EE server        
  +        startJ2EEServer();
  +        log.debug("start the J2ee server");
  +        //start the ContinerIndex
  +        startContainerIndex();
  +        log.debug("start the Continer Index");
       }
   
       /**
  @@ -131,23 +136,21 @@
        * @throws MalformedObjectNameException
        * @throws DeploymentException
        */
  -    public void startDependancies(Hashtable properites)
  -            throws MalformedObjectNameException, DeploymentException {
  -        //start the J2EE server        
  -        startJ2EEServer();
  -        log.debug("start the J2ee server");
  -        //start the ContinerIndex
  -        startContainerIndex();
  -        log.debug("start the Continer Index");
  -        
  -        //start the each dependent EJB
  -        Enumeration enu = properites.keys();
  -        while (enu.hasMoreElements()) {
  -            String dir = (String) enu.nextElement();
  -            String serviceName = (String) properites.get(dir);
  -            startDependancy(dir, serviceName);
  -        }
  -    }
  +//    public void startDependancies(Hashtable properites)
  +//            throws MalformedObjectNameException, DeploymentException {
  +//        
  +//        //start the each dependent EJB
  +//        Enumeration enu = properites.keys();
  +//        while (enu.hasMoreElements()) {
  +//            String dir = (String) enu.nextElement();
  +//            String serviceName = (String) properites.get(dir);
  +//            ObjectName serviceobjectName = ObjectName.getInstance("test:configuration="
  +//                    + serviceName);
  +//            String wsimpl = (String)properites.get("impl");
  +//            File unpackedDir = new File(configStore, dir);
  +//            startDependancy(unpackedDir, serviceobjectName,configStore,kernel,wsimpl);
  +//        }
  +//    }
   
       /**
        * Method stopDependancies
  @@ -178,15 +181,16 @@
        * @param service
        * @throws DeploymentException
        */
  -    private void startDependancy(String outDir, String service)
  +    public static ClassLoader startDependancy(File unpackedDir, 
  +        ObjectName service,
  +        File configStore,
  +        Kernel kernel)
               throws DeploymentException {
           try {
  -            File unpackedDir = new File(configStore, outDir);
  -
               // load the configuration
               GBeanMBean config = loadConfig(unpackedDir);
  -            ObjectName objectName = ObjectName.getInstance("test:configuration="
  -                    + service);
  +            System.out.println("Context Loader "+Thread.currentThread().getContextClassLoader());
  +            ObjectName objectName = service;
   
               dependedEJBs.add(objectName);
               kernel.loadGBean(objectName, config);
  @@ -195,10 +199,13 @@
               // start the configuration
               kernel.startRecursiveGBean(objectName);
               
  +            ClassLoader cl = (ClassLoader)kernel.getAttribute(objectName,"classLoader");
  +            //ClassUtils.setClassLoader(wsimpl,cl);
  +            //ClassUtils.setDefaultClassLoader(cl);
  +            
               System.out.println("start dependent EJB name="+objectName
  -            +" dir="+unpackedDir.getAbsolutePath());
  -            log.debug("start dependent EJB name="+objectName
  -                +" dir="+unpackedDir.getAbsolutePath());
  +            +" dir="+unpackedDir.getAbsolutePath()+ "the config CL ="+cl);
  +            return cl;
           } catch (DeploymentException e) {
              throw e;
           }catch (Exception e) {
  @@ -360,7 +367,7 @@
        * @return
        * @throws Exception
        */
  -    private GBeanMBean loadConfig(File unpackedCar) throws Exception {
  +    private static GBeanMBean loadConfig(File unpackedCar) throws Exception {
           InputStream in = new FileInputStream(new File(unpackedCar,
                   "META-INF/config.ser"));
   
  @@ -368,12 +375,15 @@
               ObjectInputStream ois =
                       new ObjectInputStream(new BufferedInputStream(in));
               GBeanInfo gbeanInfo = Configuration.GBEAN_INFO;
  -            GBeanMBean config = new GBeanMBean(gbeanInfo);
  -
  +            GBeanMBean config = new GBeanMBean(gbeanInfo,ClassUtils.getDefaultClassLoader());
               Configuration.loadGMBeanState(config, ois);
               return config;
           } finally {
               in.close();
           }
  +    }
  +    
  +    public static void addDependentEJB(ObjectName serviceName){
  +        dependedEJBs.add(serviceName);
       }
   }
  
  
  
  1.6       +93 -67    incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis/WebServiceContainer.java
  
  Index: WebServiceContainer.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis/WebServiceContainer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WebServiceContainer.java	28 Jul 2004 14:24:48 -0000	1.5
  +++ WebServiceContainer.java	11 Aug 2004 13:27:16 -0000	1.6
  @@ -15,28 +15,30 @@
    */
   package org.apache.geronimo.axis;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -import org.apache.geronimo.gbean.jmx.GBeanMBean;
  -import org.apache.geronimo.jetty.JettyWebAppContext;
  -import org.apache.geronimo.kernel.Kernel;
  -import org.apache.geronimo.transaction.UserTransactionImpl;
  -
  -import javax.management.MBeanServer;
  -import javax.management.MalformedObjectNameException;
  -import javax.management.ObjectName;
   import java.io.File;
   import java.io.FileInputStream;
   import java.net.MalformedURLException;
   import java.net.URI;
   import java.net.URL;
   import java.net.URLClassLoader;
  +import java.util.ArrayList;
   import java.util.Collections;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
   import java.util.Properties;
   import java.util.Set;
  -import java.util.Vector;
  +import java.util.zip.ZipFile;
  +
  +import javax.management.MBeanServer;
  +import javax.management.MalformedObjectNameException;
  +import javax.management.ObjectName;
  +
  +import org.apache.axis.utils.ClassUtils;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +import org.apache.geronimo.deployment.DeploymentException;
  +import org.apache.geronimo.gbean.jmx.GBeanMBean;
  +import org.apache.geronimo.jetty.JettyWebAppContext;
  +import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.transaction.UserTransactionImpl;
   
   /**
    * Class WebServiceContainer
  @@ -124,38 +126,42 @@
       public void doStart() throws Exception {
           ejbManager = new DependancyEJBManager(kernel);
           
  -        //The code needed a axis.properties file. If it is not there it is created.
  -        //the ideal case is this information should be in the server-config.wsdd file
  -        //but still the Axis is stanalone. I do not like the idea of yet another 
  -        //deployment discrypter.    
  -        File axisPopertiesfile =
  -                new File(new File(AxisGeronimoConstants.AXIS_CONFIG_STORE),
  -                        "axis.properties");
  -        Properties axisProperties = new Properties();
  -
  -        if (axisPopertiesfile.exists()) {
  -            axisProperties.load(new FileInputStream(axisPopertiesfile));
  -            log.debug(axisPopertiesfile.getAbsoluteFile() + " file found and loaded");
  -        } else {
  -            axisPopertiesfile.getParentFile().mkdirs();
  -            axisPopertiesfile.createNewFile();
  -            log.debug(" axis.properties file not found and created");
  -        }
  +//        //The code needed a axis.properties file. If it is not there it is created.
  +//        //the ideal case is this information should be in the server-config.wsdd file
  +//        //but still the Axis is stanalone. I do not like the idea of yet another 
  +//        //deployment discrypter.    
  +//        File axisPopertiesfile =
  +//                new File(new File(AxisGeronimoConstants.AXIS_CONFIG_STORE),
  +//                        "axis.properties");
  +//        Properties axisProperties = new Properties();
  +//
  +//        if (axisPopertiesfile.exists()) {
  +//            axisProperties.load(new FileInputStream(axisPopertiesfile));
  +//            log.debug(axisPopertiesfile.getAbsoluteFile() + " file found and loaded");
  +//        } else {
  +//            axisPopertiesfile.getParentFile().mkdirs();
  +//            axisPopertiesfile.createNewFile();
  +//            log.debug(" axis.properties file not found and created");
  +//        }
   
           // TODO deployed webservices should be stored in the local config store
           // This is a hack till it is found out how to do it
  -        ClassLoader myCl =
  -                new URLClassLoader(loadDeployedWebservices(axisProperties));
  -
  -        // Start the EJB's that depend on the webservices
  -        ejbManager.startDependancies(axisProperties);
  -        log.debug("start dependent EJBs ");
  +//        ClassLoader myCl =
  +//                new URLClassLoader(loadDeployedWebservices(axisProperties));
  +//        ClassUtils.setDefaultClassLoader(myCl);   
  +//        System.out.println("Calss Utils class lader set at WS continaer start ="+myCl);     
  +//
  +//        // Start the EJB's that depend on the webservices
  +//        ejbManager.startDependancies(axisProperties);
  +//        log.debug("start dependent EJBs ");
           
           //This code is taken from the org.apache.geronimo.jetty.ApplicationTest in the 
  -        //jetty module tests .. If something is not working we got to test weather the 
  +        //jetty module tests .. If something is not working we got to test wheather the 
           //test has changed
  +        ClassUtils.setDefaultClassLoader(Thread.currentThread().getContextClassLoader());
  +        loadDeployedWebservices();
           
  -        GBeanMBean app = new GBeanMBean(JettyWebAppContext.GBEAN_INFO, myCl);
  +        GBeanMBean app = new GBeanMBean(JettyWebAppContext.GBEAN_INFO);
           URL url =
                   Thread.currentThread().getContextClassLoader().getResource("deployables/axis/");
   
  @@ -226,37 +232,57 @@
        * @return
        * @throws MalformedURLException
        */
  -    public URL[] loadDeployedWebservices(Hashtable properties)
  -            throws MalformedURLException {
  -        if (properties == null) {
  -            return new URL[0];
  -        }
  -
  -        Vector urls = new Vector();
  -        Enumeration enu = properties.keys();
  -        File configStroe =
  -                new File(AxisGeronimoConstants.AXIS_CONFIG_STORE);
  -
  -        while (enu.hasMoreElements()) {
  -            File libfile = new File(configStroe, enu.nextElement().toString());
  -            if (libfile.exists()) {
  -                File[] jars = libfile.listFiles();
  -                if (jars != null) {
  -                    for (int i = 0; i < jars.length; i++) {
  -                        if (jars[i].getAbsolutePath().endsWith(".jar")) {
  -                            urls.add(jars[i].toURL());
  -                            log.debug("found a jar" + jars[i].getAbsolutePath());
  -                        }
  +    public void loadDeployedWebservices()
  +            throws MalformedURLException,DeploymentException {
  +        try{
  +            File configStroe = new File(AxisGeronimoConstants.AXIS_CONFIG_STORE);
  +            File[] apps = configStroe.listFiles();
  +            ClassLoader classloader;
  +            if(apps != null){
  +                for(int i = 0;i<apps.length;i++){
  +                    File f = new File(apps[i],"axis.properties");
  +                    if(f.exists()){
  +                      Properties p = new Properties();
  +                      FileInputStream in = new FileInputStream(f);
  +                      p.load(in);
  +                      in.close();  
  +                        //that mean this a Web Service
  +                      String dir = f.getName();
  +                      String serviceName = (String) p.get(dir);
  +                      String style = (String)p.get("style");
  +                      File module = null;
  +
  +                      File[] jars = f.listFiles();
  +                      if (jars != null) {
  +                          for (int j = 0; j < jars.length; j++) {
  +                              if (jars[i].getAbsolutePath().endsWith(".jar")) {
  +                                  module = jars[i];
  +                                  log.debug("found a jar" + jars[i].getAbsolutePath());
  +                                  break;
  +                              }
  +                          }
  +                      }
  +
  +                      
  +                      if("ejb".equals(style)){
  +                          ObjectName serviceobjectName = ObjectName.getInstance("test:configuration="
  +                                  + serviceName);
  +                          classloader = DependancyEJBManager.startDependancy(apps[i], serviceobjectName,configStroe,kernel);
  +                      }else{
  +                          classloader = new URLClassLoader(new URL[]{module.toURL()});
  +                      }
  +                      
  +                      ArrayList classList = AxisGeronimoUtils.getClassFileList(new ZipFile(module));
  +                      for(int j = 0;j<classList.size();j++){
  +                          String className = (String)classList.get(i);
  +                          System.out.println(className);
  +                          ClassUtils.setClassLoader(className,classloader);                
  +                      }
                       }
                   }
               }
  -        }
  -
  -        URL[] urlList = new URL[urls.size()];
  -        for (int i = 0; i < urls.size(); i++) {
  -            urlList[i] = (URL) urls.get(i);
  -            System.out.println(urlList[i]);
  -        }
  -        return urlList;
  +        }catch(Exception e){
  +            throw new DeploymentException(e);       
  +        }    
       }
   }
  
  
  
  1.4       +81 -67    incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis/WebServiceDeployer.java
  
  Index: WebServiceDeployer.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/axis/src/java/org/apache/geronimo/axis/WebServiceDeployer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WebServiceDeployer.java	6 Aug 2004 22:44:36 -0000	1.3
  +++ WebServiceDeployer.java	11 Aug 2004 13:27:16 -0000	1.4
  @@ -20,8 +20,10 @@
   import java.io.FileNotFoundException;
   import java.io.FileOutputStream;
   import java.io.IOException;
  +import java.io.InputStream;
   import java.net.URL;
   import java.net.URLClassLoader;
  +import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.Properties;
   import java.util.zip.ZipEntry;
  @@ -29,13 +31,15 @@
   
   import javax.management.ObjectName;
   
  +import org.apache.axis.client.AdminClient;
  +import org.apache.axis.client.Call;
  +import org.apache.axis.utils.ClassUtils;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.geronimo.deployment.DeploymentException;
   import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2ee;
   import org.apache.geronimo.ews.ws4j2ee.utils.packager.load.PackageModule;
   import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
  -import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
   import org.apache.geronimo.kernel.Kernel;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
   import org.apache.geronimo.system.configuration.LocalConfigStore;
  @@ -120,6 +124,8 @@
        * Field hasEJB
        */
       private boolean hasEJB = false;
  +    
  +    private  File axisPopertiesfile;
   
       /**
        * Constructor WebServiceDeployer
  @@ -181,8 +187,14 @@
           }
   
           File file = findTheImpl();
  +        
  +//        ZipFile zipfile = new ZipFile(module);
  +//        ZipEntry pentry = new ZipEntry("ws.properties");
  +//        Properties p = new Properties();
  +//        InputStream in = zipfile.getInputStream(pentry);
  +//        p.load(in);
  +//        in.close();
           deployTheWebService(file);
  -        addEntryToAxisDDStatically(file);
       }
   
       /**
  @@ -211,10 +223,9 @@
                   break;
               } 
           }
  -
  +        
           File file = new File(module);
           deployTheWebService(file);
  -        addEntryToAxisDDStatically(file);
           
       }
   
  @@ -240,14 +251,9 @@
           }
   
           outDir = String.valueOf(index);
  -
  -        File axisPopertiesfile = new File(configStore, "axis.properties");
  -
  -        if (axisPopertiesfile.exists()) {
  -            axisProperties.load(new FileInputStream(axisPopertiesfile));
  -        } else {
  -            axisPopertiesfile.createNewFile();
  -        }
  +        axisPopertiesfile = new File(configStore, outDir+"/axis.properties");
  +        axisPopertiesfile.getParentFile().mkdirs();
  +        axisPopertiesfile.createNewFile();
       }
   
       /**
  @@ -261,10 +267,7 @@
   
           properites.store(new FileOutputStream(popertiesfile),
                   "ws configuration");
  -
  -        File axispopertiesfile = new File(configStore, "axis.properties");
  -
  -        axisProperties.store(new FileOutputStream(axispopertiesfile),
  +        axisProperties.store(new FileOutputStream(axisPopertiesfile),
                   "ws configuration");
       }
   
  @@ -274,10 +277,14 @@
        * @param earFile
        * @throws DeploymentException
        */
  -    public void deployTheWebService(File earFile) throws DeploymentException {
  +    public void deployTheWebService(File module) throws DeploymentException {
           File unpackedDir = null;
   
           try {
  +            ClassLoader parentClassLoder = ClassUtils.getDefaultClassLoader();
  +            ClassLoader classloader 
  +                = new URLClassLoader(new URL[]{module.toURL()},parentClassLoder);
  +
               loadPropertyFiles();
               properites.setProperty(j2eeModuleName, outDir);
               axisProperties.setProperty(outDir, j2eeModuleName);
  @@ -286,12 +293,30 @@
   
               unpackedDir.mkdirs();
   
  +
               if (hasEJB) {
  -                deployEJB(earFile, unpackedDir);
  +                classloader = deployEJB(module, unpackedDir,classloader);
  +                axisProperties.setProperty("style","ejb");
               } else {
  -                File out = new File(unpackedDir, earFile.getName());
  -                copyTheFile(earFile, out);
  +                File out = new File(unpackedDir, module.getName());
  +                copyTheFile(module, out);
  +                axisProperties.setProperty("style","web");
  +            }
  +            
  +            //right now class name is not avalible here So we set the default
  +            //classloader
  +            ArrayList classList = AxisGeronimoUtils.getClassFileList(new ZipFile(module));
  +            for(int i = 0;i<classList.size();i++){
  +                String className = (String)classList.get(i);
  +                System.out.println(className);
  +                ClassUtils.setClassLoader(className,classloader);                
               }
  +
  +            System.out.println("Calss Utils class lader set at deployment ="+classloader);
  +
  +            //This must come after the Classloader set as axis try to load the
  +            //Classes at the deployment 
  +            addEntryToAxisDD(module);
           } catch (Exception e) {
               // if something goes wrong make sure nothing leaves in a middle
               // state
  @@ -309,7 +334,7 @@
        * @param unpackedDir
        * @throws DeploymentException
        */
  -    private void deployEJB(File earFile, File unpackedDir)
  +    private ClassLoader deployEJB(File earFile, File unpackedDir,ClassLoader cl)
               throws DeploymentException {
           try {
   /////////////////////////////////////////////////////////////////////////////////////////////            
  @@ -321,12 +346,12 @@
              * But this can quickly fix looking at it.      
              */
   
  -            OpenEJBModuleBuilder moduleBuilder = new OpenEJBModuleBuilder(kernel);
  -            ClassLoader oldCl =
  -                    Thread.currentThread().getContextClassLoader();
  -            ClassLoader cl =
  -                    new URLClassLoader(new URL[]{earFile.toURL()}, oldCl);
  -
  +          OpenEJBModuleBuilder moduleBuilder = new OpenEJBModuleBuilder(kernel);
  +//            ClassLoader oldCl =
  +//                    Thread.currentThread().getContextClassLoader();
  +//            ClassLoader cl =
  +//                    new URLClassLoader(new URL[]{earFile.toURL()}, oldCl);
  +//
               Thread.currentThread().setContextClassLoader(cl);
   
               File carFile = File.createTempFile("OpenEJBTest", ".car");
  @@ -340,7 +365,7 @@
                           AxisGeronimoConstants.TRACKEDCONNECTIONASSOCIATOR_NAME, 
                           AxisGeronimoConstants.TRANSACTIONALTIMER_NAME, 
                           AxisGeronimoConstants.NONTRANSACTIONALTIMER_NAME, 
  -                        null, moduleBuilder, moduleBuilder, null, null, null);
  +                        null, moduleBuilder,moduleBuilder, null, null, null);
                   XmlObject plan =
                           earConfigBuilder.getDeploymentPlan(earFile.toURL());
   
  @@ -351,6 +376,10 @@
   /////////////////////////////////////////////////////////////////////////////////
                   // store the property IFF all goes well
                   storeProperties();
  +                //start the ejb                
  +                ObjectName serviceobjectName = ObjectName.getInstance("test:configuration="
  +                        + j2eeModuleName);
  +                return DependancyEJBManager.startDependancy(unpackedDir,serviceobjectName,configStore,kernel); 
               } finally {
                   carFile.delete();
               }
  @@ -415,44 +444,29 @@
        * @param module
        * @throws DeploymentException
        */
  -    private void addEntryToAxisDDStatically(File module)throws DeploymentException{
  -//        try {
  -//            InputStream wsddconf = null;
  -//            File file = null;
  -//            ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); 
  -//            URL url = contextLoader.getResource("deployables/axis/WEB-INF/server-config.wsdd");
  -//            if(url != null){
  -//                file = new File(url.getFile());
  -//                if(!url.sameFile(file.toURL()))
  -//                    throw new DeploymentException("can not load the configuaration");
  -//                wsddconf = new FileInputStream(file);
  -//            }
  -//            
  -//            if(wsddconf == null){
  -//                wsddconf = contextLoader.getResourceAsStream("org/apache/axis/server/server-config.wsdd");            
  -//            }
  -//        
  -//            ZipFile zipfile = new ZipFile(module);
  -//            ZipEntry zentry = zipfile.getEntry("deploy.wsdd");
  -//            InputStream deplydd = zipfile.getInputStream(zentry);
  -//            
  -//            Admin admin = new Admin();
  -//
  -//            WSDDDocument wsddDoc = new WSDDDocument(XMLUtils.newDocument(wsddconf));
  -//            WSDDDeployment deployment = wsddDoc.getDeployment();
  -//            AxisEngine engine = new AxisServer(deployment);
  -//            engine.setShouldSaveConfig(true);
  -//            engine.init();
  -//            MessageContext msgContext = new MessageContext(engine);
  -//            
  -//            Document doc = XMLUtils.newDocument(deplydd);
  -//            Document result = admin.process(msgContext, doc.getDocumentElement());
  -//            System.out.println(XMLUtils.DocumentToString(result));
  -//            PrintWriter w = new PrintWriter(new FileWriter(file));
  -//            deployment.writeToContext(new SerializationContextImpl(w));
  -//            w.close();
  -//        } catch (Exception e) {
  -//            throw new DeploymentException(e);
  -//        } 
  +    private void addEntryToAxisDD(File module)throws DeploymentException{
  +        try {
  +          ZipFile jarmodule = new ZipFile(module);
  +          ZipEntry deployentry = jarmodule.getEntry("deploy.wsdd");
  +          if(deployentry != null){
  +              InputStream deplydd = jarmodule.getInputStream(deployentry);
  +              AdminClient adminClient = new AdminClient();
  +              URL requestUrl = new URL("http://localhost:"
  +                   +AxisGeronimoConstants.AXIS_SERVICE_PORT
  +                   +"/axis/services/AdminService");
  +              Call call = adminClient.getCall();
  +              call.setTargetEndpointAddress(requestUrl);
  +              String result = adminClient.process(null,deplydd);
  +              System.out.println(result);
  +          }else{
  +              throw new DeploymentException("the deploy.wsdd can not be found");
  +          }
  +            
  +        }catch (DeploymentException e) {
  +            throw e;
  +        }  catch (Exception e) {
  +            e.printStackTrace();
  +            throw new DeploymentException(e);
  +        } 
       }
   }
  
  
  

Mime
View raw message