Return-Path: X-Original-To: apmail-incubator-deltaspike-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-deltaspike-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 89DD7E080 for ; Sat, 15 Dec 2012 19:43:00 +0000 (UTC) Received: (qmail 69636 invoked by uid 500); 15 Dec 2012 19:43:00 -0000 Delivered-To: apmail-incubator-deltaspike-commits-archive@incubator.apache.org Received: (qmail 69617 invoked by uid 500); 15 Dec 2012 19:43:00 -0000 Mailing-List: contact deltaspike-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltaspike-dev@incubator.apache.org Delivered-To: mailing list deltaspike-commits@incubator.apache.org Received: (qmail 69610 invoked by uid 99); 15 Dec 2012 19:43:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Dec 2012 19:43:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Dec 2012 19:42:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 55CA92388B3A for ; Sat, 15 Dec 2012 19:42:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r842539 - in /websites/staging/deltaspike/trunk/content: ./ deltaspike/core.html Date: Sat, 15 Dec 2012 19:42:39 -0000 To: deltaspike-commits@incubator.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121215194239.55CA92388B3A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: buildbot Date: Sat Dec 15 19:42:38 2012 New Revision: 842539 Log: Staging update by buildbot for deltaspike Modified: websites/staging/deltaspike/trunk/content/ (props changed) websites/staging/deltaspike/trunk/content/deltaspike/core.html Propchange: websites/staging/deltaspike/trunk/content/ ------------------------------------------------------------------------------ --- cms:source-revision (original) +++ cms:source-revision Sat Dec 15 19:42:38 2012 @@ -1 +1 @@ -1422323 +1422328 Modified: websites/staging/deltaspike/trunk/content/deltaspike/core.html ============================================================================== --- websites/staging/deltaspike/trunk/content/deltaspike/core.html (original) +++ websites/staging/deltaspike/trunk/content/deltaspike/core.html Sat Dec 15 19:42:38 2012 @@ -156,6 +156,59 @@ If a simple but manual bean-lookup is ne +

Type-safe ProjectStage

+

Project stages allow to use implementations depending on the current environment. E.g. you can implement a bean which creates sample-data for system tests which gets activated only in case of project-stage SystemTest.

+

Besides custom project-stages it's possible to use the following pre-defined project-stages:

+
    +
  • UnitTest
  • +
  • Development
  • +
  • SystemTest
  • +
  • IntegrationTest
  • +
  • Staging
  • +
  • Production
  • +
+

The core provides a pluggable and type-safe approach for using project stages in a project (it's also used within the framework). Furthermore, @Exclude 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 DeltaSpike.

+

Resolving and using the Project-Stage:

+
@Inject
+private ProjectStage projectStage;
+
+//...
+
+boolean isDevProjectStage = ProjectStage.Development.equals(this.projectStage);
+
+ + +

Custom Project Stages

+

It's possible to provide custom project stage implementations. +Therefore, you have to provide an implementation of the ProjectStageHolder interface. +In this class you nest the custom project-stage implementations which have to be public static final class and it's required to extend ProjectStage. +It's required to provide a public static final instance even though, you won't use it directly.

+

ProjectStageHolder for custom project stage implementations:

+
public class CustomProjectStageHolder implements ProjectStageHolder
+{
+    public static final class CustomProjectStage extends ProjectStage
+    {
+        private static final long serialVersionUID = 1029094387976167179L;
+    }
+
+    public static final CustomProjectStage CustomProjectStage = new CustomProjectStage();
+}
+
+ + +

Configure your custom ProjectStageHolder in META-INF/services/org.apache.deltaspike.core.api.projectstage.ProjectStageHolder. The file has to provide the fully qualified class name of the custom implementation of the ProjectStageHolder interface.

+

Usage of a custom project stage:

+
ProjectStage customProjectStage;
+customProjectStage = ProjectStage.valueOf("CustomProjectStage");
+//or
+customProjectStage = CustomProjectStageHolder.CustomProjectStage;
+//or
+@Exclude(ifProjectStage = CustomProjectStageHolder.CustomProjectStage.class)
+
+ + +

ProjectStageProducer (for 3rd party portable extensions)

+

ProjectStageProducer provides the producer method which allows to inject the current project-stage. However, in some cases it's needed to use project-stages also during the bootstrapping process of the CDI container and you can't use injection. In such cases you can use ProjectStageProducer.getInstance().getProjectStage() to resolve the current project-stage. This helper also contains helpers for unit-tests - e.g. #setProjectStage. However, those methods shouldn't be needed for users (we just need them for testing different project-stage scenarios).

@Exclude

With @Exclude it's possible to annotate beans which should be ignored by CDI even if they are in a CDI enabled archive.

Excluding a bean in any case:

@@ -225,8 +278,6 @@ This config entry won't be changed e.g. -

Type-safe ProjectStage

-

TODO

Type-safe config

TODO

@ConfigProperty