tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r594446 - in /openejb/trunk/openejb3: container/openejb-core/src/main/java/org/apache/openejb/config/ container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ container/openejb-core/src/main/java/org/apache/openejb/core/webs...
Date Tue, 13 Nov 2007 07:10:15 GMT
Author: dain
Date: Mon Nov 12 23:10:14 2007
New Revision: 594446

URL: http://svn.apache.org/viewvc?rev=594446&view=rev
Log:
Fix implicity service ref resolution by matching on service endpoint interface
If ejb or pojo web service implements only one interface and it is annotated @WebService,
set it as the service endpoint interface

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/JaxWsUtils.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddress.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddressRegistry.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddressRegistryImpl.java
    openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=594446&r1=594445&r2=594446&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
Mon Nov 12 23:10:14 2007
@@ -855,7 +855,12 @@
                         }
 
                         for (Class interfce : copy(interfaces)) {
-                            if (interfce.isAnnotationPresent(Remote.class)) {
+                            if (interfce.isAnnotationPresent(WebService.class)) {
+                                if (sessionBean.getServiceEndpoint().equals(DeploymentInfo.ServiceEndpoint.class.getName()))
{
+                                    sessionBean.setServiceEndpoint(interfce.getName());
+                                }
+                                interfaces.remove(interfce);
+                            } else if (interfce.isAnnotationPresent(Remote.class)) {
                                 remotes.add(interfce);
                                 interfaces.remove(interfce);
                             } else {

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java?rev=594446&r1=594445&r2=594446&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java
Mon Nov 12 23:10:14 2007
@@ -69,16 +69,19 @@
     }
 
     public Object getObject() throws javax.naming.NamingException {
-        Set<PortAddress> portAddresses = PortAddressRegistry().getPorts(id, serviceQName);
+        String referenceClassName = referenceClass != null ? referenceClass.getName() : null;
+        Set<PortAddress> portAddresses = getPortAddressRegistry().getPorts(id, serviceQName,
referenceClassName);
 
-        // if we only have one address, use that address for the wsdl
+        // if we only have one address, use that address for the wsdl and the serviceQName
         URL wsdlUrl = this.wsdlUrl;
+        QName serviceQName = this.serviceQName;
         if (portAddresses.size() == 1) {
+            PortAddress portAddress = portAddresses.iterator().next();
             try {
-                PortAddress portAddress = portAddresses.iterator().next();
                 wsdlUrl = new URL(portAddress.getAddress() + "?wsdl");
             } catch (MalformedURLException e) {
             }
+            serviceQName = portAddress.getServiceQName();
         }
 
         // add the port addresses to the portRefData
@@ -94,10 +97,10 @@
 
         // add PortRefData for any portAddress not added above
         for (PortAddress portAddress : portAddresses) {
-            PortRefData port = portsByQName.get(portAddress.getQName());
+            PortRefData port = portsByQName.get(portAddress.getPortQName());
             if (port == null) {
                 port = new PortRefData();
-                port.setQName(portAddress.getQName());
+                port.setQName(portAddress.getPortQName());
                 port.setServiceEndpointInterface(portAddress.getServiceEndpointInterface());
                 port.getAddresses().add(portAddress.getAddress());
                 ports.add(port);
@@ -153,7 +156,7 @@
         return port;
     }
 
-    private PortAddressRegistry PortAddressRegistry() {
+    private PortAddressRegistry getPortAddressRegistry() {
         if (portAddressRegistry == null) {
             portAddressRegistry = SystemInstance.get().getComponent(PortAddressRegistry.class);
         }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/JaxWsUtils.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/JaxWsUtils.java?rev=594446&r1=594445&r2=594446&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/JaxWsUtils.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/JaxWsUtils.java
Mon Nov 12 23:10:14 2007
@@ -253,6 +253,25 @@
             return endpointInterface;
         }
 
+        // if the bean implements only one WebService class, that is the SEI
+        String endpointInterface = null;
+        for (Class intf : clazz.getInterfaces()) {
+            webService = clazz.getAnnotation(WebService.class);
+            if (webService != null) {
+                if (endpointInterface == null) {
+                    endpointInterface = intf.getName();
+                } else {
+                    // multiple endpoint interfaces
+                    endpointInterface = null;
+                    break;
+                }
+            }
+        }
+
+        if (endpointInterface != null) {
+            return endpointInterface;
+        }
+
         return null;
     }
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddress.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddress.java?rev=594446&r1=594445&r2=594446&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddress.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddress.java
Mon Nov 12 23:10:14 2007
@@ -20,24 +20,30 @@
 import javax.xml.namespace.QName;
 
 public class PortAddress {
-    private final String id;
-    private final QName qname;
+    private final String portId;
+    private final QName serviceQName;
+    private final QName portQName;
     private final String address;
     private final String serviceEndpointInterface;
 
-    public PortAddress(String id, QName qname, String address, String serviceEndpointInterface)
{
-        this.id = id;
-        this.qname = qname;
+    public PortAddress(String portId, QName serviceQName, QName portQName, String address,
String serviceEndpointInterface) {
+        this.portId = portId;
+        this.serviceQName = serviceQName;
+        this.portQName = portQName;
         this.address = address;
         this.serviceEndpointInterface = serviceEndpointInterface;
     }
 
-    public String getId() {
-        return id;
+    public String getPortId() {
+        return portId;
     }
 
-    public QName getQName() {
-        return qname;
+    public QName getServiceQName() {
+        return serviceQName;
+    }
+
+    public QName getPortQName() {
+        return portQName;
     }
 
     public String getAddress() {

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddressRegistry.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddressRegistry.java?rev=594446&r1=594445&r2=594446&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddressRegistry.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddressRegistry.java
Mon Nov 12 23:10:14 2007
@@ -25,5 +25,5 @@
 public interface PortAddressRegistry {
     void addPort(String serviceId, QName serviceQName, String portId, QName portQName, String
portInterface, String address) throws OpenEJBException;
     void removePort(String serviceId, QName serviceQName, String portId);
-    Set<PortAddress> getPorts(String id, QName serviceQName);
+    Set<PortAddress> getPorts(String id, QName serviceQName, String referenceClassName);
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddressRegistryImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddressRegistryImpl.java?rev=594446&r1=594445&r2=594446&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddressRegistryImpl.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortAddressRegistryImpl.java
Mon Nov 12 23:10:14 2007
@@ -29,6 +29,7 @@
 
 public class PortAddressRegistryImpl implements PortAddressRegistry {
     private Map<String, PortAddress> portsById = new TreeMap<String, PortAddress>();
+    private Map<String, Map<String, PortAddress>> portsByInterface = new TreeMap<String,
Map<String, PortAddress>>();
     private Map<String, Map<String, PortAddress>> portsByServiceId = new TreeMap<String,
Map<String, PortAddress>>();
     private Map<QName, Map<String, PortAddress>> portsByServiceQName = new HashMap<QName,
Map<String, PortAddress>>();
 
@@ -42,19 +43,29 @@
         // create portAddress
         PortAddress portAddress = portsById.get(portId);
         if (portAddress != null) {
-            throw new OpenEJBException("A webservice port with qname " + portAddress.getQName()
+ " is already registered to the portId " + portId);
+            throw new OpenEJBException("A webservice port with qname " + portAddress.getPortQName()
+ " is already registered to the portId " + portId);
         }
-        portAddress = new PortAddress(portId, portQName, address, portInterface);
+        portAddress = new PortAddress(portId, serviceQName, portQName, address, portInterface);
         portsById.put(portId, portAddress);
 
+        // portsByInterface
+        Map<String, PortAddress> ports = portsByInterface.get(portInterface);
+        if (ports == null) {
+            ports = new TreeMap<String, PortAddress>();
+            portsByInterface.put(portInterface, ports);
+        }
+        ports.put(portId, portAddress);
 
-        Map<String, PortAddress> ports = portsByServiceId.get(serviceId);
+
+        // portsByServiceId
+        ports = portsByServiceId.get(serviceId);
         if (ports == null) {
             ports = new TreeMap<String, PortAddress>();
             portsByServiceId.put(serviceId, ports);
         }
         ports.put(portId, portAddress);
 
+        // portsByServiceQName
         ports = portsByServiceQName.get(serviceQName);
         if (ports == null) {
             ports = new TreeMap<String, PortAddress>();
@@ -75,8 +86,17 @@
             return;
         }
 
+        // remove from portsByInterface
+        Map<String, PortAddress> ports = portsByInterface.get(serviceId);
+        if (ports != null) {
+            ports.remove(portId);
+            if (ports.isEmpty()) {
+                portsByInterface.remove(serviceId);
+            }
+        }
+
         // remove from portsByServiceId
-        Map<String, PortAddress> ports = portsByServiceId.get(serviceId);
+        ports = portsByServiceId.get(serviceId);
         if (ports != null) {
             ports.remove(portId);
             if (ports.isEmpty()) {
@@ -94,13 +114,22 @@
         }
     }
 
-    public synchronized Set<PortAddress> getPorts(String id, QName serviceQName) {
+    public synchronized Set<PortAddress> getPorts(String id, QName serviceQName, String
referenceClassName) {
         if (serviceQName == null) throw new NullPointerException("serviceQName is null");
 
         // check if there is a port with the id
         if (id != null) {
             PortAddress portAddress = portsById.get(id);
             if (portAddress != null) {
+                return Collections.singleton(portAddress);
+            }
+        }
+
+        // check if there is a unique port with the specifiec interface
+        if (referenceClassName != null) {
+            Map<String, PortAddress> interfacePorts = portsByInterface.get(referenceClassName);
+            if (interfacePorts != null && interfacePorts.size() == 1) {
+                PortAddress portAddress = interfacePorts.values().iterator().next();
                 return Collections.singleton(portAddress);
             }
         }

Modified: openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java?rev=594446&r1=594445&r2=594446&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
(original)
+++ openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
Mon Nov 12 23:10:14 2007
@@ -196,7 +196,7 @@
                     PortAddressRegistry portAddressRegistry = SystemInstance.get().getComponent(PortAddressRegistry.class);
                     Set<PortAddress> portAddresses = null;
                     if (portAddressRegistry != null) {
-                        portAddresses = portAddressRegistry.getPorts(serviceRef.getId(),
serviceRef.getServiceQName());
+                        portAddresses = portAddressRegistry.getPorts(serviceRef.getId(),
serviceRef.getServiceQName(), referenceClassName);
                     }
 
                     // resolve the wsdl url
@@ -251,10 +251,10 @@
 
                     // add PortRefMetaData for any portAddress not added above
                     for (PortAddress portAddress : portAddresses) {
-                        PortRefMetaData portRefMetaData = portsByQName.get(portAddress.getQName());
+                        PortRefMetaData portRefMetaData = portsByQName.get(portAddress.getPortQName());
                         if (portRefMetaData == null) {
                             portRefMetaData = new PortRefMetaData();
-                            portRefMetaData.setQName(portAddress.getQName());
+                            portRefMetaData.setQName(portAddress.getPortQName());
                             portRefMetaData.setServiceEndpointInterface(portAddress.getServiceEndpointInterface());
                             portRefMetaData.getAddresses().add(portAddress.getAddress());
                             serviceMetaData.getPortRefs().add(portRefMetaData);



Mime
View raw message