01: /*****************************************************************************
02: * Copyright (c) PicoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: *****************************************************************************/package org.picocontainer.containers;
09:
10: import java.util.Properties;
11:
12: import org.picocontainer.DefaultPicoContainer;
13: import org.picocontainer.MutablePicoContainer;
14: import org.picocontainer.PicoContainer;
15:
16: /**
17: * immutable pico container constructed from properties.
18: * intendet to be used with config parameter
19: *
20: * @author k.pribluda
21: *
22: */
23: @SuppressWarnings("serial")
24: public class PropertiesPicoContainer extends
25: AbstractDelegatingPicoContainer {
26:
27: /**
28: * create with parent container and populate from properties
29: * @param properties
30: * @param parent
31: */
32: public PropertiesPicoContainer(Properties properties,
33: PicoContainer parent) {
34: super (new DefaultPicoContainer(parent));
35: // populate container from properties
36: for (Object key : properties.keySet()) {
37: ((MutablePicoContainer) getDelegate()).addComponent(key,
38: properties.get(key));
39: }
40: }
41:
42: /**
43: * construct without a parent
44: * @param properties
45: */
46: public PropertiesPicoContainer(Properties properties) {
47: this(properties, null);
48: }
49: }
|