Changeset 3990
- Timestamp:
- 19/10/08 16:11:23 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/java/org/sarugo/xtc/TemplateFactory.java
r3966 r3990 31 31 public abstract class TemplateFactory { 32 32 33 private static volatileResolver resolver = new Resolver();33 private static Resolver resolver = new Resolver(); 34 34 35 private static T hreadLocal<TemplateFactory> instance = new ThreadLocal<TemplateFactory>();35 private static TemplateFactory instance; 36 36 37 37 private static final String PROVIDER_RESOURCE = "META-INF/services/org.sarugo.xtc.TemplateFactory"; … … 65 65 66 66 /** 67 * Contructs a thread-local singleton based on the configured service68 * provider . The providerclass is configured in67 * Contructs a singleton based on the configured service provider. The 68 * provider class is configured in 69 69 * <code>META-INF/services/org.sarugo.xtc.TemplateFactory</code>. 70 70 * 71 * @return thread-localsingleton.71 * @return singleton. 72 72 */ 73 public static TemplateFactory getInstance() { 74 TemplateFactory result = instance.get(); 75 if (result == null) { 73 public static synchronized TemplateFactory getInstance() { 74 if (instance == null) { 76 75 try { 77 instance .set((TemplateFactory) Classpath78 .instanceFromConfig(PROVIDER_RESOURCE) );76 instance = (TemplateFactory) Classpath 77 .instanceFromConfig(PROVIDER_RESOURCE); 79 78 } catch (Exception e) { 80 79 throw new RuntimeException( … … 82 81 e); 83 82 } 84 result = instance.get();85 83 } 86 if ( result== null) {84 if (instance == null) { 87 85 throw new RuntimeException( 88 86 "Unable to register the TemplateFactory implementation"); 89 87 } 90 return result;88 return instance; 91 89 } 92 90 … … 96 94 * @param resolver 97 95 */ 98 public static void setResolver(Resolver resolver) {96 public static synchronized void setResolver(Resolver resolver) { 99 97 TemplateFactory.resolver = resolver; 100 98 } 101 99 102 public static Resolver getResolver() {100 public static synchronized Resolver getResolver() { 103 101 return resolver; 104 102 } trunk/src/main/java/org/sarugo/xtc/impl/DefaultTemplateFactory.java
r3966 r3990 65 65 this.templates = new HashMap(); 66 66 this.relativeLocations = new HashMap(); 67 this.refreshPeriod = (refreshPeriod > 0) ? refreshPeriod * 1000: -1;67 this.refreshPeriod = (refreshPeriod > 0) ? refreshPeriod : -1; 68 68 log.fine("Using Refresh Period: " + this.refreshPeriod); 69 69 }
