View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
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 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.transport.servlet.ServletTransportFactory;
28  import org.kuali.rice.core.exception.RiceRemoteServiceConnectionException;
29  import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
30  import org.kuali.rice.ksb.messaging.MessageHelper;
31  import org.kuali.rice.ksb.messaging.RemotedServiceRegistry;
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.service.ServiceRegistry;
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  
49  	/**
50  	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.OBJECT_REMOTER
51  	 */
52  	@Deprecated
53      public static final String OBJECT_REMOTER = KSBConstants.ServiceNames.OBJECT_REMOTER;
54  	
55  	/**
56  	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.SERVICE_REMOVER_SERVICE
57  	 */
58  	@Deprecated
59      public static final String SERVICE_REMOVER_SERVICE = KSBConstants.ServiceNames.SERVICE_REMOVER_SERVICE;
60  	
61  	/**
62  	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.THREAD_POOL_SERVICE
63  	 */
64  	@Deprecated
65      public static final String THREAD_POOL_SERVICE = KSBConstants.ServiceNames.THREAD_POOL_SERVICE;
66  	
67  	/**
68  	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.REMOTED_SERVICE_REGISTRY
69  	 */
70  	@Deprecated
71      public static final String REMOTED_SERVICE_REGISTRY = KSBConstants.ServiceNames.REMOTED_SERVICE_REGISTRY;
72  	
73  	/**
74  	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.REPEAT_TOPIC_INVOKING_QUEUE
75  	 */
76  	@Deprecated
77      public static final String REPEAT_TOPIC_INVOKING_QUEUE = KSBConstants.ServiceNames.REPEAT_TOPIC_INVOKING_QUEUE;
78  	
79  	/**
80  	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.ENCRYPTION_SERVICE
81  	 */
82  	@Deprecated
83      public static final String ENCRYPTION_SERVICE = KSBConstants.ServiceNames.ENCRYPTION_SERVICE;
84  	
85  	/**
86  	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.DIGITAL_SIGNATURE_SERVICE
87  	 */
88  	@Deprecated
89      public static final String DIGITAL_SIGNATURE_SERVICE = KSBConstants.ServiceNames.DIGITAL_SIGNATURE_SERVICE;
90  	
91  	/**
92  	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.JAVA_SECURITY_MANAGEMENT_SERVICE
93  	 */
94  	@Deprecated
95      public static final String JAVA_SECURITY_MANAGEMENT_SERVICE = KSBConstants.ServiceNames.JAVA_SECURITY_MANAGEMENT_SERVICE;
96  	
97  	/**
98  	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.CACHE_ADMINISTRATOR_FACTORY
99  	 */
100 	@Deprecated
101     public static final String CACHE_ADMINISTRATOR_FACTORY = KSBConstants.ServiceNames.CACHE_ADMINISTRATOR_FACTORY;
102 	
103 	/**
104 	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.JTA_TRANSACTION_MANAGER
105 	 */
106 	@Deprecated
107     public static final String JTA_TRANSACTION_MANAGER = KSBConstants.ServiceNames.JTA_TRANSACTION_MANAGER;
108 	
109 	/**
110 	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.SCHEDULED_THREAD_POOL_SERVICE
111 	 */
112 	@Deprecated
113     public static final String SCHEDULED_THREAD_POOL_SERVICE = KSBConstants.ServiceNames.SCHEDULED_THREAD_POOL_SERVICE;
114 	
115 	/**
116 	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.BUS_ADMIN_SERVICE
117 	 */
118 	@Deprecated
119     public static final String BUS_ADMIN_SERVICE = KSBConstants.ServiceNames.BUS_ADMIN_SERVICE;
120     
121 	/**
122 	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.MESSAGE_ENTITY_MANAGER_FACTORY
123 	 */
124 	@Deprecated
125     public static final String MESSAGE_ENTITY_MANAGER_FACTORY = KSBConstants.ServiceNames.MESSAGE_ENTITY_MANAGER_FACTORY;
126     
127     /**
128 	 * @deprecated Use org.kuali.rice.ksb.util.KSBConstants.ServiceNames.REGISTRY_ENTITY_MANAGER_FACTORY
129 	 */
130 	@Deprecated
131     public static final String REGISTRY_ENTITY_MANAGER_FACTORY = KSBConstants.ServiceNames.REGISTRY_ENTITY_MANAGER_FACTORY;
132 
133 	
134     public static Object getService(String name) {
135         return GlobalResourceLoader.getService(name);
136     }
137 
138     public static EntityManagerFactory getMessageEntityManagerFactory() {
139         return (EntityManagerFactory) getService(KSBConstants.ServiceNames.MESSAGE_ENTITY_MANAGER_FACTORY);
140     }
141     
142     public static EntityManagerFactory getRegistryEntityManagerFactory() {
143         return (EntityManagerFactory) getService(KSBConstants.ServiceNames.REGISTRY_ENTITY_MANAGER_FACTORY);
144     }
145     
146     public static TransactionTemplate getTransactionTemplate() {
147         return (TransactionTemplate) getService(KSBConstants.ServiceNames.TRANSACTION_TEMPLATE);
148     }
149 
150     public static PlatformTransactionManager getPlatformTransactionManager() {
151         return (PlatformTransactionManager) getService(KSBConstants.ServiceNames.TRANSACTION_MANAGER);
152     }
153 
154     public static BAMService getBAMService() {
155         return (BAMService) getService(KSBConstants.ServiceNames.BAM_SERVICE);
156     }
157 
158     public static MessageHelper getMessageHelper() {
159         return (MessageHelper) getService(KSBConstants.ServiceNames.MESSAGE_HELPER);
160     }
161 
162     public static MessageQueueService getRouteQueueService() {
163         return (MessageQueueService) getService(KSBConstants.ServiceNames.ROUTE_QUEUE_SERVICE);
164     }
165 
166     public static ExceptionRoutingService getExceptionRoutingService() {
167         return (ExceptionRoutingService) getService(KSBConstants.ServiceNames.EXCEPTION_MESSAGING_SERVICE);
168     }
169 
170     public static RemotedServiceRegistry getServiceDeployer() {
171         return (RemotedServiceRegistry) getService(KSBConstants.ServiceNames.REMOTED_SERVICE_REGISTRY);
172     }
173 
174     public static DigitalSignatureService getDigitalSignatureService() {
175         return (DigitalSignatureService) getService(KSBConstants.ServiceNames.DIGITAL_SIGNATURE_SERVICE);
176     }
177 
178     public static JavaSecurityManagementService getJavaSecurityManagementService() {
179         return (JavaSecurityManagementService) getService(KSBConstants.ServiceNames.JAVA_SECURITY_MANAGEMENT_SERVICE);
180     }
181 
182     public static KSBThreadPool getThreadPool() {
183         return (KSBThreadPool) getService(KSBConstants.ServiceNames.THREAD_POOL_SERVICE);
184     }
185 
186     public static KSBScheduledPool getScheduledPool() {
187         return (KSBScheduledPool) getService(KSBConstants.ServiceNames.SCHEDULED_THREAD_POOL_SERVICE);
188     }
189 
190     public static ServiceRegistry getServiceRegistry() {
191         return (ServiceRegistry) getService(KSBConstants.ServiceNames.SERVICE_REGISTRY);
192     }
193 
194     public static Bus getCXFBus(){
195     	return (CXFBusImpl) getService(KSBConstants.ServiceNames.CXF_BUS);
196     }
197 
198     public static ServletTransportFactory getCXFServletTransportFactory(){
199     	return (ServletTransportFactory)getService(KSBConstants.ServiceNames.CXF_SERVLET_TRANSPORT_FACTORY);
200     }
201     
202     public static ServerRegistry getCXFServerRegistry(){
203     	return (ServerRegistry)getService(KSBConstants.ServiceNames.CXF_SERVER_REGISTRY);
204     }
205     
206     public static List<Interceptor> getInInterceptors() {
207     	try {
208     		return (List<Interceptor>) getService(KSBConstants.ServiceNames.BUS_IN_INTERCEPTORS);
209     	}
210     	catch(RiceRemoteServiceConnectionException ex) {
211     		// swallow this exception, means no bus wide interceptors defined
212     		return null;
213     	}
214     }
215     
216     public static List<Interceptor> getOutInterceptors() {
217     	try {
218     		return (List<Interceptor>) getService(KSBConstants.ServiceNames.BUS_OUT_INTERCEPTORS);
219     	}
220     	catch(RiceRemoteServiceConnectionException ex) {
221     		// swallow this exception, means no bus wide interceptors defined
222     		return null;
223     	}
224     }
225 
226     public static DataSource getMessageDataSource() {
227         return (DataSource) getService(KSBConstants.ServiceNames.MESSAGE_DATASOURCE);
228     }
229 
230     public static DataSource getMessageNonTransactionalDataSource() {
231         return (DataSource) getService(KSBConstants.ServiceNames.MESSAGE_NON_TRANSACTIONAL_DATASOURCE);
232     }
233 
234     public static DataSource getRegistryDataSource() {
235         return (DataSource) getService(KSBConstants.ServiceNames.REGISTRY_DATASOURCE);
236     }
237 
238     public static Scheduler getScheduler() {
239         return (Scheduler) getService(KSBConstants.ServiceNames.SCHEDULER);
240     }
241 
242     public static BusAdminService getService() {
243         return (BusAdminService) getService(KSBConstants.ServiceNames.BUS_ADMIN_SERVICE);
244     }
245 
246 }