|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| CacheServiceManagerImpl.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/**
|
|
| 2 |
* @(#)CacheServiceManagerImpl.java
|
|
| 3 |
*
|
|
| 4 |
* JFoxSOAF, Service-Oriented Application Framework
|
|
| 5 |
*
|
|
| 6 |
* Copyright(c) JFoxSOAF Team
|
|
| 7 |
*
|
|
| 8 |
* Licensed under the GNU LGPL, Version 2.1 (the "License");
|
|
| 9 |
* you may not use this file except in compliance with the License.
|
|
| 10 |
* You may obtain a copy of the License at
|
|
| 11 |
*
|
|
| 12 |
* http://www.gnu.org/copyleft/lesser.html
|
|
| 13 |
*
|
|
| 14 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 15 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 16 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 17 |
* See the License for the specific language governing permissions and
|
|
| 18 |
* limitations under the License.
|
|
| 19 |
*
|
|
| 20 |
* For more information, please visit:
|
|
| 21 |
* http://www.jfox.cn/confluence/display/JFoxSOAF/Home
|
|
| 22 |
* http://www.huihoo.org/jfox/jfoxsoaf
|
|
| 23 |
*/
|
|
| 24 |
|
|
| 25 |
package org.huihoo.jfox.soaf.services.cache;
|
|
| 26 |
|
|
| 27 |
import java.io.IOException;
|
|
| 28 |
import java.io.InputStream;
|
|
| 29 |
import java.util.Properties;
|
|
| 30 |
|
|
| 31 |
import org.huihoo.jfox.soaf.exception.CacheServiceException;
|
|
| 32 |
import org.huihoo.jfox.soaf.util.resource.ResourceHelper;
|
|
| 33 |
|
|
| 34 |
/**
|
|
| 35 |
* <p>
|
|
| 36 |
* CachingServiceManager is medator of pluggable service provider.
|
|
| 37 |
* </p>
|
|
| 38 |
*
|
|
| 39 |
* @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
|
|
| 40 |
* @version $Revision: 1.1 $ $Date: 2005/05/22 06:48:52 $
|
|
| 41 |
* @version Revision: 1.0
|
|
| 42 |
*/
|
|
| 43 |
|
|
| 44 |
public class CacheServiceManagerImpl implements CacheServiceManager { |
|
| 45 |
|
|
| 46 | 0 |
public CacheServiceManagerImpl() {
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
/**
|
|
| 50 |
* @see org.huihoo.jfox.soaf.services.cache.CacheServiceManager#getCacheService()
|
|
| 51 |
*/
|
|
| 52 | 0 |
public CacheService getCacheService(String regionName, Properties prop)
|
| 53 |
throws CacheServiceException {
|
|
| 54 | 0 |
CacheServiceProvider cacheServiceProvider = null;
|
| 55 | 0 |
Properties props = null;
|
| 56 | 0 |
try {
|
| 57 | 0 |
InputStream stream = ResourceHelper |
| 58 |
.getResourceAsStream(CacheConstant.CACHE_PROPERTIES); |
|
| 59 |
|
|
| 60 | 0 |
if (stream != null) { |
| 61 | 0 |
props = new Properties();
|
| 62 | 0 |
props.load(stream); |
| 63 | 0 |
stream.close(); |
| 64 |
} |
|
| 65 |
} catch (IOException e) {
|
|
| 66 | 0 |
throw new CacheServiceException( |
| 67 |
"Load Cache configuration IO exception " + e);
|
|
| 68 |
} catch (SecurityException e) {
|
|
| 69 | 0 |
throw new CacheServiceException("Cache access security exception " |
| 70 |
+ e); |
|
| 71 |
} |
|
| 72 |
|
|
| 73 | 0 |
String providerClass = props.getProperty(CacheConstant.CACHE_PROVIDER); |
| 74 | 0 |
if (providerClass != null && !providerClass.equals("")) { |
| 75 | 0 |
cacheServiceProvider = getCacheServiceProvider(providerClass); |
| 76 |
} else {
|
|
| 77 | 0 |
cacheServiceProvider = new HashMapCacheServiceProvider();
|
| 78 |
} |
|
| 79 | 0 |
return cacheServiceProvider.buildCacheService(regionName, prop);
|
| 80 |
|
|
| 81 |
} |
|
| 82 |
|
|
| 83 |
/**
|
|
| 84 |
* Load cache service provider.
|
|
| 85 |
*
|
|
| 86 |
* @param providerClass
|
|
| 87 |
* @return CacheServiceProvider
|
|
| 88 |
* @throws CacheServiceException
|
|
| 89 |
*/
|
|
| 90 | 0 |
private CacheServiceProvider getCacheServiceProvider(String providerClass)
|
| 91 |
throws CacheServiceException {
|
|
| 92 | 0 |
try {
|
| 93 | 0 |
return (CacheServiceProvider) Class.forName(providerClass)
|
| 94 |
.newInstance(); |
|
| 95 |
} catch (Exception e) {
|
|
| 96 | 0 |
throw new CacheServiceException("Getting cahce service provider ", |
| 97 |
e); |
|
| 98 |
} |
|
| 99 |
} |
|
| 100 |
|
|
| 101 |
} |
|
||||||||||