Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
titleUsage of a custom project stage
ProjectStage customProjectStage;
customProjectStage = ProjectStage.valueOf("CustomProjectStage");
//or
customProjectStage = CustomProjectStageHolder.CustomProjectStage;
//or
@ProjectStageActivated(CustomProjectStageHolder.CustomProjectStage.class)

Deactivating default implementations

CDI provides the mechanism of @Alternative implementations. As soon as MyFaces CODI provides a default implementation as CDI bean, it's possible to provide a custom implementation via @Alternative (+ the corresponding std. CDI config). However, some CDI artifacts like CDI-Extensions (javax.enterprise.inject.spi.Extension) and Interceptors (javax.interceptor.Interceptor) don't support the mechanism for providing alternative implementations. Therefore, MyFaces CODI allows to create a custom implementation of the ClassDeactivator interface (or AbstractClassDeactivator).

Code Block
java
java
titleImplementing a custom Class-Deactivator

public class CustomClassDeactivation extends AbstractClassDeactivator
{
    protected void deactivateClasses()
    {
        addDeactivatedClass(DefaultImpl.class);
        //...
    }
}

You can provide a custom ClassDeactivator via JNDI (name: java:comp/env/myfaces-codi/ClassDeactivator) or VM parameter (-D org.apache.myfaces.extensions.cdi.ClassDeactivator) or via a CODI Java-API ( ClassDeactivation#setClassDeactivator).

Tip
titleHint

If you would like to filter additional beans, you can provide a custom javax.enterprise.inject.spi.Extension and observe javax.enterprise.inject.spi.ProcessAnnotatedType for calling #veto on an implementation.