Author: heiko.braun(a)jboss.com
Date: 2007-09-03 05:31:45 -0400 (Mon, 03 Sep 2007)
New Revision: 4510
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/EventSink.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/EventSinkIF.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SystemStatus.java
stack/native/trunk/src/test/resources/jaxws/samples/wseventing/Readme.txt
Modified:
stack/native/trunk/ant-import-tests/build-samples-jaxws.xml
stack/native/trunk/src/main/java/org/jboss/ws/extensions/eventing/mgmt/Subscription.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SysmonTestCase.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SysmonUtil.java
stack/native/trunk/src/test/resources/jaxws/samples/wseventing/WEB-INF/wsdl/sysmon.wsdl
Log:
Extend eventing samples suing a local EJB3 web service as event sink
Modified: stack/native/trunk/ant-import-tests/build-samples-jaxws.xml
===================================================================
--- stack/native/trunk/ant-import-tests/build-samples-jaxws.xml 2007-08-31 15:48:18 UTC
(rev 4509)
+++ stack/native/trunk/ant-import-tests/build-samples-jaxws.xml 2007-09-03 09:31:45 UTC
(rev 4510)
@@ -120,7 +120,7 @@
<!-- jaxws-samples-wseventing.war -->
<war warfile="${tests.output.dir}/libs/jaxws-samples-wseventing.war"
webxml="${tests.output.dir}/resources/jaxws/samples/wseventing/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/classes">
- <include
name="org/jboss/test/ws/jaxws/samples/wseventing/*.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wseventing/Sysmon**.class"/>
</classes>
<webinf
dir="${tests.output.dir}/resources/jaxws/samples/wseventing/WEB-INF">
<include name="wsdl/jboss-web.xml"/>
@@ -130,6 +130,13 @@
<include name="wsdl/ws-addr.xsd"/>
</webinf>
</war>
+
+ <jar
destfile="${tests.output.dir}/libs/jaxws-samples-wseventing-sink.jar">
+ <fileset dir="${tests.output.dir}/classes">
+ <include
name="org/jboss/test/ws/jaxws/samples/wseventing/EventSink*.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wseventing/SystemStatus.class"/>
+ </fileset>
+ </jar>
<!-- jaxws-samples-wssecurity-encrypt -->
<war
warfile="${tests.output.dir}/libs/jaxws-samples-wssecurity-encrypt.war"
webxml="${tests.output.dir}/resources/jaxws/samples/wssecurity/WEB-INF/web.xml">
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/eventing/mgmt/Subscription.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/eventing/mgmt/Subscription.java 2007-08-31
15:48:18 UTC (rev 4509)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/eventing/mgmt/Subscription.java 2007-09-03
09:31:45 UTC (rev 4510)
@@ -41,6 +41,7 @@
import org.jboss.ws.extensions.eventing.EventingConstants;
import org.jboss.ws.extensions.eventing.jaxws.AttributedURIType;
import org.jboss.ws.extensions.eventing.jaxws.EndpointReferenceType;
+import org.jboss.ws.Constants;
import org.jboss.wsf.common.DOMWriter;
import org.w3c.dom.Element;
@@ -84,7 +85,7 @@
// notification elements need to declare their namespace locally
StringBuilder sb = new StringBuilder();
- sb.append("<env:Envelope
xmlns:env='http://www.w3.org/2003/05/soap-envelope' ");
+ sb.append("<env:Envelope xmlns:env='"+
Constants.NS_SOAP11_ENV+"' ");
sb.append("xmlns:wse='").append(EventingConstants.NS_EVENTING).append("'
");
sb.append("xmlns:wsa='").append(EventingConstants.NS_ADDRESSING).append("'>");
sb.append("<env:Header>");
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/EventSink.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/EventSink.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/EventSink.java 2007-09-03
09:31:45 UTC (rev 4510)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.wseventing;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+@Stateless
+@WebService(name = "SampleEventSink", targetNamespace =
"http://www.jboss.org/sysmon", endpointInterface =
"org.jboss.test.ws.jaxws.samples.wseventing.EventSinkIF")
+public class EventSink implements EventSinkIF
+{
+
+ public void newNotification(SystemStatus status)
+ {
+ System.out.println("Recv new notification: " + status);
+ }
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/EventSink.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/EventSinkIF.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/EventSinkIF.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/EventSinkIF.java 2007-09-03
09:31:45 UTC (rev 4510)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.wseventing;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.ejb.Remote;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+@Remote
+@WebService(name = "SampleEventSink", targetNamespace =
"http://www.jboss.org/sysmon")
+public interface EventSinkIF
+{
+ @WebMethod
+ void newNotification(SystemStatus status);
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/EventSinkIF.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SysmonTestCase.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SysmonTestCase.java 2007-08-31
15:48:18 UTC (rev 4509)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SysmonTestCase.java 2007-09-03
09:31:45 UTC (rev 4510)
@@ -26,17 +26,20 @@
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.URI;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
import javax.xml.ws.addressing.AddressingProperties;
+import javax.naming.InitialContext;
import junit.framework.Test;
import org.jboss.ws.core.StubExt;
import org.jboss.ws.extensions.addressing.AddressingClientUtil;
import org.jboss.ws.extensions.eventing.EventingConstants;
+import org.jboss.ws.extensions.eventing.mgmt.EventDispatcher;
import org.jboss.ws.extensions.eventing.jaxws.DeliveryType;
import org.jboss.ws.extensions.eventing.jaxws.EventSourceEndpoint;
import org.jboss.ws.extensions.eventing.jaxws.FilterType;
@@ -47,6 +50,8 @@
import org.jboss.ws.extensions.eventing.jaxws.Unsubscribe;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestSetup;
+import org.jboss.wsf.common.DOMUtils;
+import org.w3c.dom.Element;
/**
* Test the eventing example service.
@@ -68,7 +73,7 @@
public static Test suite()
{
- return new JBossWSTestSetup(SysmonTestCase.class,
"jaxws-samples-wseventing.war");
+ return new JBossWSTestSetup(SysmonTestCase.class,
"jaxws-samples-wseventing.war, jaxws-samples-wseventing-sink.jar");
}
protected void setUp() throws Exception
@@ -158,4 +163,36 @@
return subscriptionTicket;
}
+
+ public void testNotification() throws Exception {
+
+ SubscribeResponse response =
doSubscribe("/SystemStatus/HostName/text()='localhost'");
+ assertNotNull(response);
+
+ String notification =
+ "<sys:newNotification
xmlns:sys=\"http://www.jboss.org/sysmon\">" +
+ " <arg0>" +
+ " <activeThreadCount>12</activeThreadCount>" +
+ " <freeMemory>60000</freeMemory>" +
+ " <hostAddress>localhost</hostAddress>" +
+ " <hostname>bigben</hostname>" +
+ " <maxMemory>120000</maxMemory>" +
+ " <time>2001-10-26T21:32:52</time>" +
+ " </arg0>" +
+ " </sys:newNotification>";
+
+ Element payload = DOMUtils.parse(notification);
+ try
+ {
+ InitialContext iniCtx = getInitialContext();
+ EventDispatcher delegate = (EventDispatcher)
+ iniCtx.lookup(EventingConstants.DISPATCHER_JNDI_NAME);
+ delegate.dispatch(new
URI("http://www.jboss.org/sysmon/SystemInfo"),
payload);
+ Thread.sleep(3000);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ }
}
Modified:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SysmonUtil.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SysmonUtil.java 2007-08-31
15:48:18 UTC (rev 4509)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SysmonUtil.java 2007-09-03
09:31:45 UTC (rev 4510)
@@ -101,7 +101,7 @@
delivery.setMode(EventingConstants.getDeliveryPush().toString());
EndpointReferenceType notifyEPR = new EndpointReferenceType();
AttributedURIType attURI = new AttributedURIType();
- attURI.setValue("http://jboss.org");
+
attURI.setValue("http://localhost:8080/jaxws-samples-wseventing-sink/EventSink");
notifyEPR.setAddress(attURI);
delivery.setNotifyTo(notifyEPR);
return delivery;
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SystemStatus.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SystemStatus.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SystemStatus.java 2007-09-03
09:31:45 UTC (rev 4510)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.wseventing;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Date;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+@XmlRootElement(name="SystemStatus", namespace =
"http://www.jboss.org/sysmon")
+public class SystemStatus
+{
+ private Date time;
+ private String hostname;
+ private String hostAddress;
+ private int activeThreadCount;
+ private String freeMemory;
+ private String maxMemory;
+
+
+ public Date getTime()
+ {
+ return time;
+ }
+
+ public void setTime(Date time)
+ {
+ this.time = time;
+ }
+
+ public String getHostname()
+ {
+ return hostname;
+ }
+
+ public void setHostname(String hostname)
+ {
+ this.hostname = hostname;
+ }
+
+ public String getHostAddress()
+ {
+ return hostAddress;
+ }
+
+ public void setHostAddress(String hostAddress)
+ {
+ this.hostAddress = hostAddress;
+ }
+
+ public int getActiveThreadCount()
+ {
+ return activeThreadCount;
+ }
+
+ public void setActiveThreadCount(int activeThreadCount)
+ {
+ this.activeThreadCount = activeThreadCount;
+ }
+
+ public String getFreeMemory()
+ {
+ return freeMemory;
+ }
+
+ public void setFreeMemory(String freeMemory)
+ {
+ this.freeMemory = freeMemory;
+ }
+
+ public String getMaxMemory()
+ {
+ return maxMemory;
+ }
+
+ public void setMaxMemory(String maxMemory)
+ {
+ this.maxMemory = maxMemory;
+ }
+
+
+ public String toString()
+ {
+ return "SystemStatus {hostname="+hostname+",
freeMemory="+freeMemory+"}";
+ }
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wseventing/SystemStatus.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/src/test/resources/jaxws/samples/wseventing/Readme.txt
===================================================================
--- stack/native/trunk/src/test/resources/jaxws/samples/wseventing/Readme.txt
(rev 0)
+++ stack/native/trunk/src/test/resources/jaxws/samples/wseventing/Readme.txt 2007-09-03
09:31:45 UTC (rev 4510)
@@ -0,0 +1,31 @@
+A few things that are not so obvious when working with eventing:
+
+1.) In order to dispatch you'll need to know the wsa:Action the EventSink listens
on.
+ It's required to build the wse:Delivery EPR.
+ The WS-Eventing impl. actualy uses a naming convention:
+ It takes the EventSourceNS and appends "/Notification" to it, i.e:
+
+ EventDispatcher delegate = (EventDispatcher)
iniCtx.lookup(EventingConstants.DISPATCHER_JNDI_NAME);
+ delegate.dispatch(new
URI("http://www.jboss.org/sysmon/SystemInfo"),
payload);
+
+2.) Where do it get the EventSourceNS from?
+ Answer: There is an MBean in place that allows browsing of the registered
EventSources:
+
+ jboss.ws:service=SubscriptionManager,module=eventing
+
+ The 'showEventsourceTable()' dumps the EventSource names and namespaces.
+
+3.) I'll dispatch but never receive it at the sink.
+ Answer: You are probably using the wrong wse:Delivery EPR.
+ Take a look at the sample test case. The EPR is build like this:
+
+ EndpointReferenceType notifyEPR = new EndpointReferenceType();
+ AttributedURIType attURI = new AttributedURIType();
+
attURI.setValue("http://localhost:8080/jaxws-samples-wseventing-sink/EventSink");
+ notifyEPR.setAddress(attURI);
+ delivery.setNotifyTo(notifyEPR);
+
+ Whereas 'http://localhost:8080/jaxws-samples-wseventing-sink/EventSink' is
the event sink address
+ that's deployed as an EJB3 web service.
+
+
\ No newline at end of file
Property changes on:
stack/native/trunk/src/test/resources/jaxws/samples/wseventing/Readme.txt
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/native/trunk/src/test/resources/jaxws/samples/wseventing/WEB-INF/wsdl/sysmon.wsdl
===================================================================
---
stack/native/trunk/src/test/resources/jaxws/samples/wseventing/WEB-INF/wsdl/sysmon.wsdl 2007-08-31
15:48:18 UTC (rev 4509)
+++
stack/native/trunk/src/test/resources/jaxws/samples/wseventing/WEB-INF/wsdl/sysmon.wsdl 2007-09-03
09:31:45 UTC (rev 4510)
@@ -19,30 +19,37 @@
<xs:include schemaLocation='ws-eventing.xsd'/>
</xs:schema>
- <xs:schema
-
targetNamespace="http://www.jboss.org/sysmon"
- elementFormDefault="qualified"
- blockDefault="#all">
+ <!--
+ Take a look at the WSDL from EventSink enedpoint, that get's deployed.
+ The schema is taken from there.
+ -->
+ <xs:schema
targetNamespace='http://www.jboss.org/sysmon'
version='1.0'
xmlns:tns='http://www.jboss.org/sysmon'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+ <xs:element name='SystemStatus' type='tns:systemStatus'/>
+ <xs:element name='newNotification'
type='tns:newNotification'/>
- <xs:element name="SystemStatus">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="Time "
type="xs:dateTime"/>
- <xs:element name="HostName"
type="xs:string"/>
- <xs:element name="HostAddress"
type="xs:string"/>
- <xs:element name="ActiveThreadCount"
type="xs:int"/>
- <xs:element name="FreeMemory"
type="xs:string"/>
- <xs:element name="MaxMemory"
type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- </xs:schema>
+ <xs:complexType name='newNotification'>
+ <xs:sequence>
+ <xs:element minOccurs='0' name='arg0'
type='tns:systemStatus'/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name='systemStatus'>
+ <xs:sequence>
+ <xs:element name='activeThreadCount' type='xs:int'/>
+ <xs:element minOccurs='0' name='freeMemory'
type='xs:string'/>
+ <xs:element minOccurs='0' name='hostAddress'
type='xs:string'/>
+ <xs:element minOccurs='0' name='hostname'
type='xs:string'/>
+ <xs:element minOccurs='0' name='maxMemory'
type='xs:string'/>
+
+ <xs:element minOccurs='0' name='time'
type='xs:dateTime'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+
</wsdl:types>
<wsdl:message name='SystemInfoMsg'>
- <wsdl:part name='body' element='tns:SystemStatus'/>
+ <wsdl:part name='body' element='tns:newNotification'/>
</wsdl:message>
<wsdl:portType name='SystemInfo' wse:EventSource='true'>