Author: lischke
Date: Sun Feb  6 15:47:09 2005
New Revision: 151642

URL: http://svn.apache.org/viewcvs?view=rev&rev=151642
Log:
redesigned to work with Apollo Framework

Added:
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/RemoteSubscriptionHome.java
    incubator/hermes/trunk/src/java/org/apache/ws/eventing/SubscriptionHome.java
    incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/JettyBroker.java
    incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/WEB-INF/
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/WEB-INF/server-config.wsdd
    incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/PopUpConsumer.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/PubSubClient.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/PubSubWSmanager.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/PubSubWSsemantic.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/PubSubWSsyntactic.java
    incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/WEB-INF/
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/WEB-INF/server-config.wsdd
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/services/AbstractService.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/services/publisher/PublisherService.java
Removed:
    incubator/hermes/trunk/src/java/org/apache/ws/eventing/SubscriberStore.java
    incubator/hermes/trunk/src/java/org/apache/ws/eventing/YFilterStore.java
Modified:
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/AbstractSubscription.java
    incubator/hermes/trunk/src/java/org/apache/ws/eventing/ForwardConsumer.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/RemoteSubscription.java
    incubator/hermes/trunk/src/java/org/apache/ws/eventing/Subscriber.java
    incubator/hermes/trunk/src/java/org/apache/ws/eventing/Subscription.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/porttype/EventSourcePortType.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/porttype/SubscriptionEndPortType.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/porttype/SubscriptionManagerPortType.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/porttype/impl/EventSourcePortTypeImpl.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/porttype/impl/NotificationPortTypeImpl.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/porttype/impl/SubscriptionManagerPortTypeImpl.java
    
incubator/hermes/trunk/src/java/org/apache/ws/eventing/wsaSOAPConnection.java

Modified: 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/AbstractSubscription.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/eventing/AbstractSubscription.java?view=diff&r1=151641&r2=151642
==============================================================================
--- 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/AbstractSubscription.java
 (original)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/AbstractSubscription.java
 Sun Feb  6 15:47:09 2005
@@ -15,14 +15,10 @@
  */
 package org.apache.ws.eventing;
 
-import org.apache.axis.configuration.FileProvider;
-import org.apache.ws.addressing.*;
+import org.apache.ws.pubsub.*;
 
-//import org.apache.ws.eventing.base.*;
-//import org.apache.ws.eventing.services.*;
-//import org.apache.ws.eventing.services.subscriber.SubscriberServiceLocator;
+import org.apache.ws.addressing.EndpointReference;
 
-import org.apache.ws.pubsub.*;
 
 import org.apache.xmlbeans.*;
 import org.w3c.dom.*;
@@ -30,11 +26,19 @@
 
 public abstract class AbstractSubscription implements 
org.apache.ws.pubsub.Subscription, org.apache.ws.resource.Resource {
     
-//    public SubscriptionManager sMan;
     private NotificationConsumer consumer;
+    private EndpointReference epr;
     private String QueryID;
-    private String id;
+    protected String m_id;
     
+    public EndpointReference getEpr(){
+        return this.epr;
+    }
+    
+    public void setEpr(EndpointReference epr){
+        this.epr=epr; 
+    }
+  
     public String getFilterString()throws Exception{
         //TODO !! have an own Filter
         return null;
@@ -48,37 +52,12 @@
     }
     
     public Object getID(){
-        return this.id;
+        return this.m_id;
     }
-    public void setID(String id){
-        this.id=id;
-    }
-    public void setSubscriptionManager(EndpointReference epr){
-        try{
-            //extract ew:identifier
-            XmlObject rp[] = (XmlObject[])epr.getReferenceProperties();
-            //TODO iterate over all rps
-            Node n = rp[0].newDomNode();
-            // ("http://schemas.xmlsoap.org/ws/2004/08/eventing";, 
"Identifier"));
-            if(n!=null)
-                this.id= n.getFirstChild().getNodeValue();
-            //Subscription Manager
-            //SubscriberServiceLocator pubsubwsLoc = new 
SubscriberServiceLocator(new 
FileProvider("org/apache/ws/eventing/client-config.wsdd"));
-            //this.sMan = pubsubwsLoc.getSubscriptionManagerPort(new 
java.net.URL(epr.getAddress().toString()));
-            System.out.println("got SubscritpionManager 
"+epr.getAddress().toString());
-        }catch(Exception e){
-            e.printStackTrace();
-        }
-    }
-    
-    public void unsubscribe(){
-      /*  try{
-            this.sMan.unsubscribeMsg(new Unsubscribe(new 
MessageElement[0],this.id));
-            SubscriberStore.instance().removeSubscription(this.getID());
-        }catch(Exception e){
-            e.printStackTrace();
-        }*/
+    public void setID(Object id){
+        this.m_id=(String)id;
     }
+ 
     
     public void setNotificationConsumer(NotificationConsumer consumer) {
         this.consumer = consumer;

Modified: 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/ForwardConsumer.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/eventing/ForwardConsumer.java?view=diff&r1=151641&r2=151642
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/eventing/ForwardConsumer.java 
(original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/eventing/ForwardConsumer.java 
Sun Feb  6 15:47:09 2005
@@ -18,11 +18,6 @@
 
 public class ForwardConsumer implements 
org.apache.ws.pubsub.NotificationConsumer {
     private EndpointReference epr;
-    /*
-    private Subscription s;   
-    public ForwardConsumer(Subscription s){
-        this.s=s;
-    }*/
     
     public EndpointReference getEPR(){
         return this.epr;

Modified: 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/RemoteSubscription.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/eventing/RemoteSubscription.java?view=diff&r1=151641&r2=151642
==============================================================================
--- 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/RemoteSubscription.java 
(original)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/RemoteSubscription.java 
Sun Feb  6 15:47:09 2005
@@ -15,21 +15,43 @@
  */
 package org.apache.ws.eventing;
 
+import org.apache.ws.util.uuid.UuidGenerator;
+import org.apache.ws.util.uuid.UuidGeneratorFactory;
+import org.apache.ws.resource.ResourceHome;
+import org.apache.ws.resource.ResourceKey;
+
 /**
  *
- * @author  Administrator
+ * @author  Stefan Lischke
  */
-public class RemoteSubscription extends AbstractSubscription /*implements 
org.apache.ws.resource.Resource*/{
+public class RemoteSubscription extends AbstractSubscription { 
+    private static final UuidGenerator UUID_GEN =
+            UuidGeneratorFactory.createUUIdGenerator();
     
     private org.xmlsoap.schemas.ws.x2004.x08.eventing.SubscribeDocument subdom;
+    private ResourceHome rH;
+    private ResourceKey rK; 
     
-    public 
RemoteSubscription(org.xmlsoap.schemas.ws.x2004.x08.eventing.SubscribeDocument 
subdom){
+    public 
RemoteSubscription(org.xmlsoap.schemas.ws.x2004.x08.eventing.SubscribeDocument 
subdom, ResourceHome rH){
+        m_id = UUID_GEN.generateUuid();
         this.subdom =subdom;
+        this.rH= rH;
     }
     public String getFilterString()throws Exception{
         System.out.println("getFilterString : 
"+this.subdom.getSubscribe().getFilter().newCursor().getTextValue());
         return 
this.subdom.getSubscribe().getFilter().newCursor().getTextValue();
     }        
+    public void setResourceKey(ResourceKey rK){
+        this.rK=rK;
+    }
+    public void unsubscribe(){
+        try{
+            this.rH.remove(this.rK);
+        }catch(Exception e){
+            e.printStackTrace();
+            //TODO
+        }
+    }
     
     public void destroy() {
         System.out.println("destroy");
@@ -37,10 +59,5 @@
     
     public void init() {
         System.out.println("init");
-    }
-    
-    public void setID(Object id) {
-        System.out.println("set id "+id);
-    }
-    
+    }    
 }

Added: 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/RemoteSubscriptionHome.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/eventing/RemoteSubscriptionHome.java?view=auto&rev=151642
==============================================================================
--- 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/RemoteSubscriptionHome.java
 (added)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/RemoteSubscriptionHome.java
 Sun Feb  6 15:47:09 2005
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.eventing;
+
+import org.xmlsoap.schemas.ws.x2004.x08.eventing.SubscribeDocument;
+
+import edu.berkeley.cs.db.yfilter.filter.*;
+import edu.berkeley.cs.db.yfilterplus.queryparser.*;
+import edu.berkeley.cs.db.yfilterplus.xmltree.*;
+
+import org.apache.axis.message.*;
+import org.apache.axis.utils.XMLUtils;
+
+import org.apache.ws.resource.impl.SimpleTypeResourceKey;
+import org.apache.ws.resource.*;
+import org.apache.ws.addressing.*;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.*;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.ws.util.XmlBeanUtils;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class RemoteSubscriptionHome extends 
org.apache.ws.resource.impl.AbstractResourceHome{
+    private static final Log LOG = LogFactory.getLog( 
Subscriber.class.getName() );
+    
+    private static final String SERVICE_NAME = "SubscriptionManagerPort";
+    public static final String HOME_LOCATION = 
JndiConstants.CONTEXT_NAME_SERVICES + "/" + SERVICE_NAME + "/" + 
JndiConstants.ATOMIC_NAME_HOME;
+    
+    public int c=0;
+    
+    private java.util.HashMap subs;
+    private java.util.HashMap queriesBack;
+    private String[] queries;
+    
+    EXfilterBasic yfilter;
+    
+    /** Creates a new instance of ResourceHome */
+    public RemoteSubscriptionHome() {
+        yfilter = new EXfilterBasic();
+        subs=  new java.util.HashMap();
+        queriesBack=  new java.util.HashMap();
+        queries=  new String[1000000];
+        System.out.println("ResourceHome"+this.toString());
+    }
+    
+    public org.apache.ws.resource.Resource 
getInstance(org.apache.ws.resource.ResourceContext resourceContext) throws 
org.apache.ws.resource.ResourceException, 
org.apache.ws.resource.ResourceContextException, 
org.apache.ws.resource.ResourceUnknownException {
+        System.out.println("getInstance ResourceHome");
+        return find( resourceContext.getResourceKey() );
+    }
+    
+    public RemoteSubscription create(SubscribeDocument subdom){
+        RemoteSubscription rs = new RemoteSubscription(subdom,this);
+        String id = (String) rs.getID();
+        
+        SimpleTypeResourceKey resourceKey = new SimpleTypeResourceKey( 
QName.valueOf( getResourceKeyName()), id);
+        rs.setEpr(getEPR(resourceKey));
+        rs.setResourceKey(resourceKey);
+        
+        addSubscription(rs);
+        return rs;
+    }
+    
+/*
+ *-------------------------------------------------------------------
+ */
+    
+    private void addSubscription(RemoteSubscription s){
+        try{
+            c++;
+            Query query = XPQuery.parseQuery(s.getFilterString(),c);
+            System.out.println("addSubscription "+s.getID()+" query :"+query);
+            yfilter.addQuery(query);
+            
+            s.setNotificationConsumer(new ForwardConsumer());
+            
+            subs.put(s.getID(), s);
+            queriesBack.put(s.getID(),query);
+            queries[c]=(String)s.getID();
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+    }
+    
+    public Resource find( ResourceKey key ) throws ResourceException, 
NoSuchResourceException, InvalidResourceKeyException{
+        LOG.info("find "+ key.getValue()+" have "+subs.size());
+        if(subs.containsKey(key.getValue())){
+            RemoteSubscription s = 
(RemoteSubscription)subs.get(key.getValue());
+            return s;
+        }else
+            throw new NoSuchResourceException();
+    }
+    /**
+     * Removes a resource. If the resource implements the [EMAIL PROTECTED] 
RemoveCallback RemoveCallback} interface, the
+     * implementation must invoke the remove() operation on the resource 
itself.
+     *
+     * @throws NoSuchResourceException     if no resource exists with the 
given key
+     * @throws InvalidResourceKeyException if the resource key is invalid.
+     * @throws RemoveNotSupportedException if remove operation is not 
supported.
+     * @throws ResourceException           if any other error occurs.
+     */
+    public void remove( ResourceKey key ) throws ResourceException, 
NoSuchResourceException, InvalidResourceKeyException, 
RemoveNotSupportedException{
+        System.out.println("removeSubscription : "+key.getValue());
+        Query q=(Query)queriesBack.get(key.getValue());
+        yfilter.deleteQuery(q,q.getQueryId());
+        //TODO remove from Hashmap
+    }
+    
+    public void notify(Object message) {
+        org.apache.axis.message.SOAPEnvelope env = 
(org.apache.axis.message.SOAPEnvelope)message;
+        //first check dialect
+        try{
+            System.out.println("Notify: ");
+            String xml =XMLUtils.ElementToString(env.getBody());
+            System.out.println("--"+xml+"--");
+            //copy
+            
+            //first parse and drive YFilter,
+            XMLTree tree = new XMLTree(new java.io.StringReader(xml));
+            yfilter.setEventSequence(tree.getEvents());
+            yfilter.startParsing();
+            //xfilterTest.startParsing(xmlFile);
+            
+            // print the matched queries //
+            if (SystemGlobals.hasQueries) {
+                yfilter.printQueryResults(System.out);
+            }else{
+                System.out.println("no match");
+            }
+            //get matches
+            java.util.Iterator it= yfilter.getMatchedQueries().iterator();
+            while(it.hasNext()){
+                Integer qid = (Integer) it.next();
+                String sid = queries[qid.intValue()];
+                RemoteSubscription s = 
(RemoteSubscription)(RemoteSubscription)subs.get(sid);
+                //notify matches
+                System.out.println("notify : "+sid);
+                s.getNotificationConsumer().notify(s,message);
+            }
+            yfilter.clear();
+            
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+    }
+    public EndpointReference getEPR( ResourceKey resourceKey) {
+        //TODO !!!!! woher kommt publisher epr url ???
+        String subscriptionAddress = 
"http://localhost:8080/axis/services/SubscriptionManagerPort";;
+        
+        EndpointReferenceDocument eprDoc = 
EndpointReferenceDocument.Factory.newInstance();
+        EndpointReferenceType epr = eprDoc.addNewEndpointReference();
+        AttributedURI address = epr.addNewAddress();
+        address.setStringValue( subscriptionAddress );
+        // TODO: set portType and serviceName! (read from config file)
+        ReferencePropertiesType refProps = epr.addNewReferenceProperties();
+        
+        XmlObject xmlObject = XmlBeanUtils.addChildElement( refProps, 
resourceKey.getName() );
+        XmlCursor xmlCursor = xmlObject.newCursor();
+        xmlCursor.setTextValue(resourceKey.getValue().toString());
+        xmlCursor.dispose();
+        return new XmlBeansEndpointReference(epr);
+    }
+}

Modified: incubator/hermes/trunk/src/java/org/apache/ws/eventing/Subscriber.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/eventing/Subscriber.java?view=diff&r1=151641&r2=151642
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/eventing/Subscriber.java 
(original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/eventing/Subscriber.java Sun 
Feb  6 15:47:09 2005
@@ -34,29 +34,63 @@
 import org.apache.axis.AxisProperties;
 import org.apache.axis.configuration.EngineConfigurationFactoryDefault;
 import java.util.Calendar;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.ws.util.jndi.XmlBeanJndiUtils;
+
+import org.xmlsoap.schemas.soap.envelope.EnvelopeDocument;
+
 public class Subscriber implements NotificationProducer {
-//    private EventSource es;
+   /**
+    * DOCUMENT_ME
+    */
+   private static final Log LOG = LogFactory.getLog( 
Subscriber.class.getName() );
+    
     private EndpointReference epr;
-    private SubscriberStore store;
+    private SubscriptionHome sH;
+    //    private SubscriberStore store;
     
     public Subscriber(String url){
         //Axis stuff to enable Addressing HandlerChain
         
AxisProperties.setProperty(EngineConfigurationFactoryDefault.OPTION_CLIENT_CONFIG_FILE,"/org/apache/ws/eventing/client-config.wsdd");
    
         try{
-//            SubscriberServiceLocator pubsubwsLoc = new 
SubscriberServiceLocator(new 
FileProvider("org/apache/ws/eventing/client-config.wsdd"));
+            //read jndi-config.xml
+            init();
+            
+            //create EPR TODO clean
             org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType 
e = 
org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType.Factory.newInstance();
             org.xmlsoap.schemas.ws.x2004.x08.addressing.AttributedURI auri = 
org.xmlsoap.schemas.ws.x2004.x08.addressing.AttributedURI.Factory.newInstance();
 
             auri.setStringValue(url);
             e.setAddress(auri);    
             //wrapper
             this.epr= new XmlBeansEndpointReference(e); 
-        
-            store= SubscriberStore.instance();
+
+            //getlocal SubscriptionHome from jndi-config
+            Context initialContext = new InitialContext(  );
+            System.out.println("get SubscriptionHome " + 
SubscriptionHome.HOME_LOCATION);
+            sH = (SubscriptionHome) initialContext.lookup( 
SubscriptionHome.HOME_LOCATION );
+
         }catch (Exception e){
             e.printStackTrace();
         }      
     }
-
+   /**
+    * runs resource discovery.
+    *
+    */
+   public void init()
+         throws Exception
+   {
+         LOG.info(this.getClass().getName()+" : initialize with 
jndi-config.xml");
+         
XmlBeanJndiUtils.initializeFromInputStream(Thread.currentThread().getContextClassLoader().getResourceAsStream(XmlBeanJndiUtils.JNDI_CONFIG_FILENAME));
+   }
+   
+   //TODO
     public Object getCurrentMessage(org.apache.ws.pubsub.Filter[] filters) {
         return null;
     }
@@ -83,7 +117,7 @@
             filter.setDialect(uri.toString());
         filter.newCursor().setTextValue((String)filters[0].getExpression());
 
-        
+        SubscribeResponseDocument.SubscribeResponse sresres=null;
         try{
             //now call 
             wsaSOAPConnection sconn = wsaSOAPConnection.newInstance();
@@ -91,29 +125,32 @@
             SOAPMessage soapm = mf.createMessage();
             //put XMLbean into SOAPBody
             soapm.getSOAPBody().addDocument((org.w3c.dom.Document) 
sdom.newDomNode());
-            SOAPMessage subscribeResponse = sconn.call(soapm, epr);
+            SOAPMessage subscribeResponse = sconn.call(soapm, 
epr.getAddress().toString());
+            java.io.ByteArrayOutputStream os = new 
java.io.ByteArrayOutputStream();
+            subscribeResponse.writeTo(os);
+            EnvelopeDocument sres = EnvelopeDocument.Factory.parse(new 
java.io.ByteArrayInputStream(os.toByteArray()));
 
-            SubscribeResponseDocument.SubscribeResponse sres = 
SubscribeResponseDocument.SubscribeResponse.Factory.newInstance();
-//            sres.
-//            subscribeResponse.getSOAPBody().get
-        }catch(javax.xml.soap.SOAPException e){
+            //extract SubscribeResponse from SOAPBody
+            /*SubscribeResponseDocument sresdom = 
SubscribeResponseDocument.Factory.newInstance();
+            sresres= sresdom.addNewSubscribeResponse();
+            sresres.set(sres.getEnvelope().getBody());
+             */
+            SubscribeResponseDocument sresdom = 
SubscribeResponseDocument.Factory.parse(sres.getEnvelope().getBody().xmlText());
+            sresres= sresdom.getSubscribeResponse();
+        }catch(Exception e){
             e.printStackTrace();
         }
+
         //create local Subscription
-        org.apache.ws.eventing.Subscription ls = new 
org.apache.ws.eventing.Subscription();
+        //add to local SubscriptionHome
+        //create ID         
+        org.apache.ws.eventing.Subscription ls = this.sH.create(sresres); 
         ls.setNotificationConsumer(notificationConsumer);
-        
-        //TODO set SubscriptionID from subscribeResponse
-        
-        //add to local store
-        store.addSubscription(ls);
-        return ls;
-        
+              
+        return ls;        
     }
     
     public EndpointReference getEPR() {
         return epr;
     }
-    
-    
 }

Modified: 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/Subscription.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/eventing/Subscription.java?view=diff&r1=151641&r2=151642
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/eventing/Subscription.java 
(original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/eventing/Subscription.java 
Sun Feb  6 15:47:09 2005
@@ -14,15 +14,59 @@
  * limitations under the License.
  */
 package org.apache.ws.eventing;
+import org.xmlsoap.schemas.ws.x2004.x08.eventing.SubscribeResponseDocument;
+import org.xmlsoap.schemas.ws.x2004.x08.eventing.UnsubscribeDocument;
+import 
org.xmlsoap.schemas.ws.x2004.x08.eventing.UnsubscribeDocument.Unsubscribe;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
+import org.apache.xmlbeans.XmlCursor;
+
+import javax.xml.soap.*;
 /**
  *
- * @author  Administrator
+ * @author  Stefan Lischke
  */
 public class Subscription extends AbstractSubscription{
+    private static final Log LOG = LogFactory.getLog( 
Subscriber.class.getName() );
+    
+    private EndpointReferenceType sMan;
     
     /** Creates a new instance of Subscription */
-    public Subscription() {
+    public Subscription(SubscribeResponseDocument.SubscribeResponse sresdom) {
+      sMan = sresdom.getSubscriptionManager();
+      //get id with XmlCursor;
+      XmlCursor xc = sMan.getReferenceProperties().newCursor(); 
+      
xc.toChild("http://schemas.xmlsoap.org/ws/2004/08/eventing","Identifier";);
+      setID(xc.getTextValue());
+      if(getID()==null)
+          throw new RuntimeException("There is no Subscription Id");
+      LOG.info("new local Subscription : "+getID());
+    }
+    
+    public void unsubscribe(){
+        UnsubscribeDocument usdom= UnsubscribeDocument.Factory.newInstance();
+        UnsubscribeDocument.Unsubscribe us = usdom.addNewUnsubscribe();
+        try{
+            //now call 
+            wsaSOAPConnection sconn = wsaSOAPConnection.newInstance();
+            MessageFactory mf = MessageFactory.newInstance();
+            SOAPMessage soapm = mf.createMessage();
+            //put XMLbean into SOAPBody
+            soapm.getSOAPBody().addDocument((org.w3c.dom.Document) 
usdom.newDomNode());
+            
+            sconn.call(soapm,sMan.getAddress().getStringValue(),(String) 
getID());
+        }catch(Exception e){
+            e.printStackTrace();
+        }            
+    }
+    
+    public void destroy() {
+        System.out.println("local destroy");
     }
     
+    public void init() {
+        System.out.println("local init");
+    }  
 }

Added: 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/SubscriptionHome.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/eventing/SubscriptionHome.java?view=auto&rev=151642
==============================================================================
--- 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/SubscriptionHome.java 
(added)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/SubscriptionHome.java 
Sun Feb  6 15:47:09 2005
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ws.eventing;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xmlsoap.schemas.ws.x2004.x08.eventing.SubscribeResponseDocument;
+
+import org.apache.ws.resource.JndiConstants;
+import org.apache.ws.resource.impl.SimpleTypeResourceKey;
+
+import javax.xml.namespace.QName;
+/**
+ *
+ * @author  Stefan Lischke
+ */
+public class SubscriptionHome extends 
org.apache.ws.resource.impl.AbstractResourceHome {
+    private static final String SERVICE_NAME = "NotificationPort";
+    public static final String HOME_LOCATION = 
JndiConstants.CONTEXT_NAME_SERVICES + "/" + SERVICE_NAME + "/" + 
JndiConstants.ATOMIC_NAME_HOME;
+    
+    private java.util.HashMap subs;
+    
+    public SubscriptionHome() {
+        System.out.println("local SubscriptionHome "+this.toString());        
+        subs=  new java.util.HashMap();
+    }  
+    
+    public Subscription create(SubscribeResponseDocument.SubscribeResponse 
sresdom){
+        Subscription s = new Subscription(sresdom); 
+        String id = (String) s.getID();
+
+        SimpleTypeResourceKey resourceKey = new SimpleTypeResourceKey( 
QName.valueOf( getResourceKeyName()), id);
+        add(resourceKey,s);
+        return s;
+    }
+    public String addSubscription(org.apache.ws.pubsub.Subscription ss) {
+        Subscription s = (Subscription)ss;
+        subs.put(s.getID(),s);
+        return(s.getID().toString());
+    }
+    
+    public org.apache.ws.pubsub.Subscription getSubscription(String id) {
+        if(subs.containsKey(id)){
+            Subscription s = (Subscription)subs.get(id);
+            return s;
+        }else
+            return null;//    throw new RuntimeException("Cannot find 
Subscription with id "+id);
+        
+    }
+    
+    public void notify(Object message) {
+        org.apache.axis.message.SOAPEnvelope env = 
(org.apache.axis.message.SOAPEnvelope)message;
+        String id;
+        try{
+            javax.xml.soap.SOAPHeader h = env.getHeader();
+            NodeList it = 
h.getElementsByTagNameNS("http://schemas.xmlsoap.org/ws/2004/08/eventing";, 
"Identifier");
+            if(it.getLength()==0)
+                throw new javax.xml.soap.SOAPException("<wse:Identifier> Tag 
is missing in the Header.... i dunno which Subscription you mean");
+            Node idnode = it.item(0);
+            
if((idnode.getFirstChild()!=null)&&(idnode.getFirstChild().getNodeType()==Node.TEXT_NODE))
+                id = idnode.getFirstChild().getNodeValue();
+            else
+                throw new javax.xml.soap.SOAPException("<wse:Identifier> Tag 
is empty in the Header.... i dunno which Subscription you mean");
+            
+            //check ResourceProperties for SubscriptionID
+            
+            System.out.println("SubscriberStore notify "+id);
+            org.apache.ws.pubsub.Subscription s = getSubscription(id);
+            if(s!=null)
+                s.getNotificationConsumer().notify(s,message);
+        }catch(javax.xml.soap.SOAPException e){
+            e.printStackTrace();
+        }
+    }
+    
+    public void removeSubscription(String id) {
+        subs.remove(id);
+    }
+    
+    public org.apache.ws.resource.Resource 
getInstance(org.apache.ws.resource.ResourceContext resourceContext) throws 
org.apache.ws.resource.ResourceException, 
org.apache.ws.resource.ResourceContextException, 
org.apache.ws.resource.ResourceUnknownException {
+        System.out.println("local SubscriptionHome getInstance");
+        return null;
+    }
+    
+}

Added: 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/JettyBroker.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/JettyBroker.java?view=auto&rev=151642
==============================================================================
--- 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/JettyBroker.java
 (added)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/JettyBroker.java
 Sun Feb  6 15:47:09 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.eventing.app.broker;
+
+import org.apache.ws.eventing.app.JettyAxisServer;
+
+public class JettyBroker {
+    
+    /** Creates a new instance of JettyBroker */
+    public JettyBroker(String hermes_home) {
+//        String hermes_home= System.getProperty("HERMES_HOME");
+        if(hermes_home==null){
+            System.out.println("HERMES_HOME not set");
+        }else{
+            try{
+                JettyAxisServer jas = new JettyAxisServer();
+                jas.setPort(8080);
+                
jas.setResourceBase(hermes_home+"/trunk/src/java/org/apache/ws/eventing/app/broker");
+                jas.start();
+                
+                System.out.println("JAS started"+jas.log.toString());
+            }catch(Exception e){
+                e.printStackTrace();
+            }}
+    }
+    
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        JettyBroker jB = new JettyBroker("d:\\projects\\hermes");
+    }
+    
+}

Added: 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/WEB-INF/server-config.wsdd
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/WEB-INF/server-config.wsdd?view=auto&rev=151642
==============================================================================
--- 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/WEB-INF/server-config.wsdd
 (added)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/broker/WEB-INF/server-config.wsdd
 Sun Feb  6 15:47:09 2005
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="http://xml.apache.org/axis/wsdd/"; 
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>
+ <globalConfiguration>
+  <parameter name="adminPassword" value="admin"/>
+  <parameter name="disablePrettyXML" value="true"/>
+  <parameter name="sendXsiTypes" value="true"/>
+  <parameter name="sendMultiRefs" value="true"/>
+  <parameter name="sendXMLDeclaration" value="true"/>
+  <requestFlow>
+   <handler 
type="java:org.apache.axis.message.addressing.handler.AddressingHandler"/>
+  </requestFlow>
+  <responseFlow>
+   <handler 
type="java:org.apache.axis.message.addressing.handler.AddressingHandler"/>
+  </responseFlow>
+ </globalConfiguration>
+ <handler name="LocalResponder" 
type="java:org.apache.axis.transport.local.LocalResponder"/>
+ <handler name="URLMapper" 
type="java:org.apache.axis.handlers.http.URLMapper"/>
+ <handler name="Authenticate" 
type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
+
+ <service name="AdminService" provider="java:MSG">
+  <parameter name="allowedMethods" value="AdminService"/>
+  <parameter name="enableRemoteAdmin" value="false"/>
+  <parameter name="className" value="org.apache.axis.utils.Admin"/>
+  <namespace>http://xml.apache.org/axis/wsdd/</namespace>
+  <namespace>http://xml.apache.org/axis/wsdd/</namespace>
+ </service>
+
+ <service name="Version" provider="java:RPC">
+  <parameter name="allowedMethods" value="getVersion"/>
+  <parameter name="className" value="org.apache.axis.Version"/>
+ </service>
+
+ <service name="EventSourcePort" provider="java:WSRF" style="document" 
use="literal">
+<!--  
+      <wsdlFile>/wsdl/SubscriptionManager.wsdl</wsdlFile>      
+      <parameter name="wsdlTargetNamespace" 
value="http://schemas.xmlsoap.org/ws/2004/08/eventing/services"/>
+      <parameter name="wsdlServiceElement" value="EventingService"/>
+      <parameter name="wsdlServicePort" value="EventSourcePort"/>
+
+    <parameter name="className" 
value="org.apache.ws.eventing.services.publisher.EventSourceBindingSkeleton"/>
+      <parameter name="wsdlPortType" value="EventSource"/>
+      <parameter name="allowedMethods" value="*"/>
+-->
+</service>
+
+ <service name="SubscriptionManagerPort" provider="java:WSRF" style="document" 
use="literal">
+<!--
+      <parameter name="wsdlTargetNamespace" 
value="http://schemas.xmlsoap.org/ws/2004/08/eventing/services"/>
+      <parameter name="wsdlServiceElement" value="EventingService"/>
+      <parameter name="wsdlServicePort" value="SubscriptionManagerPort"/>
+
+<parameter name="className" 
value="org.apache.ws.eventing.services.publisher.SubscriptionManagerBindingSkeleton"/>
+      <parameter name="wsdlPortType" value="SubscriptionManager"/>
+      <parameter name="allowedMethods" value="*"/>
+-->
+
+</service>
+
+ <service name="SubscriptionEndPort" provider="java:WSRF" style="document" 
use="literal">
+ <!--
+  <parameter name="allowedMethods" value="*"/>
+  <parameter name="wsdlPortType" value="SubscriptionEnd"/>
+ <parameter name="className" 
value="org.apache.ws.eventing.services.subscriber.SubscriptionEndPort"/>
+ <parameter name="wsdlServicePort" value="SubscriptionEndPort"/>
+  <parameter name="wsdlTargetNamespace" 
value="http://schemas.xmlsoap.org/ws/2004/08/eventing/services"/>
+  <parameter name="wsdlServiceElement" value="EventingService"/>
+ -->
+</service>
+
+ <service name="NotificationPort" provider="java:MSG" style="message" 
use="literal">
+  <parameter name="allowedMethods" value="filter"/>
+  <parameter name="wsdlPortType" value="Notification"/>
+  <parameter name="className" 
value="org.apache.ws.eventing.services.NotificationPort"/>
+  <parameter name="wsdlServicePort" value="NotificationPort"/>
+  <parameter name="wsdlTargetNamespace" 
value="http://schemas.xmlsoap.org/ws/2004/08/eventing/services"/>
+  <parameter name="wsdlServiceElement" value="NotificationService"/>
+ </service>
+
+ <transport name="http">
+  <requestFlow>
+   <handler type="URLMapper"/>
+   <handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
+  </requestFlow>
+  <parameter name="qs:list" 
value="org.apache.axis.transport.http.QSListHandler"/>
+  <parameter name="qs:wsdl" 
value="org.apache.axis.transport.http.QSWSDLHandler"/>
+  <parameter name="qs.list" 
value="org.apache.axis.transport.http.QSListHandler"/>
+  <parameter name="qs.method" 
value="org.apache.axis.transport.http.QSMethodHandler"/>
+  <parameter name="qs:method" 
value="org.apache.axis.transport.http.QSMethodHandler"/>
+  <parameter name="qs.wsdl" 
value="org.apache.axis.transport.http.QSWSDLHandler"/>
+ </transport>
+ <transport name="local">
+  <responseFlow>
+   <handler type="LocalResponder"/>
+  </responseFlow>
+ </transport>
+</deployment>

Added: 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/PopUpConsumer.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/PopUpConsumer.java?view=auto&rev=151642
==============================================================================
--- 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/PopUpConsumer.java
 (added)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/eventing/app/client/PopUpConsumer.java
 Sun Feb  6 15:47:09 2005
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ws.eventing.app.client;
+
+/**
+ *
+ * @author  Stefan Lischke
+ */
+
+
+public class PopUpConsumer extends org.apache.ws.eventing.EchoConsumer{
+    SubListModel comp;
+    /** Creates a new instance of PopUpConsumer */
+    public PopUpConsumer(String epr,SubListModel comp) throws Exception{
+        super(epr);
+        this.comp=comp;
+    }
+    public void notify(org.apache.ws.pubsub.Subscription subscription, Object 
message ){
+        try{
+            javax.xml.soap.SOAPEnvelope 
env=(javax.xml.soap.SOAPEnvelope)message;
+            System.out.println("-- got notification --");
+            System.out.println(env.toString());
+            comp.addData(new 
notentry(((org.apache.ws.eventing.Subscription)subscription).getID().toString(),message));
+            //             JWindow wind = new JWindow();
+            //             wind.add(new 
java.awt.Label(((org.apache.ws.eventing.Subscription)subscription).getID()+" 
"+env.toString()));
+            //             wind.show();
+            
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+    }
+}
+class notentry{
+    public String id;
+    public String content;
+    public notentry(String id, Object message)throws Exception{
+        this.id=id;
+        
this.content=((org.apache.axis.message.SOAPEnvelope)message).getBody().toString();
+    }
+    
+    public String toString(){
+        return id;//+" "+content;
+    }
+    
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to