You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2010/03/07 12:31:55 UTC

svn commit: r919970 - in /myfaces/extensions/cdi/branches/branch_for_jsf_1_2: core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/common/qualifier/ core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/project/stage/ core/api/...

Author: gpetracek
Date: Sun Mar  7 11:31:54 2010
New Revision: 919970

URL: http://svn.apache.org/viewvc?rev=919970&view=rev
Log:
cleanup

Added:
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/StringUtils.java
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/listener/
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/listener/phase/
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/listener/phase/FacesDemoBean.java
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/ApplicationProjectStageDemoBean.java
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/JsfProjectStageDemoBean.java
Removed:
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/common/qualifier/Current.java
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java
Modified:
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/project/stage/ProjectStage.java
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/project/stage/ApplicationProjectStageResolver.java
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/webapp/helloMyFacesCodi.jsp
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/project/stage/JsfProjectStageBuilder.java

Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/project/stage/ProjectStage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/project/stage/ProjectStage.java?rev=919970&r1=919969&r2=919970&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/project/stage/ProjectStage.java (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/project/stage/ProjectStage.java Sun Mar  7 11:31:54 2010
@@ -18,11 +18,11 @@
  */
 package org.apache.myfaces.extensions.cdi.core.api.project.stage;
 
-import org.apache.myfaces.extensions.cdi.core.api.common.qualifier.Current;
-
 import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
 import java.io.Serializable;
 
+@Typed()
 public class ProjectStage implements Serializable
 {
     private static final long serialVersionUID = 8372440985154139133L;
@@ -42,7 +42,6 @@
     }
 
     @Produces
-    @Current
     public ProjectStage createProjectStage(ProjectStageResolver projectStageResolver)
     {
         return new ProjectStage(projectStageResolver.getCurrentProjectStageName());

Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/StringUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/StringUtils.java?rev=919970&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/StringUtils.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/StringUtils.java Sun Mar  7 11:31:54 2010
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.cdi.core.api.util;
+
+public class StringUtils
+{
+    public static boolean isEmpty(String string)
+    {
+        return string == null || "".equals(string);
+    }
+}

Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/project/stage/ApplicationProjectStageResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/project/stage/ApplicationProjectStageResolver.java?rev=919970&r1=919969&r2=919970&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/project/stage/ApplicationProjectStageResolver.java (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/project/stage/ApplicationProjectStageResolver.java Sun Mar  7 11:31:54 2010
@@ -23,6 +23,7 @@
 import org.apache.myfaces.extensions.cdi.core.api.project.config.InitParameterNames;
 import org.apache.myfaces.extensions.cdi.core.api.project.stage.ProjectStageResolver;
 import org.apache.myfaces.extensions.cdi.core.api.project.stage.ProjectStage;
+import static org.apache.myfaces.extensions.cdi.core.api.util.StringUtils.*;
 
 import javax.inject.Inject;
 
@@ -45,7 +46,7 @@
     {
         String result = this.configManager.getValue(InitParameterNames.APPLICATION_PROJECT_STAGE);
 
-        if (result == null || "".equals(result))
+        if (isEmpty(result))
         {
             return ProjectStage.DEFAULT_STAGE;
         }

Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/listener/phase/FacesDemoBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/listener/phase/FacesDemoBean.java?rev=919970&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/listener/phase/FacesDemoBean.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/listener/phase/FacesDemoBean.java Sun Mar  7 11:31:54 2010
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.blank.listener.phase;
+
+import org.apache.myfaces.extensions.cdi.core.api.listener.phase.annotation.View;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.JsfLifecyclePhaseInformation;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.PhaseId;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.AfterPhase;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.BeforePhase;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Model;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.inject.Inject;
+
+@Model
+public class FacesDemoBean
+{
+    @Inject
+    private FacesContext facesContext;
+
+    @Inject
+    private JsfLifecyclePhaseInformation phaseInformation;
+
+    private String text;
+
+    //no restriction via @View -> invoked before rendering any view
+    public void preRenderView(@Observes @BeforePhase(PhaseId.RENDER_RESPONSE) PhaseEvent event)
+    {
+        addGlobalMessage("preRenderView in phase:" + event.getPhaseId());
+
+        this.text = "Hello MyFaces CODI";
+    }
+
+    @View("/helloMyFacesCodi.jsp")
+    public void preInvokeApplication(@Observes @BeforePhase(PhaseId.INVOKE_APPLICATION) PhaseEvent event)
+    {
+        addGlobalMessage("preInvokeApplication in phase:" + event.getPhaseId());
+    }
+
+    @View("/invalidPage.jsp")
+    public void postRestoreViewInvalid(@Observes @AfterPhase(PhaseId.RESTORE_VIEW) PhaseEvent event)
+    {
+        addGlobalMessage("postRestoreViewInvalid in phase:" + event.getPhaseId());
+    }
+
+    @View({"/invalidPage.jsp", "/helloMyFacesCodi.jsp"})
+    public void postRestoreView(@Observes @AfterPhase(PhaseId.RESTORE_VIEW) PhaseEvent event)
+    {
+        addGlobalMessage("postRestoreView in phase:" + event.getPhaseId());
+    }
+
+    //no restriction via @View -> invoked for any view
+    public void preAny(@Observes @BeforePhase(PhaseId.ANY_PHASE) PhaseEvent event)
+    {
+        addGlobalMessage("preAny in phase:" + event.getPhaseId());
+    }
+
+    public void preAnyFiltered1(@Observes @BeforePhase(PhaseId.ANY_PHASE) PhaseEvent event)
+    {
+        if (event.getPhaseId().equals(javax.faces.event.PhaseId.APPLY_REQUEST_VALUES) ||
+                event.getPhaseId().equals(javax.faces.event.PhaseId.UPDATE_MODEL_VALUES))
+        {
+            addGlobalMessage("preAnyFiltered1 in phase:" + event.getPhaseId());
+        }
+    }
+
+    public void preAnyFiltered2(@Observes @AfterPhase(PhaseId.ANY_PHASE) PhaseEvent event)
+    {
+        if (this.phaseInformation.isProcessValidationsPhase() || this.phaseInformation.isUpdateModelValuesPhase())
+        {
+            addGlobalMessage("preAnyFiltered2 in phase:" + event.getPhaseId());
+        }
+    }
+
+    public String getText()
+    {
+        return this.text;
+    }
+
+    private void addGlobalMessage(String messageText)
+    {
+        this.facesContext.addMessage(null, new FacesMessage(messageText));
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/ApplicationProjectStageDemoBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/ApplicationProjectStageDemoBean.java?rev=919970&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/ApplicationProjectStageDemoBean.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/ApplicationProjectStageDemoBean.java Sun Mar  7 11:31:54 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.blank.project.stage;
+
+import org.apache.myfaces.extensions.cdi.core.api.project.stage.ProjectStage;
+
+import javax.enterprise.inject.Model;
+import javax.inject.Inject;
+
+@Model
+public class ApplicationProjectStageDemoBean
+{
+    @Inject
+    private ProjectStage projectStage;
+
+    public String getProjectStageName()
+    {
+        return this.projectStage.toString();
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/JsfProjectStageDemoBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/JsfProjectStageDemoBean.java?rev=919970&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/JsfProjectStageDemoBean.java (added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/project/stage/JsfProjectStageDemoBean.java Sun Mar  7 11:31:54 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.blank.project.stage;
+
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.project.stage.JsfProjectStage;
+
+import javax.enterprise.inject.Model;
+import javax.inject.Inject;
+
+@Model
+public class JsfProjectStageDemoBean
+{
+    @Inject
+    private JsfProjectStage jsfProjectStage;
+
+    public String getProjectStageName()
+    {
+        return this.jsfProjectStage.toString();
+    }
+}
\ No newline at end of file

Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/webapp/helloMyFacesCodi.jsp
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/webapp/helloMyFacesCodi.jsp?rev=919970&r1=919969&r2=919970&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/webapp/helloMyFacesCodi.jsp (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/webapp/helloMyFacesCodi.jsp Sun Mar  7 11:31:54 2010
@@ -26,10 +26,13 @@
             <h:form id="mainForm">
                 <h:panelGrid columns="2">
                     <h:outputLabel for="txtInfo" value="Bean-value:"/>
-                    <h:outputText id="txtInfo" value="#{helloCodiBean.text}"/>
+                    <h:outputText id="txtInfo" value="#{facesDemoBean.text}"/>
 
-                    <h:outputLabel for="txtProjctStage" value="Project stage:"/>
-                    <h:outputText id="txtProjctStage" value="#{helloCodiBean.projectStageName}"/>
+                    <h:outputLabel for="txtAppProjctStage" value="App-Project stage:"/>
+                    <h:outputText id="txtAppProjctStage" value="#{applicationProjectStageDemoBean.projectStageName}"/>
+
+                    <h:outputLabel for="txtJsfProjctStage" value="Jsf-Project stage:"/>
+                    <h:outputText id="txtJsfProjctStage" value="#{jsfProjectStageDemoBean.projectStageName}"/>
 
                     <h:commandButton value="send"/>
                 </h:panelGrid>

Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/project/stage/JsfProjectStageBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/project/stage/JsfProjectStageBuilder.java?rev=919970&r1=919969&r2=919970&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/project/stage/JsfProjectStageBuilder.java (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/project/stage/JsfProjectStageBuilder.java Sun Mar  7 11:31:54 2010
@@ -18,7 +18,6 @@
  */
 package org.apache.myfaces.extensions.cdi.javaee.jsf.impl.project.stage;
 
-import org.apache.myfaces.extensions.cdi.core.api.common.qualifier.Current;
 import org.apache.myfaces.extensions.cdi.core.api.project.stage.ProjectStage;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.api.project.stage.JsfProjectStage;
 
@@ -43,7 +42,7 @@
     }
 
     @Produces
-    public JsfProjectStage createJsfProjectStage(@Current ProjectStage projectStage)
+    public JsfProjectStage createJsfProjectStage(ProjectStage projectStage)
     {
         return new JsfProjectStageBuilder(projectStage);
     }