axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r525802 - in /webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2: transport/http/HTTPWorker.java util/Counter.java
Date Thu, 05 Apr 2007 11:59:09 GMT
Author: deepal
Date: Thu Apr  5 04:59:08 2007
New Revision: 525802

URL: http://svn.apache.org/viewvc?view=rev&rev=525802
Log:
?xsd did not work when aar file is deploy with wsdl
- Made the counter class changes 

Modified:
    webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java
    webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/util/Counter.java

Modified: webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java?view=diff&rev=525802&r1=525801&r2=525802
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java
(original)
+++ webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java
Thu Apr  5 04:59:08 2007
@@ -23,6 +23,7 @@
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.deployment.DeploymentConstants;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.engine.Handler.InvocationResponse;
 import org.apache.axis2.transport.RequestResponseTransport;
@@ -30,14 +31,7 @@
 import org.apache.axis2.transport.http.server.OutputBuffer;
 import org.apache.axis2.transport.http.server.Worker;
 import org.apache.axis2.transport.http.util.RESTUtil;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
-import org.apache.http.MethodNotSupportedException;
+import org.apache.http.*;
 import org.apache.http.entity.ContentProducer;
 import org.apache.http.entity.EntityTemplate;
 import org.apache.http.entity.StringEntity;
@@ -45,7 +39,9 @@
 import org.apache.http.message.BasicStatusLine;
 import org.apache.ws.commons.schema.XmlSchema;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
 import java.util.HashMap;
@@ -185,9 +181,38 @@
                         response.setEntity(entity);
                         return;
                     } else {
-                        // no schema available by that name  - send 404
-                        response.setStatusLine(new BasicStatusLine(ver, 404, "Schema Not
Found!"));
-                        return;
+                      final  InputStream in = service.getClassLoader()
+                                .getResourceAsStream(DeploymentConstants.META_INF + "/" +
schemaName);
+                        if (in != null) {
+                            EntityTemplate entity = new EntityTemplate(new ContentProducer()
{
+
+                                public void writeTo(final OutputStream outstream) {
+                                    try {
+                                        boolean checkLength = true;
+                                        int length = Integer.MAX_VALUE;
+                                        int nextValue = in.read();
+                                        if (checkLength) length--;
+                                        while (-1 != nextValue && length >= 0)
{
+                                            outstream.write(nextValue);
+                                            nextValue = in.read();
+                                            if (checkLength) length--;
+                                        }
+
+                                        outstream.flush();
+                                    } catch (IOException e) {
+                                        e.printStackTrace();  
+                                    }
+                                }
+                            });
+                            entity.setContentType("text/xml");
+                            response.setEntity(entity);
+                            return;
+                        } else {
+                            // no schema available by that name  - send 404
+                            response.setStatusLine(
+                                    new BasicStatusLine(ver, 404, "Schema Not Found!"));
+                            return;
+                        }
                     }
                 }
             }
@@ -214,15 +239,15 @@
             String contentType = processContentType(inentity, msgContext);
             if (HTTPTransportUtils.isRESTRequest(contentType)) {
                 pi = RESTUtil.processXMLRequest(msgContext, inentity.getContent(),
-                                                outbuffer.getOutputStream(), contentType);
+                        outbuffer.getOutputStream(), contentType);
             } else {
-                String ip = (String)msgContext.getProperty(MessageContext.TRANSPORT_ADDR);
-                if(ip!=null){
+                String ip = (String) msgContext.getProperty(MessageContext.TRANSPORT_ADDR);
+                if (ip != null) {
                     uri = ip + uri;
                 }
                 pi = HTTPTransportUtils.processHTTPPostRequest(msgContext, inentity.getContent(),
-                                                               outbuffer.getOutputStream(),
-                                                               contentType, soapAction, uri);
+                        outbuffer.getOutputStream(),
+                        contentType, soapAction, uri);
             }
 
 
@@ -231,7 +256,7 @@
             HttpEntity inentity = ((HttpEntityEnclosingRequest) request).getEntity();
             String contentType = processContentType(inentity, msgContext);
             pi = RESTUtil.processXMLRequest(msgContext, inentity.getContent(),
-                                            outbuffer.getOutputStream(), contentType);
+                    outbuffer.getOutputStream(), contentType);
 
         } else if (method.equals(HTTPConstants.HEADER_DELETE)) {
             outbuffer = copyCommonProperties(msgContext, request);
@@ -303,7 +328,7 @@
         msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, outbuffer);
         msgContext.setTo(new EndpointReference(request.getRequestLine().getUri()));
         msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
-                               new SimpleHTTPRequestResponseTransport());
+                new SimpleHTTPRequestResponseTransport());
         return outbuffer;
     }
 
@@ -325,18 +350,18 @@
         private CountDownLatch responseReadySignal = new CountDownLatch(1);
         RequestResponseTransportStatus status = RequestResponseTransportStatus.INITIAL;
         AxisFault faultToBeThrownOut = null;
-        
+
         public void acknowledgeMessage(MessageContext msgContext) throws AxisFault {
             //TODO: Once the core HTTP API allows us to return an ack before unwinding, then
the should be fixed
             signalResponseReady();
         }
 
-        public void awaitResponse() throws InterruptedException,AxisFault {
+        public void awaitResponse() throws InterruptedException, AxisFault {
             status = RequestResponseTransportStatus.WAITING;
             responseReadySignal.await();
-            
-            if (faultToBeThrownOut!=null)
-            	throw faultToBeThrownOut;
+
+            if (faultToBeThrownOut != null)
+                throw faultToBeThrownOut;
         }
 
         public void signalResponseReady() {
@@ -348,10 +373,10 @@
             return status;
         }
 
-		public void signalFaultReady(AxisFault fault) {
-			faultToBeThrownOut = fault;
-			signalResponseReady();
-		}
-        
+        public void signalFaultReady(AxisFault fault) {
+            faultToBeThrownOut = fault;
+            signalResponseReady();
+        }
+
     }
 }

Modified: webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/util/Counter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/util/Counter.java?view=diff&rev=525802&r1=525801&r2=525802
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/util/Counter.java
(original)
+++ webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/util/Counter.java
Thu Apr  5 04:59:08 2007
@@ -22,44 +22,9 @@
 // Counter uses java.util.concurrent.atomic.AtomicLong if present,
 // else falls back to the backport version
 public class Counter {
-    private static Class clazz;
-    private static Method method;
-    private Object counter;
+    private long value = 0L;
 
-    static {
-        try {
-            clazz = Class.forName("java.util.concurrent.atomic.AtomicLong");
-        } catch (ClassNotFoundException e) {
-            try {
-                clazz = Class.forName("edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong");
-            } catch (ClassNotFoundException e1) {
-                throw new RuntimeException(e1);
-            }
-        }
-        try {
-            method = clazz.getMethod("incrementAndGet", new Class[]{});
-        } catch (NoSuchMethodException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    public Counter() {
-        try {
-            counter = clazz.newInstance();
-        } catch (InstantiationException e) {
-            throw new RuntimeException(e);
-        } catch (IllegalAccessException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    public final synchronized long incrementAndGet() {
-        try {
-            return ((Long) method.invoke(counter, new Object[]{})).longValue();
-        } catch (IllegalAccessException e) {
-            throw new RuntimeException(e);
-        } catch (InvocationTargetException e) {
-            throw new RuntimeException(e);
-        }
-    }
+    public synchronized long incrementAndGet() {
+        return ++value;
+     }
 }



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


Mime
View raw message