| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| BrokerTemplateProvider |
|
| 1.0;1 |
| 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 | package org.webmacro.resource; | |
| 24 | ||
| 25 | import org.slf4j.Logger; | |
| 26 | import org.slf4j.LoggerFactory; | |
| 27 | import org.webmacro.Broker; | |
| 28 | import org.webmacro.InitException; | |
| 29 | import org.webmacro.ResourceException; | |
| 30 | import org.webmacro.util.Settings; | |
| 31 | ||
| 32 | /** | |
| 33 | * The BrokerTemplateProvider loads templates through Broker.getResource(). | |
| 34 | * Templates might be loaded from a file, from a WAR, from a JAR, etc. | |
| 35 | * It just passes the requests on to a BrokerTemplateProviderHelper object. | |
| 36 | * | |
| 37 | * @author Brian Goetz | |
| 38 | * @since 0.96 | |
| 39 | * @see org.webmacro.Provider | |
| 40 | * @see BrokerTemplateProviderHelper | |
| 41 | */ | |
| 42 | 0 | final public class BrokerTemplateProvider extends CachingProvider |
| 43 | { | |
| 44 | ||
| 45 | private BrokerTemplateProviderHelper _helper; | |
| 46 | 0 | static Logger _log = LoggerFactory.getLogger(BrokerTemplateProvider.class); |
| 47 | ||
| 48 | public void init (Broker b, Settings config) throws InitException | |
| 49 | { | |
| 50 | 0 | super.init(b, config); |
| 51 | 0 | _helper = new BrokerTemplateProviderHelper(); |
| 52 | 0 | _helper.init(b, config); |
| 53 | 0 | _helper.setReload(_cacheSupportsReload); |
| 54 | 0 | } |
| 55 | ||
| 56 | final public String getType () | |
| 57 | { | |
| 58 | 0 | return "template"; |
| 59 | } | |
| 60 | ||
| 61 | final public Object load (String name, CacheElement ce) | |
| 62 | throws ResourceException | |
| 63 | { | |
| 64 | 0 | _log.info("Loading template: " + name); |
| 65 | 0 | return _helper.load(name, ce); |
| 66 | } | |
| 67 | ||
| 68 | } | |
| 69 | ||
| 70 |