Author: ngallardo
Date: Mon Apr 16 13:34:36 2007
New Revision: 529388
URL: http://svn.apache.org/viewvc?view=rev&rev=529388
Log:
AXIS2-2539
Some initial support for the publish() API.
Added:
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java?view=diff&rev=529388&r1=529387&r2=529388
==============================================================================
---
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java
(original)
+++
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java
Mon Apr 16 13:34:36 2007
@@ -18,36 +18,62 @@
*/
package org.apache.axis2.jaxws.server.endpoint;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.binding.BindingImpl;
+import org.apache.axis2.jaxws.description.DescriptionFactory;
import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.transport.http.HTTPWorkerFactory;
+import org.apache.axis2.transport.http.server.SimpleHttpServer;
+import org.apache.axis2.transport.http.server.WorkerFactory;
import javax.xml.transform.Source;
import javax.xml.ws.Binding;
+
+import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
public class EndpointImpl extends javax.xml.ws.Endpoint {
+ private boolean published;
private Object implementor;
private EndpointDescription endpointDesc;
private Binding binding;
+ private SimpleHttpServer server;
public EndpointImpl(Object o) {
implementor = o;
initialize();
}
- public EndpointImpl(Object o, EndpointDescription ed) {
+ public EndpointImpl(Object o, Binding bnd, EndpointDescription ed) {
implementor = o;
endpointDesc = ed;
initialize();
}
private void initialize() {
+ if (implementor == null) {
+ throw ExceptionFactory.makeWebServiceException("The implementor
object cannot be null");
+ }
+
+ // If we don't have the necessary metadata, let's go ahead and
+ // create it.
+ if (endpointDesc == null) {
+ ServiceDescription sd =
DescriptionFactory.createServiceDescription(implementor.getClass());
+ endpointDesc =
sd.getEndpointDescriptions_AsCollection().iterator().next();
+ }
+
if (endpointDesc != null) {
binding = new BindingImpl(endpointDesc);
}
+
+ published = false;
}
/*
@@ -111,7 +137,7 @@
* @see javax.xml.ws.Endpoint#isPublished()
*/
public boolean isPublished() {
- return false;
+ return published;
}
/*
@@ -127,7 +153,31 @@
* @see javax.xml.ws.Endpoint#publish(java.lang.String)
*/
public void publish(String s) {
+ ConfigurationContext ctx =
endpointDesc.getServiceDescription().getAxisConfigContext();
+
+ try {
+ // For some reason the AxisService has not been added to the
ConfigurationContext
+ // at this point, so we need to do it for the service to be
available.
+ AxisService svc = endpointDesc.getAxisService();
+ ctx.getAxisConfiguration().addService(svc);
+ } catch (AxisFault e) {
+ throw ExceptionFactory.makeWebServiceException(e);
+ }
+
+ // Remove the default "axis2" context root.
+ ctx.setContextRoot("/");
+
+ WorkerFactory wf = new HTTPWorkerFactory();
+
+ try {
+ server = new SimpleHttpServer(ctx, wf, 8080); //TODO: Add a
configurable port
+ server.init();
+ server.start();
+ } catch (IOException e) {
+ throw ExceptionFactory.makeWebServiceException(e);
+ }
+ published = true;
}
/*
@@ -143,7 +193,12 @@
* @see javax.xml.ws.Endpoint#stop()
*/
public void stop() {
-
+ try {
+ server.destroy();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
}
-
}
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
URL:
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java?view=diff&rev=529388&r1=529387&r2=529388
==============================================================================
---
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
(original)
+++
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
Mon Apr 16 13:34:36 2007
@@ -21,6 +21,9 @@
import javax.xml.namespace.QName;
import javax.xml.ws.Endpoint;
import javax.xml.ws.spi.ServiceDelegate;
+
+import org.apache.axis2.jaxws.server.endpoint.EndpointImpl;
+
import java.net.URL;
public class Provider extends javax.xml.ws.spi.Provider {
@@ -31,9 +34,8 @@
}
@Override
- public Endpoint createEndpoint(String s, Object obj) {
- // TODO Auto-generated method stub
- return null;
+ public Endpoint createEndpoint(String binding, Object obj) {
+ return new EndpointImpl(obj);
}
@Override
Added:
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java
URL:
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java?view=auto&rev=529388
==============================================================================
---
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java
(added)
+++
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java
Mon Apr 16 13:34:36 2007
@@ -0,0 +1,45 @@
+/*
+ * 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.endpoint;
+
+import javax.jws.WebService;
+import javax.xml.ws.Endpoint;
+
+import junit.framework.TestCase;
+
+public class BasicEndpointTests extends TestCase {
+
+ public void testCreateSimpleEndpoint() {
+ SampleEndpoint sample = new SampleEndpoint();
+
+ Endpoint ep = Endpoint.create(sample);
+ assertTrue("The returned Endpoint instance was null", ep != null);
+
+ ep.publish("test");
+ assertTrue("The endpoint was not published successfully",
ep.isPublished());
+ }
+
+ @WebService
+ class SampleEndpoint {
+
+ public int foo(String bar) {
+ return bar.length();
+ }
+ }
+}
\ No newline at end of file
Modified:
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL:
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=529388&r1=529387&r2=529388
==============================================================================
---
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
(original)
+++
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
Mon Apr 16 13:34:36 2007
@@ -36,6 +36,7 @@
import org.apache.axis2.jaxws.description.WSDLTests;
import org.apache.axis2.jaxws.dispatch.DispatchTestSuite;
import org.apache.axis2.jaxws.dispatch.SOAP12Dispatch;
+import org.apache.axis2.jaxws.endpoint.BasicEndpointTests;
import org.apache.axis2.jaxws.exception.ExceptionFactoryTests;
import org.apache.axis2.jaxws.handler.HandlerChainProcessorTests;
import org.apache.axis2.jaxws.handler.context.LogicalMessageContextTests;
@@ -191,6 +192,9 @@
suite.addTestSuite(BindingProviderTests.class);
// Commented due to test failure...
// suite.addTestSuite(StringListTests.class);
+
+ // ------ Endpoint Tests ------
+ suite.addTestSuite(BasicEndpointTests.class);
// Start (and stop) the server only once for all the tests
TestSetup testSetup = new TestSetup(suite) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]