diff --git a/docs/reference/data.xml b/docs/reference/data.xml index 4dba7230..ed2475e1 100644 --- a/docs/reference/data.xml +++ b/docs/reference/data.xml @@ -41,4 +41,130 @@ documentation. +
+ Wiring <interfacename>Declarable</interfacename> components + + GemFire XML configuration (usually named cache.xml allows user objects to be declared as part of the fabric config. Usually these objects + are CacheLoaders or other pluggable components into GemFire. Out of the box, each such type declared through XML must implement the Declarable + interface which allows arbitrary parameters to be passed to the declared class through a Properties instance. + + + Eliminate <interfacename>Declarable</interfacename> components + One can configure custom types entirely inside through Spring as mentioned in . That way, one does not have to implement the + Declarable interface and gets access to all the features of the Spring IoC container (including not just dependency injection but also + life-cycle and instance management). + + + Consider the following declaration (taken from the Declarable javadoc): + + + com.company.app.DBLoader + + jdbc://12.34.56.78/mydb + +]]> + + To simplify the task of parsing, converting the parameters and initializing the object, SGI offers a base class (WiringDeclarableSupport) that allows GemFire + user objects to be wired through autowiring or based on declarations available inside the Spring container. To take advantage of this feature, the user objects need to extends + WiringDeclarableSupport which automatically locates the declaring BeanFactory and performs wiring as part of the initialization process. + + + + Why is a base class needed? + Unfortunately, in the current GemFire release there is no concept of an object factory and the types declared are instantiated and used as is - that is + there are no other ways in which third parties can take care of the object creation outside GemFire. This feature is planned for the up-coming GemFire release (6.5) + + +
+ Using Auto/Annotation-wiring + + If no parameters are given, WiringDeclarableSupport will autowire + the declaring instance. In short, this means that unless any metadata is offered by the instance, the container will find the object setters and try to automatically satisfy + these dependencies. However, one can also use JDK 5 annotations to provide additional information to the auto-wiring process. We strongly recommend reading the dedicated + chapter in the Spring documentation for more information + on the supported annotations and enabling factors. + + + For example, the hypothetical DBLoader declaration above can be injected with a Spring-configured DataSource in the following way: + + + + + com.company.app.DBLoader + +]]> + + + + + + + + +]]> + + + By using the JSR-330 annotations, the cache loader code has been simplified since the location and creation of the DataSource has been externalized and the user code is concerned + only with the loading process. The DataSource might be transactional, created lazily, shared between multiple objects or retrieved from JNDI - these aspects + can be easily configured and changed through the Spring container without touching the DBLoader code. +
+ +
+ Using <emphasis>template</emphasis> definitions + + For cases where auto/annotation-wiring is not enough (or not an option), one can instruct SGI class to use an existing bean definition as a template for wiring. Let's see how our + DBLoader declaration would look in that case: + + + + + com.company.app.DBLoader + + + template-bean + +]]> + + + + + + + + + + +]]> + + + The template bean definitions do not have to be declared in XML - any format is allowed (Groovy, annotations, etc..). +
+ +
\ No newline at end of file diff --git a/docs/reference/serialization.xml b/docs/reference/serialization.xml index dd72cd97..7a146237 100644 --- a/docs/reference/serialization.xml +++ b/docs/reference/serialization.xml @@ -1,17 +1,20 @@ - + Bootstrapping GemFire through the Spring container -
- Requirements +
+ Wiring deserialized instances + +
+ +
+ Auto-generating custom <classname>Instantiator</classname>s - -
\ No newline at end of file