01: /*
02: * This file is part of PFIXCORE.
03: *
04: * PFIXCORE is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU Lesser General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * PFIXCORE is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with PFIXCORE; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package de.schlund.pfixxml.config.impl;
20:
21: import java.util.HashSet;
22: import java.util.Properties;
23: import java.util.Set;
24:
25: import org.apache.log4j.Logger;
26:
27: import de.schlund.pfixcore.workflow.ContextResource;
28: import de.schlund.pfixxml.config.ContextResourceConfig;
29:
30: /**
31: * Stores configuration for a ContextResource
32: *
33: * @author Sebastian Marsching <sebastian.marsching@1und1.de>
34: */
35: public class ContextResourceConfigImpl implements ContextResourceConfig {
36: private final static Logger LOG = Logger
37: .getLogger(ContextResourceConfigImpl.class);
38:
39: private Class<? extends ContextResource> resourceClass = null;
40: private HashSet<Class<? extends ContextResource>> interfaces = new HashSet<Class<? extends ContextResource>>();
41: private Properties props = new Properties();
42: private ContextConfigImpl parent;
43:
44: public ContextResourceConfigImpl(
45: Class<? extends ContextResource> clazz,
46: ContextConfigImpl parent) {
47: this .resourceClass = clazz;
48: this .parent = parent;
49: }
50:
51: /* (non-Javadoc)
52: * @see de.schlund.pfixxml.config.ContextResourceConfig#getContextResourceClass()
53: */
54: public Class<? extends ContextResource> getContextResourceClass() {
55: return this .resourceClass;
56: }
57:
58: public void addInterface(Class<? extends ContextResource> clazz) {
59: this .interfaces.add(clazz);
60: ContextResourceConfig oldConfig = this .parent
61: .getContextResourceConfigForInterface(clazz);
62: if (oldConfig != null) {
63: LOG.warn("Binding interface " + clazz.getName()
64: + " already bound to "
65: + oldConfig.getClass().getName() + " to new class "
66: + this .resourceClass.getName());
67: }
68: this .parent.interfaceToResource.put(clazz, this );
69: }
70:
71: /* (non-Javadoc)
72: * @see de.schlund.pfixxml.config.ContextResourceConfig#getInterfaces()
73: */
74: public Set<Class<? extends ContextResource>> getInterfaces() {
75: return this .interfaces;
76: }
77:
78: /* (non-Javadoc)
79: * @see de.schlund.pfixxml.config.ContextResourceConfig#getProperties()
80: */
81: public Properties getProperties() {
82: return this.props;
83: }
84: }
|