View Javadoc

1   /*
2    * $Id: Constants.java,v 1.1 2007/10/30 13:46:42 oeuillot Exp $
3    */
4   package org.rcfaces.core.internal.style;
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: 2007/10/30 13:46:42 $
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_STYLE_LOADER_FACTORY = true;
23  
24      private static final String CONSTANT_PREFIX;
25      static {
26          String name = Constants.class.getPackage().getName();
27          int idx = name.indexOf(".internal");
28          if (idx >= 0) {
29              name = name.substring(0, idx)
30                      + name.substring(name.indexOf('.', idx + 1));
31          }
32  
33          CONSTANT_PREFIX = name;
34      }
35  
36      private static final IResourceLoaderFactory DESIGNER_STYLE_LOADER_FACTORY = new ClassLoaderResourceLoaderFactory();
37  
38      private static final IResourceLoaderFactory STYLE_LOADER_FACTORY;
39  
40      static {
41  
42          if (USE_INCLUDE_STYLE_LOADER_FACTORY) {
43              STYLE_LOADER_FACTORY = new IncludeResourceLoaderFactory();
44  
45          } else {
46              STYLE_LOADER_FACTORY = DESIGNER_STYLE_LOADER_FACTORY;
47          }
48  
49          LOG.info("USE_INCLUDE_STYLE_LOADER_FACTORY="
50                  + USE_INCLUDE_STYLE_LOADER_FACTORY + " ("
51                  + STYLE_LOADER_FACTORY.getName() + ")");
52      }
53  
54      public static final String getPackagePrefix() {
55          return CONSTANT_PREFIX;
56      }
57  
58      public static final IResourceLoaderFactory getStyleLoaderFactory() {
59          return STYLE_LOADER_FACTORY;
60      }
61  
62      public static final IResourceLoaderFactory getDesignerStyleLoaderFactory() {
63          return DESIGNER_STYLE_LOADER_FACTORY;
64      }
65  }