Versions Compared

Key

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

...

See Pre-required readings

Usage for Users

Activation

ProjectStageActivated

ProjectStage

The core provides a pluggable and type-safe approach for using project stages in a project (it's also used within the framework). Furthermore, @ProjectStageActivated allows to use e.g. implementations annotated with javax.enterprise.inject.Alternative for specific project-stages. Besides the out-of-This annotation allows to activate beans for a special project-stage. It's possible to use one of the out-of-the-box project-stages or a custom typesafe project-stageit's possible to implement custom but type-safe project-stages which will be exposed by CODI.

Code Block
java
java
titleAlternative implementation activated for Resolving and using the Project-Stage UnitTest
@Alternative@Inject
@ProjectStageActivated(ProjectStage.UnitTest.class)
public class TestServiceMockImpl implements Service
{
  private ProjectStage projectStage;

//...
}

boolean isDevProjectStage = ProjectStage.Development.equals(this.projectStage);

Activation

ProjectStageActivated

This annotation allows to activate beans for a special project-stage. It's possible to use one of the out-of-the-box project-stages or a custom typesafe project-stage.

Code Block
java
java
titleAlternative implementation activated for Project-Stage UnitTest

@Alternative
@ProjectStageActivated(ProjectStage.UnitTest.class)
public class TestServiceMockImpl implements Service
{
  //...
}
Code Block
java
java
titleAlternative implementation activated for Project-Stages UnitTest Stages UnitTest and Development
@Alternative
@ProjectStageActivated({ProjectStage.UnitTest.class, ProjectStage.Development.class})
public class DevServiceMockImpl implements Service
{
  //...
}

...

However, with a custom ConfiguredValueResolver it's possible to resolve configured values from any kind of configuration-source.

Logging

To avoid external dependencies, CODI uses the JDK Logger. However, CDI often requires serializable beans - therefore CODI provides a serializable wrapper for the JDK Logger.

...


public class MyBean
{
    @Inject
    private Logger logger;
}

By default the fully qualified class name of the target class which uses the injected logger, will be used to create the logger. As an alternative it's possible to use the LoggerDetails qualifier to provide e.g. a name for the loggerresolve configured values from any kind of configuration-source.

Logging

To avoid external dependencies, CODI uses the JDK Logger. However, CDI often requires serializable beans - therefore CODI provides a serializable wrapper for the JDK Logger.

Code Block
java
java
titleInjectable JDK logger with a custom name
public class MyBean
{
    @Inject
    @LoggerDetails(name = "AppLogger") class MyBean
{
    @Inject
    private Logger logger;
}

ProjectStage

The core provides a pluggable and type-safe approach for using project stages in a project (it's also used within the framework). Furthermore, @ProjectStageActivated allows to use e.g. implementations annotated with javax.enterprise.inject.Alternative for specific project-stages. Besides the out-of-the-box project-stages it's possible to implement custom but type-safe project-stages which will be exposed by CODIBy default the fully qualified class name of the target class which uses the injected logger, will be used to create the logger. As an alternative it's possible to use the LoggerDetails qualifier to provide e.g. a name for the logger.

Code Block
java
java
titleResolving and using the Project-StageInjectable JDK logger with a custom name

public class MyBean
{
    @Inject
    @LoggerDetails(name = "AppLogger")
    private Logger logger;
}
@Inject
private ProjectStage projectStage;

//...

boolean isDevProjectStage = ProjectStage.Development.equals(this.projectStage);

Provider

BeanManagerProvider

...