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