You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by ks...@apache.org on 2009/05/13 23:14:33 UTC
svn commit: r774539 - in /webservices/juddi/branches/v3_trunk:
juddi-core/src/main/java/org/apache/juddi/
juddi-core/src/main/java/org/apache/juddi/api/impl/
juddi-core/src/main/java/org/apache/juddi/mapping/
juddi-core/src/main/java/org/apache/juddi/m...
Author: kstam
Date: Wed May 13 21:14:32 2009
New Revision: 774539
URL: http://svn.apache.org/viewvc?rev=774539&view=rev
Log:
JUDDI-205 adding subscriptionNotification code. Work in progress.
Added:
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java (contents, props changed)
- copied, changed from r773657, webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/SubscriptionNotifier.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/TypeConvertor.java
webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/subscription/
webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/subscription/SubscriptionNotifierTest.java
Removed:
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/SubscriptionNotifier.java
Modified:
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Subscription.java
webservices/juddi/branches/v3_trunk/juddi-cxf/src/main/java/org/apache/juddi/RegistryServlet.java
webservices/juddi/branches/v3_trunk/juddi-tomcat/context.xml
webservices/juddi/branches/v3_trunk/uddi-client/src/test/java/org/apache/juddi/client/UDDI_080_SubscriptionTest.java
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java?rev=774539&r1=774538&r2=774539&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java Wed May 13 21:14:32 2009
@@ -107,8 +107,10 @@
tx.commit();
em.close();
}
-
-
+
+ public SubscriptionResultsList getSubscriptionResults(GetSubscriptionResults body) throws DispositionReportFaultMessage {
+ return getSubscriptionResults(body, null);
+ }
/* (non-Javadoc)
* @see org.uddi.v3_service.UDDISubscriptionPortType#getSubscriptionResults(org.uddi.sub_v3.GetSubscriptionResults)
*
@@ -117,16 +119,20 @@
* time of the subscription save. The result of this policy is that if an entity is deleted, that deleted result will appear in the keyBag
* on every call to this method. To resolve this, the user can renew the subscription at which time the "match" snapshot will be refreshed.
*
+ * The WS needs to be authenticated (null publisher), however the notificationSubscriber is calling this method also. The
+ * notificationSubscriber will pass in the publisher and this method will work in unauthenticated mode.
*/
@SuppressWarnings("unchecked")
- public SubscriptionResultsList getSubscriptionResults(GetSubscriptionResults body) throws DispositionReportFaultMessage {
+ public SubscriptionResultsList getSubscriptionResults(GetSubscriptionResults body, UddiEntityPublisher publisher) throws DispositionReportFaultMessage {
EntityManager em = PersistenceManager.getEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
-
- UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());
- new ValidateSubscription(publisher).validateGetSubscriptionResults(em, body);
+
+ if (publisher==null) {
+ publisher = this.getEntityPublisher(em, body.getAuthInfo());
+ new ValidateSubscription(publisher).validateGetSubscriptionResults(em, body);
+ }
org.apache.juddi.model.Subscription modelSubscription = em.find(org.apache.juddi.model.Subscription.class, body.getSubscriptionKey());
SubscriptionFilter subscriptionFilter = null;
@@ -788,6 +794,7 @@
MappingApiToModel.mapSubscription(apiSubscription, modelSubscription);
modelSubscription.setAuthorizedName(publisher.getAuthorizedName());
+ modelSubscription.setCreateDate(new Date());
// Add the matching keys to the match collection
List<?> keys = getSubscriptionMatches(apiSubscription.getSubscriptionFilter(), em);
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java?rev=774539&r1=774538&r2=774539&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java Wed May 13 21:14:32 2009
@@ -18,21 +18,16 @@
package org.apache.juddi.mapping;
import java.util.Collections;
-import java.util.Date;
-import java.util.GregorianCalendar;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
-import javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.DatatypeFactory;
-import javax.xml.datatype.Duration;
-import javax.xml.datatype.XMLGregorianCalendar;
import org.apache.juddi.error.ErrorMessage;
import org.apache.juddi.error.FatalErrorException;
import org.apache.juddi.model.OverviewDoc;
import org.apache.juddi.model.UddiEntity;
+import org.apache.juddi.subscription.TypeConvertor;
import org.apache.juddi.util.JAXBMarshaller;
import org.apache.log4j.Logger;
import org.uddi.api_v3.CompletionStatus;
@@ -724,9 +719,9 @@
OperationalInfo apiOperationalInfo)
throws DispositionReportFaultMessage {
- apiOperationalInfo.setCreated(convertDateToXMLGregorianCalendar(modelUddiEntity.getCreated()));
- apiOperationalInfo.setModified(convertDateToXMLGregorianCalendar(modelUddiEntity.getModified()));
- apiOperationalInfo.setModifiedIncludingChildren(convertDateToXMLGregorianCalendar(modelUddiEntity.getModifiedIncludingChildren()));
+ apiOperationalInfo.setCreated(TypeConvertor.convertDateToXMLGregorianCalendar(modelUddiEntity.getCreated()));
+ apiOperationalInfo.setModified(TypeConvertor.convertDateToXMLGregorianCalendar(modelUddiEntity.getModified()));
+ apiOperationalInfo.setModifiedIncludingChildren(TypeConvertor.convertDateToXMLGregorianCalendar(modelUddiEntity.getModifiedIncludingChildren()));
apiOperationalInfo.setNodeID(modelUddiEntity.getNodeId());
apiOperationalInfo.setAuthorizedName(modelUddiEntity.getAuthorizedName());
}
@@ -738,10 +733,10 @@
apiSubscription.setSubscriptionKey(modelSubscription.getSubscriptionKey());
apiSubscription.setBrief(modelSubscription.isBrief());
- apiSubscription.setExpiresAfter(convertDateToXMLGregorianCalendar(modelSubscription.getExpiresAfter()));
+ apiSubscription.setExpiresAfter(TypeConvertor.convertDateToXMLGregorianCalendar(modelSubscription.getExpiresAfter()));
apiSubscription.setBindingKey(modelSubscription.getBindingKey());
apiSubscription.setMaxEntities(modelSubscription.getMaxEntities());
- apiSubscription.setNotificationInterval(converStringToDuration(modelSubscription.getNotificationInterval()));
+ apiSubscription.setNotificationInterval(TypeConvertor.convertStringToDuration(modelSubscription.getNotificationInterval()));
try {
SubscriptionFilter existingFilter = (SubscriptionFilter)JAXBMarshaller.unmarshallFromString(modelSubscription.getSubscriptionFilter(), JAXBMarshaller.PACKAGE_SUBSCRIPTION);
@@ -753,35 +748,7 @@
}
}
- public static XMLGregorianCalendar convertDateToXMLGregorianCalendar(Date date) throws DispositionReportFaultMessage {
- XMLGregorianCalendar result = null;
- try {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTimeInMillis(date.getTime());
-
- DatatypeFactory df = DatatypeFactory.newInstance();
- result = df.newXMLGregorianCalendar(gc);
- }
- catch(DatatypeConfigurationException ce) {
- throw new FatalErrorException(new ErrorMessage("errors.Unspecified"));
- }
-
- return result;
- }
- public static Duration converStringToDuration(String duration) throws DispositionReportFaultMessage {
- Duration result = null;
- try {
-
- DatatypeFactory df = DatatypeFactory.newInstance();
- result = df.newDuration(duration);
- }
- catch(DatatypeConfigurationException ce) {
- throw new FatalErrorException(new ErrorMessage("errors.Unspecified"));
- }
-
- return result;
- }
}
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Subscription.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Subscription.java?rev=774539&r1=774538&r2=774539&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Subscription.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Subscription.java Wed May 13 21:14:32 2009
@@ -47,6 +47,8 @@
private Integer maxEntities;
private Date expiresAfter;
private Boolean brief;
+ private Date lastNotified;
+ private Date createDate;
private List<SubscriptionMatch> subscriptionMatches = new ArrayList<SubscriptionMatch>(0);
public Subscription() {
@@ -133,4 +135,24 @@
public void setSubscriptionMatches(List<SubscriptionMatch> subscriptionMatches) {
this.subscriptionMatches = subscriptionMatches;
}
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "last_notified", length = 29)
+ public Date getLastNotified() {
+ return lastNotified;
+ }
+
+ public void setLastNotified(Date lastNotified) {
+ this.lastNotified = lastNotified;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "create_date", length = 29, nullable = false)
+ public Date getCreateDate() {
+ return createDate;
+ }
+
+ public void setCreateDate(Date createDate) {
+ this.createDate = createDate;
+ }
}
Copied: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java (from r773657, webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/SubscriptionNotifier.java)
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java?p2=webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java&p1=webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/SubscriptionNotifier.java&r1=773657&r2=774539&rev=774539&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/SubscriptionNotifier.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java Wed May 13 21:14:32 2009
@@ -1,30 +1,182 @@
-package org.apache.juddi;
+package org.apache.juddi.subscription;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Query;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.juddi.api.impl.UDDISubscriptionImpl;
import org.apache.juddi.config.AppConfig;
import org.apache.juddi.config.Property;
+import org.apache.juddi.model.Subscription;
+import org.apache.juddi.model.SubscriptionMatch;
+import org.apache.juddi.model.UddiEntityPublisher;
+import org.apache.juddi.query.PersistenceManager;
import org.apache.log4j.Logger;
+import org.uddi.sub_v3.CoveragePeriod;
+import org.uddi.sub_v3.GetSubscriptionResults;
+import org.uddi.sub_v3.SubscriptionResultsList;
-public class SubscriptionNotifier implements Runnable {
+public class SubscriptionNotifier extends TimerTask {
private Logger log = Logger.getLogger(this.getClass());
+ Timer timer = new Timer();
+ long interval = AppConfig.getConfiguration().getLong(Property.JUDDI_NOTIFICATION_INTERVAL, 300000l); //5 min default
+ UDDISubscriptionImpl subscriptionImpl = new UDDISubscriptionImpl();
+ private static long ACCEPTABLE_LAG_TIME = 20l; //20 milliseconds
+
+ public SubscriptionNotifier() throws ConfigurationException {
+ super();
+ timer.scheduleAtFixedRate(this, new Date(), interval);
+ }
+
+ public void run()
+ {
+ if (firedOnTime(scheduledExecutionTime())) {
+ long startTime = System.currentTimeMillis();
+ log.info("Start Notification background task; checking if subscription notifications need to be send out..");
+
+ Collection<Subscription> subscriptions = getAllSubscriptions();
+ for (Subscription subscription : subscriptions) {
+ if (subscription.getExpiresAfter()==null || subscription.getExpiresAfter().getTime() > startTime) {
+ SubscriptionResultsList resultList = getSubscriptionResultList(subscription);
+ if (resultListContainsChanges(resultList)) {
+ log.info("We need to notify..");
+ System.out.println(resultList);
+ //Obtain the service we need to call.
+
+
+ //now log to the db that we notified.
+ //Date notificationDate = new Date();
+ //subscription.setLastNotified(notificationDate);
+ //em.persist(subscription);
+ }
+ }
+ }
+ long endTime = System.currentTimeMillis();
+
+ if ((endTime-startTime) > interval) {
+ log.warn("Notification background task duration exceeds the JUDDI_NOTIFICATION_INTERVAL of " + interval);
+ log.warn("Notification background task took " + (endTime - startTime) + " milliseconds.");
+ } else {
+ log.info("Notification background task took " + (endTime - startTime) + " milliseconds.");
+ }
+ } else {
+ log.warn("Skipping current notification cycle because the registry is busy.");
+ }
+ }
- public void run() {
-
- while(true) {
- try {
- Thread.sleep(AppConfig.getConfiguration().getLong(Property.JUDDI_NOTIFICATION_INTERVAL, 60000l));
- log.info("SubscriptionNotifier wakes up.");
- //check subscriptions
+ private boolean firedOnTime(long scheduleExecutionTime) {
+ long lagTime = System.currentTimeMillis() - scheduleExecutionTime;
+ if (lagTime <= ACCEPTABLE_LAG_TIME) {
+ return true;
+ } else {
+ log.warn("NotificationTimer is lagging " + lagTime + " milli seconds behind. A lag time "
+ + "which exceeds an acceptable lagtime of " + ACCEPTABLE_LAG_TIME + "ms indicates "
+ + "that the registry server is under stress. We are therefore skipping this notification "
+ + "cycle.");
+ return false;
+ }
+ }
+ /**
+ * Obtains the SubscriptionResultsList for a subscription.
+ *
+ * @param subscription
+ * @return
+ */
+ protected SubscriptionResultsList getSubscriptionResultList(Subscription subscription) {
+ SubscriptionResultsList resultList = null;
+ try {
+ Date startPoint = subscription.getLastNotified();
+ if (startPoint==null) startPoint = subscription.getCreateDate();
+ Date endPoint = new Date(scheduledExecutionTime());
+
+ Duration duration = TypeConvertor.convertStringToDuration(subscription.getNotificationInterval());
+ Date nextDesiredNotificationDate = startPoint;
+ duration.addTo(nextDesiredNotificationDate);
+
+ if (subscription.getLastNotified()==null || nextDesiredNotificationDate.after(startPoint) && nextDesiredNotificationDate.before(endPoint)) {
+ GetSubscriptionResults subscriptionResults = new GetSubscriptionResults();
- //send out notifications who are either WS calls, or emails
+ CoveragePeriod period = new CoveragePeriod();
+ GregorianCalendar calendar = new GregorianCalendar();
+ calendar.setTimeInMillis(startPoint.getTime());
+ period.setStartPoint(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
+ calendar.setTimeInMillis(endPoint.getTime());
+ period.setEndPoint(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
+ subscriptionResults.setCoveragePeriod(period);
- } catch (Exception e) {
- e.printStackTrace();
- //TODO
+ subscriptionResults.setSubscriptionKey(subscription.getSubscriptionKey());
+ UddiEntityPublisher publisher = new UddiEntityPublisher();
+ publisher.setAuthorizedName(subscription.getAuthorizedName());
+ resultList = subscriptionImpl.getSubscriptionResults(subscriptionResults, publisher);
+ }
+
+ } catch (Exception e) {
+ log.error("Could not obtain subscriptionResult for subscriptionKey "
+ + subscription.getSubscriptionKey() + ". " + e.getMessage(),e);
+ }
+ return resultList;
+ }
+ protected boolean resultListContainsChanges(SubscriptionResultsList resultList)
+ {
+ if (resultList==null) return false;
+ if (resultList.getBindingDetail() !=null || resultList.getBusinessDetail()!=null
+ || resultList.getBusinessList() !=null || resultList.getServiceDetail() !=null
+ || resultList.getServiceList() !=null || resultList.getTModelDetail() !=null
+ || resultList.getTModelList() !=null || resultList.getRelatedBusinessesList() !=null) {
+ return true;
+ }
+ return false;
+ }
+ /**
+ * Obtains all subscriptions in the system.
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ protected Collection<Subscription> getAllSubscriptions() {
+ EntityManager em = PersistenceManager.getEntityManager();
+ EntityTransaction tx = em.getTransaction();
+ tx.begin();
+ Query query = em.createQuery("SELECT s FROM Subscription s");
+ Collection<Subscription> subscriptions = (Collection<Subscription>) query.getResultList();
+ tx.commit();
+ em.close();
+ return subscriptions;
+ }
+ /**
+ * Sends out the notifications.
+ * @param resultList
+ * @throws MalformedURLException
+ */
+ protected void notify(SubscriptionResultsList resultList) throws MalformedURLException {
+ EntityManager em = PersistenceManager.getEntityManager();
+ EntityTransaction tx = em.getTransaction();
+ tx.begin();
+ org.apache.juddi.model.Subscription modelSubscription = em.find(org.apache.juddi.model.Subscription.class, resultList.getSubscription().getSubscriptionKey());
+ org.apache.juddi.model.BindingTemplate bindingTemplate= em.find(org.apache.juddi.model.BindingTemplate.class, modelSubscription.getBindingKey());
+ if (bindingTemplate!=null) {
+ if (bindingTemplate.getAccessPointType().equalsIgnoreCase("wsdl")) {
+ URL url = new URL(bindingTemplate.getAccessPointUrl());
+ //TODO call this url.
+ } else if (bindingTemplate.getAccessPointType().equalsIgnoreCase("email")) {
+ log.warn("Notifications via email are not yet supported");
+ } else {
+ log.error("Not supported binding type.");
}
- log.info("Hello");
}
-
+ System.out.println("hello");
}
}
Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java
------------------------------------------------------------------------------
svn:mergeinfo =
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/TypeConvertor.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/TypeConvertor.java?rev=774539&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/TypeConvertor.java (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/TypeConvertor.java Wed May 13 21:14:32 2009
@@ -0,0 +1,45 @@
+package org.apache.juddi.subscription;
+
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.juddi.error.ErrorMessage;
+import org.apache.juddi.error.FatalErrorException;
+import org.uddi.v3_service.DispositionReportFaultMessage;
+
+public class TypeConvertor {
+ public static XMLGregorianCalendar convertDateToXMLGregorianCalendar(Date date) throws DispositionReportFaultMessage {
+ XMLGregorianCalendar result = null;
+ try {
+ GregorianCalendar gc = new GregorianCalendar();
+ gc.setTimeInMillis(date.getTime());
+
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ result = df.newXMLGregorianCalendar(gc);
+ }
+ catch(DatatypeConfigurationException ce) {
+ throw new FatalErrorException(new ErrorMessage("errors.Unspecified"));
+ }
+
+ return result;
+ }
+
+ public static Duration convertStringToDuration(String duration) throws DispositionReportFaultMessage {
+ Duration result = null;
+ try {
+
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ result = df.newDuration(duration);
+ }
+ catch(DatatypeConfigurationException ce) {
+ throw new FatalErrorException(new ErrorMessage("errors.Unspecified"));
+ }
+
+ return result;
+ }
+}
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/subscription/SubscriptionNotifierTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/subscription/SubscriptionNotifierTest.java?rev=774539&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/subscription/SubscriptionNotifierTest.java (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/subscription/SubscriptionNotifierTest.java Wed May 13 21:14:32 2009
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ *
+ * Licensed 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.juddi.subscription;
+
+import java.net.MalformedURLException;
+import java.util.Collection;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.juddi.api.impl.API_010_PublisherTest;
+import org.apache.juddi.api.impl.UDDIInquiryImpl;
+import org.apache.juddi.api.impl.UDDIPublicationImpl;
+import org.apache.juddi.api.impl.UDDISecurityImpl;
+import org.apache.juddi.api.impl.UDDISubscriptionImpl;
+import org.apache.juddi.model.Subscription;
+import org.apache.juddi.subscription.SubscriptionNotifier;
+import org.apache.log4j.Logger;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.uddi.api_v3.tck.TckBindingTemplate;
+import org.uddi.api_v3.tck.TckBusiness;
+import org.uddi.api_v3.tck.TckBusinessService;
+import org.uddi.api_v3.tck.TckPublisher;
+import org.uddi.api_v3.tck.TckSecurity;
+import org.uddi.api_v3.tck.TckSubscription;
+import org.uddi.api_v3.tck.TckTModel;
+import org.uddi.sub_v3.SubscriptionResultsList;
+import org.uddi.v3_service.DispositionReportFaultMessage;
+
+/**
+ * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
+ */
+public class SubscriptionNotifierTest
+{
+ private static Logger logger = Logger.getLogger(SubscriptionNotifierTest.class);
+ private static API_010_PublisherTest api010 = new API_010_PublisherTest();
+ private static TckTModel tckTModel = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
+ private static TckBusiness tckBusiness = new TckBusiness(new UDDIPublicationImpl(), new UDDIInquiryImpl());
+ private static TckBusinessService tckBusinessService = new TckBusinessService(new UDDIPublicationImpl(), new UDDIInquiryImpl());
+ private static TckBindingTemplate tckBindingTemplate = new TckBindingTemplate(new UDDIPublicationImpl(), new UDDIInquiryImpl());
+ private static TckSubscription tckSubscription = new TckSubscription(new UDDISubscriptionImpl(), new UDDISecurityImpl());
+
+ private static String authInfoJoe = null;
+
+ @BeforeClass
+ public static void setup() {
+ logger.debug("Getting auth token..");
+ try {
+ api010.saveJoePublisher();
+ authInfoJoe = TckSecurity.getAuthToken(new UDDISecurityImpl(), TckPublisher.JOE_PUBLISHER_ID, TckPublisher.JOE_PUBLISHER_CRED);
+ tckTModel.saveJoePublisherTmodel(authInfoJoe);
+ tckBusiness.saveJoePublisherBusiness(authInfoJoe);
+ tckBusinessService.saveJoePublisherService(authInfoJoe);
+ tckBindingTemplate.saveJoePublisherBinding(authInfoJoe);
+ tckSubscription.saveJoePublisherSubscription(authInfoJoe);
+ tckSubscription.getJoePublisherSubscriptionResults(authInfoJoe);
+ } catch (DispositionReportFaultMessage e) {
+ logger.error(e.getMessage(), e);
+ Assert.fail("Could not obtain authInfo token.");
+ }
+ }
+ @Test
+ public void testGetSubscriptionResults() throws ConfigurationException, MalformedURLException
+ {
+ SubscriptionNotifier notifier = new SubscriptionNotifier();
+ notifier.cancel();
+ Collection<Subscription> subscriptions = notifier.getAllSubscriptions();
+ Assert.assertEquals(1, subscriptions.size());
+ Subscription subscription = subscriptions.iterator().next();
+ SubscriptionResultsList resultList = notifier.getSubscriptionResultList(subscription);
+ //We're expecting a changed service (since it was added in the
+ Assert.assertNotNull(resultList.getServiceList());
+ //We should detect these changes.
+ boolean hasChanges = notifier.resultListContainsChanges(resultList);
+ Assert.assertTrue(hasChanges);
+ System.out.print(resultList);
+ notifier.notify(resultList);
+ }
+
+
+ @AfterClass
+ public static void teardown() {
+ tckSubscription.deleteJoePublisherSubscription(authInfoJoe);
+ tckBindingTemplate.deleteJoePublisherBinding(authInfoJoe);
+ tckBusinessService.deleteJoePublisherService(authInfoJoe);
+ tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
+ tckTModel.deleteJoePublisherTmodel(authInfoJoe);
+ }
+
+}
Modified: webservices/juddi/branches/v3_trunk/juddi-cxf/src/main/java/org/apache/juddi/RegistryServlet.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-cxf/src/main/java/org/apache/juddi/RegistryServlet.java?rev=774539&r1=774538&r2=774539&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-cxf/src/main/java/org/apache/juddi/RegistryServlet.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-cxf/src/main/java/org/apache/juddi/RegistryServlet.java Wed May 13 21:14:32 2009
@@ -21,6 +21,7 @@
import org.apache.commons.configuration.ConfigurationException;
import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.subscription.SubscriptionNotifier;
import org.apache.log4j.Logger;
/**
@@ -33,7 +34,7 @@
{
private static final long serialVersionUID = 1L;
private Logger log = Logger.getLogger(this.getClass());
- private Thread subscriptionNotifierThread = null;
+ private SubscriptionNotifier subscriptionNotifier = null;
/**
* Initialize all core components.
@@ -45,8 +46,8 @@
super.init(config);
try {
AppConfig.getInstance();
- subscriptionNotifierThread = new Thread(new SubscriptionNotifier());
- subscriptionNotifierThread.start();
+ //subscriptionNotifier = new SubscriptionNotifier();
+
} catch (ConfigurationException ce) {
throw new ServletException(ce.getMessage(),ce);
}
@@ -61,6 +62,6 @@
{
super.destroy();
log.info("jUDDI Stopping: Cleaning up existing resources.");
- subscriptionNotifierThread = null;
+ subscriptionNotifier.cancel();
}
}
\ No newline at end of file
Modified: webservices/juddi/branches/v3_trunk/juddi-tomcat/context.xml
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-tomcat/context.xml?rev=774539&r1=774538&r2=774539&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-tomcat/context.xml (original)
+++ webservices/juddi/branches/v3_trunk/juddi-tomcat/context.xml Wed May 13 21:14:32 2009
@@ -2,11 +2,21 @@
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
+ <!-- -->
<Resource name="jdbc/JuddiDS" auth="Container"
type="javax.sql.DataSource" username="" password=""
driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
url="jdbc:derby:juddi-derby-test-db;create=true"
maxActive="8"
/>
+
+ <!-- mysql
+ <Resource name="jdbc/JuddiDS" auth="Container"
+ type="javax.sql.DataSource" username="root" password=""
+ driverClassName="com.mysql.jdbc.Driver"
+ url="jdbc:mysql://localhost:3306/juddiv3"
+ maxActive="8"
+ />
+ -->
</Context>
Modified: webservices/juddi/branches/v3_trunk/uddi-client/src/test/java/org/apache/juddi/client/UDDI_080_SubscriptionTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/uddi-client/src/test/java/org/apache/juddi/client/UDDI_080_SubscriptionTest.java?rev=774539&r1=774538&r2=774539&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/uddi-client/src/test/java/org/apache/juddi/client/UDDI_080_SubscriptionTest.java (original)
+++ webservices/juddi/branches/v3_trunk/uddi-client/src/test/java/org/apache/juddi/client/UDDI_080_SubscriptionTest.java Wed May 13 21:14:32 2009
@@ -18,7 +18,6 @@
import org.apache.log4j.helpers.Loader;
import org.junit.Assert;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.uddi.api_v3.client.config.ClientConfig;
import org.uddi.api_v3.client.config.Property;
---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org