This project has retired. For details please refer to its
Attic page.
RMIRegistration xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.rmi;
17
18 import java.rmi.RemoteException;
19 import java.rmi.registry.LocateRegistry;
20 import java.rmi.registry.Registry;
21
22 import javax.naming.NamingException;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27
28
29
30 public class RMIRegistration
31 {
32 public static final String JUDDI = "/juddiv3";
33 public static final String UDDI_SECURITY_SERVICE = JUDDI + "/UDDISecurityService";
34 public static final String UDDI_PUBLICATION_SERVICE = JUDDI + "/UDDIPublicationService";
35 public static final String UDDI_INQUIRY_SERVICE = JUDDI + "/UDDIInquiryService";
36 public static final String UDDI_SUBSCRIPTION_SERVICE = JUDDI + "/UDDISubscriptionService";
37 public static final String UDDI_SUBSCRIPTION_LISTENER_SERVICE = JUDDI + "/UDDISubscriptionListenerService";
38 public static final String UDDI_CUSTODY_TRANSFER_SERVICE = JUDDI + "/UDDICustodyTransferService";
39 public static final String JUDDI_PUBLISHER_SERVICE = JUDDI + "/JUDDIApiService";
40
41 private UDDISecurityService securityService = null;
42 private UDDIPublicationService publicationService = null;
43 private UDDIInquiryService inquiryService = null;
44 private UDDISubscriptionService subscriptionService = null;
45 private UDDISubscriptionListenerService subscriptionListenerService = null;
46 private UDDICustodyTransferService custodyTransferService = null;
47 private JUDDIApiService publisherService = null;
48
49 private Log log = LogFactory.getLog(this.getClass());
50 Registry registry = null;
51 private static RMIRegistration registration = null;
52
53 public static RMIRegistration getInstance(int port) throws NamingException, RemoteException {
54 if (registration==null) {
55 registration = new RMIRegistration(port);
56 }
57 return registration;
58 }
59
60 private RMIRegistration(int port) throws NamingException, RemoteException{
61 super();
62 registry = LocateRegistry.createRegistry(port);
63 }
64
65
66
67
68 public void register(int port) {
69 try {
70 securityService = new UDDISecurityService(port);
71 if (log.isDebugEnabled()) log.debug("Setting " + UDDI_SECURITY_SERVICE + ", " + securityService.getClass());
72 registry.bind(UDDI_SECURITY_SERVICE, securityService);
73
74 publicationService = new UDDIPublicationService(port);
75 if (log.isDebugEnabled()) log.debug("Setting " + UDDI_PUBLICATION_SERVICE + ", " + publicationService.getClass());
76 registry.bind(UDDI_PUBLICATION_SERVICE, publicationService);
77
78 inquiryService = new UDDIInquiryService(port);
79 if (log.isDebugEnabled()) log.debug("Setting " + UDDI_INQUIRY_SERVICE + ", " + inquiryService.getClass());
80 registry.bind(UDDI_INQUIRY_SERVICE, inquiryService);
81
82 subscriptionService = new UDDISubscriptionService(port);
83 if (log.isDebugEnabled()) log.debug("Setting " + UDDI_SUBSCRIPTION_SERVICE + ", " + subscriptionService.getClass());
84 registry.bind(UDDI_SUBSCRIPTION_SERVICE, subscriptionService);
85
86 subscriptionListenerService = new UDDISubscriptionListenerService(port);
87 if (log.isDebugEnabled()) log.debug("Setting " + UDDI_SUBSCRIPTION_LISTENER_SERVICE + ", " + subscriptionListenerService.getClass());
88 registry.bind(UDDI_SUBSCRIPTION_LISTENER_SERVICE, subscriptionListenerService);
89
90 custodyTransferService = new UDDICustodyTransferService(port);
91 if (log.isDebugEnabled()) log.debug("Setting " + UDDI_CUSTODY_TRANSFER_SERVICE + ", " + custodyTransferService.getClass());
92 registry.bind(UDDI_CUSTODY_TRANSFER_SERVICE, custodyTransferService);
93
94 publisherService = new JUDDIApiService(port);
95 if (log.isDebugEnabled()) log.debug("Setting " + JUDDI_PUBLISHER_SERVICE + ", " + publisherService.getClass());
96 registry.bind(JUDDI_PUBLISHER_SERVICE, publisherService);
97
98 } catch (Exception e) {
99 log.error(e.getMessage(),e);
100 }
101 }
102
103 public void unregister() {
104
105 try {
106 registry.unbind(UDDI_SECURITY_SERVICE);
107 } catch (Exception e) {
108 log.error(e.getMessage(),e);
109 }
110 securityService = null;
111 try {
112 registry.unbind(UDDI_PUBLICATION_SERVICE);
113 } catch (Exception e) {
114 log.error(e.getMessage(),e);
115 }
116 publicationService = null;
117 try {
118 registry.unbind(UDDI_INQUIRY_SERVICE);
119 } catch (Exception e) {
120 log.error(e.getMessage(),e);
121 }
122 inquiryService = null;
123 try {
124 registry.unbind(UDDI_SUBSCRIPTION_SERVICE);
125 } catch (Exception e) {
126 log.error(e.getMessage(),e);
127 }
128 subscriptionService = null;
129 try {
130 registry.unbind(UDDI_SUBSCRIPTION_LISTENER_SERVICE);
131 } catch (Exception e) {
132 log.error(e.getMessage(),e);
133 }
134 subscriptionListenerService = null;
135 try {
136 registry.unbind(UDDI_CUSTODY_TRANSFER_SERVICE);
137 } catch (Exception e) {
138 log.error(e.getMessage(),e);
139 }
140 custodyTransferService = null;
141 try {
142 registry.unbind(JUDDI_PUBLISHER_SERVICE);
143 } catch (Exception e) {
144 log.error(e.getMessage(),e);
145 }
146 publisherService = null;
147
148 }
149 }