This project has retired. For details please refer to its
Attic page.
JNDI_RMINotifier xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juddi.subscription.notify;
18
19 import java.io.IOException;
20 import java.net.URI;
21 import java.net.URISyntaxException;
22 import java.rmi.NotBoundException;
23 import java.rmi.RemoteException;
24 import java.util.Properties;
25
26 import javax.naming.InitialContext;
27 import javax.naming.NamingException;
28 import javax.xml.bind.JAXBException;
29
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32 import org.apache.juddi.InitialContextInfo;
33 import org.apache.juddi.Property;
34 import org.apache.juddi.api_v3.AccessPointType;
35 import org.apache.juddi.jaxb.JAXBMarshaller;
36 import org.apache.juddi.model.BindingTemplate;
37 import org.apache.juddi.model.TmodelInstanceInfo;
38 import org.uddi.api_v3.DispositionReport;
39 import org.uddi.subr_v3.NotifySubscriptionListener;
40 import org.uddi.v3_service.DispositionReportFaultMessage;
41 import org.uddi.v3_service.UDDISubscriptionListenerPortType;
42
43 public class JNDI_RMINotifier implements Notifier {
44
45 Log log = LogFactory.getLog(this.getClass());
46 UDDISubscriptionListenerPortType subscriptionListenerPort = null;
47 public static final String JNDI_RMI_TRANSPORT_KEY = "uddi:uddi.org:transport:jndi-rmi";
48
49 public JNDI_RMINotifier(BindingTemplate bindingTemplate) throws IOException,
50 URISyntaxException, NotBoundException, NamingException, JAXBException {
51 super();
52 if (!AccessPointType.END_POINT.toString().equalsIgnoreCase(bindingTemplate.getAccessPointType())) {
53 log.error("jndi-rmi enpoints only support AccessPointType " + AccessPointType.END_POINT);
54 }
55 String accessPointUrl = bindingTemplate.getAccessPointUrl().toLowerCase();
56 if (!accessPointUrl.startsWith("jndi-rmi")) {
57 log.warn("jndi-rmi accessPointUrl for bindingTemplate " + bindingTemplate.getEntityKey() +
58 " should start with 'jndi-rmi'");
59 }
60 InitialContext context = new InitialContext();
61 for (TmodelInstanceInfo tModelInstanceInfo : bindingTemplate.getTmodelInstanceInfos()) {
62 if (tModelInstanceInfo.getTmodelKey().equals(JNDI_RMI_TRANSPORT_KEY)) {
63 if (log.isDebugEnabled()) log.debug("Found transport tModelKey " + tModelInstanceInfo.getTmodelKey());
64 String instanceParmsStr = tModelInstanceInfo.getInstanceParms();
65 if (instanceParmsStr!=null) {
66 if (log.isDebugEnabled()) log.debug("Found instanceParms with value: " + instanceParmsStr);
67 InitialContextInfo icInfo = (InitialContextInfo) JAXBMarshaller.unmarshallFromString(instanceParmsStr, JAXBMarshaller.PACKAGE_JUDDI);
68 Properties properties = new Properties();
69 for (Property property: icInfo.getContextProperty()) {
70 if (log.isDebugEnabled()) {
71 log.debug("Initial Context Property from instanceParms " +
72 property.getName() + ":" + property.getValue());
73 }
74 properties.put(property.getName(), property.getValue());
75 }
76 context = new InitialContext(properties);
77 break;
78 }
79 }
80 }
81 URI accessPointURI = new URI(accessPointUrl);
82 String path = accessPointURI.getPath();
83
84 subscriptionListenerPort = (UDDISubscriptionListenerPortType) context.lookup(path);
85 log.info("Successfully located " + path);
86 }
87
88 public DispositionReport notifySubscriptionListener(NotifySubscriptionListener body) throws DispositionReportFaultMessage, RemoteException {
89 return subscriptionListenerPort.notifySubscriptionListener(body);
90 }
91 }