blob: a2c23f68125af912a00cdd3d8d984490c2c04855 [file] [log] [blame]
:moduledeps: core, proxy
= 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.
== 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#, Configure DeltaSpike in Your Projects>>. For Maven-independent projects, see <<configure#config-maven-indep,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:
[source,xml]
----
<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`:
[source]
----
runtime 'org.apache.deltaspike.modules:deltaspike-partial-bean-module-impl'
compile 'org.apache.deltaspike.modules:deltaspike-partial-bean-module-api'
----
IMPORTANT: 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.
[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
}
}
-------------------------------------------------------------------------------------