axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r513359 - in /webservices/axis/trunk/proposals/dug/java/src/org/apache/axis: persistence/JVMPersistence.java persistence/Persistence.java wsa/EndpointReference.java wsa/MIHeader.java wsa/WSAHandler.java
Date Thu, 01 Mar 2007 14:56:35 GMT
Author: dug
Date: Thu Mar  1 06:56:34 2007
New Revision: 513359

URL: http://svn.apache.org/viewvc?view=rev&rev=513359
Log:
sync with head

Modified:
    webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/persistence/JVMPersistence.java
    webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/persistence/Persistence.java
    webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/EndpointReference.java
    webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/MIHeader.java
    webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/WSAHandler.java

Modified: webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/persistence/JVMPersistence.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/persistence/JVMPersistence.java?view=diff&rev=513359&r1=513358&r2=513359
==============================================================================
--- webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/persistence/JVMPersistence.java
(original)
+++ webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/persistence/JVMPersistence.java
Thu Mar  1 06:56:34 2007
@@ -1,27 +1,106 @@
 package org.apache.axis.persistence ;
 
+import java.util.Enumeration ;
 import java.util.Hashtable ;
+import java.util.Vector ;
 
 public class JVMPersistence implements Persistence {
-  private Hashtable queues = new Hashtable();
+  class Entry { 
+    String    entryID = null ;
+    Hashtable keys    = null ;
+    Object    obj     = null ;
 
-  public Object get(String queue, String id) throws Exception {
-    Hashtable q = (Hashtable) queues.get( queue );
+    void remove() {
+      Enumeration Qs = keys.keys();
+      while ( Qs.hasMoreElements() ) {
+        String qName = (String) Qs.nextElement();
+        String qId   = (String) keys.get( qName );
+
+        Hashtable q = (Hashtable) queues.get( qName );
+        if ( q == null ) continue ;
+        Vector entryIDs = (Vector) q.get( qId );
+        if ( entryIDs == null ) continue ;
+        entryIDs.remove( entryID );
+        if ( entryIDs.size() == 0 ) q.remove( qId );
+      }
+    }
+  };
+
+  private long      count   = 0 ;
+  private Hashtable entries = new Hashtable();
+  private Hashtable queues  = new Hashtable();
+
+  public Object get(String qName, String id) throws Exception {
+    Hashtable q = (Hashtable) queues.get( qName );
     if ( q == null ) return null ;
-    return q.get( id );
+    Vector entryIDs = (Vector) q.get( id );
+    if ( entryIDs == null ) return null ;
+    String entryID = (String) entryIDs.get( 0 );
+
+    Entry entry = (Entry) entries.get( entryID );
+    return entry.obj ;
   }
 
-  public Object remove(String queue, String id) throws Exception {
-    Hashtable q = (Hashtable) queues.get( queue );
+  public Object remove(String qName, String id) throws Exception {
+    Hashtable q = (Hashtable) queues.get( qName );
     if ( q == null ) return null ;
-    Object obj = q.remove( id );
-    return obj ;
+    Vector entryIDs = (Vector) q.get( id );
+    if ( entryIDs == null ) return null ;
+
+    String entryID = (String) entryIDs.get( 0 );
+
+    Entry entry = (Entry) entries.get( entryID );
+    entry.remove();
+    return entry.obj ;
   }
 
-  public void put(String queue, String id, Object obj) throws Exception {
-    Hashtable q = (Hashtable) queues.get( queue );
-    if ( q == null ) queues.put( queue, q = new Hashtable());
-    q.put( id, obj );
+  public long size(String qName, String qKey) throws Exception {
+    Hashtable q = (Hashtable) queues.get( qName );
+    if ( q == null ) return 0 ;
+    Vector entryIDs = (Vector) q.get( qKey );
+    if ( entryIDs == null ) return 0 ;
+    return entryIDs.size();
+  }
+
+  static String lock = "" ;
+
+  public void put(String qName, String id, Object obj) throws Exception {
+    synchronized(lock) {
+      Hashtable q = (Hashtable) queues.get( qName );
+      if ( q == null ) queues.put( qName, q = new Hashtable());
+      Entry  entry = new Entry();
+      entry.entryID = "" + (++count) ;
+      entry.keys    = new Hashtable();
+      entry.keys.put( qName, id );
+      entry.obj = obj ;
+      entries.put( entry.entryID, entry );
+      Vector entryIDs = (Vector) q.get( id );
+      if ( entryIDs == null ) q.put( id, entryIDs = new Vector() );
+      entryIDs.add( entry.entryID );
+    }
+  }
+
+  public void put(Hashtable keys, Object obj) throws Exception {
+    synchronized(lock) {
+      Entry  entry = new Entry();
+      entry.entryID = "" + (++count);
+      entry.keys    = new Hashtable();
+      entry.obj     = obj ;
+      entries.put( entry.entryID, entry );
+
+      Enumeration ee = keys.keys();
+      while ( ee.hasMoreElements() ) {
+        String qName = (String) ee.nextElement();
+        Hashtable q = (Hashtable) queues.get( qName );
+        if ( q == null ) queues.put( qName, q = new Hashtable() );
+
+        String qVal = (String) keys.get(qName);
+        Vector entryIDs = (Vector) q.get( qVal );
+        if ( entryIDs == null ) q.put( qVal, entryIDs = new Vector() );
+        entryIDs.add( entry.entryID );
+        entry.keys.put( qName, qVal );
+      }
+    }
   }
 
 }

Modified: webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/persistence/Persistence.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/persistence/Persistence.java?view=diff&rev=513359&r1=513358&r2=513359
==============================================================================
--- webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/persistence/Persistence.java
(original)
+++ webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/persistence/Persistence.java
Thu Mar  1 06:56:34 2007
@@ -1,7 +1,11 @@
 package org.apache.axis.persistence ;
 
+import java.util.Hashtable ;
+
 public interface Persistence {
-  public Object get(String queue, String id) throws Exception;
-  public Object remove(String queue, String id) throws Exception;
-  public void   put(String queue, String id, Object obj) throws Exception;
+  public Object get(String qName, String qKey) throws Exception;
+  public Object remove(String qName, String qKey) throws Exception;
+  public void   put(String qName, String qKey, Object obj) throws Exception;
+  public void   put(Hashtable keys, Object obj) throws Exception;
+  public long   size(String qName, String qKey) throws Exception ;
 }

Modified: webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/EndpointReference.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/EndpointReference.java?view=diff&rev=513359&r1=513358&r2=513359
==============================================================================
--- webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/EndpointReference.java
(original)
+++ webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/EndpointReference.java
Thu Mar  1 06:56:34 2007
@@ -80,7 +80,8 @@
   }
 
   public String toString() {
-    return "" + getClass() +"@"+ hashCode() + " address: '" +address + 
+    return "" + getClass() +"@"+ hashCode() + "ns: " + namespace + 
+           " address: '" +address + 
            "' refProps: '" + referenceProperties + "' refParams: '" + 
            referenceParameters + "'"; 
   }
@@ -99,15 +100,17 @@
   }
 
   public static EndpointReference Anonymous() { 
-    if ( staticNS.equals(WSAConstants.NS_WSA1) )
-      return EndpointReference.fromLocation( staticNS + "/role/anonymous" );
-    return EndpointReference.fromLocation( staticNS + "/anonymous" );
+    return Anonymous( staticNS );
   }
 
   public static EndpointReference Anonymous(String ns) { 
+    EndpointReference newEPR = newInstance( ns );
+
     if ( ns.equals(WSAConstants.NS_WSA1) )
-      return EndpointReference.fromLocation( ns + "/role/anonymous" );
-    return EndpointReference.fromLocation( ns + "/anonymous" );
+      newEPR.setAddress( ns + "/role/anonymous" );
+    else
+      newEPR.setAddress( ns + "/anonymous" );
+    return newEPR ;
   }
 
   public boolean isAnonymous() {
@@ -117,15 +120,17 @@
   }
 
   public static EndpointReference None() { 
-    if ( staticNS.equals(WSAConstants.NS_WSA1) )  // should fault or something
-      return EndpointReference.fromLocation( staticNS + "/role/none" );
-    return EndpointReference.fromLocation( staticNS + "/none" );
+    return None( staticNS );
   }
 
   public static EndpointReference None(String ns) { 
+    EndpointReference newEPR = newInstance( ns );
+
     if ( ns.equals(WSAConstants.NS_WSA1) )  // should fault or something
-      return EndpointReference.fromLocation( ns + "/role/none" );
-    return EndpointReference.fromLocation( ns + "/none" );
+      newEPR.setAddress( ns + "/role/none" );
+    else
+      newEPR.setAddress( ns + "/none" );
+    return newEPR ;
   }
 
   public boolean isNone() {

Modified: webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/MIHeader.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/MIHeader.java?view=diff&rev=513359&r1=513358&r2=513359
==============================================================================
--- webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/MIHeader.java (original)
+++ webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/MIHeader.java Thu Mar
 1 06:56:34 2007
@@ -61,10 +61,10 @@
   // but it works.
 
   public String toString() {
-    return "{ns: " + getWSAVersion() + " id:" + getMessageID()+ 
-           " to:" + getTo() + " from:" + getFrom() +
-           " replyTo:" + getReplyTo() + " faultTo:" + getFaultTo() +
-           " action:" + getAction() + " toFault:" + getToFault() + "}" ;
+    return "{ns: " + namespace + " id:" + messageID + 
+           " to:" + to + " from:" + from +
+           " replyTo:" + replyTo + " faultTo:" + faultTo +
+           " action:" + action + " toFault:" + toFault + "}" ;
   }
 
   // Potentially problem causing. Would rather remove this constructor
@@ -74,6 +74,13 @@
     setMessageID( "uuid:" + UUIDGenerator.getInstance().getUUID());
   }
 
+  public MIHeader(String ns) {
+    namespace = ns ;
+    processedOnGet = true ;
+    removeOnGet = false ;
+    setMessageID( "uuid:" + UUIDGenerator.getInstance().getUUID());
+  }
+
   /**
    * Constructor intended for client use to create an
    * MIHeader instance that will interact with a Call
@@ -158,7 +165,7 @@
   }
 
   public MIHeader generateReplyMI() throws Exception {
-    MIHeader newMIH = new MIHeader();
+    MIHeader newMIH = new MIHeader( this.getWSAVersion() );
 
     EndpointReference toEPR = getEffectiveReplyTo();
     newMIH.setWSAVersion( namespace );
@@ -371,6 +378,13 @@
   }
 
   public EndpointReference getTo() {
+    /*
+    if ( to == null )
+      to = EndpointReference.Anonymous( namespace );
+    */
+    return to ; 
+  }
+  public EndpointReference getEffectiveTo() {
     if ( to == null )
       to = EndpointReference.Anonymous( namespace );
     return to ; 

Modified: webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/WSAHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/WSAHandler.java?view=diff&rev=513359&r1=513358&r2=513359
==============================================================================
--- webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/WSAHandler.java (original)
+++ webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/WSAHandler.java Thu
Mar  1 06:56:34 2007
@@ -53,11 +53,18 @@
      Message  msg = msgContext.getRequestMessage();
 
      if ( mih == null ) {
-       if ( msgContext.getAxisEngine().getOption("useWSA") == null &&
-            msgContext.getProperty("useWSA") == null )
-         return ;
-
+       String wsaVersion = (String) msgContext.getProperty( "useWSA" );
+       if ( wsaVersion == null ) 
+         wsaVersion = (String) msgContext.getAxisEngine().getOption("useWSA");
+       if ( wsaVersion == null ) return ;
+       if ( wsaVersion.equals("false") ) return ;
+
+       if ( !WSAConstants.NS_WSA1.equals(wsaVersion) &&
+            !WSAConstants.NS_WSA2.equals(wsaVersion) )
+         wsaVersion = WSAConstants.NS_WSA ;
+       
        msgContext.setProperty(WSAConstants.REQ_MIH, mih = new MIHeader());
+       mih.setWSAVersion( wsaVersion );
        mih.setRemoveOnGet(true);
        mih.fromEnvelope( msg.getSOAPEnvelope() );
      }
@@ -157,17 +164,16 @@
 
      MIHeader resMIH = null ;
      Message  msg    = null ;
-     String   to     = null ;
+     EndpointReference to = null ;
      
      resMIH = MIHeader.fromResponse();
      if ( resMIH == null ) return ;
 
-     if ( resMIH.getTo() != null )
-       to = resMIH.getTo().getAddress();
+     to = resMIH.getTo();
 
      msg = msgContext.getResponseMessage();
 
-     if ( msg==null || to==null || resMIH.getTo().isAnonymous() )
+     if ( msg==null || to==null || to.isAnonymous() )
        return ;
 
      Vector   relates    = (Vector) resMIH.getRelatesTo();
@@ -186,7 +192,7 @@
          }
 
          call.setSOAPVersion( msgContext.getSOAPConstants() );
-         call.setTargetEndpointAddress(resMIH.getTo().getAddress() );
+         call.setTargetEndpointAddress(to.getAddress() );
          call.setRequestMessage(msg);
          call.setSOAPActionURI( msgContext.getSOAPActionURI() );
 



---------------------------------------------------------------------
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