sample.js.rpc

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

License

License

Categories

Categories

JavaScript Languages
GroupId

GroupId

org.naike
ArtifactId

ArtifactId

sample-js-rpc
Last Version

Last Version

3.1
Release Date

Release Date

Type

Type

jar
Description

Description

sample.js.rpc
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Project URL

Project URL

http://maven.apache.org
Source Code Management

Source Code Management

https://github.com/sxwailyc/sample-js-rpc

Download sample-js-rpc

How to add to project

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

Dependencies

compile (5)

Group / Artifact Type Version
javax.servlet : servlet-api jar 3.0.1
org.codehaus.jackson : jackson-mapper-asl jar 1.9.12
org.codehaus.jackson : jackson-core-asl jar 1.9.2
org.springframework : spring-context jar 3.2.2.RELEASE
org.springframework : spring-webmvc jar 3.2.2.RELEASE

test (1)

Group / Artifact Type Version
junit : junit jar 3.8.1

Project Modules

There are no modules declared in this project.

sample-js-rpc Is a simple RPC JSON implementation

Server

  1. config

maven

<dependency>
    <groupId>org.naike</groupId>
    <artifactId>sample-js-rpc</artifactId>
    <version>1.0</version>
</dependency>


  let spring scan the js-rpc core class 

`<context:component-scan base-package="com.dt.sample.js.rpc.controller"></context:component-scan>`
  1. java codeing

eg.

@Service
@Lazy(false)
public class DemoWebServiceImpl implements DemoWebService {

    @Override
    public String say(String name) {
	    return "hello " + name;
    }

    @Override
    public Date getTime() {
	    return new Date();
    }

    @Override
    public int addition(int num1, int num2) {
	     return num1 + num2;
    }

}

Client

  1. import rpc.js

    <script src="/js/rpc.js"></script>

  2. register rpc interface

    var service = new rpc.ServiceProxy("/services/demo", {asynchronous:false, methods: ['say', 'getTime', 'addition']});

  3. call the remote method by javascript

eg.

 service.say('han mei mei') -> hello han mei mei

 service.getTime() -> 1444614301489

 service.addition(1, 2) -> 3

Versions

Version
3.1
3.0
2.0
1.0