01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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: package edu.iu.uis.eden.messaging.config;
17:
18: import org.kuali.bus.services.KSBServiceLocator;
19: import org.kuali.rice.resourceloader.GlobalResourceLoader;
20:
21: import edu.iu.uis.eden.messaging.ServiceDefinition;
22:
23: /**
24: * Registers {@link ServiceDefinition} objects
25: * configured as a service (typically a Spring bean) dynamically with the
26: * service registry.
27: *
28: *
29: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
30: *
31: */
32: public class ServiceBasedServiceDefinitionRegisterer {
33:
34: private String serviceName;
35:
36: public ServiceBasedServiceDefinitionRegisterer(String serviceName) {
37: this .setServiceName(serviceName);
38: }
39:
40: /**
41: * Goes to the {@link GlobalResourceLoader} to find the ServiceDefinition using the name
42: * passed in. Validates the Definition and registers it with the registry.
43: *
44: * @param serviceName
45: * @param forceRegistryRefresh
46: */
47: public void registerServiceDefinition(boolean forceRegistryRefresh) {
48: ServiceDefinition serviceDef = (ServiceDefinition) GlobalResourceLoader
49: .getService(this .getServiceName());
50: serviceDef.validate();
51: KSBServiceLocator.getServiceDeployer().registerService(
52: serviceDef, forceRegistryRefresh);
53: }
54:
55: public void unregisterServiceDefinition() {
56: ServiceDefinition serviceDef = (ServiceDefinition) GlobalResourceLoader
57: .getService(this .getServiceName());
58: KSBServiceLocator.getServiceDeployer()
59: .removeRemoteServiceFromRegistry(
60: serviceDef.getServiceName());
61: }
62:
63: public String getServiceName() {
64: return this .serviceName;
65: }
66:
67: public void setServiceName(String serviceName) {
68: this.serviceName = serviceName;
69: }
70: }
|