You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by jl...@apache.org on 2007/06/26 11:43:39 UTC
svn commit: r550756 - in /incubator/cxf/trunk:
api/src/main/java/org/apache/cxf/service/model/
integration/jca/src/test/java/org/apache/cxf/jca/cxf/
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/
rt/frontend/jaxws/src/test/java/org/apache/cxf/ja...
Author: jliu
Date: Tue Jun 26 02:43:37 2007
New Revision: 550756
URL: http://svn.apache.org/viewvc?view=rev&rev=550756
Log:
CXF-735: javax.xml.ws.Service.getPort(java.lang.Class<T> serviceEndpointInterface) does not work
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java
incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionImplTest.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ServiceImplTest.java
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java
Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java?view=diff&rev=550756&r1=550755&r2=550756
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java Tue Jun 26 02:43:37 2007
@@ -20,6 +20,7 @@
package org.apache.cxf.service.model;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import javax.xml.namespace.QName;
@@ -107,5 +108,31 @@
}
}
return names;
+ }
+
+ public static EndpointInfo findBestEndpointInfo(QName qn, List<ServiceInfo> serviceInfos) {
+ for (ServiceInfo serviceInfo : serviceInfos) {
+ Collection<EndpointInfo> eps = serviceInfo.getEndpoints();
+ for (EndpointInfo ep : eps) {
+ if (ep.getInterface().getName().equals(qn)) {
+ return ep;
+ }
+ }
+ }
+
+ EndpointInfo best = null;
+ for (ServiceInfo serviceInfo : serviceInfos) {
+ Collection<EndpointInfo> eps = serviceInfo.getEndpoints();
+ for (EndpointInfo ep : eps) {
+ if (best == null) {
+ best = ep;
+ }
+ if (ep.getTransportId().equals("http://schemas.xmlsoap.org/wsdl/soap/")) {
+ return ep;
+ }
+ }
+ }
+
+ return best;
}
}
Modified: incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionImplTest.java?view=diff&rev=550756&r1=550755&r2=550756
==============================================================================
--- incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionImplTest.java (original)
+++ incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionImplTest.java Tue Jun 26 02:43:37 2007
@@ -56,11 +56,12 @@
cri = new CXFConnectionRequestInfo(Foo.class, null, serviceName, null);
try {
- //current cxf supprot pojo simple frontend, so it is ok to create proxy now
+ //Can not create JAX-WS proxy using pojo
mci.getConnection(subj, cri);
-
+ fail("Did not get expected ResourceAdapterInternalException");
+
} catch (ResourceAdapterInternalException raie) {
- fail("NotExpected ResourceAdapterInternalException");
+ //do nothing
}
}
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties?view=diff&rev=550756&r1=550755&r2=550756
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties Tue Jun 26 02:43:37 2007
@@ -46,4 +46,6 @@
FAILED_TO_INITIALIZE_JAXBCONTEXT = Failed to initialize JAXB context for types used by {0}.
ASYNC_HANDLER_TIMEDOUT_EXC = AsynHandler did not complete time.
-SEI_METHOD_NOT_FOUND= Service class {1} does not implement {0} method.
+SEI_METHOD_NOT_FOUND = Service class {1} does not implement {0} method.
+SEI_NO_WEBSERVICE_ANNOTATION = service endpoint interface class {0} does not have javax.jws.WebService annotation.
+COULD_NOT_LOAD_CLASS = Unalbe to load class {0}.
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?view=diff&rev=550756&r1=550755&r2=550756
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java Tue Jun 26 02:43:37 2007
@@ -32,6 +32,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.jws.WebService;
import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.ws.Dispatch;
@@ -67,6 +68,8 @@
import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.service.model.ServiceModelUtil;
+import org.apache.cxf.tools.util.URIParserUtil;
import org.apache.cxf.transport.DestinationFactory;
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.workqueue.OneShotAsyncExecutor;
@@ -301,11 +304,24 @@
}
if (portName == null) {
- clientFac.create();
- portName = serviceFactory.getEndpointName();
- } else {
- serviceFactory.setEndpointName(portName);
+ QName portTypeName = getPortTypeName(serviceEndpointInterface);
+
+ Service service = serviceFactory.getService();
+ if (service == null) {
+ serviceFactory.setServiceClass(serviceEndpointInterface);
+ serviceFactory.setBus(getBus());
+ service = serviceFactory.create();
+ }
+
+ EndpointInfo ei = ServiceModelUtil.findBestEndpointInfo(portTypeName, service.getServiceInfos());
+ if (ei != null) {
+ portName = ei.getName();
+ } else {
+ portName = serviceFactory.getEndpointName();
+ }
}
+
+ serviceFactory.setEndpointName(portName);
if (epr != null) {
clientFac.setEndpointReference(epr);
@@ -345,7 +361,7 @@
ports.add(portName);
return serviceEndpointInterface.cast(obj);
}
-
+
private EndpointInfo createEndpointInfo(AbstractServiceFactoryBean serviceFactory,
QName portName,
PortInfoImpl portInfo) throws BusException {
@@ -393,7 +409,47 @@
// TODO if the portName null ?
return portInfos.get(portName);
}
+
+ private QName getPortTypeName(Class<?> serviceEndpointInterface) {
+ Class<?> seiClass = serviceEndpointInterface;
+ if (!serviceEndpointInterface.isAnnotationPresent(WebService.class)) {
+ Message msg = new Message("SEI_NO_WEBSERVICE_ANNOTATION", BUNDLE, serviceEndpointInterface
+ .getCanonicalName());
+ throw new WebServiceException(msg.toString());
+ }
+
+ if (!serviceEndpointInterface.isInterface()) {
+ WebService webService = serviceEndpointInterface.getAnnotation(WebService.class);
+ String epi = webService.endpointInterface();
+ if (epi.length() > 0) {
+ try {
+ seiClass = Thread.currentThread().getContextClassLoader().loadClass(epi);
+ } catch (ClassNotFoundException e) {
+ Message msg = new Message("COULD_NOT_LOAD_CLASS", BUNDLE,
+ seiClass.getCanonicalName());
+ throw new WebServiceException(msg.toString());
+ }
+ if (!seiClass.isAnnotationPresent(javax.jws.WebService.class)) {
+ Message msg = new Message("SEI_NO_WEBSERVICE_ANNOTATION", BUNDLE,
+ seiClass.getCanonicalName());
+ throw new WebServiceException(msg.toString());
+ }
+ }
+ }
+
+ WebService webService = seiClass.getAnnotation(WebService.class);
+ String name = webService.name();
+ if (name.length() == 0) {
+ name = seiClass.getSimpleName();
+ }
+
+ String tns = webService.targetNamespace();
+ if (tns.length() == 0) {
+ tns = URIParserUtil.getNamespace(seiClass.getPackage().getName());
+ }
+ return new QName(tns, name);
+ }
// TODO JAX-WS 2.1
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ServiceImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ServiceImplTest.java?view=diff&rev=550756&r1=550755&r2=550756
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ServiceImplTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ServiceImplTest.java Tue Jun 26 02:43:37 2007
@@ -42,7 +42,6 @@
import org.apache.cxf.frontend.ClientProxy;
import org.apache.hello_world_soap_http.Greeter;
import org.apache.hello_world_soap_http.SOAPService;
-import org.junit.Ignore;
import org.junit.Test;
public class ServiceImplTest extends AbstractJaxWsTest {
@@ -70,7 +69,6 @@
}
@Test
- @Ignore("this test does not work, see CXF-735 ")
public void testNonSpecificGetPort() throws Exception {
SOAPService service = new SOAPService();
Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java?view=diff&rev=550756&r1=550755&r2=550756
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java Tue Jun 26 02:43:37 2007
@@ -19,7 +19,6 @@
package org.apache.cxf.frontend;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
@@ -47,7 +46,7 @@
import org.apache.cxf.service.factory.ServiceConstructionException;
import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.service.model.ServiceModelUtil;
import org.apache.cxf.transport.DestinationFactory;
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.transport.local.LocalTransportFactory;
@@ -99,7 +98,8 @@
if (ei == null) {
if (getAddress() == null) {
- ei = findBestEndpointInfo(service.getServiceInfos());
+ ei = ServiceModelUtil.findBestEndpointInfo(serviceFactory.getInterfaceName(), service
+ .getServiceInfos());
}
if (ei == null) {
ei = createEndpointInfo();
@@ -117,6 +117,7 @@
ep = serviceFactory.createEndpoint(ei);
((EndpointImpl)ep).initializeActiveFeatures(getFeatures());
} else {
+ serviceFactory.setEndpointName(ei.getName());
if (ep.getActiveFeatures() == null) {
((EndpointImpl)ep).initializeActiveFeatures(getFeatures());
}
@@ -141,34 +142,6 @@
ep.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
}
return ep;
- }
-
- protected EndpointInfo findBestEndpointInfo(List<ServiceInfo> serviceInfos) {
-
- QName qn = serviceFactory.getInterfaceName();
- for (ServiceInfo serviceInfo : serviceInfos) {
- Collection<EndpointInfo> eps = serviceInfo.getEndpoints();
- for (EndpointInfo ep : eps) {
- if (ep.getInterface().getName().equals(qn)) {
- return ep;
- }
- }
- }
-
- EndpointInfo best = null;
- for (ServiceInfo serviceInfo : serviceInfos) {
- Collection<EndpointInfo> eps = serviceInfo.getEndpoints();
- for (EndpointInfo ep : eps) {
- if (best == null) {
- best = ep;
- }
- if (ep.getTransportId().equals("http://schemas.xmlsoap.org/wsdl/soap/")) {
- return ep;
- }
- }
- }
-
- return best;
}
protected EndpointInfo createEndpointInfo() throws BusException {