Atmosphere Framework and the Netty Framework
Nettosphere: A Java WebSocket and HTTP server powered by theThe easiest way to get started with NettoSphere is to download a sample and start it. Or look at the Javadoc. You can download one of our sample distribution.
% unzip nettosphere-<name>-distribution.jar
% chmod a+x ./bin/nettosphere.sh
% ./bin/nettosphere.sh
Samples are the same as the ones available in Atmosphere. Bootstrap classes looks like Bootstrap or Bootstrap Jersey
Download Nettosphere here or use Maven
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>nettosphere</artifactId>
<version>3.2.7</version>
</dependency>
Super Simple Web Application
Nettosphere server = new Nettosphere.Builder().config(
new Config.Builder()
.host("127.0.0.1")
.port(8080)
.resource(MyClass.class)
.build())
.build();
server.start();
or
Nettosphere server = new Nettosphere.Builder().config(
new Config.Builder()
.host("127.0.0.1")
.port(8080)
.resource(new Handler() {
public void handle(AtmosphereResource r) {
try {
r.getResponse().write("Hello World").write(" from Nettosphere").flushBuffer();
} catch (IOException e) {
e.printStackTrace();
}
}
})
.build())
.build();
server.start();
Server static and dynamic resources, use atmosphere.xml to configure NettoSphere
Config.Builder b = new Config.Builder();
b.resource("./webapps")
.port(8080)
.host("127.0.0.1")
.configFile("../conf/atmosphere.xml")
.build();
Nettosphere s = new Nettosphere.Builder().config(b.build()).build();
Deploy a Resource (annotated using Jersey), access it using HTTP or WebSocket
Nettosphere server = new Nettosphere.Builder().config(
new Config.Builder()
.host("127.0.0.1")
.port(8080)
.resource(MyResource.class)
.build())
.build();
server.start();
Deploy an AtmosphereHandler, access it using HTTP or WebSocket
Nettosphere server = new Nettosphere.Builder().config(
new Config.Builder()
.host("127.0.0.1")
.port(8080)
.resource("/*", MyAtmosphereHandler.class)
.build())
.build();
server.start();
Deploy an AtmosphereHandler, define a WebSocket protocol
Nettosphere server = new Nettosphere.Builder().config(
new Config.Builder()
.host("127.0.0.1")
.port(8080)
.webSocketProtocol(JMSOverWebSocketProtocol.class)
.resource("/*", MyAtmosphereHandler.class)
.build())
.build();
server.start();
Deploy a Servlet which use Meteor
Nettosphere server = new Nettosphere.Builder().config(
new Config.Builder()
.host("127.0.0.1")
.port(8080)
.resource("/*", MyServlet.class)
.build())
.build();
server.start();
The Server can also be started using java
java -cp nettosphere-all.jar
org.atmosphere.nettosphere.Nettosphere
[/path/to/an/exploded/war/file] [host] [port]
Using Maven and the Git repo
mvn exec:java -Dexec.arguments='path to your exploded war file'