the net4j signalling platform developing pluggable client/server applications
DESCRIPTION
Eike Stepper [email protected] http://www.esc-net.de http://thegordian.blogspot.com Berlin, Germany. The Net4j Signalling Platform Developing Pluggable Client/Server Applications. Agenda. Requirements Architecture Buffers Channels Connectors Acceptors Protocols Signals Examples - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/1.jpg)
© 2009 by Eike Stepper; made available under the EPL v1.0 | 06-09-2009
The Net4j Signalling PlatformDeveloping Pluggable Client/Server Applications
Eike Stepper
[email protected]://www.esc-net.de
http://thegordian.blogspot.com
Berlin, Germany
![Page 2: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/2.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Agenda
• Requirements• Architecture
Buffers Channels Connectors Acceptors Protocols Signals
• Examples• FileShare Demo
![Page 3: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/3.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Requirements
• High performance java.nio.DirectByteBuffer, zero copying
• Good scalability java.nio.channels.Selector, single I/O thread possible
• Multiple transports Shipped with TCP, HTTP and JVM transports
• Pluggable protocols Independent of chosen transport
• Server-initiated push services (agent paradigm) Asynchronous and synchronous requests towards the client
• OSGi™ and stand-alone modes
![Page 4: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/4.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Architecture
AcceptorsAcceptors
OSGi / EclipseOSGi / Eclipse
TCPTCP
UtilsUtils
BuffersBuffers
ChannelsChannels
ConnectorsConnectors
SignalsSignals
ProtocolsProtocols
JVMJVM App1App1 App2App2
![Page 5: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/5.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Buffers
IBufferIBuffer IBufferProviderIBufferProvider
IBufferPoolIBufferPool
extends
IBufferHandlerIBufferHandlerhandles
BufferStateBufferState
BufferInputStreamBufferInputStream
BufferOutputStreamBufferOutputStream
reads
writes
![Page 6: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/6.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Channels
IChannelIChannelIBufferHandlerIBufferHandlerreceiveHandler
IChannelMultiplexerIChannelMultiplexer
ChannelInputStreamChannelInputStream
ChannelOutputStreamChannelOutputStream
reads
writes
BufferInputStreamBufferInputStream
BufferOutputStreamBufferOutputStream
extends
extends
![Page 7: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/7.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Connectors
ConnectorStateConnectorState
IConnectorIConnector TCPConnectorTCPConnector
ConnectorLocationConnectorLocation
implements
IChannelIChannelIBufferHandlerIBufferHandler
extends
creates
JVMConnectorJVMConnector
IChannelMultiplexerIChannelMultiplexer
![Page 8: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/8.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Acceptors
IAcceptorIAcceptor TCPAcceptorTCPAcceptorimplements
IConnectorIConnector
accepts
JVMAcceptorJVMAcceptor
TCPConnectorTCPConnectorJVMConnectorJVMConnector
createscreates
implements
implements
implements
![Page 9: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/9.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Protocols
IProtocolIProtocol
IProtocolProviderIProtocolProvider
IBufferHandlerIBufferHandler
extends
provides server protocolprovides client protocol
IChannelIChannel
uses
![Page 10: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/10.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
SignalsSignalProtocolSignalProtocol
SignalSignal
IProtocolIProtocolimplements
SignalActorSignalActor SignalReactorSignalReactor
RequestRequest RequestWithConfirmationRequestWithConfirmation IndicationIndication IndicationWithResponseIndicationWithResponse
creates
ThreadThread
extends
extends extends extends extends
extends
runs in
![Page 11: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/11.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Examples
public class JMSLogonRequest extends RequestWithConfirmation<Boolean> {
private String userName;
private String password;
public JMSLogonRequest(IChannel channel, String userName, String password) {
super(channel);
this.userName = userName;
this.password = password;
}
@Override
protected short getSignalID() { return JMSProtocolConstants.SIGNAL_LOGON; }
@Override
protected void requesting(ExtendedDataOutputStream out) throws IOException {
out.writeString(userName);
out.writeString(password);
}
@Override
protected Boolean confirming(ExtendedDataInputStream in) throws IOException {
return in.readBoolean();
}
}
![Page 12: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/12.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Examples
public class JMSLogonIndication extends IndicationWithResponse
{
private boolean ok;
@Override
protected short getSignalID()
{
return JMSProtocolConstants.SIGNAL_LOGON;
}
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
String userName = in.readString();
String password = in.readString();
ok = JMSServer.INSTANCE.logon(userName, password);
}
@Override
protected void responding(ExtendedDataOutputStream out) throws IOException
{
out.writeBoolean(ok);
}
}
![Page 13: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/13.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Examples
public class JMSServerProtocol extends SignalProtocol
{
public String getType()
{
return JMSProtocolConstants.PROTOCOL_NAME;
}
@Override
protected SignalReactor doCreateSignalReactor(short signalID)
{
switch (signalID)
{
case JMSProtocolConstants.SIGNAL_SYNC:
return new JMSSyncIndication();
case JMSProtocolConstants.SIGNAL_LOGON:
return new JMSLogonIndication();
}
return null;
}
}
![Page 14: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/14.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
Examples
// Start a TCP acceptor that is configured through extension points
IAcceptor acceptor = TCPUtil.getAcceptor(IPluginContainer.INSTANCE, "0.0.0.0:2036");
// Open a TCP connection that is configured through extension points
IConnector connector = TCPUtil.getConnector(IPluginContainer.INSTANCE, "localhost:2036");
// Open a channel with the JMS protocol
IChannel channel = connector.openChannel(JMSProtocolConstants.PROTOCOL_NAME);
try
{
// Create a logon request and send it through the channel
JMSLogonRequest request = new JMSLogonRequest(channel, "stepper", "secret");
boolean ok = request.send();
}
catch (Exception ex)
{
OM.LOG.error("Problem during logon", ex);
}
finally
{
channel.close();
}
![Page 15: The Net4j Signalling Platform Developing Pluggable Client/Server Applications](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681592d550346895dc65990/html5/thumbnails/15.jpg)
Developing Pluggable Client/Server Applications with Net4j | © 2009 by Eike Stepper; made available under the EPL v1.0
FileShare Demo