Giter Site home page Giter Site logo

rop's Introduction

Introduction

   ROP is the Rapid Open Platform ,thus like the TOP(Taobao Open Platform:http://api.taobao.com).

   The rest url of ROP  is thus like the following :
   1)http://yourhost?method=rop.user.add&v=1.0&param1=value1&param=value2...
   2)http://yourhost?method=rop.user.update&v=1.0&param1=value1&param=value2...
   ROP can router the request to the dest handler's api.You can use the 
@ServiceMethod("rop.user.add") annotation to mark the api method in the handler.
Handler must be a add a @ServiceMethodBean annotation ,ServiceMethodBean has already
annotated a @Service(Spring),So the Service Class would be a Spring Service Bean automaticly.

This is a right handler rest service api method:
   
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
   
@ServiceMethodBean//<--1. must mark the annotation,let it be a Service Bean
public class SampleRestService {

    @ServiceMethod("rop.sample.method1")//<--2.Let it be a Service Method.
    public Object method1(SampleRopRequest1 request1) {
        SampleRopResponse1 response = new SampleRopResponse1();
        response.setCreateTime("20120101010101");
        response.setUserId("1");
        return response;
    }
}
   The parameter's list of the api method must extends the RopRequest,and the
Return parameter can be any Object.
   The Rop can marshaller the response to the xml or json format output,you can
control the output format by "format" parameter.

Author and participants

1)Stamen       XiaMen       http://stamen.iteye.com/  
2)Wangxiancai  GuangZhou    http://wangxiancai.iteye.com/

   Good Luck! 2014!
   stame by 2014-07-16 Xiamen China

rop's People

Contributors

itstamen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rop's Issues

pom.xml

rop-parent com.rop 1.0

parent呢?

有个问题请教下

报错:org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.bookegou.com/schema/rop]
Offending resource: file [D:\developer\workspace\mss\src\main\webapp\WEB-INF\classes\spring\ropApplicationContext.xml]
配置文件是这样的:

com.rop.impl.AnnotationServletServiceRouter多处空指针异常

下面两个方法很明显,一旦异常,在catch中会有个空指针异常

/**
* 在服务调用之前拦截
*
* @param ropRequestContext
*/
private void invokeBeforceServiceOfInterceptors(RopRequestContext ropRequestContext) {
Interceptor tempInterceptor = null;
try {
if (interceptors != null && interceptors.size() > 0) {
for (Interceptor interceptor : interceptors) {

                interceptor.beforeService(ropRequestContext);

                //如果有一个产生了响应,则阻止后续的调用
                if (ropRequestContext.getRopResponse() != null) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("拦截器[" + interceptor.getClass().getName() + "]产生了一个RopResponse," +
                                " 阻止本次服务请求继续,服务将直接返回。");
                    }
                    return;
                }
            }
        }
    } catch (Throwable e) {
        ropRequestContext.setRopResponse(new ServiceUnavailableErrorResponse(ropRequestContext.getMethod(), ropRequestContext.getLocale(), e));
        logger.error("在执行拦截器[" + tempInterceptor.getClass().getName() + "]时发生异常.", e);
    }
}

/**
 * 在服务调用之后,返回响应之前拦截
 *
 * @param ropRequestContext
 */
private void invokeBeforceResponseOfInterceptors(RopRequestContext ropRequestContext) {
    Interceptor tempInterceptor = null;
    try {
        if (interceptors != null && interceptors.size() > 0) {
            for (Interceptor interceptor : interceptors) {
                interceptor.beforeResponse(ropRequestContext);
            }
        }
    } catch (Throwable e) {
        ropRequestContext.setRopResponse(new ServiceUnavailableErrorResponse(ropRequestContext.getMethod(), ropRequestContext.getLocale(), e));
        logger.error("在执行拦截器[" + tempInterceptor.getClass().getName() + "]时发生异常.", e);
    }
}

使用DefaultRopClient post数据时,中文乱码

在使用DefaultRopClient post数据时,如果参数是中文,在服务器接收方参数会变成乱码。经过查看源代码,发现DefaultRopClient是使用Spring的RestTemplate进行post数据,RestTemplate构造函数里默认的字符串编码是ISO-8859-1,所以会造成中文编码?请问这个问题Rop里面怎么解决?

SubErrors#getSubErrorCode类型转换bug

如果参数是Number类型就没法强制转换为String,那么错误信息就没法准确定位了

public static String getSubErrorCode(SubErrorType subErrorType, Object... params) {
String subErrorCode = subErrorType.value();
if (params.length > 0) {
if (params.length == 1) {
subErrorCode = subErrorCode.replace(PARAM_1, (String) params[0]);
} else {
subErrorCode = subErrorCode.replace(PARAM_1, (String) params[0]);
if (params[1] != null) {
subErrorCode = subErrorCode.replace(PARAM_2, (String) params[1]);
}
}
}
return subErrorCode;
}


目前是修改为

public static String getSubErrorCode(SubErrorType subErrorType, Object... params) {
String subErrorCode = subErrorType.value();
if (params.length > 0) {
String replaceStr=params[0] instanceof Number?String.valueOf(params[0]):(String) params[0];
if (params.length == 1) {
subErrorCode = subErrorCode.replace(PARAM_1, replaceStr);
} else {
subErrorCode = subErrorCode.replace(PARAM_1, replaceStr);
if (params[1] != null) {
subErrorCode = subErrorCode.replace(PARAM_2, params[0] instanceof Number?String.valueOf(params[1]):(String) params[1]);
}
}
}
return subErrorCode;
}

securityManager and sessionChecker

Hi,

We are creating a tool that can detect bugs that related to the use of XML file. Our tool found two potential bugs in your fullRopConfig.xml file. There are two child nodes of , which are and . There are no field named as "securityManager" and "sessionChecker" or their setter methods in the java class of this bean. And also, no super class of this java class, which declared these two. In this case, can you have a property named as those in your corresponding xml file? We are very unsure about this bug. Could you please give some explanation on how do you construct this bean to help us improve our tool?

Thanks you very much.

Very respectful,

rop中线程问题

程序中用了这个 LinkedBlockingDeque队列
// 设置异步执行器
if (this.threadPoolExecutor == null) {
this.threadPoolExecutor = new ThreadPoolExecutor(200,Integer.MAX_VALUE, 5 * 60, TimeUnit.SECONDS,new LinkedBlockingDeque());
}
然而在Future<?> future = this.threadPoolExecutor.submit(runnable);用了这个,很明显,在多线程环境下,排队多了的情况,会有概率性,出现执行的并不是当前 request的线程。也有可能是 a客户端的request,的结果返回给了b客户端,虽然概率很低很低,但是会有可能发生,建议主机把 LinkedBlockingDeque提出来。

Question: securityManager and sessionChecker

Hi,

We are creating a tool that can detect bugs that related to the use of XML file. Our tool found two potential bugs in your fullRopConfig.xml file. There are two child nodes of , which are and . There are no field named as "securityManager" and "sessionChecker" or their setter methods in the java class of this bean. And also, no super class of this java class, which declared these two. In this case, can you have a property named as those in your corresponding xml file? We are very unsure about this bug. Could you please give some explanation on how do you construct this bean to help us improve our tool?

Thanks you very much.

Very respectful,

Session manage recommendation

Rop user SessionManager to manage the session, You can use standalone server just like redis or memcached and so on to manage the session status.Not recommend us servlet HttpSession to manage the session, cause it can't make you architecture be horizontal scale.

the following is example which using redis to manage the session data:

import com.google.common.collect.Maps;
import com.rop.session.Session;
import com.rop.session.SessionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisTemplate;
import redis.clients.jedis.Jedis;

import java.util.Date;
import java.util.Map;

/**

  • @author : chenxh([email protected])

  • @Date: 13-10-16
    */
    public class AppSessionManager implements SessionManager {

    private RedisTemplate redisTemplate;

    private static Map<String,Long> lastTimeMap = Maps.newHashMap();

    @OverRide
    public void addSession(String key, Session session) {
    redisTemplate.opsForValue().set(key,session);
    redisTemplate.expireAt(key, getSessionExpireDate());
    lastTimeMap.put(key,System.currentTimeMillis());
    }

    @OverRide
    public Session getSession(String key) {
    Session session = (Session) redisTemplate.opsForValue().get(key);
    Long lastTime = lastTimeMap.get(key);
    //5分钟后重新设置过期时间
    if(lastTime!=null && System.currentTimeMillis()-lastTime>5_60_1000){
    redisTemplate.expireAt(key, getSessionExpireDate());
    lastTimeMap.put(key,System.currentTimeMillis());
    }
    return session;
    }

    @OverRide
    public void removeSession(String key) {
    redisTemplate.delete(key);
    lastTimeMap.remove(key);
    }

    @Autowired
    public void setRedisTemplate(RedisTemplate redisTemplate) {
    this.redisTemplate = redisTemplate;
    }

    /**

    • 登录一个小时 session自动失效
    • @return
      _/
      private Date getSessionExpireDate(){
      return new Date(getCurrentTimeMillis() + 60_60* 1000);
      }

    /**

    • 取redis当前时间
    • @return
      */
      public long getCurrentTimeMillis() {
      RedisConnection conn = redisTemplate.getConnectionFactory().getConnection();
      try{
      Jedis jedis = (Jedis) conn.getNativeConnection();
      Object resultObj = jedis.eval("return redis.call('time')[1]");
      return Long.parseLong(resultObj.toString()) * 1000;
      }
      finally {
      conn.close();
      }
      }
      }

大家好,我将开始重新维护ROP

由于2013年真太忙了,整天加班,所以ROP的维护工作就放下了,想不到使用ROP的人还挺多的,经常抱怨我怎么没有维护了,实在是对不住大家了。

由于ROP一直在我工作中都有用,所以这一年其实也改了挺多东西的,可以说在实际使用中还真是挺好用的,发现的BUG不多,新增的功能只是增量的东西,不影响原来的使用的。

2014年我会持续维护ROP,把这个平台打造得更强更好。谢谢大家,并祝大家马年马到成功,事事顺心!

stamen 2014-01-25

处理com.rop.event.AfterDoServiceEvent事件发生异常

在做压力测试的时候,并发量为100的时候,后台收到了下面的异常,不知道如何处理。感觉是我的连接池参数配置的问题,请指教。谢谢

这个是我在Rop里的配置:
core-pool-size="200"
max-pool-size="500"
queue-capacity="10"
keep-alive-seconds="30"
sign-enable="true"

我的数据库最大连接数是50。

2014.07.24 17:19:33 [org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean#0-461] ERROR [com.rop.event.SimpleRopEventMulticaster] - 处理com.rop.event.AfterDoServiceEvent事件发生异常
java.util.concurrent.RejectedExecutionException: Task com.rop.event.SimpleRopEventMulticaster$1@71e818ae rejected from java.util.concurrent.ThreadPoolExecutor@40999a27[Running, pool size = 499, active threads = 47, queued tasks = 10, completed tasks = 10760]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2048)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:821)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1372)
at com.rop.event.SimpleRopEventMulticaster.multicastEvent(SimpleRopEventMulticaster.java:32)
at com.rop.impl.AnnotationServletServiceRouter.fireAfterDoServiceEvent(AnnotationServletServiceRouter.java:437)
at com.rop.impl.AnnotationServletServiceRouter.access$1000(AnnotationServletServiceRouter.java:40)
at com.rop.impl.AnnotationServletServiceRouter$ServiceRunnable.run(AnnotationServletServiceRouter.java:374)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
2

rop service中无法获取spring security oauth2 的Authentication对象

使用spring security oauth2 认证,OAuth2AuthenticationProcessingFilter 通过access_token获取到Authentication对象,设置到SecurityContextHolder.getContext().setAuthentication(authResult);中。
但AnnotationServletServiceRouter是异步方式执行service method,不在同一个线程中。System.out.println("auth = " + SecurityContextHolder.getContext().getAuthentication());
获取为空。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.