Author: kstam
Date: Thu Jun  2 15:07:45 2011
New Revision: 1130596

URL: http://svn.apache.org/viewvc?rev=1130596&view=rev
Log:
JUDDI-479 some fixes to the servicelocator code; use of a static Map so we can 
get to the ServiceCache

Modified:
    
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ServiceLocator.java
    
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/UDDIClientSubscriptionListenerImpl.java
    
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/UDDIServiceCache.java

Modified: 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ServiceLocator.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ServiceLocator.java?rev=1130596&r1=1130595&r2=1130596&view=diff
==============================================================================
--- 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ServiceLocator.java
 (original)
+++ 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ServiceLocator.java
 Thu Jun  2 15:07:45 2011
@@ -18,7 +18,6 @@ import java.lang.reflect.InvocationTarge
 import java.net.MalformedURLException;
 import java.rmi.RemoteException;
 import java.util.ArrayList;
-import java.util.List;
 import java.util.Properties;
 
 import javax.wsdl.WSDLException;
@@ -93,7 +92,7 @@ public class ServiceLocator {
                if (topology==null) {
                        topology = lookupEndpointInUDDI(serviceKey);
                }
-           if (topology.getEprs().size() > 0) {
+           if (topology!=null && topology.getEprs().size() > 0) {
                epr = selectionPolicy.select(topology);
            }
                return epr;

Modified: 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/UDDIClientSubscriptionListenerImpl.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/UDDIClientSubscriptionListenerImpl.java?rev=1130596&r1=1130595&r2=1130596&view=diff
==============================================================================
--- 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/UDDIClientSubscriptionListenerImpl.java
 (original)
+++ 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/UDDIClientSubscriptionListenerImpl.java
 Thu Jun  2 15:07:45 2011
@@ -18,6 +18,8 @@
 package org.apache.juddi.v3.client.mapping;
 
 import java.io.StringWriter;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.jws.WebService;
 import javax.xml.bind.JAXBContext;
@@ -44,15 +46,26 @@ import org.uddi.v3_service.UDDISubscript
                        targetNamespace = "urn:uddi-org:v3_service")
 public class UDDIClientSubscriptionListenerImpl implements 
UDDISubscriptionListenerPortType {
        
+       
+
        private static final long serialVersionUID = 100157393329807903L;
        private static Log logger = 
LogFactory.getLog(UDDIClientSubscriptionListenerImpl.class);
-       private UDDIServiceCache serviceCache;
+       private static Map<String,UDDIServiceCache> serviceCacheMap = new 
ConcurrentHashMap<String,UDDIServiceCache>();
+       
+       public UDDIClientSubscriptionListenerImpl(String bindingKey, 
UDDIServiceCache serviceCache) {
+               super();
+               serviceCacheMap.put(bindingKey, serviceCache);
+       }
        
-       public UDDIClientSubscriptionListenerImpl(UDDIServiceCache 
serviceCache) {
+       public UDDIClientSubscriptionListenerImpl() {
                super();
-               this.serviceCache = serviceCache;
+               // TODO Auto-generated constructor stub
        }
        
+       public static Map<String, UDDIServiceCache> getServiceCacheMap() {
+               return serviceCacheMap;
+       }
+
        public DispositionReport notifySubscriptionListener(
                        NotifySubscriptionListener body)
                        throws DispositionReportFaultMessage 
@@ -63,12 +76,13 @@ public class UDDIClientSubscriptionListe
                        StringWriter sw = new StringWriter();
                        marshaller.marshal(body, sw);
                        logger.info("Notification received by 
UDDISubscriptionListenerService : " + sw.toString());
-                       
-                       //Update the current subscription
-                       serviceCache.registerSubscription();
-                       //reset the cache
-                       serviceCache.removeAll();
-                       
+                       String bindingKey = 
body.getSubscriptionResultsList().getSubscription().getBindingKey();
+                       if (serviceCacheMap.containsKey(bindingKey)) {
+                               UDDIServiceCache serviceCache = 
serviceCacheMap.get(bindingKey);
+                               // reset the cache, big hammer for now, we 
could figure out changed from the
+                               // subscriptionResults, and be more selective.
+                               serviceCache.removeAll();
+                       }
                } catch (Exception e) {
                        e.printStackTrace();
                }

Modified: 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/UDDIServiceCache.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/UDDIServiceCache.java?rev=1130596&r1=1130595&r2=1130596&view=diff
==============================================================================
--- 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/UDDIServiceCache.java
 (original)
+++ 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/UDDIServiceCache.java
 Thu Jun  2 15:07:45 2011
@@ -17,7 +17,6 @@ package org.apache.juddi.v3.client.mappi
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.rmi.RemoteException;
-import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -71,25 +70,25 @@ public class UDDIServiceCache {
                this.clerk = clerk;
                this.urlLocalizer = urlLocalizer;
                this.properties = properties;
-               this.port = 
Integer.valueOf(properties.getProperty("serverPort", "8080")) + 7;
-               this.serverName = 
properties.getProperty("serverName","localhost");
                this.subscriptionKey = Property.getSubscriptionKey(properties);
                
                init();
        }
 
        private void init() throws DatatypeConfigurationException, 
MalformedURLException, WSDLException, RemoteException, ConfigurationException, 
TransportException {
-               //TODO make the URL more configurable (https)
-               serviceUrl = new URL("http://localhost:"; + port + 
"/uddiclientsubscriptionlistener");
-               endpoint = Endpoint.publish(serviceUrl.toExternalForm(), new 
UDDIClientSubscriptionListenerImpl(this));
                
                QName serviceQName = new QName("urn:uddi-org:v3_service", 
"UDDISubscriptionListenerService");
                String portName = "UDDISubscriptionListenerImplPort";
+               String url = urlLocalizer.rewrite(new 
URL("http://localhost:8080/subscriptionlistener_"; + clerk.getManagerName()));
+               serviceUrl = new URL(url);
                
                WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(clerk, urlLocalizer, 
properties);
                Definition wsdlDefinition = new 
ReadWSDL().readWSDL("uddi_v3_service.wsdl");
                bindingKey = wsdl2UDDI.register(serviceQName, portName, 
serviceUrl, wsdlDefinition).getBindingKey();
                
+               endpoint = Endpoint.create(new 
UDDIClientSubscriptionListenerImpl(bindingKey,this));
+               endpoint.publish(serviceUrl.toExternalForm());
+               
                registerSubscription();
        }
        
@@ -100,6 +99,7 @@ public class UDDIServiceCache {
                WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(clerk, urlLocalizer, 
properties);
                wsdl2UDDI.unRegister(serviceQName, portName, serviceUrl);
                endpoint.stop();
+               
UDDIClientSubscriptionListenerImpl.getServiceCacheMap().remove(bindingKey);
        }
        
        public void removeAll() {
@@ -127,17 +127,18 @@ public class UDDIServiceCache {
        public void registerSubscription() throws 
DatatypeConfigurationException {
                
                //Create a subscription for changes in any Service in the 
Registry
+               FindService findAllServices = new FindService();
                FindQualifiers qualifiers = new FindQualifiers();
-               qualifiers.getFindQualifier().add("approxateMatch");
+               qualifiers.getFindQualifier().add("approximateMatch");
+               
+               findAllServices.setFindQualifiers(qualifiers);
                
-               FindService findAllServices = new FindService();
                Name name = new Name();
                name.setValue("%");
                findAllServices.getName().add(name);
                
                SubscriptionFilter filter = new SubscriptionFilter();
-               filter.getFindService().setFindQualifiers(qualifiers);
-               filter.getFindService().getName().add(name);
+               filter.setFindService(findAllServices);
                
                Subscription subscription = new Subscription();
                subscription.setSubscriptionFilter(filter);
@@ -145,7 +146,7 @@ public class UDDIServiceCache {
                subscription.setBrief(true);
                Duration oneMinute = 
DatatypeFactory.newInstance().newDuration("PT1M");
                subscription.setNotificationInterval(oneMinute);
-               subscription.setSubscriptionKey("create the key");
+               subscription.setSubscriptionKey(subscriptionKey);
                clerk.register(subscription);
        }
        



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to