annotation

jsonrpc is a lightweight Rpc Framework

License

License

Categories

Categories

JSON Data
GroupId

GroupId

com.quhaodian.jsonrpc
ArtifactId

ArtifactId

annotation
Last Version

Last Version

1.01
Release Date

Release Date

Type

Type

jar
Description

Description

annotation
jsonrpc is a lightweight Rpc Framework
Project URL

Project URL

https://github.com/cng1985/jsonrpc

Download annotation

How to add to project

<!-- https://jarcasting.com/artifacts/com.quhaodian.jsonrpc/annotation/ -->
<dependency>
    <groupId>com.quhaodian.jsonrpc</groupId>
    <artifactId>annotation</artifactId>
    <version>1.01</version>
</dependency>
// https://jarcasting.com/artifacts/com.quhaodian.jsonrpc/annotation/
implementation 'com.quhaodian.jsonrpc:annotation:1.01'
// https://jarcasting.com/artifacts/com.quhaodian.jsonrpc/annotation/
implementation ("com.quhaodian.jsonrpc:annotation:1.01")
'com.quhaodian.jsonrpc:annotation:jar:1.01'
<dependency org="com.quhaodian.jsonrpc" name="annotation" rev="1.01">
  <artifact name="annotation" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.quhaodian.jsonrpc', module='annotation', version='1.01')
)
libraryDependencies += "com.quhaodian.jsonrpc" % "annotation" % "1.01"
[com.quhaodian.jsonrpc/annotation "1.01"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

jsonrpc

maven QQ Apache-2.0 使用IntelliJ IDEA开发维护 GitHub forks

##一个简单android访问api组件## 部分代码参考:https://github.com/RitwikSaikia/jsonrpc 这部分代码版权归RitwikSaikia所有。服务端缓存、客服端缓存、注解支持,spring支持等版权归ada.young所有。

##maven使用##

       <dependency>
           <groupId>com.quhaodian.jsonrpc</groupId>
           <artifactId>core</artifactId>
           <version>1.01</version>
       </dependency>

使用方法

  1. 定义接口

         @RestFul(api=Calculator.class,value="calculator")
         public interface Calculator {
             double add(double x, double y);
             double multiply(double x, double y);
         }
    
  2. 实现接口

     public class SimpleCalculatorImpl implements Calculator {
     
         public double add(double x, double y) {
           return x + y;
         }
         
         public double multiply(double x, double y) {
           return x * y;
         }
     
     }
    
  3. 通过与spring集成,配置servlet。

     <context-param>
         <param-name>contextConfigLocation</param-name>
         <param-value>classpath:context.xml</param-value>
     </context-param>
     
     <listener>
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
     
     <servlet>
         <servlet-name>dispatcher</servlet-name>
         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
         <init-param>
             <param-name>contextConfigLocation</param-name>
             <param-value></param-value>
         </init-param>
         <load-on-startup>1</load-on-startup>
     </servlet> 
       
     <servlet>
         <servlet-name>rpc</servlet-name>
         <servlet-class>com.quhaodian.servlet.RpcServlet</servlet-class>
         <load-on-startup>2</load-on-startup>
     </servlet>
     
     <servlet-mapping>
          <servlet-name>rpc</servlet-name>
          <url-pattern>/rpc</url-pattern>
     </servlet-mapping>
    
  4. 客服端访问

        String url="远程服务端servlet地址"
    
        Calculator  s = RestFulClient.getService(url, Calculator .class);
    
        double result = calc.add(1.2, 7.5);
    

Versions

Version
1.01