1 /* 2 * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.properties.core.services; 17 18 import java.io.IOException; 19 import java.io.Serializable; 20 21 import org.apache.commons.lang.StringUtils; 22 23 import de.smartics.properties.api.core.config.BootPropertiesProvider; 24 25 /** 26 * Base implementation for lookup loaders of extension configurations from JNDI. 27 */ 28 public abstract class AbstractJndiLookupLoader implements Serializable 29 { 30 // ********************************* Fields ********************************* 31 32 // --- constants ------------------------------------------------------------ 33 34 /** 35 * The class version identifier. 36 */ 37 private static final long serialVersionUID = 1L; 38 39 // --- members -------------------------------------------------------------- 40 41 // ****************************** Initializer ******************************* 42 43 // ****************************** Constructors ****************************** 44 45 /** 46 * Default constructor. 47 */ 48 protected AbstractJndiLookupLoader() 49 { 50 } 51 52 // ****************************** Inner Classes ***************************** 53 54 // ********************************* Methods ******************************** 55 56 // --- init ----------------------------------------------------------------- 57 58 // --- get&set -------------------------------------------------------------- 59 60 // --- business ------------------------------------------------------------- 61 62 /** 63 * Determines the name of the extension configuration to use. 64 * 65 * @return the name to use. Must not be <code>null</code>- 66 * @throws IOException on any problem loading the configuration name. 67 */ 68 protected static final String calcConfigurationName() throws IOException 69 { 70 String configurationName = 71 ThreadLocalAdminRuntime.getInstance().getConfigurationName(); 72 if (StringUtils.isBlank(configurationName)) 73 { 74 final BootPropertiesProvider loader = 75 BootPropertiesProvider.createFromClasspath(); 76 configurationName = loader.getConfigurationName(); 77 } 78 return configurationName; 79 } 80 81 // --- object basics -------------------------------------------------------- 82 83 }