1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.service;
17
18 import java.util.List;
19
20 import javax.persistence.EntityManagerFactory;
21 import javax.sql.DataSource;
22
23 import org.apache.cxf.Bus;
24 import org.apache.cxf.bus.CXFBusImpl;
25 import org.apache.cxf.endpoint.ServerRegistry;
26 import org.apache.cxf.interceptor.Interceptor;
27 import org.apache.cxf.message.Message;
28 import org.apache.cxf.transport.servlet.ServletTransportFactory;
29 import org.kuali.rice.core.api.exception.RiceRemoteServiceConnectionException;
30 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
31 import org.kuali.rice.ksb.api.messaging.MessageHelper;
32 import org.kuali.rice.ksb.messaging.bam.service.BAMService;
33 import org.kuali.rice.ksb.messaging.exceptionhandling.ExceptionRoutingService;
34 import org.kuali.rice.ksb.messaging.service.BusAdminService;
35 import org.kuali.rice.ksb.messaging.service.MessageQueueService;
36 import org.kuali.rice.ksb.messaging.serviceexporters.ServiceExportManager;
37 import org.kuali.rice.ksb.messaging.threadpool.KSBScheduledPool;
38 import org.kuali.rice.ksb.messaging.threadpool.KSBThreadPool;
39 import org.kuali.rice.ksb.security.admin.service.JavaSecurityManagementService;
40 import org.kuali.rice.ksb.security.service.DigitalSignatureService;
41 import org.kuali.rice.ksb.util.KSBConstants;
42 import org.quartz.Scheduler;
43 import org.springframework.transaction.PlatformTransactionManager;
44 import org.springframework.transaction.support.TransactionTemplate;
45
46
47 public class KSBServiceLocator {
48 public static Object getService(String name) {
49 return GlobalResourceLoader.getService(name);
50 }
51
52 public static EntityManagerFactory getMessageEntityManagerFactory() {
53 return (EntityManagerFactory) getService(KSBConstants.ServiceNames.MESSAGE_ENTITY_MANAGER_FACTORY);
54 }
55
56 public static EntityManagerFactory getRegistryEntityManagerFactory() {
57 return (EntityManagerFactory) getService(KSBConstants.ServiceNames.REGISTRY_ENTITY_MANAGER_FACTORY);
58 }
59
60 public static TransactionTemplate getTransactionTemplate() {
61 return (TransactionTemplate) getService(KSBConstants.ServiceNames.TRANSACTION_TEMPLATE);
62 }
63
64 public static PlatformTransactionManager getPlatformTransactionManager() {
65 return (PlatformTransactionManager) getService(KSBConstants.ServiceNames.TRANSACTION_MANAGER);
66 }
67
68 public static BAMService getBAMService() {
69 return (BAMService) getService(KSBConstants.ServiceNames.BAM_SERVICE);
70 }
71
72 public static MessageQueueService getMessageQueueService() {
73 return (MessageQueueService) getService(KSBConstants.ServiceNames.MESSAGE_QUEUE_SERVICE);
74 }
75
76 public static ExceptionRoutingService getExceptionRoutingService() {
77 return (ExceptionRoutingService) getService(KSBConstants.ServiceNames.EXCEPTION_MESSAGING_SERVICE);
78 }
79
80 public static ServiceExportManager getServiceExportManager() {
81 return (ServiceExportManager) getService(KSBConstants.ServiceNames.SERVICE_EXPORT_MANAGER);
82 }
83
84 public static DigitalSignatureService getDigitalSignatureService() {
85 return (DigitalSignatureService) getService(KSBConstants.ServiceNames.DIGITAL_SIGNATURE_SERVICE);
86 }
87
88 public static JavaSecurityManagementService getJavaSecurityManagementService() {
89 return (JavaSecurityManagementService) getService(KSBConstants.ServiceNames.JAVA_SECURITY_MANAGEMENT_SERVICE);
90 }
91
92 public static KSBThreadPool getThreadPool() {
93 return (KSBThreadPool) getService(KSBConstants.ServiceNames.THREAD_POOL_SERVICE);
94 }
95
96 public static KSBScheduledPool getScheduledPool() {
97 return (KSBScheduledPool) getService(KSBConstants.ServiceNames.SCHEDULED_THREAD_POOL_SERVICE);
98 }
99
100 public static Bus getCXFBus(){
101 return (CXFBusImpl) getService(KSBConstants.ServiceNames.CXF_BUS);
102 }
103
104 public static ServletTransportFactory getCXFServletTransportFactory(){
105 return (ServletTransportFactory)getService(KSBConstants.ServiceNames.CXF_SERVLET_TRANSPORT_FACTORY);
106 }
107
108 public static ServerRegistry getCXFServerRegistry(){
109 return (ServerRegistry)getService(KSBConstants.ServiceNames.CXF_SERVER_REGISTRY);
110 }
111
112 public static List<Interceptor<? extends Message>> getInInterceptors() {
113 try {
114 return (List<Interceptor<? extends Message>>) getService(KSBConstants.ServiceNames.BUS_IN_INTERCEPTORS);
115 }
116 catch(RiceRemoteServiceConnectionException ex) {
117
118 return null;
119 }
120 }
121
122 public static List<Interceptor<? extends Message>> getOutInterceptors() {
123 try {
124 return (List<Interceptor<? extends Message>>) getService(KSBConstants.ServiceNames.BUS_OUT_INTERCEPTORS);
125 }
126 catch(RiceRemoteServiceConnectionException ex) {
127
128 return null;
129 }
130 }
131
132 public static DataSource getMessageDataSource() {
133 return (DataSource) getService(KSBConstants.ServiceNames.MESSAGE_DATASOURCE);
134 }
135
136 public static DataSource getMessageNonTransactionalDataSource() {
137 return (DataSource) getService(KSBConstants.ServiceNames.MESSAGE_NON_TRANSACTIONAL_DATASOURCE);
138 }
139
140 public static DataSource getRegistryDataSource() {
141 return (DataSource) getService(KSBConstants.ServiceNames.REGISTRY_DATASOURCE);
142 }
143
144 public static Scheduler getScheduler() {
145 return (Scheduler) getService(KSBConstants.ServiceNames.SCHEDULER);
146 }
147
148 public static BusAdminService getService() {
149 return (BusAdminService) getService(KSBConstants.ServiceNames.BUS_ADMIN_SERVICE);
150 }
151
152 }