You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sc...@apache.org on 2008/03/04 19:08:01 UTC

svn commit: r633573 - in /webservices/axis2/trunk/java/modules: jaxws-integration/test/org/apache/axis2/jaxws/sample/ jaxws-integration/test/org/apache/axis2/jaxws/sample/wrap/ jaxws/src/org/apache/axis2/datasource/jaxb/ jaxws/src/org/apache/axis2/jaxw...

Author: scheu
Date: Tue Mar  4 10:07:49 2008
New Revision: 633573

URL: http://svn.apache.org/viewvc?rev=633573&view=rev
Log:
AXIS2-3546
Contributor:Rich Scheuerle
Changes to the JAXWS engine to install a JAXBCustomBuilder on the StAXBuilder.

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilderMonitor.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalInfo.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalMessageContextListener.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/MessageContextListener.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/WrapTests.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/wrap/DocLitWrapImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/Parameter.java
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/WrapTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/WrapTests.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/WrapTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/WrapTests.java Tue Mar  4 10:07:49 2008
@@ -24,8 +24,11 @@
 
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Holder;
+import javax.xml.ws.WebServiceException;
 
 import junit.framework.TestCase;
+
+import org.apache.axis2.datasource.jaxb.JAXBCustomBuilderMonitor;
 import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrap;
 import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrapService;
 import org.apache.axis2.jaxws.TestLogger;
@@ -53,161 +56,315 @@
 		super(arg0);
 		// TODO Auto-generated constructor stub
 	}
-	
-	public void testTwoWaySync(){
-        TestLogger.logger.debug("------------------------------");
-        TestLogger.logger.debug("Test : " + getName());
-		try{
-			String reqString = "Test twoWay Sync";
-			DocLitWrapService service = new DocLitWrapService();
-			DocLitWrap proxy = service.getDocLitWrapPort();
-	        BindingProvider p = (BindingProvider) proxy;
-	        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
-
-			String response = proxy.twoWay(reqString);
-            TestLogger.logger.debug("Sync Response =" + response);
-            TestLogger.logger.debug("------------------------------");
-		}catch(Exception e){
-			e.printStackTrace();
-			fail();
-		}
-	}
-	
-	public void testOneWayVoidWithNoInputParams(){
-        TestLogger.logger.debug("------------------------------");
-        TestLogger.logger.debug("Test : " + getName());
-		try{
-			
-			DocLitWrapService service = new DocLitWrapService();
-			DocLitWrap proxy = service.getDocLitWrapPort();
-	        BindingProvider p = (BindingProvider) proxy;
-	        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
-			proxy.oneWayVoid();
-
-            TestLogger.logger.debug("------------------------------");
-		}catch(Exception e){
-			e.printStackTrace();
-			fail();
-		}
-	}
-	
-	public void testTwoWayHolder(){
-        TestLogger.logger.debug("------------------------------");
-        TestLogger.logger.debug("Test : " + getName());
-		try{
-			String holderString = new String("Test twoWay Sync");
-			Integer holderInteger = new Integer(0);
-			Holder<String> strHolder = new Holder<String>(holderString);
-			Holder<Integer> intHolder = new Holder<Integer>(holderInteger);
-			DocLitWrapService service = new DocLitWrapService();
-			DocLitWrap proxy = service.getDocLitWrapPort();
-	        BindingProvider p = (BindingProvider) proxy;
-	        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
-			proxy.twoWayHolder(strHolder, intHolder);
-            TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
-            TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
-            TestLogger.logger.debug("------------------------------");
-		}catch(Exception e){
-			e.printStackTrace();
-			fail();
-		}
-	}
-	
-	public void testTwoWayWithHeadersAndHolders(){
-        TestLogger.logger.debug("------------------------------");
-        TestLogger.logger.debug("Test : " + getName());
-		try{
-			Header header = new Header();
-			header.setOut(0);
-			HeaderPart0 hp0= new HeaderPart0();
-			hp0.setHeaderType("Client setup Header Type for HeaderPart0");
-			HeaderPart1 hp1 = new HeaderPart1();
-			hp1.setHeaderType("Client setup Header Type for HeaderPart0");
-			Holder<HeaderPart0> holder = new Holder<HeaderPart0>(hp0);
-			DocLitWrapService service = new DocLitWrapService();
-			DocLitWrap proxy = service.getDocLitWrapPort();
-	        BindingProvider p = (BindingProvider) proxy;
-	        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
-			HeaderResponse hr = proxy.header(header, holder, hp1);
-			hp0=holder.value;
-            TestLogger.logger.debug("Holder Response String =" + hp0.getHeaderType());
-            TestLogger.logger.debug("Header Response Long =" + hr.getOut());
-            TestLogger.logger.debug("------------------------------");
-		}catch(Exception e){
-			e.printStackTrace();
-			fail();
-		}
-	}
-
-	public void testTwoWayHolderAsync(){
-        TestLogger.logger.debug("------------------------------");
-        TestLogger.logger.debug("Test : " + getName());
-		try{
-			String holderString = new String("Test twoWay Sync");
-			Integer holderInteger = new Integer(0);
-			Holder<String> strHolder = new Holder<String>(holderString);
-			Holder<Integer> intHolder = new Holder<Integer>(holderInteger);
-			DocLitWrapService service = new DocLitWrapService();
-			DocLitWrap proxy = service.getDocLitWrapPort();
-	        BindingProvider p = (BindingProvider) proxy;
-	        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
-			proxy.twoWayHolder(strHolder, intHolder);
-            TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
-            TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
-            TestLogger.logger.debug("------------------------------");
-		}catch(Exception e){
-			e.printStackTrace();
-			fail();
-		}
-	}
-    
-    /**
-     * This is a test of a doc/lit method that passes the 
-     * request in a header.  This can only be reproduced via
-     * annotations and WSGEN.  WSImport will not allow this.
-     */
-    public void testEchoStringWSGEN1() {
-        TestLogger.logger.debug("------------------------------");
-        TestLogger.logger.debug("Test : " + getName());
-        try{
-            String request = "hello world";
-            
+        
+        /**
+         * Get theDocLitWrap Prxoy
+         * @return DocLitWrapProxy
+         */
+        private DocLitWrap getProxy() {
             DocLitWrapService service = new DocLitWrapService();
             DocLitWrap proxy = service.getDocLitWrapPort();
             BindingProvider p = (BindingProvider) proxy;
             p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
-            String response = proxy.echoStringWSGEN1(request);
-            assertTrue(response.equals(request));
+            return proxy;
+        }
+	
+        public void testTwoWaySync(){
             TestLogger.logger.debug("------------------------------");
-        }catch(Exception e){
-            e.printStackTrace();
-            fail();
-        }
-    }
-    
-    /**
-     * This is a test of a doc/lit method that passes the 
-     * response in a header.  This can only be reproduced via
-     * annotations and WSGEN.  WSImport will not allow this.
-     */
-    
-    public void testEchoStringWSGEN2() {
-        TestLogger.logger.debug("------------------------------");
-        TestLogger.logger.debug("Test : " + getName());
-        try{
-            String request = "hello world 2";
-            
-            DocLitWrapService service = new DocLitWrapService();
-            DocLitWrap proxy = service.getDocLitWrapPort();
-            BindingProvider p = (BindingProvider) proxy;
-            p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
-            String response = proxy.echoStringWSGEN2(request);
-            assertTrue(response.equals(request));
+            TestLogger.logger.debug("Test : " + getName());
+            try{
+                String reqString = "Test twoWay Sync";
+                DocLitWrap proxy = getProxy();
+
+                String response = proxy.twoWay(reqString);
+                TestLogger.logger.debug("Sync Response =" + response);
+                TestLogger.logger.debug("------------------------------");
+            }catch(Exception e){
+                e.printStackTrace();
+                fail();
+            }
+        }
+
+        public void testOneWayVoidWithNoInputParams(){
+            TestLogger.logger.debug("------------------------------");
+            TestLogger.logger.debug("Test : " + getName());
+            try{
+
+                DocLitWrapService service = new DocLitWrapService();
+                DocLitWrap proxy = getProxy();
+                proxy.oneWayVoid();
+
+                TestLogger.logger.debug("------------------------------");
+            }catch(Exception e){
+                e.printStackTrace();
+                fail();
+            }
+        }
+
+        public void testTwoWayHolder(){
+            TestLogger.logger.debug("------------------------------");
+            TestLogger.logger.debug("Test : " + getName());
+            try{
+                String holderString = new String("Test twoWay Sync");
+                Integer holderInteger = new Integer(0);
+                Holder<String> strHolder = new Holder<String>(holderString);
+                Holder<Integer> intHolder = new Holder<Integer>(holderInteger);
+                DocLitWrap proxy = getProxy();
+                proxy.twoWayHolder(strHolder, intHolder);
+                TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
+                TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
+                TestLogger.logger.debug("------------------------------");
+            }catch(Exception e){
+                e.printStackTrace();
+                fail();
+            }
+        }
+
+        public void testTwoWayWithHeadersAndHolders(){
+            TestLogger.logger.debug("------------------------------");
+            TestLogger.logger.debug("Test : " + getName());
+            try{
+                Header header = new Header();
+                header.setOut(0);
+                HeaderPart0 hp0= new HeaderPart0();
+                hp0.setHeaderType("Client setup Header Type for HeaderPart0");
+                HeaderPart1 hp1 = new HeaderPart1();
+                hp1.setHeaderType("Client setup Header Type for HeaderPart0");
+                Holder<HeaderPart0> holder = new Holder<HeaderPart0>(hp0);
+                DocLitWrap proxy = getProxy();
+                HeaderResponse hr = proxy.header(header, holder, hp1);
+                hp0=holder.value;
+                TestLogger.logger.debug("Holder Response String =" + hp0.getHeaderType());
+                TestLogger.logger.debug("Header Response Long =" + hr.getOut());
+                TestLogger.logger.debug("------------------------------");
+            }catch(Exception e){
+                e.printStackTrace();
+                fail();
+            }
+        }
+
+        public void testTwoWayHolderAsync(){
+            TestLogger.logger.debug("------------------------------");
+            TestLogger.logger.debug("Test : " + getName());
+            try{
+                String holderString = new String("Test twoWay Sync");
+                Integer holderInteger = new Integer(0);
+                Holder<String> strHolder = new Holder<String>(holderString);
+                Holder<Integer> intHolder = new Holder<Integer>(holderInteger);
+                DocLitWrap proxy = getProxy();
+                proxy.twoWayHolder(strHolder, intHolder);
+                TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
+                TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
+                TestLogger.logger.debug("------------------------------");
+            }catch(Exception e){
+                e.printStackTrace();
+                fail();
+            }
+        }
+
+        /**
+         * This is a test of a doc/lit method that passes the 
+         * request in a header.  This can only be reproduced via
+         * annotations and WSGEN.  WSImport will not allow this.
+         */
+        public void testEchoStringWSGEN1() {
+            TestLogger.logger.debug("------------------------------");
+            TestLogger.logger.debug("Test : " + getName());
+            try{
+                String request = "hello world";
+
+                DocLitWrap proxy = getProxy();
+                String response = proxy.echoStringWSGEN1(request);
+                assertTrue(response.equals(request));
+                TestLogger.logger.debug("------------------------------");
+            }catch(Exception e){
+                e.printStackTrace();
+                fail();
+            }
+        }
+
+        /**
+         * This is a test of a doc/lit method that passes the 
+         * response in a header.  This can only be reproduced via
+         * annotations and WSGEN.  WSImport will not allow this.
+         */
+
+        public void testEchoStringWSGEN2() {
+            TestLogger.logger.debug("------------------------------");
+            TestLogger.logger.debug("Test : " + getName());
+            try{
+                String request = "hello world 2";
+
+                DocLitWrap proxy = getProxy();
+                String response = proxy.echoStringWSGEN2(request);
+                assertTrue(response.equals(request));
+                TestLogger.logger.debug("------------------------------");
+            }catch(Exception e){
+                e.printStackTrace();
+                fail();
+            }
+        }
+        
+        /**
+         * Test to validate whether a JAXBCustomBuilder is plugged in
+         * on the server.
+         */
+        public void testJAXBCB_Server1(){
+            TestLogger.logger.debug("------------------------------");
+            TestLogger.logger.debug("Test  : " + getName());
+            try{
+                String reqString = "JAXBCustomBuilderServer1";
+                DocLitWrap proxy = getProxy();
+                
+                // Start Monitoring
+                proxy.twoWay("JAXBCustomBuilderMonitorStart");
+                
+                String response = proxy.twoWay(reqString);
+                // The returned response will contain the number of JAXBCustomBuilders
+                // for the server this could be any number 0 or greater.
+                TestLogger.logger.debug("Response 1 =" + response);
+                String response2 = proxy.twoWay(reqString);
+                TestLogger.logger.debug("Response 2 =" + response2);
+                // The returned response will contain the number of JAXBCustomBuilders
+                // this could be any number 1 or greater.  The assumption is that
+                // the JAXBCustomBuilder will be installed on the second invoke
+                Integer r = Integer.parseInt(response2);
+                assertTrue(r.intValue() >= 1);
+                TestLogger.logger.debug("------------------------------");
+                
+                // End Monitoring
+                proxy.twoWay("JAXBCustomBuilderMonitorEnd");
+            }catch(Exception e){
+                e.printStackTrace();
+                fail();
+            }
+        }
+        
+        /**
+         * Test to validate whether a JAXBCustomBuilder is plugged in
+         * and used on the server.
+         */
+        public void testJAXBCB_Server2(){
+            TestLogger.logger.debug("------------------------------");
+            TestLogger.logger.debug("Test  : " + getName());
+            try{
+                String reqString = "JAXBCustomBuilderServer2";
+                DocLitWrap proxy = getProxy();
+                
+                // Start Monitoring
+                proxy.twoWay("JAXBCustomBuilderMonitorStart");
+                
+                String response = proxy.twoWay(reqString);
+                // The returned response will contain the number of JAXBCustomBuilders
+                // usages.
+                TestLogger.logger.debug("Response 1 =" + response);
+                Integer r1 = Integer.parseInt(response);
+                String response2 = proxy.twoWay(reqString);
+                TestLogger.logger.debug("Response 2 =" + response2);
+                // The returned response will contain the number of JAXBCustomBuilders
+                // usages.  This should be greater than the first response
+                Integer r2 = Integer.parseInt(response2);
+                assertTrue(r2.intValue() > r1.intValue());
+                TestLogger.logger.debug("------------------------------");
+                
+
+                // End Monitoring
+                proxy.twoWay("JAXBCustomBuilderMonitorEnd");
+            }catch(Exception e){
+                e.printStackTrace();
+                fail();
+            }
+        }
+        
+        /**
+         * Test to validate whether a JAXBCustomBuilder is plugged and used
+         * on the client
+         */
+        public void testJAXBCB_Client(){
+            TestLogger.logger.debug("------------------------------");
+            TestLogger.logger.debug("Test  : " + getName());
+            try{
+                String reqString = "JAXBCustomBuilderClient";
+                DocLitWrap proxy = getProxy();
+                
+                // Start Monitoring
+                JAXBCustomBuilderMonitor.setMonitoring(true);
+                JAXBCustomBuilderMonitor.clear();
+                
+                // Invoke the web services
+                proxy.twoWay(reqString);
+                
+                // The second invoke should trigger the fast
+                // unmarshalling of the response
+                proxy.twoWay(reqString);
+                
+                
+                // The returned response unmarshalling should try
+                // the JAXBCustomBuilder
+                int totalBuilders = JAXBCustomBuilderMonitor.getTotalBuilders();
+                assertTrue(totalBuilders >= 1);
+                int totalCreates = JAXBCustomBuilderMonitor.getTotalCreates();
+                assertTrue(totalCreates >= 1);
+                
+                TestLogger.logger.debug("------------------------------");
+                
+            }catch(Exception e){
+                e.printStackTrace();
+                fail();
+            } finally {
+                JAXBCustomBuilderMonitor.setMonitoring(false);
+            }
+        }
+        
+        /**
+         * Test to validate whether a JAXBCustomBuilder is plugged in
+         * on the client.  Also makes sure that the JAXBCustomBuilder
+         * falls back to normal processing when faults are thrown.
+         */
+        public void testJAXBCB_Fault(){
             TestLogger.logger.debug("------------------------------");
-        }catch(Exception e){
-            e.printStackTrace();
-            fail();
+            TestLogger.logger.debug("Test  : " + getName());
+            try{
+                String reqNormalString = "JAXBCustomBuilderClient";
+                String reqFaultString = "JAXBCustomBuilderFault";
+                DocLitWrap proxy = getProxy();
+                
+                // Start Monitoring
+                JAXBCustomBuilderMonitor.setMonitoring(true);
+                JAXBCustomBuilderMonitor.clear();
+                
+                try {
+                    // Invoke the web services
+                    proxy.twoWay(reqNormalString);
+                    
+                    // This second invoke will cause
+                    // an exception to be thrown.
+                    proxy.twoWay(reqFaultString);
+                    
+                    // An exception was expected
+                    assertTrue(false);
+                } catch (WebServiceException wse) {
+                    // An exception is expected
+                    // The returned response unmarshalling should try
+                    // the JAXBCustomBuilder but fallback to normal unmarshalling
+                    // due to the presense of a SOAPFault
+                    int totalBuilders = JAXBCustomBuilderMonitor.getTotalBuilders();
+                    assertTrue(totalBuilders >= 1);
+                    int totalCreates = JAXBCustomBuilderMonitor.getTotalCreates();
+                    assertTrue(totalCreates == 0);
+                    int totalFailedCreates = 
+                            JAXBCustomBuilderMonitor.getTotalFailedCreates();
+                    assertTrue(totalFailedCreates >= 1);
+                     
+                } 
+                TestLogger.logger.debug("------------------------------");
+                
+            } catch(Exception e){
+                e.printStackTrace();
+                fail();
+            } finally {
+                JAXBCustomBuilderMonitor.setMonitoring(false);
+            }
         }
-    }
     
 }

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/wrap/DocLitWrapImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/wrap/DocLitWrapImpl.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/wrap/DocLitWrapImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/wrap/DocLitWrapImpl.java Tue Mar  4 10:07:49 2008
@@ -25,6 +25,7 @@
 import javax.jws.WebService;
 import javax.xml.ws.Holder;
 
+import org.apache.axis2.datasource.jaxb.JAXBCustomBuilderMonitor;
 import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrap;
 import org.apache.axis2.jaxws.TestLogger;
 import org.test.sample.wrap.FinancialOperation;
@@ -77,13 +78,42 @@
 
 	}
 
-	/* (non-Javadoc)
-	 * @see org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrap#twoWay(java.lang.String)
-	 */
-	public String twoWay(String twowayStr) {
-		String retStr = new String("Acknowledgement : Request String received = "+ twowayStr);
-		return retStr;
-	}
+        /* (non-Javadoc)
+         * @see org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrap#twoWay(java.lang.String)
+         */
+        public String twoWay(String twowayStr) {
+            if (twowayStr.equals("JAXBCustomBuilderMonitorStart")) {
+                // Clear the monitor and start monitoring
+                JAXBCustomBuilderMonitor.clear();
+                JAXBCustomBuilderMonitor.setMonitoring(true);
+                return "JAXBCustomBuilderMonitorStart";
+            } else if (twowayStr.equals("JAXBCustomBuilderMonitorEnd")) {
+                // End monitoring.
+                JAXBCustomBuilderMonitor.setMonitoring(false);
+                return "JAXBCustomBuilderMonitorEnd";
+            } else if (twowayStr.equals("JAXBCustomBuilderClient")) {
+                // Clear monitor so that changes on the client can be detected
+                JAXBCustomBuilderMonitor.clear();
+                String retStr = twowayStr;
+                return retStr;
+            } else if (twowayStr.equals("JAXBCustomBuilderServer1")) {
+                // Return the number of builders from the monitor
+                String retStr = ""  + JAXBCustomBuilderMonitor.getTotalBuilders();
+                return retStr;
+            } else if (twowayStr.equals("JAXBCustomBuilderServer2")) {
+                // Return the number of creates from the monitor
+                String retStr = ""  + JAXBCustomBuilderMonitor.getTotalCreates();
+                return retStr;
+            } else if (twowayStr.equals("JAXBCustomBuilderFault")) {
+                // Clear the monitor so that chagnes on the client can be detected
+                JAXBCustomBuilderMonitor.clear();
+                // An exception is expected for this input
+                throw new RuntimeException("System Fault Occurred");
+            } else {
+                String retStr = new String("Acknowledgement : Request String received = "+ twowayStr);
+                return retStr;
+            }
+        }
 
 	/* (non-Javadoc)
 	 * @see org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrap#invoke(java.lang.String)

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java?rev=633573&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java Tue Mar  4 10:07:49 2008
@@ -0,0 +1,111 @@
+/*
+ * 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.axis2.datasource.jaxb;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.impl.builder.CustomBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * JAXBCustomBuilder creates an OMSourcedElement backed by a JAXBDataSource
+ * for the specified namespace and localPart.
+ */
+public class JAXBCustomBuilder implements CustomBuilder {
+
+    private static final Log log = LogFactory.getLog(JAXBCustomBuilder.class);
+    
+    JAXBDSContext jdsContext;
+    
+    /**
+     * Create a JAXBCustomBuilder
+     * @param context JAXBDSContext
+     */
+    public JAXBCustomBuilder(JAXBDSContext context) {
+        super();
+        this.jdsContext = context;
+        JAXBCustomBuilderMonitor.updateTotalBuilders();
+    }
+
+
+    public OMElement create(String namespace, 
+                            String localPart, 
+                            OMContainer parent,
+                            XMLStreamReader reader, 
+                            OMFactory factory) throws OMException {
+        
+        if (log.isDebugEnabled()) {
+            log.debug("create namespace = " + namespace);
+            log.debug("  localPart = " + localPart);
+            log.debug("  reader = " + reader.getClass());
+        }
+        
+        // There are some situations where we want to use normal
+        // unmarshalling, so return null
+        if (!shouldUnmarshal(namespace, localPart)) {
+            JAXBCustomBuilderMonitor.updateTotalFailedCreates();
+            return null;
+        }
+        try {
+            // Create an OMSourcedElement backed by an unmarshalled JAXB object
+            OMNamespace ns = factory.createOMNamespace(namespace, reader.getPrefix());
+            
+            Object jaxb = jdsContext.unmarshal(reader);
+            
+            OMDataSource ds = new JAXBDataSource(jaxb, jdsContext);
+            OMSourcedElement omse = factory.createOMElement(ds, localPart, ns);
+            
+            parent.addChild(omse);
+            JAXBCustomBuilderMonitor.updateTotalCreates();
+            return omse;
+        } catch (JAXBException e) {
+            JAXBCustomBuilderMonitor.updateTotalFailedCreates();
+            throw new OMException(e);
+        }
+    }
+    
+    /**
+     * @param namespace
+     * @param localPart
+     * @return true if this ns and local part is acceptable for unmarshalling
+     */
+    private boolean shouldUnmarshal(String namespace, String localPart) {
+        
+        // Don't unmarshall SOAPFaults or anything else in the SOAP 
+        // namespace.
+        // Don't unmarshall elements that are unqualified
+        if (namespace == null || namespace.length() == 0 ||
+            SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespace) ||
+            SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(namespace)) {
+            return false;
+        }
+        return true;
+        
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilderMonitor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilderMonitor.java?rev=633573&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilderMonitor.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilderMonitor.java Tue Mar  4 10:07:49 2008
@@ -0,0 +1,131 @@
+/*
+ * 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.axis2.datasource.jaxb;
+
+/**
+ * The monitor is used by the tests to ensure
+ * that the JAXBCustomBuilder is used and is functioning correctly.
+ * In normal usage, monitoring is off.
+ */
+public class JAXBCustomBuilderMonitor {
+    
+    private static boolean monitoring = false;
+    private static int totalBuilders = 0;
+    private static int totalCreates = 0;
+    private static int totalFailedCreates = 0;
+    private static String semifore = "JAXBCustomBuilderMonitor";
+    
+    /**
+     * Intentionally private.  All methods are static.
+     */
+    private JAXBCustomBuilderMonitor() {
+        
+    }
+
+    /**
+     * @return true if monitoring
+     */
+    public static boolean isMonitoring() {
+        return monitoring;
+    }
+
+    /**
+     * Set monitoring
+     * @param monitoring boolean
+     */
+    public static void setMonitoring(boolean monitoring) {
+        JAXBCustomBuilderMonitor.monitoring = monitoring;
+    }
+    
+    /**
+     * Clear the number of creates and failed creates
+     */
+    public static void clear() {
+        synchronized(semifore) {
+            totalCreates = 0;
+            totalFailedCreates = 0;
+        }
+    }
+
+    /**
+     * @return number of JAXBCustomBuilders created
+     */
+    public static int getTotalBuilders() {
+        synchronized(semifore) {
+            return totalBuilders;
+        }
+        
+    }
+
+    /**
+     * Increase number of total builders 
+     */
+    static void updateTotalBuilders() {
+        synchronized(semifore) {
+            JAXBCustomBuilderMonitor.totalBuilders++;
+        }
+    }
+
+    /**
+     * @return number of successful creates
+     */
+    public static int getTotalCreates() {
+        if (isMonitoring()) {
+            synchronized(semifore) {
+                return totalCreates;
+            }
+        }
+        return 0;
+    }
+
+    /**
+     * Increment number of creates
+     */
+    static void updateTotalCreates() {
+        if (isMonitoring()) {
+            synchronized(semifore) {
+                JAXBCustomBuilderMonitor.totalCreates++;
+            }
+        }
+    }
+
+    /**
+     * @return number of failed attempts
+     */
+    public static int getTotalFailedCreates() {
+        if (isMonitoring()) {
+            synchronized(semifore) {
+                return totalFailedCreates;
+            }
+        }
+        return 0;
+    }
+
+    /**
+     * Increment number of failed creates
+     */
+    static void updateTotalFailedCreates() {
+        if (isMonitoring()) {
+            synchronized(semifore) {
+                JAXBCustomBuilderMonitor.totalFailedCreates++;
+            }
+        }
+    }
+  
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java Tue Mar  4 10:07:49 2008
@@ -20,6 +20,7 @@
 
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
+import org.apache.axiom.om.impl.llom.OMStAXWrapper;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.java.security.AccessController;
 import org.apache.axis2.jaxws.message.databinding.JAXBUtils;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java Tue Mar  4 10:07:49 2008
@@ -87,6 +87,12 @@
                     MethodMarshallerUtils.getMarshalDesc(endpointDesc);
             TreeSet<String> packages = marshalDesc.getPackages();
             String packagesKey = marshalDesc.getPackagesKey();
+            
+            // Remember this unmarshal information so that we can speed up processing
+            // the next time.
+            MethodMarshallerUtils.registerUnmarshalInfo(message.getMessageContext(),
+                                                        packages,
+                                                        packagesKey);
 
             // Determine if a returnValue is expected.
             // The return value may be an child element
@@ -211,6 +217,10 @@
                     MethodMarshallerUtils.getMarshalDesc(endpointDesc);
             TreeSet<String> packages = marshalDesc.getPackages();
             String packagesKey = marshalDesc.getPackagesKey();
+            
+            MethodMarshallerUtils.registerUnmarshalInfo(message.getMessageContext(),
+                                                        packages,
+                                                        packagesKey);
 
             // In usage=WRAPPED, there will be a single JAXB block inside the body.
             // Get this block
@@ -412,7 +422,7 @@
             //   3) The name of the data block (m:operation) is defined by the schema and match the name of the operation.
             //      This is called the wrapper element.  The wrapper element has a corresponding JAXB element pojo.
             //   4) The parameters (m:param) are child elements of the wrapper element.
-
+            
             // Get the operation information
             ParameterDescription[] pds = operationDesc.getParameterDescriptions();
 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java Tue Mar  4 10:07:49 2008
@@ -18,8 +18,12 @@
  */
 package org.apache.axis2.jaxws.marshaller.impl.alt;
 
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.java.security.AccessController;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.description.AttachmentDescription;
 import org.apache.axis2.jaxws.description.AttachmentType;
 import org.apache.axis2.jaxws.description.EndpointDescription;
@@ -1279,5 +1283,41 @@
     static boolean isSWAAttachment(ParameterDescription pd) {
         return pd.getAttachmentDescription() != null &&
             pd.getAttachmentDescription().getAttachmentType() == AttachmentType.SWA;
+    }
+    
+    /**
+     * Register the unmarshalling information so that it can 
+     * be used to speed up subsequent marshalling events.
+     * @param mc
+     * @param packages
+     * @param packagesKey
+     */
+    static void registerUnmarshalInfo(MessageContext mc, 
+                                 TreeSet<String> packages, 
+                                 String packagesKey) throws AxisFault {
+        
+        // The information is registered on the AxisService.
+        if (mc == null ||
+            mc.getAxisMessageContext() == null ||
+            mc.getAxisMessageContext().getAxisService() == null) {
+            return;
+        }
+        AxisService ac = mc.getAxisMessageContext().getAxisService();
+        
+        // There are two things that need to be saved.
+        // 1) The UnmarshalInfo object containing the packages 
+        //    (which will be used by the CustomBuilder)
+        // 2) A MessageContextListener which (when triggered) registers
+        //    the JAXBCustomBuilder
+        Parameter param = ac.getParameter(UnmarshalInfo.KEY);
+        if (param == null) {
+            UnmarshalInfo info = new UnmarshalInfo(packages, packagesKey);
+            ac.addParameter(UnmarshalInfo.KEY, info);
+            param = ac.getParameter(UnmarshalInfo.KEY);
+            param.setTransient(true);
+            // Add a listener that will set the JAXBCustomBuilder
+            UnmarshalMessageContextListener.
+                create(mc.getAxisMessageContext().getServiceContext());
+        }
     }
 }

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalInfo.java?rev=633573&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalInfo.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalInfo.java Tue Mar  4 10:07:49 2008
@@ -0,0 +1,58 @@
+/*
+ * 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.axis2.jaxws.marshaller.impl.alt;
+
+import java.util.TreeSet;
+
+/**
+ * Information saved from a prior unmarshal that is used
+ * to speed up subsequent unmarshalling.
+ */
+public class UnmarshalInfo {
+    // The UnmarshalInfo is saved on the AxisService with the following KEY
+    public static final String KEY = "org.apache.axis2.jaxws.marshaller.impl.alt.UnmarshalInfo";
+    
+    private TreeSet<String> packages;
+    private String packagesKey;
+    
+    /**
+     * @param packages
+     * @param packagesKey
+     */
+    UnmarshalInfo(TreeSet<String> packages, String packagesKey) {
+        this.packages = packages;
+        this.packagesKey = packagesKey;
+    }
+
+    /**
+     * @return list of packages...used by caller to build a JAXBContext
+     */
+    public TreeSet<String> getPackages() {
+        return packages;
+    }
+
+    /**
+     * @return packagesKey...used by caller as a key to get JAXBContext
+     */
+    public String getPackagesKey() {
+        return packagesKey;
+    }
+    
+    
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalMessageContextListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalMessageContextListener.java?rev=633573&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalMessageContextListener.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalMessageContextListener.java Tue Mar  4 10:07:49 2008
@@ -0,0 +1,131 @@
+/*
+ * 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.axis2.jaxws.marshaller.impl.alt;
+
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.datasource.jaxb.JAXBCustomBuilder;
+import org.apache.axis2.datasource.jaxb.JAXBDSContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.MessageContextListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This MessageContextListener is triggered when 
+ * a ServiceContext is attached to the MessageContext and
+ * when a SOAPEnvelope is attached to the MessageContext.
+ * 
+ * In such cases, it attempts to get a previously cached (from a prior web service call)
+ * UnmarshalInfo object from the AxisService.  The UnmarshalInfo
+ * data is used to create a JAXBCustomBuilder on the SOAPEnvelope's builder.
+ * 
+ * The net effect is that the StAXOMBuilder will use the JAXBCustomBuilder during
+ * unmarshalling.  This saves time and space.
+ */
+public class UnmarshalMessageContextListener implements MessageContextListener {
+
+    private static final Log log = 
+            LogFactory.getLog(UnmarshalMessageContextListener.class);
+    /**
+     * Create and add a listener
+     * @param sc ServiceContext
+     */
+    public static void create(ServiceContext sc) {
+        
+        // Only create and add one listener 
+        if (sc == null || 
+            sc.getAxisService() == null ||
+            sc.getAxisService().
+               hasMessageContextListener(UnmarshalMessageContextListener.class)) {
+            return;
+        }
+        UnmarshalMessageContextListener listener = new UnmarshalMessageContextListener();
+        sc.getAxisService().addMessageContextListener(listener);
+    }
+    
+    /**
+     * User create factory method to create and register listener
+     */
+    private UnmarshalMessageContextListener() {  
+    }
+    
+    /**
+     * Attach the JAXBCustomBuilder on the Axiom builder.
+     * This will speedup the JAXB unmarshalling code
+     * @param sc
+     * @param mc
+     */
+    private void installJAXBCustomBuilder(ServiceContext sc, MessageContext mc) {
+        
+        if (log.isDebugEnabled()) {
+            log.debug("attachEvent for sc= " + sc.getName() + "and  mc=" + mc.getLogCorrelationID());
+        }
+        
+        // Make sure the MessageContext has a SOAPEnvelope and Builder
+        SOAPEnvelope envelope = mc.getEnvelope();
+        
+        if (envelope == null) {
+            return;
+        }
+        if (!(envelope.getBuilder() instanceof StAXOMBuilder)) {
+                return;
+            }
+
+        // Get the UnmarshalInfo object.
+        // This contains information from prior unmarshalling
+        AxisService as = sc.getAxisService();
+        if (as == null) {
+            return;
+        }
+        Parameter parameterInfo = as.getParameter(UnmarshalInfo.KEY);
+        if (parameterInfo == null) {
+            return;
+        }
+        UnmarshalInfo info =  (UnmarshalInfo) parameterInfo.getValue();
+        
+        if (info == null) {
+            return;
+        }
+        
+        // Crate a JAXBCustomBuilder and register it on the Axiom StAXOMBuilder
+        JAXBDSContext jaxbDSC = new JAXBDSContext(info.getPackages(), info.getPackagesKey());
+        JAXBCustomBuilder jcb = new JAXBCustomBuilder(jaxbDSC);
+        ((StAXOMBuilder) envelope.getBuilder()).registerCustomBuilderForPayload(jcb);
+        if (log.isDebugEnabled()) {
+            log.debug("Registering JAXBCustomBuilder: " + jcb);
+        }
+    }
+
+    public void attachEnvelopeEvent(MessageContext mc) {
+        if (mc.getServiceContext() != null) {
+            installJAXBCustomBuilder(mc.getServiceContext(), mc);
+        } 
+    }
+
+    public void attachServiceContextEvent(ServiceContext sc, MessageContext mc) {
+        if (mc.getEnvelope() != null) {
+            installJAXBCustomBuilder(sc, mc);
+        }
+    }
+
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java Tue Mar  4 10:07:49 2008
@@ -19,6 +19,9 @@
 package org.apache.axis2.jaxws.message.databinding.impl;
 
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axis2.datasource.jaxb.JAXBDSContext;
+import org.apache.axis2.datasource.jaxb.JAXBDataSource;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.message.Block;
@@ -26,6 +29,8 @@
 import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
 import org.apache.axis2.jaxws.message.impl.BlockFactoryImpl;
 import org.apache.axis2.jaxws.utility.XMLRootElementUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
@@ -34,7 +39,7 @@
 
 /** JAXBBlockFactoryImpl Creates a JAXBBlock */
 public class JAXBBlockFactoryImpl extends BlockFactoryImpl implements JAXBBlockFactory {
-
+    private static final Log log = LogFactory.getLog(JAXBBlockFactoryImpl.class);
 
     /** Default Constructor required for Factory */
     public JAXBBlockFactoryImpl() {
@@ -61,6 +66,40 @@
         if (qName == null) {
             qName = omElement.getQName();
         }
+        
+        if (omElement instanceof OMSourcedElement) {
+            
+            if ( ((OMSourcedElement) omElement).getDataSource() instanceof JAXBDataSource) {
+                JAXBDataSource ds = (JAXBDataSource) ((OMSourcedElement)omElement).getDataSource();
+                JAXBDSContext dsContext = ds.getContext();
+                try {
+                    if (dsContext.getJAXBContext() == ((JAXBBlockContext)context).getJAXBContext()) {
+                        // Shortcut, use existing JAXB object
+                        Object jaxb = ds.getObject();
+                        return new JAXBBlockImpl(jaxb, (JAXBBlockContext)context, qName, this);
+                    }
+                } catch (JAXBException e) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Falling back to using normal unmarshalling approach. " + e.getMessage());
+                    }
+                }
+            } else if ( ((OMSourcedElement) omElement).getDataSource() instanceof JAXBBlockImpl) {
+                JAXBBlockImpl block = (JAXBBlockImpl) ((OMSourcedElement)omElement).getDataSource();
+                JAXBBlockContext blockContext = (JAXBBlockContext) block.getBusinessContext();
+                try {
+                    if (blockContext.getJAXBContext() == ((JAXBBlockContext)context).getJAXBContext()) {
+                        // Shortcut, use existing JAXB object
+                        Object jaxb = block.getObject();
+                        return new JAXBBlockImpl(jaxb, (JAXBBlockContext)context, qName, this);
+                    }
+                } catch (JAXBException e) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Falling back to using normal unmarshalling approach. " + e.getMessage());
+                    }
+                }
+            }
+        }
+        
         return new JAXBBlockImpl(omElement, (JAXBBlockContext)context, qName, this);
     }
 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java Tue Mar  4 10:07:49 2008
@@ -24,7 +24,6 @@
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axis2.datasource.XMLStringDataSource;
 import org.apache.axis2.datasource.jaxb.JAXBDSContext;
 import org.apache.axis2.datasource.jaxb.JAXBDataSource;
 import org.apache.axis2.jaxws.ExceptionFactory;
@@ -124,6 +123,13 @@
                     throw ExceptionFactory.makeWebServiceException(e);
                 }
                 return ((JAXBDataSource) ds).getObject();
+            } else if (ds instanceof JAXBBlockImpl) {
+                // Update the business context to use the one provided by the
+                // by the datasource
+                JAXBBlockContext blockContext = (JAXBBlockContext) ((JAXBBlockImpl) ds).getBusinessContext();
+                busContext = blockContext;
+
+                return ((JAXBBlockImpl) ds).getObject();
             }
         }
         return super._getBOFromOM(omElement, busContext);

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java?rev=633573&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java Tue Mar  4 10:07:49 2008
@@ -0,0 +1,117 @@
+/*
+ * 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.axis2.jaxws.message;
+
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axis2.datasource.jaxb.JAXBCustomBuilder;
+import org.apache.axis2.datasource.jaxb.JAXBDSContext;
+import org.apache.axis2.datasource.jaxb.JAXBDataSource;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
+import org.apache.axis2.jaxws.message.databinding.JAXBUtils;
+import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+
+import test.EchoString;
+import test.ObjectFactory;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.TreeSet;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit Testing of JAXBCustomBuilder.
+ * 
+ * A JAXBCustomBuilder is an implementation of the Axiom CustomBuilder.
+ * When registered on a StAXOMBuilder, the builder will delegate to 
+ * the JAXBCustomBuilder when the payload element is encountered.
+ * 
+ * The JAXBCustomBuilder will build an OMSourcedElement backed by a JAXB
+ * object and place it in the OM tree.  This is much faster and more
+ * efficient than building an entire OM tree.
+ * 
+ * @see org.apache.axis2.jaxws.sample.WrapTests for an actual use case
+ *
+ */
+public class JAXBCustomBuilderTests extends TestCase {
+
+    private static XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+    private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+    
+    public void test() throws Exception {
+
+        // Setup: Create a jaxb object
+        ObjectFactory factory = new ObjectFactory();
+        EchoString jaxb = factory.createEchoString(); 
+        jaxb.setInput("Hello World");
+        
+        // Now create a Context for this object
+        TreeSet<String> contextPackages = new TreeSet<String>();
+        contextPackages.add(EchoString.class.getPackage().getName());
+        JAXBContext context = JAXBUtils.getJAXBContext(contextPackages);
+           
+        // Write out the xml
+        StringWriter sw = new StringWriter();
+        XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
+        Marshaller marshaller = JAXBUtils.getJAXBMarshaller(context);
+        marshaller.marshal(jaxb, writer);
+        JAXBUtils.releaseJAXBMarshaller(context, marshaller);
+        writer.flush();
+        sw.flush();
+        StringReader sr = new StringReader(sw.toString());
+        
+        // Read the sample text using OM backed by StAX.
+        XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
+        StAXOMBuilder builder = new StAXOMBuilder(inputReader); 
+        
+        // Create the JAXBCustomBuilder
+        JAXBDSContext jdsContext = new JAXBDSContext(contextPackages);
+        JAXBCustomBuilder jcb = new JAXBCustomBuilder(jdsContext);
+        
+        // Register the JAXBCustomBuilder...this will intercept the payload
+        // and build a jaxb element
+        builder.registerCustomBuilderForPayload(jcb);
+        
+        // Get the OM element
+        OMElement om = builder.getDocumentElement();  
+        
+        // Verify that the OM Element is backed by an unmarshalled jaxb object
+        assertTrue(om instanceof OMSourcedElement);
+        OMDataSource ds = ((OMSourcedElement) om).getDataSource();
+        assertTrue(ds instanceof JAXBDataSource);
+        JAXBDataSource jaxbDS = (JAXBDataSource) ds;
+        Object jaxbObject = jaxbDS.getObject();
+        assertTrue(jaxbObject instanceof EchoString);
+        EchoString result = (EchoString) jaxbObject;
+        assertTrue(result.getInput().equals("Hello World"));
+    }
+    
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java Tue Mar  4 10:07:49 2008
@@ -30,8 +30,12 @@
 import junit.framework.TestCase;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.datasource.jaxb.JAXBCustomBuilder;
+import org.apache.axis2.datasource.jaxb.JAXBDSContext;
+import org.apache.axis2.datasource.jaxb.JAXBDataSource;
 import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
 import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
 import org.apache.axis2.jaxws.message.factory.MessageFactory;
@@ -774,24 +778,27 @@
     private final int PERSIST         = 1;
     private final int SAVE_AND_PERSIST = 2;
     public void testJAXBInflow_soap11() throws Exception {
-		_testJAXBInflow(sampleJAXBEnvelope11, NO_PERSIST);
-	}
-	public void testJAXBInflow_soap12() throws Exception {
-		_testJAXBInflow(sampleJAXBEnvelope12, NO_PERSIST);
-	}
+        _testJAXBInflow(sampleJAXBEnvelope11, NO_PERSIST, false);
+    }
+    public void testJAXBInflow_soap11_withCustomBuilder() throws Exception {
+        _testJAXBInflow(sampleJAXBEnvelope11, NO_PERSIST, true);
+    }
+    public void testJAXBInflow_soap12() throws Exception {
+        _testJAXBInflow(sampleJAXBEnvelope12, NO_PERSIST, false);
+    }
     public void testJAXBInflow_soap11_withPersist() throws Exception {
-        _testJAXBInflow(sampleJAXBEnvelope11, PERSIST);
+        _testJAXBInflow(sampleJAXBEnvelope11, PERSIST, false);
     }
     public void testJAXBInflow_soap12_withPersist() throws Exception {
-        _testJAXBInflow(sampleJAXBEnvelope12, PERSIST);
+        _testJAXBInflow(sampleJAXBEnvelope12, PERSIST, false);
     }
     public void testJAXBInflow_soap11_withSaveAndPersist() throws Exception {
-        _testJAXBInflow(sampleJAXBEnvelope11, SAVE_AND_PERSIST);
+        _testJAXBInflow(sampleJAXBEnvelope11, SAVE_AND_PERSIST, false);
     }
     public void testJAXBInflow_soap12_withSaveAndPersist() throws Exception {
-        _testJAXBInflow(sampleJAXBEnvelope12, SAVE_AND_PERSIST);
+        _testJAXBInflow(sampleJAXBEnvelope12, SAVE_AND_PERSIST, false);
     }
-	public void _testJAXBInflow(String sampleJAXBEnvelope, int persist) throws Exception {
+    public void _testJAXBInflow(String sampleJAXBEnvelope, int persist, boolean installJAXBCustomBuilder) throws Exception {
         // Create a SOAP OM out of the sample incoming XML.  This
         // simulates what Axis2 will be doing with the inbound message. 
         StringReader sr = new StringReader(sampleJAXBEnvelope);
@@ -799,6 +806,12 @@
         StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
         OMElement omElement = builder.getSOAPEnvelope();
         
+        if (installJAXBCustomBuilder) {
+            JAXBDSContext jds = new JAXBDSContext(EchoStringResponse.class.getPackage().getName());
+            JAXBCustomBuilder jcb = new JAXBCustomBuilder(jds);
+            builder.registerCustomBuilderForPayload(jcb);
+        }
+        
         // Create a SOAP 1.1 Message from the sample incoming XML
         MessageFactory mf = (MessageFactory)
             FactoryRegistry.getFactory(MessageFactory.class);
@@ -817,6 +830,17 @@
             saveMsgText = m.getAsOMElement().toString();
         }
         
+        Object customBuiltObject = null;
+        if (installJAXBCustomBuilder) {
+            OMElement om = m.getAsOMElement();
+            om = ((org.apache.axiom.soap.SOAPEnvelope) om).getBody().getFirstElement();
+            if (om instanceof OMSourcedElement &&
+                ((OMSourcedElement) om).getDataSource() instanceof JAXBDataSource) {
+                customBuiltObject = ((JAXBDataSource) ((OMSourcedElement) om).getDataSource()).getObject();
+            }
+        }
+        
+        
         // Get the BlockFactory
         JAXBBlockFactory bf = (JAXBBlockFactory)
             FactoryRegistry.getFactory(JAXBBlockFactory.class);
@@ -849,6 +873,11 @@
             omElement = builder.getSOAPEnvelope();
             m = mf.createFrom(omElement, null);
         } 
+        
+        if (installJAXBCustomBuilder) {
+            // If installed jaxb custom builder, then custom built object should be same object as the business object
+            assertTrue (customBuiltObject == bo);
+        }
         
         
         // Check to make sure the right object was returned

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java Tue Mar  4 10:07:49 2008
@@ -1278,6 +1278,10 @@
                 throw new AxisFault(
                         "Unknown SOAP Version. Current Axis handles only SOAP 1.1 and SOAP 1.2 messages");
             }
+            // Inform the listeners of an attach envelope event
+            if (getAxisService() != null) {
+                getAxisService().attachEnvelopeEvent(this);
+            }
         }
     }
 
@@ -1417,7 +1421,13 @@
                 // setting service group context
                 serviceGroupContext = context.getServiceGroupContext();
             }
-            this.setAxisService(context.getAxisService());
+            AxisService axisService = context.getAxisService();
+            this.setAxisService(axisService);
+            
+            // Inform the listeners of an attach event
+            if (axisService != null) {
+                axisService.attachServiceContextEvent(serviceContext, this);
+            }
         }
     }
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java Tue Mar  4 10:07:49 2008
@@ -64,6 +64,7 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.dataretrieval.AxisDataLocator;
 import org.apache.axis2.dataretrieval.AxisDataLocatorImpl;
 import org.apache.axis2.dataretrieval.DRConstants;
@@ -287,9 +288,12 @@
 
 	// name of the binding used : use in codegeneration
 	private String bindingName;
+        
+	// List of MessageContextListeners that listen for events on the MessageContext
+        private ArrayList messageContextListeners = new ArrayList();
 
-	// names list keep to preserve the parameter order
-	private List operationsNameList;
+        // names list keep to preserve the parameter order
+        private List operationsNameList;
 
 	private String[] eprs;
 	private boolean customWsdl = false;
@@ -2878,4 +2882,67 @@
 	public Policy lookupPolicy(String key) {
 		return (Policy) policyMap.get(key);
 	}
+    
+    /**
+     * Add a ServiceContextListener
+     * @param scl
+     */
+    public void addMessageContextListener(MessageContextListener scl) {
+        synchronized (messageContextListeners) {
+            messageContextListeners.add(scl);
+        }
+    }
+    
+    /**
+     * Remove a ServiceContextListener
+     * @param scl
+     */
+    public void removeMessageContextListener(MessageContextListener scl) {
+        synchronized (messageContextListeners) {
+            messageContextListeners.remove(scl);
+        }
+    }
+    
+    /**
+     * @param cls Class of ServiceContextListener
+     * @return true if ServiceContextLister is in the list
+     */
+    public boolean hasMessageContextListener(Class cls) {
+        synchronized (messageContextListeners) {
+            for (int i=0; i<messageContextListeners.size(); i++) {
+                if (messageContextListeners.get(i).getClass() == cls) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+    
+    /**
+     * Signal an Attach ServiceContext Event
+     * @param sc ServiceContext
+     * @param mc MessageContext
+     */
+    public void attachServiceContextEvent(ServiceContext sc, MessageContext mc) {
+        synchronized (messageContextListeners) {
+            for (int i=0; i<messageContextListeners.size(); i++) {
+                ((MessageContextListener) messageContextListeners.get(i)).
+                    attachServiceContextEvent(sc, mc);
+            }
+        }
+    }
+    
+    /**
+     * Signal an Attach Envelope Event
+     * @param sc ServiceContext
+     * @param mc MessageContext
+     */
+    public void attachEnvelopeEvent(MessageContext mc) {
+        synchronized (messageContextListeners) {
+            for (int i=0; i<messageContextListeners.size(); i++) {
+                ((MessageContextListener) messageContextListeners.get(i)).
+                    attachEnvelopeEvent(mc);
+            }
+        }
+    }
 }

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/MessageContextListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/MessageContextListener.java?rev=633573&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/MessageContextListener.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/MessageContextListener.java Tue Mar  4 10:07:49 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.axis2.description;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+
+/**
+ * A MessageContextListener is registered on the AxisService.
+ * When a ServiceContext is attached to the MessageContext, 
+ * the attachServiceContextEvent is triggered.
+ * When an Envelope is attached to the MessageContext, 
+ * the attachEnvelopeEvent is triggered.
+ * 
+ * These two events occur at critical points in the message sending
+ * or receiving.  An implementation of the MessageContextListener
+ * may log information, set special properties or trigger events.
+ * 
+ * For example the JAXWS module uses a MessageContextListener to 
+ * register a JAXBCustomBuilder on the envelope's StAXOMBuilder.
+ */
+public interface MessageContextListener {
+
+    public void attachServiceContextEvent(ServiceContext sc, MessageContext mc);
+    
+    public void attachEnvelopeEvent(MessageContext mc);
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/Parameter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/Parameter.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/Parameter.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/Parameter.java Tue Mar  4 10:07:49 2008
@@ -111,9 +111,13 @@
      * Field value
      */
     private Object value;
+    
+    private boolean _transient;  // Indicates that the parameter is transient (not persisted)
 
     //To check whether the parameter is editable or not ,
     // if the value is false then no one can call setvalue
+    // TODO
+    // Currently the editable field is not persisted. This seems like a problem.
     private boolean editable = true;
 
     /**
@@ -267,6 +271,12 @@
      */
     public void writeExternal(ObjectOutput o) throws IOException {
         SafeObjectOutputStream out = SafeObjectOutputStream.install(o);
+        
+        // Don't write out transient parameters
+        if (this.isTransient()) {
+            return;  
+        }
+        
         // write out contents of this object
 
         //---------------------------------------------------------
@@ -399,5 +409,13 @@
 
     public void setEditable(boolean editable) {
         this.editable = editable;
+    }
+
+    public boolean isTransient() {
+        return _transient;
+    }
+
+    public void setTransient(boolean _transient) {
+        this._transient = _transient;
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java Tue Mar  4 10:07:49 2008
@@ -18,8 +18,17 @@
  */
 package org.apache.axis2.description;
 
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.engine.AxisConfiguration;
+
 import javax.xml.namespace.QName;
 
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+
 import junit.framework.TestCase;
 
 public class AxisServiceTest extends TestCase {
@@ -92,5 +101,96 @@
         service.addParameterObserver(observer);
         service.addParameter(PARAM_NAME, PARAM_VALUE);
         assertTrue("Didn't get notification", observer.gotIt);
+    }
+     
+    /**
+     * Simple test to ensure that Parameters marked as Transient
+     * are not persisted.
+     * @throws Exception
+     */
+    public void testTransientParameters() throws Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        
+        Parameter p1 = new Parameter("NORMAL", "Hello World");
+        Parameter p2 = new Parameter("TRANSIENT", "Hello World");
+        p2.setTransient(true);
+        
+        // The header in an object output is 4 bytes
+        final int HEADER_LENGTH = 4;
+        
+        // Make sure that non-transient value is written
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
+        p1.writeExternal(oos);
+        oos.flush();
+        oos.close();
+        int length1 = baos.toByteArray().length;
+        assertTrue( length1 > HEADER_LENGTH);
+        
+        // Make sure the transient value is not written
+        baos = new ByteArrayOutputStream();
+        oos = new ObjectOutputStream(baos);
+        p2.writeExternal(oos);
+        oos.flush();
+        oos.close();
+        int length2 = baos.toByteArray().length;
+        assertTrue( length2 <= HEADER_LENGTH);
+        
+        
+    }
+    
+    /**
+     * Simple test to make verify that the MessageContext listener
+     * is invoked when a ServiceContext is attached to the MessageContext
+     * @throws Exception
+     */
+    public void testMessageContextListener() throws Exception {
+        
+        AxisConfiguration ac = new AxisConfiguration();
+        ConfigurationContext cc = new ConfigurationContext(ac);
+        
+        // Create a dummy AxisService
+        AxisService service = new AxisService();
+        service.setName("dummy");
+        
+        AxisServiceGroup asg = new AxisServiceGroup();
+        asg.addService(service);
+        
+        // Attach a ServiceContextListener
+        // The ServiceContextListener will copy sample information from 
+        // the ServiceContext onto the MessageContext
+        service.addMessageContextListener(new MyMessageContextListener());
+        
+        // Create a Dummy ServiceContext
+        ServiceGroupContext sgc = new ServiceGroupContext(cc, asg);
+        ServiceContext sc = sgc.getServiceContext(service);
+        sc.setProperty("SERVICE_PROPERTY", "SUCCESSFUL");
+        
+        // Create a MessageContext
+        MessageContext mc = new MessageContext();
+        
+        // Attach the ServiceContext and MessageContext.
+        // This will trigger the MyServiceContextListener.attachEvent
+        mc.setServiceContext(sc);
+        
+        // Verify success
+        assertTrue("SUCCESSFUL".equals(mc.getProperty("MESSAGE_PROPERTY")));
+    }
+    
+    /**
+     * Sameple MessageContextListener which sets a property 
+     * on the MessageContext when the SerivceContext is attached.
+     */
+    class MyMessageContextListener implements MessageContextListener {
+
+
+        public void attachEnvelopeEvent(MessageContext mc) {
+            
+        }
+
+        public void attachServiceContextEvent(ServiceContext sc, MessageContext mc) {
+            String value = (String) sc.getProperty("SERVICE_PROPERTY");
+            mc.setProperty("MESSAGE_PROPERTY", value);
+        }
+        
     }
 }

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java?rev=633573&r1=633572&r2=633573&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java Tue Mar  4 10:07:49 2008
@@ -124,7 +124,9 @@
         else if (wsdlBindingType.equals(HTTPBinding.HTTP_BINDING) &&
                 endpointDesc.isEndpointBased()) {
             addValidationFailure(this,
-                                 "The HTTPBinding can not be specified for SEI-based endpoints");
+                                 "An HTTPBinding was found on an @WebService SEI based endpoint. " +
+                                 "This is not supported.  " +
+                                 "An HTTPBinding must use an @WebServiceProvider endpoint.");
             isBindingValid = false;
         } else {
             addValidationFailure(this, "Invalid binding; wsdl = " + wsdlBindingType +



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org