View Javadoc

1   /*
2    * Copyright (C) 1998-2000 Semiotek Inc.  All Rights Reserved.
3    *
4    * Redistribution and use in source and binary forms, with or without
5    * modification, are permitted under the terms of either of the following
6    * Open Source licenses:
7    *
8    * The GNU General Public License, version 2, or any later version, as
9    * published by the Free Software Foundation
10   * (http://www.fsf.org/copyleft/gpl.html);
11   *
12   *  or
13   *
14   * The Semiotek Public License (http://webmacro.org/LICENSE.)
15   *
16   * This software is provided "as is", with NO WARRANTY, not even the
17   * implied warranties of fitness to purpose, or merchantability. You
18   * assume all risks and liabilities associated with its use.
19   *
20   * See www.webmacro.org for more information on the WebMacro project.
21   */
22  
23  
24  package org.webmacro.resource;
25  
26  import org.webmacro.*;
27  import org.webmacro.util.Settings;
28  
29  /***
30   * The BrokerTemplateProvider loads templates through
31   * Broker.getResource().  Templates might be loaded from a file, from
32   * a WAR, from a JAR, etc.  It just passes the requests on to a
33   * BrokerTemplateProviderHelper object.
34   * @author Brian Goetz
35   * @since 0.96
36   * @see Provider
37   * @see BrokerTemplateProviderHelper
38   */
39  final public class BrokerTemplateProvider extends CachingProvider
40  {
41  
42      private BrokerTemplateProviderHelper _helper;
43      private Log _log;
44  
45      public void init (Broker b, Settings config) throws InitException
46      {
47          super.init(b, config);
48          _helper = new BrokerTemplateProviderHelper();
49          _helper.init(b, config);
50          _helper.setReload(_cacheSupportsReload);
51          _log = b.getLog("resource", "Object loading and caching");
52      }
53  
54      final public String getType ()
55      {
56          return "template";
57      }
58  
59      final public Object load (String name, CacheElement ce)
60              throws ResourceException
61      {
62          if (_log.loggingInfo())
63              _log.info("Loading template: " + name);
64          return _helper.load(name, ce);
65      }
66  
67  }
68  
69