@Service public class MyService implements MessageCallback { public void callback(Message message) { // ... // } }
As Errai IOC provides a container-based approach to client development, support for Errai services are exposed to the container so they may be injected and used throughout your application where appropriate. This section covers those services.
The org.jboss.errai.bus.server.annotations.Service annotation is used for binding service endpoints to the bus. Within the Errai IOC container you can annotate services and have them published to the bus on the client (or on the server) in a very straight-forward manner:
@Service public class MyService implements MessageCallback { public void callback(Message message) { // ... // } }
As with server-side use of the annotation, if a service name is not explicitly specified, the underlying class name or field name being annotated will be used as the service name.
The org.jboss.errai.bus.server.api.Local annotation is used in conjunction with the @Service annotation to advertise a service only for visibility on the local bus and thus, cannot receive messages across the wire for the service.
@Service @Local public class MyLocalService implements MessageCallback { public void callback(Message message) { // ... // } }
Services which are registered with ErraiBus via the bean manager through use of the @Service annotation, have de-registration hooks tied implicitly to the destruction of the bean. Thus, destruction of the bean implies that these associated services are to be dereferenced.