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.subscription.notify;
1819import java.io.IOException;
20import java.net.URI;
21import java.net.URISyntaxException;
22import java.rmi.NotBoundException;
23import java.rmi.RemoteException;
24import java.rmi.registry.LocateRegistry;
25import java.rmi.registry.Registry;
2627import org.apache.commons.logging.Log;
28import org.apache.commons.logging.LogFactory;
29import org.apache.juddi.api_v3.AccessPointType;
30import org.apache.juddi.model.BindingTemplate;
31import org.uddi.api_v3.DispositionReport;
32import org.uddi.subr_v3.NotifySubscriptionListener;
33import org.uddi.v3_service.DispositionReportFaultMessage;
34import org.uddi.v3_service.UDDISubscriptionListenerPortType;
3536publicclassRMINotifierimplementsNotifier {
3738 Log log = LogFactory.getLog(this.getClass());
39 UDDISubscriptionListenerPortType subscriptionListenerPort = null;
4041publicRMINotifier(BindingTemplate bindingTemplate) throws IOException, URISyntaxException, NotBoundException {
42super();
43if (!AccessPointType.END_POINT.toString().equalsIgnoreCase(bindingTemplate.getAccessPointType())) {
44 log.error("rmi enpoints only support AccessPointType " + AccessPointType.END_POINT);
45 }
46 String accessPointUrl = bindingTemplate.getAccessPointUrl().toLowerCase();
47if (!accessPointUrl.startsWith("rmi")) {
48 log.warn("rmi accessPointUrl for bindingTemplate " + bindingTemplate.getEntityKey() +
49" should start with 'rmi'");
50 }
51 URI accessPointURI = new URI(accessPointUrl);
52 String host = accessPointURI.getHost();
53int port = accessPointURI.getPort();
54 String path = accessPointURI.getPath();
55 log.debug("Connecting to " + host + ":" + port);
56 Registry registry = LocateRegistry.getRegistry(host, port);
57 subscriptionListenerPort = (UDDISubscriptionListenerPortType) registry.lookup(path);
58 }
5960publicDispositionReport notifySubscriptionListener(NotifySubscriptionListener body) throws DispositionReportFaultMessage, RemoteException {
61return subscriptionListenerPort.notifySubscriptionListener(body);
62 }
63 }