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 */17package org.apache.juddi.v3.tck;
1819import java.io.StringWriter;
20import java.rmi.RemoteException;
21import java.rmi.server.UnicastRemoteObject;
22import java.util.HashMap;
23import java.util.Map;
2425import javax.jws.WebService;
26import javax.xml.bind.JAXBContext;
27import javax.xml.bind.Marshaller;
2829import org.apache.commons.logging.Log;
30import org.apache.commons.logging.LogFactory;
31import org.uddi.api_v3.DispositionReport;
32import org.uddi.api_v3.Result;
33import org.uddi.subr_v3.NotifySubscriptionListener;
34import org.uddi.v3_service.DispositionReportFaultMessage;
35import org.uddi.v3_service.UDDISubscriptionListenerPortType;
3637/**38 * WebService which implements the UDDI v3 SubscriptionListener API. This39 * service can be brought during integration testing on the test side. The UDDI40 * server can then call in to it.41 *42 * @author kstam43 *44 */45 @WebService(serviceName = "UDDISubscriptionListenerService",
46 endpointInterface = "org.uddi.v3_service.UDDISubscriptionListenerPortType",
47 targetNamespace = "urn:uddi-org:v3_service")
48publicclassUDDISubscriptionListenerImplextends UnicastRemoteObject implements49 UDDISubscriptionListenerPortType {
5051privatestaticfinallong serialVersionUID = -4621713293140278731L;
52privatestatic Log logger = LogFactory.getLog(UDDISubscriptionListenerImpl.class);
53publicstatic Integer notificationCount = 0;
54publicstatic Map<Integer, String> notifcationMap = new HashMap<Integer, String>();
5556publicUDDISubscriptionListenerImpl() throws RemoteException {
57super();
58 }
5960publicUDDISubscriptionListenerImpl(int port) throws RemoteException {
61super(port);
62 }
6364public DispositionReport notifySubscriptionListener(
65 NotifySubscriptionListener body)
66throws DispositionReportFaultMessage {
67try {
68 JAXBContext context = JAXBContext.newInstance(body.getClass());
69 Marshaller marshaller = context.createMarshaller();
70 StringWriter sw = new StringWriter();
71 marshaller.marshal(body, sw);
72if (TckCommon.isDebug()) {
73 logger.info("Notification received by UDDISubscriptionListenerService : " + sw.toString());
74 } else {
75 logger.info("Notification received by UDDISubscriptionListenerService");
76 }
7778//Adding the received subscription XML to a Map.79 notifcationMap.put(notificationCount++, sw.toString());
8081 } catch (Exception e) {
82 e.printStackTrace();
83 }
8485 DispositionReport dr = new DispositionReport();
86 Result res = new Result();
87 dr.getResult().add(res);
88return dr;
89 }
90 }