001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.system.properties;
018    
019    import org.apache.geronimo.gbean.GBeanInfo;
020    import org.apache.geronimo.gbean.GBeanInfoBuilder;
021    
022    /** java.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory
023    java.naming.factory.url.pkgs=org.apache.geronimo.naming
024    java.naming.provider.url=rmi://localhost:1099
025    
026     */
027    public class NamingProperties {
028    
029        static final String JAVA_NAMING_FACTORY_INITIAL = "java.naming.factory.initial";
030        static final String JAVA_NAMING_FACTORY_URL_PKGS = "java.naming.factory.url.pkgs";
031        static final String JAVA_NAMING_PROVIDER_URL = "java.naming.provider.url";
032    
033        public NamingProperties(String namingFactoryInitial, String namingFactoryUrlPkgs, String namingProviderUrl) {
034            setNamingFactoryInitial(namingFactoryInitial);
035            setNamingFactoryUrlPkgs(namingFactoryUrlPkgs);
036            setNamingProviderUrl(namingProviderUrl);
037        }
038    
039        public String getNamingFactoryInitial() {
040            return System.getProperty(JAVA_NAMING_FACTORY_INITIAL);
041        }
042    
043        public void setNamingFactoryInitial(String namingFactoryInitial) {
044            System.setProperty(JAVA_NAMING_FACTORY_INITIAL, namingFactoryInitial);
045        }
046    
047        public String getNamingFactoryUrlPkgs() {
048            return System.getProperty(JAVA_NAMING_FACTORY_URL_PKGS);
049        }
050    
051        public void setNamingFactoryUrlPkgs(String namingFactoryUrlPkgs) {
052            System.setProperty(JAVA_NAMING_FACTORY_URL_PKGS, namingFactoryUrlPkgs);
053        }
054    
055        public String getNamingProviderUrl() {
056            return System.getProperty(JAVA_NAMING_PROVIDER_URL);
057        }
058    
059        public void setNamingProviderUrl(String namingProviderUrl) {
060            System.setProperty(JAVA_NAMING_PROVIDER_URL, namingProviderUrl);
061        }
062    
063        public static final GBeanInfo gbeanInfo;
064    
065        static {
066            GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(NamingProperties.class);
067            infoFactory.addAttribute("namingFactoryInitial", String.class, true);
068            infoFactory.addAttribute("namingFactoryUrlPkgs", String.class, true);
069            infoFactory.addAttribute("namingProviderUrl", String.class, true, true);
070    
071            infoFactory.setConstructor(new String[] {"namingFactoryInitial", "namingFactoryUrlPkgs", "namingProviderUrl"});
072    
073            gbeanInfo = infoFactory.getBeanInfo();
074        }
075    
076        public static GBeanInfo getGBeanInfo() {
077            return gbeanInfo;
078        }
079    }