This project has retired. For details please refer to its Attic page.
UDDISubscriptionListenerImpl xref
View Javadoc
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 at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * 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 and
14   * limitations under the License.
15   *
16   */
17  package org.apache.juddi.v3.tck;
18  
19  import java.io.StringWriter;
20  import java.rmi.RemoteException;
21  import java.rmi.server.UnicastRemoteObject;
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  import javax.jws.WebService;
26  import javax.xml.bind.JAXBContext;
27  import javax.xml.bind.Marshaller;
28  
29  import org.apache.commons.logging.Log;
30  import org.apache.commons.logging.LogFactory;
31  import org.uddi.api_v3.DispositionReport;
32  import org.uddi.api_v3.Result;
33  import org.uddi.subr_v3.NotifySubscriptionListener;
34  import org.uddi.v3_service.DispositionReportFaultMessage;
35  import org.uddi.v3_service.UDDISubscriptionListenerPortType;
36  
37  /**
38   * WebService which implements the UDDI v3 SubscriptionListener API. This
39   * service can be brought during integration testing on the test side. The UDDI
40   * server can then call in to it.
41   *
42   * @author kstam
43   *
44   */
45  @WebService(serviceName = "UDDISubscriptionListenerService",
46          endpointInterface = "org.uddi.v3_service.UDDISubscriptionListenerPortType",
47          targetNamespace = "urn:uddi-org:v3_service")
48  public class UDDISubscriptionListenerImpl extends UnicastRemoteObject implements
49          UDDISubscriptionListenerPortType {
50  
51          private static final long serialVersionUID = -4621713293140278731L;
52          private static Log logger = LogFactory.getLog(UDDISubscriptionListenerImpl.class);
53          public static Integer notificationCount = 0;
54          public static Map<Integer, String> notifcationMap = new HashMap<Integer, String>();
55  
56          public UDDISubscriptionListenerImpl() throws RemoteException {
57                  super();
58          }
59  
60          public UDDISubscriptionListenerImpl(int port) throws RemoteException {
61                  super(port);
62          }
63  
64          public DispositionReport notifySubscriptionListener(
65                  NotifySubscriptionListener body)
66                  throws DispositionReportFaultMessage {
67                  try {
68                          JAXBContext context = JAXBContext.newInstance(body.getClass());
69                          Marshaller marshaller = context.createMarshaller();
70                          StringWriter sw = new StringWriter();
71                          marshaller.marshal(body, sw);
72                          if (TckCommon.isDebug()) {
73                                  logger.info("Notification received by UDDISubscriptionListenerService : " + sw.toString());
74                          } else {
75                                  logger.info("Notification received by UDDISubscriptionListenerService");
76                          }
77  
78                          //Adding the received subscription XML to a Map.
79                          notifcationMap.put(notificationCount++, sw.toString());
80  
81                  } catch (Exception e) {
82                          e.printStackTrace();
83                  }
84  
85                  DispositionReport dr = new DispositionReport();
86                  Result res = new Result();
87                  dr.getResult().add(res);
88                  return dr;
89          }
90  }