Partial-Bean Module

Overview

The Partial-Bean module provides means for implementing a generic handler to replace manual implementations of interfaces (or abstract classes).

Project Setup

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 Configure DeltaSpike in Your Projects. For Maven-independent projects, see Configure DeltaSpike in Maven-independent Projects.

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:

<dependency>
    <groupId>org.apache.deltaspike.modules</groupId>
    <artifactId>deltaspike-partial-bean-module-api</artifactId>
    <version>${deltaspike.version}</version>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>org.apache.deltaspike.modules</groupId>
    <artifactId>deltaspike-partial-bean-module-impl</artifactId>
    <version>${deltaspike.version}</version>
    <scope>runtime</scope>
</dependency>

Or if you’re using Gradle, add these dependencies to your build.gradle:

     runtime 'org.apache.deltaspike.modules:deltaspike-partial-bean-module-impl'
     compile 'org.apache.deltaspike.modules:deltaspike-partial-bean-module-api'
Currently CDI Interceptors applied via @Interceptors, @Intercepted and @Decorator are not supported by our proxies!

@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.

@PartialBeanBinding
@Retention(RUNTIME)
@Target(TYPE)
public @interface MyPartialBeanBinding {}
//scope is optional
@MyPartialBeanBinding
public interface PartialBean
{
    String getValue();
}
//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
    }
}