| Line | Hits | Note | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * $Id: ConfigurationServiceImpl.java 1067 2008-07-08 19:13:20Z amandel $ | ||
| 3 | * | ||
| 4 | * Copyright 2006, The jCoderZ.org Project. All rights reserved. | ||
| 5 | * | ||
| 6 | * Redistribution and use in source and binary forms, with or without | ||
| 7 | * modification, are permitted provided that the following conditions are | ||
| 8 | * met: | ||
| 9 | * | ||
| 10 | * * Redistributions of source code must retain the above copyright | ||
| 11 | * notice, this list of conditions and the following disclaimer. | ||
| 12 | * * Redistributions in binary form must reproduce the above | ||
| 13 | * copyright notice, this list of conditions and the following | ||
| 14 | * disclaimer in the documentation and/or other materials | ||
| 15 | * provided with the distribution. | ||
| 16 | * * Neither the name of the jCoderZ.org Project nor the names of | ||
| 17 | * its contributors may be used to endorse or promote products | ||
| 18 | * derived from this software without specific prior written | ||
| 19 | * permission. | ||
| 20 | * | ||
| 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND | ||
| 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS | ||
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
| 28 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
| 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
| 30 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
| 31 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 32 | */ | ||
| 33 | package org.jcoderz.commons.config; | ||
| 34 | |||
| 35 | import java.util.logging.Logger; | ||
| 36 | |||
| 37 | import org.jcoderz.commons.ArgumentMalformedException; | ||
| 38 | import org.jcoderz.commons.util.Assert; | ||
| 39 | |||
| 40 | |||
| 41 | /** | ||
| 42 | * Implementation of the ConfigurationService business methods. | ||
| 43 | * | ||
| 44 | * This class holds all business logic of the service to fetch specific | ||
| 45 | * configuration data. | ||
| 46 | * Implementing the business interface ConfigurationServiceInterface. | ||
| 47 | * | ||
| 48 | * On this level only primitive types String, int, long and boolean are used. | ||
| 49 | * The well-formed and complex typed interfaces for the specific services are | ||
| 50 | * using this more simple interface. | ||
| 51 | * | ||
| 52 | * IMPORTANT: | ||
| 53 | * Because of XDoclet Bug in current version, we define delegators to the super | ||
| 54 | * class with ejb-tags here. | ||
| 55 | * These should be deleted if XDoclet is fixed. | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | 0 | (1) | public class ConfigurationServiceImpl |
| 59 | extends ConfigurationServiceCommonImpl | ||
| 60 | implements ConfigurationServiceInterface | ||
| 61 | { | ||
| 62 | /** class name for use in logging */ | ||
| 63 | private static final transient | ||
| 64 | 0 | String CLASSNAME = ConfigurationServiceImpl.class.getName(); | |
| 65 | |||
| 66 | //private static final transient String PACKAGE_NAME | ||
| 67 | // = ConfigurationServiceImpl.class.getPackage().getName(); | ||
| 68 | |||
| 69 | /** | ||
| 70 | * class logger | ||
| 71 | */ | ||
| 72 | 0 | private static final transient Logger logger = Logger.getLogger(CLASSNAME); | |
| 73 | |||
| 74 | /** | ||
| 75 | * {@inheritDoc} | ||
| 76 | * | ||
| 77 | * @ejb.interface-method view-type="remote" | ||
| 78 | * @ejb.transaction type="Required" | ||
| 79 | */ | ||
| 80 | public void addConfigurationListener (ConfigurationListener listener) | ||
| 81 | throws ArgumentMalformedException | ||
| 82 | { | ||
| 83 | 0 | Assert.notNull(listener, "listener"); | |
| 84 | 0 | getConfigurationCacheCurrent().addConfigurationListener(listener); | |
| 85 | 0 | } | |
| 86 | |||
| 87 | |||
| 88 | /** {@inheritDoc} */ | ||
| 89 | public ServiceConfiguration getServiceConfiguration ( | ||
| 90 | String classname) | ||
| 91 | throws ArgumentMalformedException | ||
| 92 | { | ||
| 93 | 0 | Assert.notNull(classname, "classname"); | |
| 94 | ServiceConfiguration config; | ||
| 95 | try | ||
| 96 | { | ||
| 97 | 0 | config = (ServiceConfiguration) Class.forName( | |
| 98 | classname + "Impl").newInstance(); | ||
| 99 | } | ||
| 100 | 0 | catch (Exception e) | |
| 101 | { | ||
| 102 | 0 | throw new ConfigurationFactoryFailedException(classname, e); | |
| 103 | 0 | } | |
| 104 | 0 | return config; | |
| 105 | } | ||
| 106 | |||
| 107 | // IMPORTANT: | ||
| 108 | // Because of XDoclet Bug in current version, we define the delegators | ||
| 109 | // here with ejb-tags. | ||
| 110 | // Normally the implementation from CommonImpl is already inherited. | ||
| 111 | (2) | // FIXME: This should be changed when XDoclet BugFix is available. | |
| 112 | |||
| 113 | /** | ||
| 114 | * {@inheritDoc} | ||
| 115 | * | ||
| 116 | * @ejb.interface-method view-type="remote" | ||
| 117 | * @ejb.transaction type="Required" | ||
| 118 | */ | ||
| 119 | (3) | public boolean getBoolean (ConfigurationKey key) | |
| 120 | throws ConfigurationValueNotFoundException, | ||
| 121 | ConfigurationTypeConversionFailedException, | ||
| 122 | ArgumentMalformedException | ||
| 123 | { | ||
| 124 | 0 | return super.getBoolean(key); | |
| 125 | } | ||
| 126 | |||
| 127 | |||
| 128 | /** | ||
| 129 | * {@inheritDoc} | ||
| 130 | * | ||
| 131 | * @ejb.interface-method view-type="remote" | ||
| 132 | * @ejb.transaction type="Required" | ||
| 133 | */ | ||
| 134 | (4) | public int getInt (ConfigurationKey key) | |
| 135 | throws ConfigurationValueNotFoundException, | ||
| 136 | ConfigurationTypeConversionFailedException, | ||
| 137 | ArgumentMalformedException | ||
| 138 | { | ||
| 139 | 0 | return super.getInt(key); | |
| 140 | } | ||
| 141 | |||
| 142 | |||
| 143 | /** | ||
| 144 | * {@inheritDoc} | ||
| 145 | * | ||
| 146 | * @ejb.interface-method view-type="remote" | ||
| 147 | * @ejb.transaction type="Required" | ||
| 148 | */ | ||
| 149 | (5) | public long getLong (ConfigurationKey key) | |
| 150 | throws ConfigurationValueNotFoundException, | ||
| 151 | ConfigurationTypeConversionFailedException, | ||
| 152 | ArgumentMalformedException | ||
| 153 | { | ||
| 154 | 0 | return super.getLong(key); | |
| 155 | } | ||
| 156 | |||
| 157 | |||
| 158 | /** | ||
| 159 | * {@inheritDoc} | ||
| 160 | * | ||
| 161 | * @ejb.interface-method view-type="remote" | ||
| 162 | * @ejb.transaction type="Required" | ||
| 163 | */ | ||
| 164 | (6) | public String getString (ConfigurationKey key) | |
| 165 | throws ConfigurationValueNotFoundException, | ||
| 166 | ArgumentMalformedException | ||
| 167 | { | ||
| 168 | 0 | return super.getString(key); | |
| 169 | } | ||
| 170 | } |