factoryinvoker.java

来自「Xfire文件 用于开发web service 的一个开源工具 很好用的」· Java 代码 · 共 43 行

JAVA
43
字号
package org.codehaus.xfire.service.invoker;

import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.fault.XFireFault;
import org.codehaus.xfire.util.factory.Factory;


/**
 * This invoker implementation calls a Factory to create the service object
 * and then applies a scope policy for caching.
 * @author Ben Yu
 * Feb 2, 2006 12:55:59 PM
 */
public class FactoryInvoker extends AbstractInvoker {
  private final Factory factory;
  private final ScopePolicy scope;
  /**
   * Create a FactoryInvoker object.
   * @param factory the factory used to create service object.
   * @param scope the scope policy. Null for default.
   */
  public FactoryInvoker(Factory factory, ScopePolicy scope) {
    this.factory = factory;
    this.scope = scope==null?new ApplicationScopePolicy():scope;
  }

  public Object getServiceObject(MessageContext context)
  throws XFireFault{
    try{
      return getScopedFactory(context).create();
    }
    catch(XFireFault e){
      throw e;
    }
    catch(Throwable e){
      throw new XFireFault(e);
    }
  }
  private Factory getScopedFactory(MessageContext context){
    return scope.applyScope(factory, context);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?