001    /*****************************************************************************
002     * Copyright (C) PicoContainer Organization. All rights reserved.            *
003     * ------------------------------------------------------------------------- *
004     * The software in this package is published under the terms of the BSD      *
005     * style license a copy of which has been included with this distribution in *
006     * the LICENSE.txt file.                                                     *
007     *                                                                           *
008     * Original code by                                                          *
009     *****************************************************************************/
010    package org.picocontainer;
011    
012    import java.util.Properties;
013    
014    /**
015     * Collection of immutable properties, holding behaviour characteristics.
016     * 
017     * @author Paul Hammant
018     */
019    public final class Characteristics {
020    
021        private static final String _INJECTION = "injection";
022        private static final String _NONE = "none";
023        private static final String _CONSTRUCTOR = "constructor";
024        private static final String _METHOD = "method";
025        private static final String _SETTER = "setter";
026        private static final String _CACHE = "cache";
027        private static final String _JMX = "jmx";
028        private static final String _SYNCHRONIZING = "synchronizing";
029        private static final String _LOCKING = "locking";
030        private static final String _HIDE_IMPL = "hide-impl";
031        private static final String _PROPERTY_APPLYING = "property-applying";
032        private static final String _AUTOMATIC = "automatic";
033    
034        private static final String FALSE = "false";
035        private static final String TRUE = "true";
036    
037        public static final Properties CDI = immutable(_INJECTION, _CONSTRUCTOR);
038    
039        public static final Properties SDI = immutable(_INJECTION, _SETTER);
040    
041        public static final Properties METHOD_INJECTION = immutable(_INJECTION, _METHOD);
042    
043        public static final Properties NO_CACHE = immutable(_CACHE, FALSE);
044    
045        public static final Properties CACHE = immutable(_CACHE, TRUE);
046    
047        public static final Properties NO_JMX = immutable(_JMX, FALSE);
048    
049        public static final Properties SYNCHRONIZE = immutable(_SYNCHRONIZING, TRUE);
050    
051        public static final Properties LOCK = immutable(_LOCKING, TRUE);
052    
053        public static final Properties SINGLE = CACHE;
054        
055        public static final Properties HIDE_IMPL = immutable(_HIDE_IMPL, TRUE);
056    
057        public static final Properties NO_HIDE_IMPL = immutable(_HIDE_IMPL, FALSE);
058        
059        public static final Properties NONE = immutable(_NONE, "");
060    
061        public static final Properties PROPERTY_APPLYING = immutable(_PROPERTY_APPLYING, TRUE);
062    
063        public static final Properties AUTOMATIC = immutable(_AUTOMATIC, TRUE);
064    
065        private static Properties immutable(String name, String value) {
066            return new ImmutableProperties(name, value);
067        }
068    
069        public static class ImmutableProperties extends Properties {
070    
071            public ImmutableProperties(String name, String value) {
072                super.setProperty(name, value);
073            }
074    
075            public Object remove(Object o) {
076                throw new UnsupportedOperationException();
077            }
078    
079            public synchronized Object setProperty(String string, String string1) {
080                throw new UnsupportedOperationException();
081            }
082        }
083    
084    }