Package com.rop

Examples of com.rop.ServiceMethodHandler


     * @return
     */
    public Object invokeServiceMethod(RopRequestContext ropRequestContext) {
        try {
            //分析上下文中的错误
            ServiceMethodHandler serviceMethodHandler = ropRequestContext.getServiceMethodHandler();
            if (logger.isDebugEnabled()) {
                logger.debug("执行" + serviceMethodHandler.getHandler().getClass() +
                        "." + serviceMethodHandler.getHandlerMethod().getName());
            }
            if (serviceMethodHandler.isHandlerMethodWithParameter()) {
                return serviceMethodHandler.getHandlerMethod().invoke(
                        serviceMethodHandler.getHandler(), ropRequestContext.getRopRequest());
            } else {
                return serviceMethodHandler.getHandlerMethod().invoke(serviceMethodHandler.getHandler());
            }
        } catch (Throwable e) {
            if (e instanceof InvocationTargetException) {
                InvocationTargetException inve = (InvocationTargetException) e;
                throw new RuntimeException(inve.getTargetException());
View Full Code Here


        Class withGroupServiceClass = WithGroupService.class;
        when(context.getType("service1")).thenReturn(withGroupServiceClass);
        RopContext ropContext = new DefaultRopContext(context);

        //method1:都在ServiceMethodGroup中定义,在ServiceMethod中直接采用
        ServiceMethodHandler handler = ropContext.getServiceMethodHandler("service.method1", "1.0");
        ServiceMethodDefinition definition = handler.getServiceMethodDefinition();
        assertNotNull(definition);
        assertEquals(definition.getMethod(), "service.method1");
        assertEquals(definition.getMethodTitle(), "测试方法1");
        assertEquals(definition.getMethodGroup(), "GROUP1");
        assertEquals(definition.getMethodGroupTitle(), "分组1");
        assertEquals(definition.getTags(), new String[]{"TAG1", "TAG2"});
        assertEquals(definition.isIgnoreSign(), true);
        assertEquals(definition.isNeedInSession(), false);
        assertEquals(definition.getTimeout(), 100);
        assertEquals(definition.getVersion(), "1.0");

        //method2:在ServiceMethodGroup中定义,在ServiceMethod显式覆盖之
        ServiceMethodHandler handler2 = ropContext.getServiceMethodHandler("service.method2", "2.0");
        ServiceMethodDefinition definition2 = handler2.getServiceMethodDefinition();
        assertNotNull(definition2);
        assertEquals(definition2.getMethod(), "service.method2");
        assertEquals(definition2.getMethodTitle(), "测试方法2");
        assertEquals(definition2.getMethodGroup(), "GROUP2");
        assertEquals(definition2.getMethodGroupTitle(), "分组2");
View Full Code Here

        Class serviceClass = IgnoreSignRopRequestService.class;
        when(context.getType("method1")).thenReturn(serviceClass);

        RopContext ropContext = new DefaultRopContext(context);

        ServiceMethodHandler method1 = ropContext.getServiceMethodHandler("method1", "1.0");
        List<String> ignoreSignFieldNames = method1.getIgnoreSignFieldNames();
        assertNotNull(ignoreSignFieldNames);
        assertEquals(ignoreSignFieldNames.size(), 4);
        assertTrue(ignoreSignFieldNames.contains("field1"));
        assertTrue(ignoreSignFieldNames.contains("field3"));
        assertTrue(ignoreSignFieldNames.contains("sign"));
View Full Code Here

        FormattingConversionService conversionService = mock(FormattingConversionService.class);
        SessionManager sessionManager = mock(SessionManager.class);
        ServletRequestContextBuilder requestContextBuilder = new ServletRequestContextBuilder(conversionService);

        RopContext ropContext = mock(RopContext.class);
        ServiceMethodHandler methodHandler = mock(ServiceMethodHandler.class);
        when(ropContext.getServiceMethodHandler("method1", "3.0")).thenReturn(methodHandler);

        //构造HttpServletRequest
        MockHttpServletRequest servletRequest = new MockHttpServletRequest();
View Full Code Here

    public void testBuildBySysParams3() throws Exception {
        FormattingConversionService conversionService = mock(FormattingConversionService.class);
        ServletRequestContextBuilder requestContextBuilder = new ServletRequestContextBuilder(conversionService);

        RopContext ropContext = mock(RopContext.class);
        ServiceMethodHandler methodHandler = mock(ServiceMethodHandler.class);
        when(ropContext.getServiceMethodHandler("method1", "3.0")).thenReturn(methodHandler);

        //创建SimpleRequestContext
        SimpleRopRequestContext requestContext =
                requestContextBuilder.buildBySysParams(ropContext, new Object(),null);
View Full Code Here

        when(context.getBeanNamesForType(Object.class)).thenReturn(new String[]{"service1"});
        Class withoutGroupServiceClass = WithoutGroupService.class;
        when(context.getType("service1")).thenReturn(withoutGroupServiceClass);

        RopContext registryMethod = new DefaultRopContext(context);
        ServiceMethodHandler handler = registryMethod.getServiceMethodHandler("service.method1", "1.0");
        ServiceMethodDefinition definition = handler.getServiceMethodDefinition();
        assertNotNull(definition);
        assertEquals(definition.getMethod(), "service.method1");
        assertEquals(definition.getMethodTitle(), "测试方法1");
        assertEquals(definition.getMethodGroup(), "GROUP1");
        assertEquals(definition.getMethodGroupTitle(), "分组1");
View Full Code Here

     */
    public Object invokeServiceMethod(RopRequest ropRequest) {
        try {
            RopRequestContext ropRequestContext = ropRequest.getRopRequestContext();
            //分析上下文中的错误
            ServiceMethodHandler serviceMethodHandler = ropRequestContext.getServiceMethodHandler();
            if (logger.isDebugEnabled()) {
                logger.debug("执行" + serviceMethodHandler.getHandler().getClass() +
                        "." + serviceMethodHandler.getHandlerMethod().getName());
            }
            if (serviceMethodHandler.isHandlerMethodWithParameter()) {
                return serviceMethodHandler.getHandlerMethod().invoke(
                        serviceMethodHandler.getHandler(),ropRequest);
            } else {
                return serviceMethodHandler.getHandlerMethod().invoke(serviceMethodHandler.getHandler());
            }
        } catch (Throwable e) {
            if (e instanceof InvocationTargetException) {
                InvocationTargetException inve = (InvocationTargetException) e;
                throw new RuntimeException(inve.getTargetException());
View Full Code Here

TOP

Related Classes of com.rop.ServiceMethodHandler

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.