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.html file. *
07: * *
08: * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant *
09: *****************************************************************************/package org.picocontainer.gems.util;
10:
11: import java.util.Properties;
12: import java.io.IOException;
13: import java.io.InputStream;
14:
15: /**
16: * constructable properties.
17: *
18: * @author Konstantin Pribluda
19: */
20: public class ConstructableProperties extends Properties {
21:
22: /**
23: * create properties from classpath resource using context classloader
24: *
25: * @param resource resource name
26: * @exception IOException passed from Properties.load()
27: */
28: public ConstructableProperties(String resource) throws IOException {
29: super ();
30: load(Thread.currentThread().getContextClassLoader()
31: .getResourceAsStream(resource));
32: }
33:
34: /**
35: *
36: * @param resource resource name
37: * @param defaults default properties
38: * @throws IOException can be thrown if something goes wrong
39: */
40: public ConstructableProperties(String resource, Properties defaults)
41: throws IOException {
42: super (defaults);
43: load(Thread.currentThread().getContextClassLoader()
44: .getResourceAsStream(resource));
45: }
46:
47: /**
48: * create properties from input stream
49: * @param stream to read from
50: * @throws IOException can be thrown by properties objkect
51: */
52: public ConstructableProperties(InputStream stream)
53: throws IOException {
54: super ();
55: load(stream);
56: }
57:
58: /**
59: * create from inpiut stream with default properties
60: * @param stream to read from
61: * @param defaults default properties
62: * @throws IOException can be thrown by properties object
63: */
64: public ConstructableProperties(InputStream stream,
65: Properties defaults) throws IOException {
66: super(defaults);
67: load(stream);
68: }
69: }
|