View Javadoc

1   /*
2    * $Id: Constants.java,v 1.1 2010/01/27 14:55:37 oeuillot Exp $
3    */
4   package org.rcfaces.core.internal.content;
5   
6   import org.apache.commons.logging.Log;
7   import org.apache.commons.logging.LogFactory;
8   import org.rcfaces.core.internal.resource.ClassLoaderResourceLoaderFactory;
9   import org.rcfaces.core.internal.resource.IResourceLoaderFactory;
10  import org.rcfaces.core.internal.resource.IncludeResourceLoaderFactory;
11  
12  /**
13   * 
14   * @author Olivier Oeuillot (latest modification by $Author: oeuillot $)
15   * @version $Revision: 1.1 $ $Date: 2010/01/27 14:55:37 $
16   */
17  public class Constants {
18      private static final String REVISION = "$Revision: 1.1 $";
19  
20      private static final Log LOG = LogFactory.getLog(Constants.class);
21  
22      private static final boolean USE_INCLUDE_IMAGE_LOADER_FACTORY = true;
23  
24      private static final String CONSTANT_PREFIX;
25      static {
26          String name = Constants.class.getPackage().getName();
27          if (name.endsWith(".internal")) {
28              name = name.substring(0, name.lastIndexOf('.'));
29          }
30  
31          CONSTANT_PREFIX = name;
32      }
33  
34      private static final IResourceLoaderFactory DESIGNER_IMAGE_LOADER_FACTORY = new ClassLoaderResourceLoaderFactory();
35  
36      private static final IResourceLoaderFactory IMAGE_LOADER_FACTORY;
37  
38      static {
39  
40          if (USE_INCLUDE_IMAGE_LOADER_FACTORY) {
41              IMAGE_LOADER_FACTORY = new IncludeResourceLoaderFactory();
42  
43          } else {
44              IMAGE_LOADER_FACTORY = DESIGNER_IMAGE_LOADER_FACTORY;
45          }
46  
47          LOG.info("USE_INCLUDE_IMAGE_LOADER_FACTORY="
48                  + USE_INCLUDE_IMAGE_LOADER_FACTORY + " ("
49                  + IMAGE_LOADER_FACTORY.getName() + ")");
50      }
51  
52      public static final String getPackagePrefix() {
53          return CONSTANT_PREFIX;
54      }
55  
56      public static final IResourceLoaderFactory getImageLoaderFactory() {
57          return IMAGE_LOADER_FACTORY;
58      }
59  
60      public static final IResourceLoaderFactory getDesignerImageLoaderFactory() {
61          return DESIGNER_IMAGE_LOADER_FACTORY;
62      }
63  }