01: /*
02: * Created on Dec 2, 2004
03: *
04: * TODO To change the template for this generated file go to
05: * Window - Preferences - Java - Code Style - Code Templates
06: */
07: package org.tigris.scarab.util;
08:
09: import org.apache.fulcrum.mimetype.MimeTypeService;
10: import org.tigris.scarab.services.ServiceManager;
11: import org.tigris.scarab.tools.localization.L10NKeySet;
12:
13: /**
14: * @author Eric Pugh
15: *
16: * TODO To change the template for this generated type comment go to Window -
17: * Preferences - Java - Code Style - Code Templates
18: */
19: public class ComponentLocator {
20: private static MimeTypeService mimeTypeService;
21:
22: /**
23: * @return Returns the mimeTypeService.
24: */
25: public static MimeTypeService getMimeTypeService() {
26: if (mimeTypeService == null) {
27: mimeTypeService = (MimeTypeService) lookup(MimeTypeService.class);
28: }
29: return mimeTypeService;
30: }
31:
32: /**
33: * @param mimeTypeService
34: * The mimeTypeService to set.
35: */
36: public static void setMimeTypeService(
37: MimeTypeService mimeTypeService) {
38: ComponentLocator.mimeTypeService = mimeTypeService;
39: }
40:
41: /**
42: * @param class1
43: * @return
44: */
45: private static Object lookup(Class clazz) {
46: try {
47: ServiceManager sm = ServiceManager.getInstance();
48: return sm.lookup(clazz);
49: } catch (Exception e) {
50: throw new ScarabRuntimeException(
51: L10NKeySet.ExceptionComponentLocator, clazz
52: .getName(), e);
53: }
54: }
55: }
|