Skip to content

Commit

Permalink
Split JRPC-Server package into: JRPC-Server-Core , JRPC-Server-HTTP a…
Browse files Browse the repository at this point in the history
…nd JRPC-Server-TCP to the users can choose which transport use or just use the message processing support.

Fixes #18
Fixed comment in JRPServer removing wording about inexistant methods
Fixes #15
  • Loading branch information
gcotelli committed Nov 15, 2019
1 parent 790d7af commit 6a64f74
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 41 deletions.
40 changes: 31 additions & 9 deletions src/BaselineOfJRPC/BaselineOfJRPC.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,49 @@ BaselineOfJRPC >> projectClass [
^ MetacelloCypressBaselineProject
]

{ #category : #baselines }
BaselineOfJRPC >> setUpClientDeploymentPackages: spec [

spec
package: 'JRPC-Client' with: [ spec requires: 'JRPC-Common' ];
group: 'Client-Deployment' with: 'JRPC-Client'.
]

{ #category : #baselines }
BaselineOfJRPC >> setUpPackages: spec [

spec package: 'JRPC-Common'.
self
setUpServerDeploymentPackages: spec;
setUpClientDeploymentPackages: spec.

spec
package: 'JRPC-Server' with: [ spec requires: 'JRPC-Common' ];
group: 'Server-Deployment' with: 'JRPC-Server'.
group: 'Deployment'
with: #('Server-Deployment' 'HTTP-Transport' 'TCP-Transport' 'Client-Deployment').

spec
package: 'JRPC-Tests' with: [ spec requires: 'Deployment' ];
group: 'Tests' with: 'JRPC-Tests'
]

{ #category : #baselines }
BaselineOfJRPC >> setUpServerDeploymentPackages: spec [

spec
for: #'pharo6.x'
do: [ spec
package: 'JRPC-Server-Pharo6';
group: 'Server-Deployment' with: 'JRPC-Server-Pharo6'
].
].
spec
package: 'JRPC-Client' with: [ spec requires: 'JRPC-Common' ];
group: 'Client-Deployment' with: 'JRPC-Client'.
spec group: 'Deployment' with: #('Server-Deployment' 'Client-Deployment').
package: 'JRPC-Server-Core' with: [ spec requires: 'JRPC-Common' ];
group: 'Server-Deployment' with: 'JRPC-Server-Core'.

spec
package: 'JRPC-Tests' with: [ spec requires: 'Deployment' ];
group: 'Tests' with: 'JRPC-Tests'.

package: 'JRPC-Server-HTTP' with: [ spec requires: 'JRPC-Server-Core' ];
group: 'HTTP-Transport' with: 'JRPC-Server-HTTP'.

spec
package: 'JRPC-Server-TCP' with: [ spec requires: 'JRPC-Server-Core' ];
group: 'TCP-Transport' with: 'JRPC-Server-TCP'
]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class {
#instVars : [
'methodName'
],
#category : #'JRPC-Server'
#category : #'JRPC-Server-Core-JRPC-Server-Core'
}

{ #category : #accessing }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #JRPCBatchRequestsObject }

{ #category : #'*JRPC-Server' }
{ #category : #'*JRPC-Server-Core' }
JRPCBatchRequestsObject >> beHandledBy: aJRPCMessageProcessor [

^ JRPCBatchResponseObject new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Class {
#instVars : [
'block'
],
#category : #'JRPC-Server'
#category : #'JRPC-Server-Core-JRPC-Server-Core'
}

{ #category : #accessing }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #JRPCErrorResponseObject }

{ #category : #'*JRPC-Server' }
{ #category : #'*JRPC-Server-Core' }
JRPCErrorResponseObject >> beHandledBy: aJRPCMessageProcessor [

"Returns self, this method is executed when a request inside a batch generated an error."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ I am an error raised when the parameters of the method called are invalid.
Class {
#name : #JRPCInvalidParameters,
#superclass : #JRPCError,
#category : #'JRPC-Server'
#category : #'JRPC-Server-Core-JRPC-Server-Core'
}

{ #category : #converting }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class {
#instVars : [
'handlersByName'
],
#category : #'JRPC-Server'
#category : #'JRPC-Server-Core-JRPC-Server-Core'
}

{ #category : #'handlers management' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Class {
'receiver',
'messageSelector'
],
#category : #'JRPC-Server'
#category : #'JRPC-Server-Core-JRPC-Server-Core'
}

{ #category : #evaluation }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
#instVars : [
'handler'
],
#category : #'JRPC-Server'
#category : #'JRPC-Server-Core-JRPC-Server-Core'
}

{ #category : #'instance creation' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ I am an error raised when the handler required does not exist.
Class {
#name : #JRPCNonExistentHandler,
#superclass : #JRPCError,
#category : #'JRPC-Server'
#category : #'JRPC-Server-Core-JRPC-Server-Core'
}

{ #category : #converting }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Extension { #name : #JRPCNotificationObject }

{ #category : #'*JRPC-Server' }
{ #category : #'*JRPC-Server-Core' }
JRPCNotificationObject >> beHandledBy: aJRPCMessageProcessor [

^ aJRPCMessageProcessor handleJRPCNotificationObject: self
]

{ #category : #'*JRPC-Server' }
{ #category : #'*JRPC-Server-Core' }
JRPCNotificationObject >> convertErrorToResponse: jrpcError [
jrpcError isIncorrectJSON
ifTrue: [ ^ jrpcError asJRPCResponseWithId: self id ].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If no method or multiple methods have <jrpc> pragma, an error is raised.
Class {
#name : #JRPCPragmaHandler,
#superclass : #JRPCMessageSendHandler,
#category : #'JRPC-Server'
#category : #'JRPC-Server-Core-JRPC-Server-Core'
}

{ #category : #private }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Extension { #name : #JRPCRequestObject }

{ #category : #'*JRPC-Server' }
{ #category : #'*JRPC-Server-Core' }
JRPCRequestObject >> beHandledBy: aJRPCMessageProcessor [

^ aJRPCMessageProcessor handleJRPCRequestObject: self
]

{ #category : #'*JRPC-Server' }
{ #category : #'*JRPC-Server-Core' }
JRPCRequestObject >> convertErrorToResponse: jrpcError [
^ jrpcError asJRPCResponseWithId: self id
]
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
"
I am an abstract server for JSON-RPC 2.0.
My subclasses define how to handle JSON-RPC objects coming from a client.
To define that, #sendRequest: message should be overriden by my subclasses.
My subclasses define how to handle JSON-RPC objects coming from a client resolving
the transport specific details and delegating later to the messageProcessor the processing
of the incoming message.
"
Class {
#name : #JRPCServer,
#superclass : #Object,
#instVars : [
'messageProcessor'
],
#category : #'JRPC-Server'
#category : #'JRPC-Server-Core-JRPC-Server-Core'
}

{ #category : #'instance creation' }
JRPCServer class >> http [
^ JRPCHTTPServer new
]

{ #category : #'instance creation' }
JRPCServer class >> tcp [
^ JRPCTCPServer new
]

{ #category : #'handlers management' }
JRPCServer >> addHandler: aJRPCHandler [

Expand Down
1 change: 1 addition & 0 deletions src/JRPC-Server-Core/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'JRPC-Server-Core' }
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Class {
#instVars : [
'server'
],
#category : #'JRPC-Server'
#category : #'JRPC-Server-HTTP'
}

{ #category : #defaults }
Expand Down
6 changes: 6 additions & 0 deletions src/JRPC-Server-HTTP/JRPCServer.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #JRPCServer }

{ #category : #'*JRPC-Server-HTTP' }
JRPCServer class >> http [
^ JRPCHTTPServer new
]
1 change: 1 addition & 0 deletions src/JRPC-Server-HTTP/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'JRPC-Server-HTTP' }
6 changes: 6 additions & 0 deletions src/JRPC-Server-TCP/JRPCServer.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #JRPCServer }

{ #category : #'*JRPC-Server-TCP' }
JRPCServer class >> tcp [
^ JRPCTCPServer new
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Class {
'serverLoop',
'process'
],
#category : #'JRPC-Server'
#category : #'JRPC-Server-TCP'
}

{ #category : #defaults }
Expand Down
1 change: 1 addition & 0 deletions src/JRPC-Server-TCP/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'JRPC-Server-TCP' }
1 change: 0 additions & 1 deletion src/JRPC-Server/package.st

This file was deleted.

0 comments on commit 6a64f74

Please sign in to comment.