|
|||||||||||||||||||
| 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 | |||||||||||||||
| ServiceContainer.java | 100% | 57.1% | 50% | 57.1% |
|
||||||||||||||
| 1 |
/**
|
|
| 2 |
* JFoxSOAF, Service-Oriented Application Framework
|
|
| 3 |
*
|
|
| 4 |
* Copyright (C) www.huihoo.org
|
|
| 5 |
*
|
|
| 6 |
* Distributable under GNU LGPL For more information, please visit:
|
|
| 7 |
* http://www.huihoo.org/jfox/jfoxsoaf
|
|
| 8 |
*/
|
|
| 9 |
|
|
| 10 |
package org.huihoo.jfox.soaf.container;
|
|
| 11 |
|
|
| 12 |
import java.util.List;
|
|
| 13 |
|
|
| 14 |
import org.picocontainer.ComponentAdapter;
|
|
| 15 |
import org.picocontainer.PicoContainer;
|
|
| 16 |
import org.picocontainer.PicoException;
|
|
| 17 |
import org.picocontainer.PicoRegistrationException;
|
|
| 18 |
import org.picocontainer.defaults.ComponentAdapterFactory;
|
|
| 19 |
import org.picocontainer.defaults.DefaultPicoContainer;
|
|
| 20 |
|
|
| 21 |
/**
|
|
| 22 |
* <p>
|
|
| 23 |
* The services container is a extension of DefaultPicoContainer.
|
|
| 24 |
* </p>
|
|
| 25 |
*
|
|
| 26 |
* @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
|
|
| 27 |
* @version $Revision: 1.7 $ $Date: 2004/10/25 13:37:43 $
|
|
| 28 |
* @version Revision: 1.0
|
|
| 29 |
*/
|
|
| 30 |
|
|
| 31 |
public class ServiceContainer extends DefaultPicoContainer { |
|
| 32 |
|
|
| 33 |
private static ServiceContainer serviceContainer; |
|
| 34 |
|
|
| 35 | 8 |
public static ServiceContainer getInstance() { |
| 36 | 8 |
if (serviceContainer == null) { |
| 37 |
|
|
| 38 | 2 |
serviceContainer = new ServiceContainer();
|
| 39 |
} |
|
| 40 | 8 |
return serviceContainer;
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
/**
|
|
| 44 |
* Creates a new container with a custom ComponentAdapterFactory and a
|
|
| 45 |
* parent container.
|
|
| 46 |
*
|
|
| 47 |
* @param componentAdapterFactory
|
|
| 48 |
* @param parent
|
|
| 49 |
*/
|
|
| 50 | 0 |
public ServiceContainer(ComponentAdapterFactory componentAdapterFactory,
|
| 51 |
PicoContainer parent) {
|
|
| 52 | 0 |
super(componentAdapterFactory, parent);
|
| 53 |
} |
|
| 54 |
|
|
| 55 |
/**
|
|
| 56 |
* Creates a new container with a parent container.
|
|
| 57 |
*
|
|
| 58 |
* @param parent
|
|
| 59 |
*/
|
|
| 60 | 0 |
public ServiceContainer(PicoContainer parent) {
|
| 61 | 0 |
super(parent);
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
/**
|
|
| 65 |
* Default Container.
|
|
| 66 |
*
|
|
| 67 |
* @param parent
|
|
| 68 |
*/
|
|
| 69 | 2 |
public ServiceContainer() {
|
| 70 | 2 |
super();
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
/**
|
|
| 74 |
* @see org.picocontainer.MutablePicoContainer#registerComponentImplementation(java.lang.Object)
|
|
| 75 |
*/
|
|
| 76 | 0 |
public ComponentAdapter registerServiceImplementation(
|
| 77 |
Class serviceImpl) throws PicoRegistrationException {
|
|
| 78 | 0 |
return super.registerComponentImplementation(serviceImpl); |
| 79 |
|
|
| 80 |
} |
|
| 81 |
|
|
| 82 |
/**
|
|
| 83 |
* @see org.picocontainer.defaults.DefaultPicoContainer#registerComponentImplementation(java.lang.Object,
|
|
| 84 |
* java.lang.Class, java.util.List)
|
|
| 85 |
*/
|
|
| 86 | 0 |
public ComponentAdapter registerServiceImplementation(Object serviceKey,
|
| 87 |
Class serviceImpl, List parameters) |
|
| 88 |
throws PicoRegistrationException {
|
|
| 89 | 0 |
return super.registerComponentImplementation(serviceKey, |
| 90 |
serviceImpl, parameters); |
|
| 91 |
} |
|
| 92 |
|
|
| 93 |
/**
|
|
| 94 |
* @see org.picocontainer.MutablePicoContainer#registerComponentImplementation(java.lang.Object,
|
|
| 95 |
* java.lang.Class)
|
|
| 96 |
*/
|
|
| 97 | 16 |
public ComponentAdapter registerServiceImplementation(Object serviceKey,
|
| 98 |
Class serviceImpl) throws PicoRegistrationException {
|
|
| 99 | 16 |
return super.registerComponentImplementation(serviceKey, |
| 100 |
serviceImpl); |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
/**
|
|
| 104 |
* @see org.picocontainer.MutablePicoContainer#registerComponentInstance(java.lang.Object,
|
|
| 105 |
* java.lang.Object)
|
|
| 106 |
*/
|
|
| 107 | 0 |
public ComponentAdapter registerServiceInstance(Object serviceKey,
|
| 108 |
Object serviceInstance) throws PicoRegistrationException {
|
|
| 109 | 0 |
return super.registerComponentInstance(serviceKey, serviceInstance); |
| 110 |
} |
|
| 111 |
|
|
| 112 |
/**
|
|
| 113 |
* @see org.picocontainer.MutablePicoContainer#registerComponentInstance(java.lang.Object)
|
|
| 114 |
*/
|
|
| 115 | 1 |
public ComponentAdapter registerServiceInstance(Object serviceInstance)
|
| 116 |
throws PicoRegistrationException {
|
|
| 117 | 1 |
return super.registerComponentInstance(serviceInstance); |
| 118 |
} |
|
| 119 |
|
|
| 120 |
/**
|
|
| 121 |
* @see org.picocontainer.PicoContainer#getComponentInstance(java.lang.Object)
|
|
| 122 |
*/
|
|
| 123 | 1 |
public Object getService(Object serviceKey) throws PicoException { |
| 124 | 1 |
return super.getComponentInstance(serviceKey); |
| 125 |
} |
|
| 126 |
|
|
| 127 |
/**
|
|
| 128 |
* @see org.picocontainer.PicoContainer#getComponentInstanceOfType(java.lang.Class)
|
|
| 129 |
*/
|
|
| 130 | 8 |
public Object getServiceOfType(Class serviceType) {
|
| 131 | 8 |
return super.getComponentInstanceOfType(serviceType); |
| 132 |
} |
|
| 133 |
|
|
| 134 |
/**
|
|
| 135 |
* Unregister service.
|
|
| 136 |
*
|
|
| 137 |
* @param service
|
|
| 138 |
* @return ComponentAdapter
|
|
| 139 |
*/
|
|
| 140 | 0 |
public ComponentAdapter unregisterService(Object service) {
|
| 141 | 0 |
return super.unregisterComponent(service); |
| 142 |
} |
|
| 143 |
} |
|
||||||||||