1 7 package org.tigris.scarab.util; 8 9 import org.apache.fulcrum.TurbineServices; 10 import org.apache.fulcrum.mimetype.MimeTypeService; 11 import org.apache.turbine.services.yaaficomponent.YaafiComponentService; 12 import org.tigris.scarab.tools.localization.L10NKeySet; 13 14 20 public class ComponentLocator { 21 private static MimeTypeService mimeTypeService; 22 23 26 public static MimeTypeService getMimeTypeService() { 27 if (mimeTypeService == null) { 28 mimeTypeService = (MimeTypeService) lookup(MimeTypeService.class); 29 } 30 return mimeTypeService; 31 } 32 33 37 public static void setMimeTypeService(MimeTypeService mimeTypeService) { 38 ComponentLocator.mimeTypeService = mimeTypeService; 39 } 40 41 45 private static Object lookup(Class clazz) { 46 YaafiComponentService yaafi = (YaafiComponentService) TurbineServices 47 .getInstance().getService(YaafiComponentService.SERVICE_NAME); 48 try { 49 return yaafi.lookup(clazz.getName()); 50 } catch (Exception e) { 51 throw new ScarabRuntimeException( 52 L10NKeySet.ExceptionComponentLocator, 53 clazz.getName(), 54 e); 55 } 56 } 57 } | Popular Tags |