Package com.bj58.spat.gaea.server.core.communication.http

Examples of com.bj58.spat.gaea.server.core.communication.http.Action$Parameter


    }
  }

  @Override
  public void filter(GaeaContext context) throws Exception {
    StopWatch sw = context.getStopWatch();
    Collection<PerformanceCounter> pcList = sw.getMapCounter().values();
    for(PerformanceCounter pc : pcList) {
      if(pc.getExecuteTime() > minRecordTime) {
        StringBuilder sbMsg = new StringBuilder();
        sbMsg.append(serviceName);
        sbMsg.append("--");
        sbMsg.append(pc.getKey());
        sbMsg.append("--time: ");
        sbMsg.append(pc.getExecuteTime());
       
        sbMsg.append(" [fromIP: ");
        sbMsg.append(sw.getFromIP());
        sbMsg.append(";localIP: ");
        sbMsg.append(sw.getLocalIP()+"]");
       
        udpClient.send(sbMsg.toString());
      }
    }
  }
View Full Code Here


   */
  void doInvoke(GaeaContext context) {
    logger.debug("------------------------------ begin request-----------------------------");

    StringBuffer sbInvokerMsg = new StringBuffer();
    StopWatch sw = context.getStopWatch();
    Object response = null;
    Protocol protocol = null;
   
    try {
        protocol = context.getGaeaRequest().getProtocol();
      RequestProtocol request = (RequestProtocol)protocol.getSdpEntity();
     
      sbInvokerMsg.append("protocol version:");
      sbInvokerMsg.append(protocol.getVersion());
      sbInvokerMsg.append("\nfromIP:");
      sbInvokerMsg.append(context.getChannel().getRemoteIP());
      sbInvokerMsg.append("\nlookUP:");
      sbInvokerMsg.append(request.getLookup());
      sbInvokerMsg.append("\nmethodName:");
      sbInvokerMsg.append(request.getMethodName());
      sbInvokerMsg.append("\nparams:");
     
      if(request.getParaKVList() != null){
        for (KeyValuePair kv : request.getParaKVList()) {
          if(kv != null) {
            sbInvokerMsg.append("\n--key:");
            sbInvokerMsg.append(kv.getKey());
            sbInvokerMsg.append("\n--value:");
            sbInvokerMsg.append(kv.getValue());
          } else {
            logger.error("KeyValuePair is null  Lookup:" + request.getLookup() + "--MethodName:" + request.getMethodName());
          }
        }
      }
     
      logger.debug(sbInvokerMsg.toString());
      logger.debug("begin get proxy factory");
     
      // get local proxy
      IProxyStub localProxy = Global.getSingleton().getProxyFactory().getProxy(request.getLookup());
      logger.debug("proxyFactory.getProxy finish");

      if (localProxy == null) {
        ServiceFrameException sfe = new ServiceFrameException(
            "method:ProxyHandle.invoke--msg:" + request.getLookup() + "." + request.getMethodName() + " not fond",
            context.getChannel().getRemoteIP(),
            context.getChannel().getLocalIP(),
            request,
            ErrorState.NotFoundServiceException,
            null);
        response = ExceptionHelper.createError(sfe);
        logger.error("localProxy is null", sfe);
      } else {
        logger.debug("begin localProxy.invoke");
        String swInvoderKey = "InvokeRealService_" + request.getLookup() + "." + request.getMethodName();
        sw.startNew(swInvoderKey, sbInvokerMsg.toString());
        sw.setFromIP(context.getChannel().getRemoteIP());
        sw.setLocalIP(context.getChannel().getLocalIP());
       
        //invoker real service
        GaeaResponse gaeaResponse = localProxy.invoke(context);
       
        sw.stop(swInvoderKey);
       
        logger.debug("end localProxy.invoke");
        context.setGaeaResponse(gaeaResponse);
        response = createResponse(gaeaResponse);
        logger.debug("localProxy.invoke finish");
View Full Code Here

    HttpContext hc = new HttpContext();
    hc.setUri("/news/101001");
    hc.setMethod(HttpRequestMethod.GET);

    Action action = RequestMapping.getAction(hc);
    List<Parameter> paraList = action.getParamList();

    Assert.assertEquals("RestService", action.getLookup());
    Assert.assertEquals("getNews", action.getMethodName());
    Assert.assertEquals(1, paraList.size());
    Assert.assertEquals("newsID", paraList.get(0).getMapping());
    Assert.assertEquals(0, paraList.get(0).getMethodParaIndex());
    Assert.assertEquals(0, paraList.get(0).getUrlParaIndex());
    Assert.assertEquals(101001, paraList.get(0).getValue());
    Assert.assertEquals(HttpParameterType.PathParameter, paraList.get(0)
        .getParaType());

    hc.setUri("/newslist/101002/123");
    action = RequestMapping.getAction(hc);

    Assert.assertEquals("RestService", action.getLookup());
    Assert.assertEquals("getNews", action.getMethodName());
    Assert.assertEquals(2, action.getParamList().size());

    Assert.assertEquals("cateID", action.getParamList().get(0).getMapping());
    Assert.assertEquals(0, action.getParamList().get(0)
        .getMethodParaIndex());
    Assert.assertEquals(0, action.getParamList().get(0).getUrlParaIndex());
    Assert.assertEquals(101002, action.getParamList().get(0).getValue());
    Assert.assertEquals(HttpParameterType.PathParameter, action
        .getParamList().get(0).getParaType());

    Assert.assertEquals("userID", action.getParamList().get(1).getMapping());
    Assert.assertEquals(1, action.getParamList().get(1)
        .getMethodParaIndex());
    Assert.assertEquals(1, action.getParamList().get(1).getUrlParaIndex());
    Assert.assertEquals(123, action.getParamList().get(1).getValue());
    Assert.assertEquals(HttpParameterType.PathParameter, action
        .getParamList().get(1).getParaType());
  }
View Full Code Here

 
  private static String jarPath = "E:\\javaproject\\bj58.gaea.server\\lib";
 
  @Test
  public void testContract() {
    ClassInfo ciMulti = ScanClass.contract(IMulti.class);
    List<MethodInfo> miList1 = ciMulti.getMethodList();
    Assert.assertEquals("loadByID", miList1.get(0).getMethod().getName());
    Assert.assertEquals("loadByName", miList1.get(1).getMethod().getName());

   
    ClassInfo ciSingle = ScanClass.contract(ISingle.class);
    List<MethodInfo> miList2 = ciSingle.getMethodList();
    Assert.assertEquals("loadByID", miList2.get(0).getMethod().getName());
  }
View Full Code Here

  @SuppressWarnings("rawtypes")
  @Test
  public void testGetContractInfo() throws Exception {
    DynamicClassLoader classLoader = new DynamicClassLoader();
    classLoader.addFolder(jarPath);
    ContractInfo ci = ScanClass.getContractInfo(jarPath, classLoader);
    for(SessionBean sb : ci.getSessionBeanList()) {
     
      Assert.assertEquals("com.bj58.spat.servicedemo.contract.INewsService", sb.getInterfaceName());
     
      Map<String, String> map = sb.getInstanceMap();
      Iterator it = map.entrySet().iterator();
View Full Code Here

        }
        allMethodList.add(m);
      }
    }

    ProxyClassCreater pcc = new ProxyClassCreater();
    // method
    for (Method m : uniqueMethodList) {
      System.out.println("create method:" + m.getName());
      String methodStr = pcc.createMethods("TestClass", m.getName(),
          allMethodList, uniqueNameList);
      System.out.println("method(" + m.getName() + ") source code:"
          + methodStr);

      TestEntity te = new TestEntity();
View Full Code Here

 
  @SuppressWarnings("rawtypes")
  @Test
  public void testGetContractInfo() throws Exception {
    DynamicClassLoader classLoader = new DynamicClassLoader();
    classLoader.addFolder(jarPath);
    ContractInfo ci = ScanClass.getContractInfo(jarPath, classLoader);
    for(SessionBean sb : ci.getSessionBeanList()) {
     
      Assert.assertEquals("com.bj58.spat.servicedemo.contract.INewsService", sb.getInterfaceName());
     
View Full Code Here

 
 

  @Test
  public void testGetContractClassInfos() throws Exception {
    DynamicClassLoader classLoader = new DynamicClassLoader();
    classLoader.addFolder(jarPath);
    List<ClassInfo> ciList = ScanClass.getContractClassInfos(jarPath, classLoader);
   
    for(int i=0; i<ciList.size(); i++) {
      if(i == 0) {
        Assert.assertEquals("com.bj58.spat.servicedemo.contract.INewsService",
View Full Code Here

 
 

  @Test
  public void testGetBehaviorClassInfos() throws Exception {
    DynamicClassLoader classLoader = new DynamicClassLoader();
    classLoader.addFolder(jarPath);
    List<ClassInfo> ciList = ScanClass.getBehaviorClassInfos(jarPath, classLoader);
   
    for(int i=0; i<ciList.size(); i++) {
      if(i == 0) {
        Assert.assertEquals("NewsService",
View Full Code Here

  }
  /**build tree*/
  public JTree buildTree() {
    JTree tree = null;
    /**load file jar and class*/
    DynamicClassLoader classLoader = new DynamicClassLoader();
    try {
      classLoader.addFolder(AssistUtils.getPath());
    } catch (Exception e) {
      e.printStackTrace();
    }
    logger.info("-----------------build Tree Start------------------");
   
    CheckNode parnodes = new CheckNode("method");
    tree = new JTree(parnodes);
   
    List<String> jarList = classLoader.getJarList();
    if(jarList!=null && jarList.size()>0){
      loadClassTreeList(jarList,parnodes,classLoader);
    }
   
    tree.setCellRenderer(new CheckRenderer());
View Full Code Here

TOP

Related Classes of com.bj58.spat.gaea.server.core.communication.http.Action$Parameter

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.