1/*2 * Copyright 2001-2008 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 *16 */1718package org.apache.juddi.v3.client.mapping;
1920import java.io.StringWriter;
2122import javax.jws.WebService;
23import javax.xml.bind.JAXBContext;
24import javax.xml.bind.Marshaller;
2526import org.apache.commons.logging.Log;
27import org.apache.commons.logging.LogFactory;
28import org.apache.juddi.v3.client.subscription.SubscriptionCallbackListener;
29import org.uddi.api_v3.DispositionReport;
30import org.uddi.api_v3.Result;
31import org.uddi.subr_v3.NotifySubscriptionListener;
32import org.uddi.v3_service.DispositionReportFaultMessage;
33import org.uddi.v3_service.UDDISubscriptionListenerPortType;
3435/**36 * WebService which implements the UDDI v3 SubscriptionListener API. This service will be called by37 * the UDDI registry when any change to a Service or BindingTemplate38 * call in to it.39 * 40 * @author kstam41 * @see SubscriptionCallbackListener42 *43 */44 @WebService(serviceName="UDDIClientSubscriptionListenerService",
45 endpointInterface="org.uddi.v3_service.UDDISubscriptionListenerPortType",
46 targetNamespace = "urn:uddi-org:v3_service")
4748publicclassUDDIClientSubscriptionListenerImplimplementsUDDISubscriptionListenerPortType {
4950privatestaticfinal Log logger = LogFactory.getLog(UDDIClientSubscriptionListenerImpl.class);
51privateUDDIServiceCache serviceCache = null;
5253publicUDDIClientSubscriptionListenerImpl() {
54super();
55 }
5657publicUDDIClientSubscriptionListenerImpl(String bindingKey, UDDIServiceCache serviceCache) {
58super();
59this.serviceCache = serviceCache;
60 }
616263/**64 * The SubscriptionListener is called by the UDDI Server when there is a change to any of the65 * services Endpoints. With every call the serviceCache is cleared.66 * @param body67 * @return success or fail68 * @throws DispositionReportFaultMessage 69 */70publicDispositionReport notifySubscriptionListener(
71 NotifySubscriptionListener body)
72throwsDispositionReportFaultMessage73 {
74try {
75 JAXBContext context = JAXBContext.newInstance(body.getClass());
76 Marshaller marshaller = context.createMarshaller();
77 StringWriter sw = new StringWriter();
78 marshaller.marshal(body, sw);
79 logger.info("Notification received by UDDISubscriptionListenerService : " + sw.toString());
80// reset the cache, big hammer for now, we could figure out changed from the81// subscriptionResults, and be more selective.82if (serviceCache!=null) serviceCache.removeAll();
8384 } catch (Exception e) {
85 logger.error(e.getMessage(),e);
86 }
8788 DispositionReport dr = newDispositionReport();
89 Result res = newResult();
90 dr.getResult().add(res);
91return dr;
92 }
9394 }