Return-Path: X-Original-To: apmail-deltaspike-commits-archive@www.apache.org Delivered-To: apmail-deltaspike-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 347FE10530 for ; Fri, 27 Feb 2015 09:22:11 +0000 (UTC) Received: (qmail 96650 invoked by uid 500); 27 Feb 2015 09:22:11 -0000 Delivered-To: apmail-deltaspike-commits-archive@deltaspike.apache.org Received: (qmail 96614 invoked by uid 500); 27 Feb 2015 09:22:11 -0000 Mailing-List: contact commits-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltaspike.apache.org Delivered-To: mailing list commits@deltaspike.apache.org Received: (qmail 96605 invoked by uid 99); 27 Feb 2015 09:22:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Feb 2015 09:22:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 01663E03C8; Fri, 27 Feb 2015 09:22:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tandraschko@apache.org To: commits@deltaspike.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: deltaspike git commit: DELTASPIKE-823 updated documentation Date: Fri, 27 Feb 2015 09:22:11 +0000 (UTC) Repository: deltaspike Updated Branches: refs/heads/master c58aae597 -> 0208611fb DELTASPIKE-823 updated documentation Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/0208611f Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/0208611f Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/0208611f Branch: refs/heads/master Commit: 0208611fbe3d249f044cad2a21b69944fc72ac8e Parents: c58aae5 Author: tandraschko Authored: Fri Feb 27 10:21:49 2015 +0100 Committer: tandraschko Committed: Fri Feb 27 10:21:49 2015 +0100 ---------------------------------------------------------------------- .../src/main/asciidoc/partial-bean.adoc | 189 ++++++++----------- 1 file changed, 75 insertions(+), 114 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/0208611f/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 5f449e8..9bdeb15 100644 --- a/documentation/src/main/asciidoc/partial-bean.adoc +++ b/documentation/src/main/asciidoc/partial-bean.adoc @@ -1,114 +1,75 @@ -= Partial-Bean Module - -:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - -:toc: - -== Overview -The Partial-Bean module provides means for implementing a generic handler to replace manual implementations of interfaces (or abstract classes). - -== Configure Your Projects -The configuration information provided here is for Maven-based projects and it assumes that you have already declared the DeltaSpike version and DeltaSpike Core module for your projects, as detailed in <>. For Maven-independent projects, see <>. - -=== Declare Partial-Bean Module Dependencies -Add the Partial-Bean module to the list of dependencies in the project `pom.xml` file using this code snippet: - -[source,xml] ----- - - org.apache.deltaspike.modules - deltaspike-partial-bean-module-api - ${deltaspike.version} - compile - - - - org.apache.deltaspike.modules - deltaspike-partial-bean-module-impl - ${deltaspike.version} - runtime - ----- - -== Use the Module Features - -IMPORTANT: Currently CDI Interceptors can only by applied to beans which will be registred via the PartialBeanProvider. - - -=== @PartialBeanBinding - -Partial beans allow you to implement a generic handler to replace manual -implementations of interfaces (or abstract classes). - -`@PartialBeanBinding` is the binding-annotation for creating a custom -interface (/abstract class) to generic handler binding. - -[source,java] -------------------------------------------------------------------------------------- -@PartialBeanBinding -@Retention(RUNTIME) -@Target(TYPE) -public @interface MyPartialBeanBinding {} -------------------------------------------------------------------------------------- - -[source,java] -------------------------------------------------------------------------------------- -//scope is optional -@MyPartialBeanBinding -public interface PartialBean -{ - String getValue(); -} -------------------------------------------------------------------------------------- - -[source,java] -------------------------------------------------------------------------------------- -//scope is optional -@MyPartialBeanBinding -public class MyPartialBeanHandler implements java.lang.reflect.InvocationHandler -{ - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable - { - //generic handler logic - } -} -------------------------------------------------------------------------------------- - - -=== PartialBeanProvider - -Due the CDI nature, to support CDI Interceptors, we need to register the partial beans in BeforeBeanDiscovery as a completely new AnnotatedType. - -This is possible if you provide a PartialBeanProvider via the ServiceLoader approach. - -The following example shows how to enable your repositories to support interceptors like @Transactional: - - -[source,java] -------------------------------------------------------------------------------------- -package de.test; - -public class RepositoryPartialBeanProvider extends AbstractPartialBeanProvider -{ - public RepositoryPartialBeanProvider() - { - PartialBeanBuilder partialBeanBuilder = new PartialBeanBuilder( - org.apache.deltaspike.data.api.Repository.class, - org.apache.deltaspike.data.impl.handler.QueryHandler.class); - partialBeanBuilder.addClasses(UserRepository.class, CompanyRepository.class, CountryRepository.class); - add(partialBeanBuilder); - } -} -------------------------------------------------------------------------------------- - - -Config file `#META-INF/services/org.apache.deltaspike.partialbean.spi.PartialBeanProvider`: - -[source] -------------------------------------------------------------------------------------- -de.test.RepositoryPartialBeanProvider -------------------------------------------------------------------------------------- - -Custom implementations might use a classpath scanner like xbeans-finder, scannotations, reflections. - -We didn't found an completely portable way, therefore we didn't include it directly in DeltaSpike. += Partial-Bean Module + +:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + +:toc: + +== Overview +The Partial-Bean module provides means for implementing a generic handler to replace manual implementations of interfaces (or abstract classes). + +== Configure Your Projects +The configuration information provided here is for Maven-based projects and it assumes that you have already declared the DeltaSpike version and DeltaSpike Core module for your projects, as detailed in <>. For Maven-independent projects, see <>. + +=== Declare Partial-Bean Module Dependencies +Add the Partial-Bean module to the list of dependencies in the project `pom.xml` file using this code snippet: + +[source,xml] +---- + + org.apache.deltaspike.modules + deltaspike-partial-bean-module-api + ${deltaspike.version} + compile + + + + org.apache.deltaspike.modules + deltaspike-partial-bean-module-impl + ${deltaspike.version} + runtime + +---- + +== Use the Module Features + +IMPORTANT: Currently CDI Interceptors applied via @Interceptors and @Decorator are not supported by partial beans! + + +=== @PartialBeanBinding + +Partial beans allow you to implement a generic handler to replace manual +implementations of interfaces (or abstract classes). + +`@PartialBeanBinding` is the binding-annotation for creating a custom +interface (/abstract class) to generic handler binding. + +[source,java] +------------------------------------------------------------------------------------- +@PartialBeanBinding +@Retention(RUNTIME) +@Target(TYPE) +public @interface MyPartialBeanBinding {} +------------------------------------------------------------------------------------- + +[source,java] +------------------------------------------------------------------------------------- +//scope is optional +@MyPartialBeanBinding +public interface PartialBean +{ + String getValue(); +} +------------------------------------------------------------------------------------- + +[source,java] +------------------------------------------------------------------------------------- +//scope is optional +@MyPartialBeanBinding +public class MyPartialBeanHandler implements java.lang.reflect.InvocationHandler +{ + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable + { + //generic handler logic + } +} +-------------------------------------------------------------------------------------