org.apache.myfaces.extensions.cdi.core.api.projectstage
Class ProjectStage

java.lang.Object
  extended by org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ProjectStage.Development, ProjectStage.IntegrationTest, ProjectStage.Production, ProjectStage.Staging, ProjectStage.SystemTest, ProjectStage.UnitTest

@Typed
public abstract class ProjectStage
extends Object
implements Serializable

This class is the base of all ProjectStages. A ProjectStage identifies the environment the application currently runs in. It provides the same functionality as the JSF-2 ProjectStage but has a few additional benefits:

Technically this is kind of a 'dynamic enum'.

The following ProjectStages are provided by default

The following resolution mechanism is used to determine the current ProjectStage:

Adding a new ProjectStage is done via the ServiceLoader mechanism. A class deriving from ProjectStage must be provided and used for creating a single static instance of it.

Custom ProjectStages can be implemented by writing anonymous ProjectStage members into a registered ProjectStageHolder as shown in the following sample:

 package org.apache.myfaces.extensions.cdi.test.api.projectstage;
 public class MyProjectStages implements ProjectStageHolder {
     public static final class MyOwnProjectStage extends ProjectStage {};
     public static final MyOwnProjectStage MyOwnProjectStage = new MyOwnProjectStage();

     public static final class MyOtherProjectStage extends ProjectStage {};
     public static final MyOtherProjectStage MyOtherProjectStage = new MyOtherProjectStage();
 }
 

For activating those projectstages, you have to register this ProjectStageHolder class to get picked up via the java.util.ServiceLoader mechanism. Simply create a file

 META-INF/services/org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStageHolder
 
which contains the fully qualified class name of custom ProjectStageHolder implementation:
 # this class now gets picked up by java.util.ServiceLoader
 org.apache.myfaces.extensions.cdi.core.test.api.projectstage.MyProjectStages
 

You can use your own ProjectStages exactly the same way as all the ones provided by the system:

 ProjectStage myOwnPs = ProjectStage.valueOf("MyOwnProjectStage");
   if (myOwnPs.equals(MyOwnProjectStage.MyOwnProjectStage)) ...
 

See Also:
Serialized Form

Nested Class Summary
static class ProjectStage.Development
          Project-stage for development
static class ProjectStage.IntegrationTest
          Project-stage for integration-tests
static class ProjectStage.Production
          Default project-stage for production
static class ProjectStage.Staging
          Project-stage for staging
static class ProjectStage.SystemTest
          Project-stage for system-tests
static class ProjectStage.UnitTest
          Project-stage for unit-tests
 
Field Summary
static ProjectStage.Development Development
          Type-safe ProjectStage
static ProjectStage.IntegrationTest IntegrationTest
          Type-safe ProjectStage
static ProjectStage.Production Production
          Type-safe ProjectStage
static ProjectStage.Staging Staging
          Type-safe ProjectStage
static ProjectStage.SystemTest SystemTest
          Type-safe ProjectStage
static ProjectStage.UnitTest UnitTest
          Type-safe ProjectStage
 
Constructor Summary
protected ProjectStage()
          The protected constructor will register the given ProjectStage via its name.
 
Method Summary
 String toString()
          
static ProjectStage valueOf(String projectStageClassName)
           
static ProjectStage[] values()
          Exposes all registered ProjectStage implementations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UnitTest

public static final ProjectStage.UnitTest UnitTest
Type-safe ProjectStage


Development

public static final ProjectStage.Development Development
Type-safe ProjectStage


SystemTest

public static final ProjectStage.SystemTest SystemTest
Type-safe ProjectStage


IntegrationTest

public static final ProjectStage.IntegrationTest IntegrationTest
Type-safe ProjectStage


Staging

public static final ProjectStage.Staging Staging
Type-safe ProjectStage


Production

public static final ProjectStage.Production Production
Type-safe ProjectStage

Constructor Detail

ProjectStage

protected ProjectStage()
The protected constructor will register the given ProjectStage via its name. The name is returned by the toString() method of the ProjectStage.

Method Detail

valueOf

public static ProjectStage valueOf(String projectStageClassName)
Parameters:
projectStageClassName - the name of the ProjectStage
Returns:
the ProjectStage which is identified by it's name

values

public static ProjectStage[] values()
Exposes all registered ProjectStage implementations

Returns:
provided and custom project-stage implementations

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.