You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by ta...@apache.org on 2016/03/31 16:33:52 UTC

deltaspike git commit: DELTASPIKE-1069 documentation

Repository: deltaspike
Updated Branches:
  refs/heads/master 6522fcb9e -> c2fedf39b


DELTASPIKE-1069 documentation

Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/c2fedf39
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/c2fedf39
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/c2fedf39

Branch: refs/heads/master
Commit: c2fedf39b7b9bfbdfc463b324e7aa837006aaa0f
Parents: 6522fcb
Author: tandraschko <ta...@apache.org>
Authored: Thu Mar 31 16:33:11 2016 +0200
Committer: tandraschko <ta...@apache.org>
Committed: Thu Mar 31 16:33:11 2016 +0200

----------------------------------------------------------------------
 .../src/main/asciidoc/partial-bean.adoc         |  2 +-
 documentation/src/main/asciidoc/proxy.adoc      | 67 +++++++++++++++++++-
 2 files changed, 66 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/c2fedf39/documentation/src/main/asciidoc/partial-bean.adoc
----------------------------------------------------------------------
diff --git a/documentation/src/main/asciidoc/partial-bean.adoc b/documentation/src/main/asciidoc/partial-bean.adoc
index ba12675..4cf8cfc 100644
--- a/documentation/src/main/asciidoc/partial-bean.adoc
+++ b/documentation/src/main/asciidoc/partial-bean.adoc
@@ -30,7 +30,7 @@ Add the Partial-Bean module to the list of dependencies in the project `pom.xml`
 </dependency>
 ----
 
-IMPORTANT: Currently CDI Interceptors applied via @Interceptors and @Decorator are not supported by partial beans!
+IMPORTANT: Currently CDI Interceptors applied via @Interceptors, @Intercepted and @Decorator are not supported by our proxies!
 
 
 == @PartialBeanBinding

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/c2fedf39/documentation/src/main/asciidoc/proxy.adoc
----------------------------------------------------------------------
diff --git a/documentation/src/main/asciidoc/proxy.adoc b/documentation/src/main/asciidoc/proxy.adoc
index e2d1c04..61350ad 100644
--- a/documentation/src/main/asciidoc/proxy.adoc
+++ b/documentation/src/main/asciidoc/proxy.adoc
@@ -7,7 +7,9 @@
 == Overview
 The Proxy Module provides a simple CDI based wrapper for creating dynamic proxies that can be used within other extensions. +
 The benefit of the DeltaSpike Proxy Module (compared to Javassist or any library) is that the DeltaSpike proxies will execute CDI interceptors. +
-The Proxy Module also provides the 'DeltaSpikeProxyContextualLifecycle', which enables you to dynamically register a proxy as CDI bean via our 'BeanBuilder'.
+The Proxy Module also provides the 'DeltaSpikeProxyContextualLifecycle', which enables you to dynamically register a proxy as CDI bean via the DeltaSpike 'BeanBuilder'.
+
+IMPORTANT: Currently CDI Interceptors applied via @Interceptors, @Intercepted and @Decorator are not supported by our proxies!
 
 === 1. Declare Proxy Module Dependencies
 
@@ -34,4 +36,65 @@ The currently provided implementation is a wrapper for ASM 5, which gets shaded
 
 === 2. Extend `DeltaSpikeProxyFactory`
 
-The key to making the proxy module work is to provide an implementation of `DeltaSpikeProxyFactory` which will do your proxy work for you.  DeltaSpike ships a default one in the PartialBean module which demonstrates how its meant to work.
\ No newline at end of file
+The key to making the proxy module work is to provide an implementation of `DeltaSpikeProxyFactory` which will do your proxy work for you. +
+DeltaSpike ships 3 implementations which demonstrates how its meant to work: +
+
+- org.apache.deltaspike.partialbean.impl.PartialBeanProxyFactory
+- org.apache.deltaspike.proxy.util.EnableInterceptorsProxyFactory
+- org.apache.deltaspike.jsf.impl.injection.proxy.ConverterAndValidatorProxyFactory
+
+=== 3. Using `@EnableInterceptors`
+
+`@EnableInterceptors` allows you to enable your bean interceptors for @Produces, which is not supported via the CDI API. +
+Both interceptors on method and class level are supported.
+
+[source,java]
+--------------------------------------
+@MyCustomInterceptor
+public SomeServiceImpl implements SomeService
+{
+    @Transactional
+    public void doSomething()
+    {
+        ....
+    }
+}
+--------------------------------------
+
+[source,java]
+--------------------------------------
+@Produces
+@EnableInterceptors
+public SomeService produce()
+{
+    return new SomeServiceImpl();
+}
+--------------------------------------
+
+=== 4. Using `EnableInterceptorsProxyFactory`
+
+`@EnableInterceptors` is just a API for producers which is built on `EnableInterceptorsProxyFactory`. +
+With `EnableInterceptorsProxyFactory` you can just proxy an existing object and let it execute CDI interceptors, if they are defined on the given object class.
+
+[source,java]
+--------------------------------------
+@MyCustomInterceptor
+public SomeServiceImpl implements SomeService
+{
+    @Transactional
+    public void doSomething()
+    {
+        ....
+    }
+}
+--------------------------------------
+
+[source,java]
+--------------------------------------
+public void init()
+{
+    SomeServiceImpl myService = new SomeServiceImpl();
+    myService = EnableInterceptorsProxyFactory.wrap(myService, BeanManagerProvider.getInstance().getBeanManager());
+    myService.doSomething(); // will execute the interceptors
+}
+--------------------------------------