Skip to content

Getting Started with the samples

Brice Copy edited this page Jun 26, 2014 · 29 revisions

The table below describes every Atmosphere's sample by defining the server and client API used to build it. You can download the sample by clicking on its name.

Recommended samples for getting started are the chat, which demonstrate usage of all transports using an AtmosphereHandler, or the jquery-pubsub, which demonstrate how to switch from one transport to another using a Jersey Resources. If you are interested to write WebSocket only application, take a look at the atmosphere-websockethandler-pubsub sample. The pubsub sample contains a lot of small demonstration on how the Jersey extension can be used. If you are interested to write HTML5 Server Side Events application, take a look at the atmosphere-sse-xxx samples.

If you plan to use Spring or GWT, take a look at their specific samples.

All sample supports WebSocket and Long Polling by default. Streaming and JSONP are supported by the majority of pubsub samples. If you are interested to write HTML5 Server Side Events application, take a look at the atmosphere-sse-xxx samples.

Sample Name Description Server Components Client Components
[all-api-pubsub](http://search.maven.org/#browse%7C-579854646) This sample implements a pubsub example that demonstrates all Atmosphere's API and extension. The use of AtmosphereResource, Meteor, Annotation like @Suspend and @Broadcast are demonstrated [AtmosphereHandler](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/all-api-pubsub/src/main/scala/org/atmosphere/samples/pubsub/websocket/AtmosphereHandler.scala) [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/all-api-pubsub/src/main/scala/org/atmosphere/samples/pubsub/websocket/Resource.scala) [Meteor](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/all-api-pubsub/src/main/scala/org/atmosphere/samples/pubsub/websocket/Meteor.scala) [WebSocketProtocol](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/all-api-pubsub/src/main/scala/org/atmosphere/samples/pubsub/websocket/DevoxxWebSocketProtocol.scala) Single [Callback](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/all-api-pubsub/src/main/webapp/index.html) supporting WebSocket, Long-Polling, JSONP, Http-Streaming
[async-annotation-pubsub](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-async-channel%22) This sample demonstrates the use of the @Asynchronous annotation combined with the Callable> API, showing how an application can be fully asynchronous in its execution. The sample implements the pubsub concepts. [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/async-annotation-pubsub/src/main/java/org/atmosphere/samples/pubsub/AsynchronousAnnotation.java) Single [Callback](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/async-annotation-pubsub/src/main/webapp/index.html#L36) supporting WebSocket, Long-Polling, JSONP, Http-Streaming
[atmosphere-ee6](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-ee6%22) This sample demonstrates the use of @Suspend with Java EE's 6 annotation like @Resource and EJB Timer [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/atmosphere-ee6/src/main/java/org/jersey/devoxx/samples/ee6/atmosphere/TimerResource.java) Http-Streaming
[channel](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-channel%22) This sample demonstrate the use of @Subscribe and @Publish annotation using a pub sub application. If you are migrating from CometD, this sample is for you. [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/channel/src/main/java/org/atmosphere/samples/pubsub/TypedChannel.java)
[chat-guice](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-guice-chat%22) This sample demonstrate the use of Google Guice with Atmosphere. The Chat application is implemented using @Suspend and @Broadcast annotation [Guice](https://github.com/Atmosphere/atmosphere-extensions/blob/master/guice/samples/chat-guice/src/main/java/org/atmosphere/samples/guice/GuiceChatConfig.java#L58) [Jersey Resource](https://github.com/Atmosphere/atmosphere-extensions/blob/master/guice/samples/chat-guice/src/main/java/org/atmosphere/samples/guice/ResourceChat.java) Javascript Functions demonstrating [WebSocket, falling back to Long-Polling](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/chat-guice/src/main/webapp/jquery/application.js)
[chat](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-chat%22) This sample demonstrates the use of WebSocket (falling back to Long-Polling) using a simple AtmosphereHandler. The sample also demonstrates how to detect which transport are supported by the client and server by negotiating with the server. [AtmosphereHandler](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/chat/src/main/java/org/atmosphere/samples/chat/Chat.java) Javascript Functions demonstrating [WebSocket, falling back to Long-Polling](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/chat/src/main/webapp/javascript/application.js). Code demonstrating how to negotiate with the server demonstrated as well
[di-guice-sample](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-di-guice-sample%22) The sample demonstrates the use of Atmosphere's Dependencies Injection using Guice [Jersey Resource](https://github.com/Atmosphere/atmosphere-extensions/blob/master/guice/samples/di-guice-sample/src/main/java/org/atmosphere/samples/di/guice/MessageResource.java) [Guice](https://github.com/Atmosphere/atmosphere-extensions/blob/master/guice/samples/di-guice-sample/src/main/java/org/atmosphere/samples/di/guice/GuiceContextListener.java) [Javascript Callback](https://github.com/Atmosphere/atmosphere-extensions/blob/master/guice/samples/di-guice-sample/src/main/webapp/index.html#L46)
[gwt-demo](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-gwt-demo%22) This samples demonstrates the use of the Atmosphere GWT extension. To start type "mvn gwt:run" [GWT](https://github.com/Atmosphere/atmosphere-extensions/blob/master/gwt/samples/gwt-demo/src/main/java/org/atmosphere/samples/server/AtmosphereHandler.java) [GWT](https://github.com/Atmosphere/atmosphere-extensions/blob/master/gwt/samples/gwt-demo/src/main/java/org/atmosphere/samples/client/GWTDemo.java)
[gwt-jsdemo](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-gwt-jsdemo%22) This sample demonstrates the use of the GWT Javascript client [GWT](https://github.com/Atmosphere/atmosphere-extensions/blob/master/gwt/samples/gwt-jsdemo/src/main/webapp/index.html) [GWT Javascript Library](https://github.com/Atmosphere/atmosphere-extensions/blob/master/gwt/samples/gwt-jsdemo/src/main/webapp/index.html)
[gwt-chat](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-gwt-chat%22) This sample demonstrates the use of the GWT Javascript client to create multiple chatrooms. It shows how to use the connection url and broadcasters to seperate messages into different communication channels. To start type "mvn gwt:run" [ChatHandler (AtmosphereGwtHandler)](https://github.com/Atmosphere/atmosphere-extensions/blob/master/gwt/samples/gwt-chat/src/main/java/org/atmosphere/samples/server/ChatHandler.java) [GWT Chat Code](https://github.com/Atmosphere/atmosphere-extensions/blob/master/gwt/samples/gwt-chat/src/main/java/org/atmosphere/samples/client/GWTDemo.java)
[gwt-conn-share](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-gwt-connection-sharing%22) This sample demonstrates the use of the AtmosphereProxy on the client. It is an intelligent wrapper for the AtmosphereClient connection that is able to share the connection between multiple windows. It detects this automatically and is able to detect when a window is closed and the master connection needs to be reestablished from another window. All incoming and outgoing events are bubbled to all the client windows. Outgoing events are routed to the correct window that has the master connection. It is also possible to broadcast messages locally, which means the message gets send to all the client windows, but not to the server. To start type "mvn gwt:run" [AtmosphereGwtHandler](https://github.com/Atmosphere/atmosphere-extensions/blob/master/gwt/samples/gwt-conn-share/src/main/java/org/atmosphere/samples/server/AtmosphereHandler.java) [GWT Code](https://github.com/Atmosphere/atmosphere-extensions/blob/master/gwt/samples/gwt-conn-share/src/main/java/org/atmosphere/samples/client/GWTDemo.java)
[jquery-atmospherehandler-pubsub](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-atmospherehandler-pubsub%22) This sample demonstrate the use of AtmosphereHandler for implementing a pub sub application. The sample supports Long-Polling, Http Streaming and WebSocket [AtmosphereHandler](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/jquery-atmospherehandler-pubsub/src/main/java/org/atmosphere/samples/pubsub/AtmosphereHandlerPubSub.java#L39) [Javascript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/jquery-atmospherehandler-pubsub/src/main/webapp/index.html)
[atmosphere-meteor-pubsub](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-meteor-pubsub%22) This sample demonstrate the use of the Meteor API, from a Servlet, for implementing a pub sub application. The sample supports Long-Polling, Http Streaming and WebSocket [Meteor](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/jquery-meteor-pubsub/src/main/java/org/atmosphere/samples/pubsub/MeteorPubSub.java) [Javascript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/jquery-meteor-pubsub/src/main/webapp/index.html#L8)
[jquery-multirequest](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-multirequest%22) This sample demonstrates how multi requests can be made using the jQuery.atmosphere.js. The sample implements the pub sub application. [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/jquery-multirequest/src/main/java/org/atmosphere/samples/multirequest/handlers/Subscriber.java#L33)/td> [Per Request and Global callback](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/jquery-multirequest/src/main/webapp/js/main.js)
[jquery-pubsub](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-jquery-pubsub%22) This sample demonstrates all transports (WebSockets, Server Side Events, Long-Polling, Http Streaming and JSONP using a super simple Jersey Resource. The sample implements a pub sub application. [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/jquery-pubsub/src/main/java/org/atmosphere/samples/pubsub/JQueryPubSub.java) [Javascript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/jquery-pubsub/src/main/webapp/index.html)
[jquery-websockethandler-pubsub](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-websockethandler-pubsub%22) This sample demonstrates how to write WebSocket only application [WebSocketHandler](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/jquery-websockethandler-pubsub/src/main/java/org/atmosphere/samples/pubsub/WebSocketPubSub.java#L36) [Javascript Funtion](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/jquery-websockethandler-pubsub/src/main/webapp/index.html#L36)
[jquery-pubsub](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-pubsub%22) This sample demonstrates a lot of server side functionality like broadcast/suspend/resume using a Jersey Resource. [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/pubsub/src/main/java/org/atmosphere/samples/pubsub/PubSub.java)
[meteor-pubsub](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-meteor-pubsub%22) This sample demonstrates of the Meteor API, from a Servlet, can be used to implement a chat application [Meteor](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/meteor-chat/src/main/java/org/atmosphere/samples/chat/MeteorChat.java) [Javascript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/meteor-chat/src/main/webapp/jquery/application.js)
[rest-chat](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-rest-chat%22) This sample demonstrates the use of a Jersey Resource for implementing a chat application [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/rest-chat/src/main/java/org/atmosphere/samples/chat/jersey/ResourceChat.java) [Javascript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/rest-chat/src/main/webapp/jquery/application.js)
[scala-chat](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-scala-chat%22) This sample demonstrates how to use Scala to write a chat application [Scala Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/scala-chat/src/main/scala/org/atmosphere/samples/scala/chat/ScalaChat.scala) [Javascript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/scala-chat/src/main/webapp/jquery/application.js)
[spring-tiles](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-spring-tiles%22) This sample demonstrates how to use the Spring and Tiles Framework with AtmosphereHandler. The sample implements a pubsub application [Spring Controller](https://github.com/Atmosphere/atmosphere-extensions/blob/master/spring/samples/spring-tiles/src/main/java/org/atmosphere/samples/pubsub/spring/PubSubController.java) [Javascript Function](https://github.com/Atmosphere/atmosphere-extensions/blob/master/spring/samples/spring-tiles/src/main/webapp/pages/pubsubHeader.jsp#L6)
[spring-websocket](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-spring-websocket%22) This sample demonstrates the use of Spring with Atmosphere WebSocketHandler, Meteor and AtmosphereHandler [Meteor](https://github.com/Atmosphere/atmosphere-extensions/blob/master/spring/samples/spring-websocket/src/main/java/org/atmosphere/samples/pubsub/utils/AtmosphereUtils.java#L31) [Service](https://github.com/Atmosphere/atmosphere-extensions/blob/master/spring/samples/spring-websocket/src/main/java/org/atmosphere/samples/pubsub/services/ChatService.java) [WebSocketProtocol](https://github.com/Atmosphere/atmosphere-extensions/blob/master/spring/samples/spring-websocket/src/main/java/org/atmosphere/samples/pubsub/config/protocol/DelegatingWebSocketProtocol.java) [Spring View](https://github.com/Atmosphere/atmosphere-extensions/blob/master/spring/samples/spring-websocket/src/main/webapp/WEB-INF/views/home.jsp#L9)
[sse-chat](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-chat-sse%22) This sample demonstrates how to use HTML 5 Server Sides Events to build a chat application using an AtmosphereHandler [AtmosphereHandler](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/sse-chat/src/main/java/org/atmosphere/samples/chat/ChatAtmosphereHandler.java) [Javascript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/sse-chat/src/main/webapp/jquery/application.js)
[sse-rest-chat](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-sse-rest-chat%22) This sample demonstrates how to use HTML 5 Server Sides Events to build a chat application using a Jersey Resource [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/sse-rest-chat/src/main/java/org/atmosphere/samples/chat/jersey/ResourceChat.java#L33) [Javascript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/sse-rest-chat/src/main/webapp/jquery/application.js)
[twitter-live-feed](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-twitter-live-feed%22) This sample demonstrates how to use jQuery.atmosphere.js to implements a real time Twitter Search using a simple Jersey Resource. It also demonstrate how BroadcastFilter can be used to mark to handle large set of data to send back to the client [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/twitter-live-feed/src/main/java/org/atmosphere/samples/twitter/TwitterFeed.java#L48) [JavaScript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/twitter-live-feed/src/main/webapp/index.html#L34)
[twitter-live-feed](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-twitter-live-feed%22) This sample demonstrates how to use jQuery.atmosphere.js to implements a real time Twitter Search using a simple Jersey Resource. It also demonstrate how BroadcastFilter can be used to mark to handle large set of data to send back to the client [Jersey Resource](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/twitter-live-feed/src/main/java/org/atmosphere/samples/twitter/TwitterFeed.java#L48) [JavaScript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/twitter-live-feed/src/main/webapp/index.html#L34)
[socketio-chat](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-socketio%22) This sample demonstrates how the SocketIO library can be used, transparently, using an AtmosphereHandler [AtmosphereHandler](https://github.com/Atmosphere/atmosphere-extensions/blob/master/socketio/samples/socketio-chat/src/main/java/org/atmosphere/samples/chat/SocketIOChatAtmosphere.java) [SocketIO](https://github.com/Atmosphere/atmosphere-extensions/blob/master/socketio/samples/socketio-chat/src/main/webapp/javascript/application.js#L1)
[native-socketio-chat](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-socketio%22) This sample demonstrates how the SocketIO library and natively extending the SocketIO protocol on the server side [AtmosphereHandler](https://github.com/Atmosphere/atmosphere-extensions/blob/master/socketio/samples/native-socketio-chat/src/main/java/org/atmosphere/samples/chat/ChatAtmosphereHandler.java) [SocketIO](https://github.com/Atmosphere/atmosphere-extensions/blob/master/socketio/samples/native-socketio-chat/src/main/webapp/index.html#L1)
[cometd/bayeux protocol](http://search.maven.org/#search|gav|1|g%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-cometd%2/) This sample deploy the [Cometd official](http://cometd.org/) demo on top of Atmosphere
[websocket-chat](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.atmosphere.samples%22%20AND%20a%3A%22atmosphere-websocket-chat%22) This sample demonstrates how to write WebSocket ONLY applications [WebSockerHandler](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/websocket-chat/src/main/java/org/atmosphere/samples/chat/WebSocketChat.java#L33) [JavaScript Function](https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/websocket-chat/src/main/webapp/jquery/application.js#L1)

Step by Step Tutorials

Concepts & Architecture

15 Minutes Tutorial

Advanced Topics

API

Known WebServer Issues

References

External Documentations

githalytics.com alpha

Clone this wiki locally