-
-
Notifications
You must be signed in to change notification settings - Fork 751
Creating your own Atmosphere Annotation
Jeanfrancois Arcand edited this page Sep 10, 2013
·
3 revisions
Atmosphere ships with many annotations in order to make the application deployment simple. Since all annotations are implemented using Atmosphere's own public API, it is possible for an application to install it's own annotation.
For example, let's say you define:
public @interface MyAnnotation {
/**
* Replace the default EndpointMapper with my own.
*/
EndpointMapper value() new MyEndpointMapper();
}
To add support in Atmosphere for your annotation, you first need to create a class that implement the Processor interface
public interface Processor {
public void handle(final AtmosphereFramework framework, final Class<?> annotatedClass);
}
For example,
public class MyProcessor implements Processor {
@Override
public void handle(AtmosphereFramework framework, Class<?> annotatedClass) {
MyClass clazz = (Class<MyClass>) annotatedClass;
MyAnnotation myAnnotation = clazz.getAnnotation(MyAnnotation.class);
framework.endPointMapper(myAnnotation.value());
}
}
Final step is to annotate your Processor with the AtmosphereAnnotation in order to associate your Processor with the annotation it handles:
@AtmosphereAnnotation(MyAnnotation.class)
public class MyProcessor implements Processor {
@Override
public void handle(AtmosphereFramework framework, Class<?> annotatedClass) {
MyClass clazz = (Class<MyClass>) annotatedClass;
MyAnnotation myAnnotation = clazz.getAnnotation(MyAnnotation.class);
}
}
Now you can annotate any classes with your annotation, and Atmosphere will execute it!
- Understanding Atmosphere
- Understanding @ManagedService
- Using javax.inject.Inject and javax.inject.PostConstruct annotation
- Understanding Atmosphere's Annotation
- Understanding AtmosphereResource
- Understanding AtmosphereHandler
- Understanding WebSocketHandler
- Understanding Broadcaster
- Understanding BroadcasterCache
- Understanding Meteor
- Understanding BroadcastFilter
- Understanding Atmosphere's Events Listeners
- Understanding AtmosphereInterceptor
- Configuring Atmosphere for Performance
- Understanding JavaScript functions
- Understanding AtmosphereResourceSession
- Improving Performance by using the PoolableBroadcasterFactory
- Using Atmosphere Jersey API
- Using Meteor API
- Using AtmosphereHandler API
- Using Socket.IO
- Using GWT
- Writing HTML5 Server-Sent Events
- Using STOMP protocol
- Streaming WebSocket messages
- Configuring Atmosphere's Classes Creation and Injection
- Using AtmosphereInterceptor to customize Atmosphere Framework
- Writing WebSocket sub protocol
- Configuring Atmosphere for the Cloud
- Injecting Atmosphere's Components in Jersey
- Sharing connection between Browser's windows and tabs
- Understanding AtmosphereResourceSession
- Manage installed services
- Server Side: javadoc API
- Server Side: atmosphere.xml and web.xml configuration
- Client Side: atmosphere.js API