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 org.apache.commons.lang.BooleanUtils;
    13  import org.apache.commons.logging.Log;
    14  import org.apache.commons.logging.LogFactory;
    15  import org.huihoo.jfox.soaf.util.resource.ResourceHelper;
    16
    17  /***
    18   * MBeanServerInterceptor intercept manageable service request and regist
    19   * service instance to a MBeanServer and ServiceContainer.
    20   *
    21   * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
    22   * @version $Revision: 1.9 $ $Date: 2004/10/28 11:09:45 $
    23   * @version Revision: 1.0
    24   */
    25
    26  public class MBeanServerInterceptor implements ServiceInterceptor {
    27
    28      private final Log logger = LogFactory.getLog(getClass());
    29
    30      private ManageableServiceContainer manageableServiceContainer = ManageableServiceContainer
    31              .getInstance();
    32
    33      /***
    34       * Interceptor invoke.
    35       *
    36       * @see org.huihoo.jfox.soaf.container.ServiceInterceptor#invoke(org.huihoo.jfox.soaf.container.ServiceEntry)
    37       */
    38      public void invoke(ServiceEntry serviceEntry) throws Throwable {
    39
    40          if (BooleanUtils.toBoolean(serviceEntry.getManageable())) {
    41              logger.info("Register Managable Service : "
    42                      + serviceEntry.getImplementation());
    43              Object object = ResourceHelper.instantiate(serviceEntry
    44                      .getImplementation());
    45              synchronized (manageableServiceContainer) {
    46                  manageableServiceContainer.registManagebleService(object,
    47                          serviceEntry);
    48              }
    49          }
    50      }
    51
    52  }