Author: danhaywood
Date: Wed Nov 19 08:51:11 2014
New Revision: 1640504

URL: http://svn.apache.org/r1640504
Log:
tutorial

Modified:
    isis/site/trunk/content/intro/tutorials/apacheconeu-2014.md
    isis/site/trunk/content/reference/services/event-bus-service.md

Modified: isis/site/trunk/content/intro/tutorials/apacheconeu-2014.md
URL: 
http://svn.apache.org/viewvc/isis/site/trunk/content/intro/tutorials/apacheconeu-2014.md?rev=1640504&r1=1640503&r2=1640504&view=diff
==============================================================================
--- isis/site/trunk/content/intro/tutorials/apacheconeu-2014.md (original)
+++ isis/site/trunk/content/intro/tutorials/apacheconeu-2014.md Wed Nov 19 
08:51:11 2014
@@ -455,8 +455,20 @@ Finally, note that the layout of contrib
 * use `.layout.json` to position as required
 
 
+
+
 ## Decoupling using the Event Bus
 
+Another way in which Apache Isis helps you keep your application nicely 
modularized is through its event bus.  Each action invocation, or property 
modification, can be used to generate a succession of events that allows 
subscribers to veto the interaction (the see it/use it/do it rules) or, if the 
action is allowed, to perform work prior to the execution of the action or 
after the execution of the action.
+
+Under the covers Isis uses the [Guava event 
bus](https://code.google.com/p/guava-libraries/wiki/EventBusExplained) and 
subscribers (always domain services) subscribe by writing methods annotated 
with `@com.google.common.eventbus.Subscribe` annotation.
+
+By default the events generated are `ActionInteractionEvent.Default` (for 
actions) and `PropertyInteractionEvent.Default` (for properties).  Subclasses 
of these can be specified using the 
[@ActionInteraction](http://isis.apache.org/reference/recognized-annotations/ActionInteraction.html)
 or 
[@PropertyInteraction](http://isis.apache.org/reference/recognized-annotations/PropertyInteraction.html).
+
+
+Using the guidance in [these docs](): 
+
+* write a domain service subscriber to 
 
 
 TODO

Modified: isis/site/trunk/content/reference/services/event-bus-service.md
URL: 
http://svn.apache.org/viewvc/isis/site/trunk/content/reference/services/event-bus-service.md?rev=1640504&r1=1640503&r2=1640504&view=diff
==============================================================================
--- isis/site/trunk/content/reference/services/event-bus-service.md (original)
+++ isis/site/trunk/content/reference/services/event-bus-service.md Wed Nov 19 
08:51:11 2014
@@ -56,16 +56,53 @@ Meanwhile, in the `BookRepository` domai
 
 This design allows the `libraryMember` module to be decoupled from the `book` 
module.
 
-### Self Registration
+## Registering for Events
 
-A good practice for domain services is to self-register when the 
`EventBusService` is injected into it:
+#### 1.8.0-SNAPSHOT
 
-    private EventBusService eventBusService;
-    public void injectEventBusService(final EventBusService eventBusService) {
-        this.eventBusService = eventBusService;
-        eventBusService.register(this);
+Register for events in the `@PostConstruct` lifecycle method (and unregister 
in `@PreDestroy`):
+
+    @DomainService
+    public class MySubscribingDomainService {
+
+        ...
+        
+        @Programmatic
+        @PostConstruct
+        public void postConstruct() {
+            eventBusService.register(this);
+        }
+        @Programmatic
+        @PreDestroy
+        public void preDestroy() {
+            eventBusService.unregister(this);
+        }
+        
+        @javax.inject.Inject
+        private EventBusService eventBusService;
     }
 
+This works for both application-scoped and request-scoped (`@RequestScoped`) 
domain services.
+
+
+#### 1.7.0 and before
+
+Register for events when the `EventBusService` is injected into it:
+
+    @DomainService
+    public class MySubscribingDomainService {
+
+        ...
+        
+        private EventBusService eventBusService;
+        public void injectEventBusService(final EventBusService 
eventBusService) {
+            this.eventBusService = eventBusService;
+            eventBusService.register(this);
+        }
+    
+    }
+
+
     
 ### `@PostsPropertyChangedEvent`
 


Reply via email to