Return-Path: X-Original-To: apmail-juddi-commits-archive@www.apache.org Delivered-To: apmail-juddi-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1AEF740FC for ; Thu, 2 Jun 2011 15:08:10 +0000 (UTC) Received: (qmail 3327 invoked by uid 500); 2 Jun 2011 15:08:10 -0000 Delivered-To: apmail-juddi-commits-archive@juddi.apache.org Received: (qmail 3303 invoked by uid 500); 2 Jun 2011 15:08:10 -0000 Mailing-List: contact commits-help@juddi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@juddi.apache.org Received: (qmail 3295 invoked by uid 99); 2 Jun 2011 15:08:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2011 15:08:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2011 15:08:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 72E04238897D; Thu, 2 Jun 2011 15:07:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1130596 - in /juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping: ServiceLocator.java UDDIClientSubscriptionListenerImpl.java UDDIServiceCache.java Date: Thu, 02 Jun 2011 15:07:45 -0000 To: commits@juddi.apache.org From: kstam@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110602150745.72E04238897D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 serviceCacheMap = new ConcurrentHashMap(); + + 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 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: commits-unsubscribe@juddi.apache.org For additional commands, e-mail: commits-help@juddi.apache.org