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;
17:
18: import java.lang.reflect.Method;
19:
20: import org.kuali.bus.services.KSBServiceLocator;
21: import org.kuali.rice.exceptions.RiceRuntimeException;
22: import org.kuali.rice.lifecycle.BaseLifecycle;
23:
24: import edu.iu.uis.eden.messaging.config.ServiceBasedServiceDefinitionRegisterer;
25:
26: public class RepeatTopicInvokerQueueImpl extends BaseLifecycle
27: implements RepeatTopicInvokerQueue {
28:
29: private ServiceBasedServiceDefinitionRegisterer defRegisterer;
30:
31: public Object invokeTopic(AsynchronousCall methodCall) {
32: ServiceInfo serviceInfo = methodCall.getServiceInfo();
33: Object service = KSBServiceLocator.getMessageHelper()
34: .getServiceAsynchronously(serviceInfo.getQname());
35: try {
36: Method method = service.getClass().getMethod(
37: methodCall.getMethodName(),
38: methodCall.getParamTypes());
39: return method.invoke(service, methodCall.getArguments());
40: } catch (Throwable t) {
41: throw new RiceRuntimeException(
42: "Caught Exception invoking repeatable topic", t);
43: }
44: }
45:
46: public void start() throws Exception {
47: this .defRegisterer = new ServiceBasedServiceDefinitionRegisterer(
48: "repeatTopicInvokerQueueDefinition");
49: this .defRegisterer.registerServiceDefinition(false);
50: setStarted(true);
51: }
52:
53: public void stop() throws Exception {
54: this .defRegisterer.unregisterServiceDefinition();
55: setStarted(false);
56: }
57: }
|