Examples of MethodContext


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

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

   * @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

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

   * @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

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

    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

Examples of com.facebook.swift.generator.template.MethodContext

    {
        final Service service = Service.class.cast(visitable);
        final ServiceContext serviceContext = contextGenerator.serviceFromThrift(service);

        for (ThriftMethod method: service.getMethods()) {
            final MethodContext methodContext = contextGenerator.methodFromThrift(method);
            serviceContext.addMethod(methodContext);

            for (final ThriftField field : method.getArguments()) {
                methodContext.addParameter(contextGenerator.fieldFromThrift(field));
            }

            for (final ThriftField field : method.getThrowsFields()) {
                methodContext.addException(contextGenerator.exceptionFromThrift(field));
            }

            if (config.containsTweak(SwiftGeneratorTweak.ADD_THRIFT_EXCEPTION)) {
                methodContext.addException(THRIFT_EXCEPTION_CONTEXT);
            }
        }

        render(serviceContext, "service");
    }
View Full Code Here

Examples of org.apache.openejb.MethodContext

                            }
                            timerServiceRequired = true;
                        }
                        for (Iterator<Map.Entry<Method, MethodContext>> it = beanContext.iteratorMethodContext(); it.hasNext();) {
                            Map.Entry<Method, MethodContext> entry = it.next();
                            MethodContext methodContext = entry.getValue();
                            if (methodContext.getSchedules().size() > 0) {
                                timerServiceRequired = true;
                                Method method = entry.getKey();
                                //TODO Need ?
                                if (beanContext.getTransactionType(method) == TransactionType.RequiresNew) {
                                    beanContext.setMethodTransactionAttribute(method, TransactionType.Required);
                                }
                            }
                        }
                        if (timerServiceRequired) {
                            // Create the timer
                            EjbTimerServiceImpl timerService = new EjbTimerServiceImpl(beanContext);
                            //Load auto-start timers
                            TimerStore timerStore = timerService.getTimerStore();
                            for (Iterator<Map.Entry<Method, MethodContext>> it = beanContext.iteratorMethodContext(); it.hasNext();) {
                                Map.Entry<Method, MethodContext> entry = it.next();
                                MethodContext methodContext = entry.getValue();
                                for(ScheduleData scheduleData : methodContext.getSchedules()) {
                                    timerStore.createCalendarTimer(timerService, (String) beanContext.getDeploymentID(), null, entry.getKey(), scheduleData.getExpression(), scheduleData.getConfig());
                                }
                            }
                            beanContext.setEjbTimerService(timerService);
                        } else {
View Full Code Here

Examples of org.apache.openejb.MethodContext

                        }
                        timerServiceRequired = true;
                    }
                    for (final Iterator<Map.Entry<Method, MethodContext>> it = beanContext.iteratorMethodContext(); it.hasNext(); ) {
                        final Map.Entry<Method, MethodContext> entry = it.next();
                        final MethodContext methodContext = entry.getValue();
                        if (methodContext.getSchedules().size() > 0) {
                            timerServiceRequired = true;
                            final Method method = entry.getKey();
                            //TODO Need ?
                            if (beanContext.getTransactionType(method) == TransactionType.RequiresNew) {
                                beanContext.setMethodTransactionAttribute(method, TransactionType.Required);
                            }
                        }
                    }

                    if (timerServiceRequired && "true".equalsIgnoreCase(appInfo.properties.getProperty(OPENEJB_TIMERS_ON, globalTimersOn))) {
                        // Create the timer
                        final EjbTimerServiceImpl timerService = new EjbTimerServiceImpl(beanContext, newTimerStore(beanContext));
                        //Load auto-start timers
                        final TimerStore timerStore = timerService.getTimerStore();
                        for (final Iterator<Map.Entry<Method, MethodContext>> it = beanContext.iteratorMethodContext(); it.hasNext(); ) {
                            final Map.Entry<Method, MethodContext> entry = it.next();
                            final MethodContext methodContext = entry.getValue();
                            for (final ScheduleData scheduleData : methodContext.getSchedules()) {
                                timerStore.createCalendarTimer(timerService,
                                    (String) beanContext.getDeploymentID(),
                                    null,
                                    entry.getKey(),
                                    scheduleData.getExpression(),
View Full Code Here

Examples of org.apache.openejb.MethodContext

           
            boolean hasSchedules = false;
           
            for (Iterator<Map.Entry<Method, MethodContext>> it = beanContext.iteratorMethodContext(); it.hasNext();) {
                Map.Entry<Method, MethodContext> entry = it.next();
                MethodContext methodContext = entry.getValue();
                if (methodContext.getSchedules().size() > 0) {
                    hasSchedules = true;
                }
            }
           
            if (!hasSchedules) {
View Full Code Here

Examples of org.apache.openejb.MethodContext

                    continue;
                }

            }
           
            MethodContext methodContext = null;
           
            if (timeoutMethodOfSchedule == null && beanContext.getEjbTimeout() != null) {
                methodContext = beanContext.getMethodContext(beanContext.getEjbTimeout());
            } else if (info.method.className == null
                    || timeoutMethodOfSchedule.getDeclaringClass().getName().equals(info.method.className)) {
View Full Code Here

Examples of org.apache.openejb.MethodContext

            }
        }

        for (Map.Entry<Method, MethodAttributeInfo> entry : attributes.entrySet()) {
            MethodConcurrencyInfo value = (MethodConcurrencyInfo) entry.getValue();
            MethodContext methodContext = beanContext.getMethodContext(entry.getKey());
            String s = value.concurrencyAttribute.toUpperCase();
            methodContext.setLockType(LockType.valueOf(s));
        }
       
        // handle @AccessTimeout
        attributes = MethodInfoUtil.resolveAttributes(accessTimeoutInfos, beanContext);
           
        if (log.isDebugEnabled()) {
            for (Map.Entry<Method, MethodAttributeInfo> entry : attributes.entrySet()) {
                Method method = entry.getKey();
                MethodConcurrencyInfo value = (MethodConcurrencyInfo) entry.getValue();
                log.debug("AccessTimeout: " + method + " -- " + MethodInfoUtil.toString(value.methods.get(0)) + " " +
                      " " + value.accessTimeout.time + " " + value.accessTimeout.unit);
            }
        }
       
        for (Map.Entry<Method, MethodAttributeInfo> entry : attributes.entrySet()) {
            MethodConcurrencyInfo value = (MethodConcurrencyInfo) entry.getValue();
            MethodContext methodContext = beanContext.getMethodContext(entry.getKey());
            Duration accessTimeout = new Duration(value.accessTimeout.time, TimeUnit.valueOf(value.accessTimeout.unit));
            methodContext.setAccessTimeout(accessTimeout);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.