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