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 get's 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
           
static class ProjectStage.IntegrationTest
           
static class ProjectStage.Production
           
static class ProjectStage.Staging
           
static class ProjectStage.SystemTest
           
static class ProjectStage.UnitTest
           
 
Field Summary
static ProjectStage.Development Development
           
static ProjectStage.IntegrationTest IntegrationTest
           
static ProjectStage.Production Production
           
static ProjectStage.Staging Staging
           
static ProjectStage.SystemTest SystemTest
           
static ProjectStage.UnitTest UnitTest
           
 
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()
           
 
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

Development

public static final ProjectStage.Development Development

SystemTest

public static final ProjectStage.SystemTest SystemTest

IntegrationTest

public static final ProjectStage.IntegrationTest IntegrationTest

Staging

public static final ProjectStage.Staging Staging

Production

public static final ProjectStage.Production Production
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()

toString

public String toString()
Overrides:
toString in class Object


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