View Javadoc

    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.5 $ $Date: 2004/10/18 04:19:54 $
    28   * @version Revision: 1.0
    29   */
    30
    31  public class ServiceContainer extends DefaultPicoContainer {
    32
    33      private static ServiceContainer serviceContainer;
    34
    35      public static ServiceContainer getInstance() {
    36          if (serviceContainer == null) {
    37              serviceContainer = new ServiceContainer();
    38          }
    39          return serviceContainer;
    40      }
    41
    42      /***
    43       * Creates a new container with a custom ComponentAdapterFactory and a
    44       * parent container.
    45       *
    46       * @param componentAdapterFactory
    47       * @param parent
    48       */
    49      public ServiceContainer(ComponentAdapterFactory componentAdapterFactory,
    50              PicoContainer parent) {
    51          super(componentAdapterFactory, parent);
    52      }
    53
    54      /***
    55       * Creates a new container with a parent container.
    56       *
    57       * @param parent
    58       */
    59      public ServiceContainer(PicoContainer parent) {
    60          super(parent);
    61      }
    62
    63      /***
    64       * Default Container.
    65       *
    66       * @param parent
    67       */
    68      public ServiceContainer() {
    69          super();
    70      }
    71
    72      /***
    73       * @see org.picocontainer.MutablePicoContainer#registerComponentImplementation(java.lang.Object)
    74       */
    75      public ComponentAdapter registerServiceImplementation(
    76              Class serviceImpl) throws PicoRegistrationException {
    77          return super.registerComponentImplementation(serviceImpl);
    78
    79      }
    80
    81      /***
    82       * @see org.picocontainer.defaults.DefaultPicoContainer#registerComponentImplementation(java.lang.Object,
    83       *      java.lang.Class, java.util.List)
    84       */
    85      public ComponentAdapter registerServiceImplementation(Object serviceKey,
    86              Class serviceImpl, List parameters)
    87              throws PicoRegistrationException {
    88          return super.registerComponentImplementation(serviceKey,
    89                  serviceImpl, parameters);
    90      }
    91
    92      /***
    93       * @see org.picocontainer.MutablePicoContainer#registerComponentImplementation(java.lang.Object,
    94       *      java.lang.Class)
    95       */
    96      public ComponentAdapter registerServiceImplementation(Object serviceKey,
    97              Class serviceImpl) throws PicoRegistrationException {
    98          return super.registerComponentImplementation(serviceKey,
    99                  serviceImpl);
    100     }
    101
    102     /***
    103      * @see org.picocontainer.MutablePicoContainer#registerComponentInstance(java.lang.Object,
    104      *      java.lang.Object)
    105      */
    106     public ComponentAdapter registerServiceInstance(Object serviceKey,
    107             Object serviceInstance) throws PicoRegistrationException {
    108         return super.registerComponentInstance(serviceKey, serviceInstance);
    109     }
    110
    111     /***
    112      * @see org.picocontainer.MutablePicoContainer#registerComponentInstance(java.lang.Object)
    113      */
    114     public ComponentAdapter registerServiceInstance(Object serviceInstance)
    115             throws PicoRegistrationException {
    116         return super.registerComponentInstance(serviceInstance);
    117     }
    118
    119     /***
    120      * @see org.picocontainer.PicoContainer#getComponentInstance(java.lang.Object)
    121      */
    122     public Object getService(Object serviceKey) throws PicoException {
    123         return super.getComponentInstance(serviceKey);
    124     }
    125
    126     /***
    127      * @see org.picocontainer.PicoContainer#getComponentInstanceOfType(java.lang.Class)
    128      */
    129     public Object getServiceOfType(Class serviceType) {
    130         return super.getComponentInstanceOfType(serviceType);
    131     }
    132
    133     /***
    134      * Unregister service.
    135      *
    136      * @param service
    137      * @return ComponentAdapter
    138      */
    139     public ComponentAdapter unregisterService(Object service) {
    140         return super.unregisterComponent(service);
    141     }
    142 }