Package cn.com.byd.compose.scope

Examples of cn.com.byd.compose.scope.MethodContext


    ModuleSource source = ModuleSource.INSTANCE;
    ModuleMethodSource methodConfig = new ModuleMethodSource();
    // 设定方法名
    methodConfig.setMethod(attributeMethod.getStringValue());
    methodConfig.setId(attributeId == null ? null : attributeId.getStringValue());
    MethodContext methodContext = new MethodContext();

    methodContext.setIsLog(attributeLog == null ? false : Boolean.parseBoolean(attributeLog.getStringValue()));

    methodContext.setIsTransaction(attributeTransaction == null ? false :
                     Boolean.parseBoolean(attributeTransaction.getStringValue()));

    methodContext.setIsVerify(attributeVerify == null ? false :
                  Boolean.parseBoolean(attributeVerify.getStringValue()));

    methodConfig.setMethodContext(methodContext);

    source.setClassAndMethodList(attributeBeanId.getStringValue(), methodConfig);

    // 解析xml内部组件
    Iterator<Element> it = element.elementIterator();
    Element subElement = null;
    while (it.hasNext()) {
      subElement = it.next();
      Object[] args = new Object[] { methodContext };
      if (ELEMENT_NAME_PARAMETER.equals(subElement.getName())) {
        Parameter parameter = new Parameter();
        methodContext.setParameter(parameter);
        args = new Object[] { parameter };
      } else if (ELEMENT_NAME_RESULT.equals(subElement.getName())) {
        Result result = new Result();
        methodContext.setReturnResult(result);
        args = new Object[] { result };
      } else if (ELEMENT_NAME_MODULE.equals(subElement.getName())) {
        ModuleBean module = new ModuleBean();
        List<ModuleBean> modules = methodContext.findCurrentModules();
        if (modules == null) {
          modules = new ArrayList<ModuleBean>();
          methodContext.setCurrentModules(modules);
        }
        modules.add(module);
        args = new Object[] { module };
      } else if (ELEMENT_NAME_ITERATOR.equals(subElement.getName())) {
        IterateModules modules = new IterateModules();
        methodContext.setIteratorModules(modules);
        args = new Object[] { modules };
      } else if (ELEMENT_NAME_NOT_EQUAL.equals(subElement.getName())) {
        EqualGroupModules modules = new EqualGroupModules();

        methodContext.setConditionGroupModule(modules);
        args = new Object[] { modules };
      } else if (ELEMENT_NAME_EQUAL.equals(subElement.getName())) {
        EqualGroupModules modules = new EqualGroupModules();

        methodContext.setConditionGroupModule(modules);
        args = new Object[] { modules };
      }
      ElementFactory.findElement(subElement.getName(), args).doParese(subElement);

    }
View Full Code Here


   * @throws NoModuleException
   * @throws ParameterException
   */
  public static Object runModules(String id, Object[] args) throws AppExceptin, NoModuleException,
                                   ParameterException {
    MethodContext methodContext = ModuleContext.INSTANCE.findMethodContext(id);
    return runModules(args, methodContext);
  }
View Full Code Here

   * @throws NoModuleException
   */
  public static Object runModules(String beanID, String methodName, Object[] args) throws AppExceptin,
                                              NoModuleException,
                                              ParameterException {
    MethodContext methodContext = ModuleContext.INSTANCE.findMethodContext(beanID, methodName);

    return runModules(args, methodContext);
  }
View Full Code Here

    this.beanID = beanID;
  }


  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    MethodContext bean = ModuleContext.INSTANCE.findMethodContext(beanID, method.getName());
    if (bean.isVerify()) {
      // 验证调用权限
      FactoryBuilder.getAuthenticationFactory().getAutoentication().checkMethodAuth(method.getName(),
                                              proxyed.getClass().getName());
    }
    // 处理日志输出
    if (bean.isLog()) {
      FactoryBuilder.getLoggerFactory().getLogger(InterceptionHandler.class).info(" ++++++++ " +
                                            proxyed.getClass().getName() + " method:" + method.getName() +
                                            " START");
    }
    // 处理事务
    if (bean.isTransaction()) {
      FactoryBuilder.getTransactionFactory().getTransaction().begin();
    }
    Object obj = null;
    try {
      obj = method.invoke(proxyed, args);
    } catch (Throwable ex) {
      FactoryBuilder.getLoggerFactory().getLogger(InterceptionHandler.class).error(ex);
      // 处理事务
      if (bean.isTransaction()) {
        FactoryBuilder.getTransactionFactory().getTransaction().rollback();
      }
      throw ex;
    }
    // 处理事务
    if (bean.isTransaction()) {
      FactoryBuilder.getTransactionFactory().getTransaction().commit();
    }
    // 处理日志输出
    if (bean.isLog()) {
      FactoryBuilder.getLoggerFactory().getLogger(InterceptionHandler.class).info(" ++++++++ " +
                                            proxyed.getClass().getName() + " method:" + method.getName() +
                                            " END");
    }
    return obj;
View Full Code Here

TOP

Related Classes of cn.com.byd.compose.scope.MethodContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.