commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r307366 - in /jakarta/commons/sandbox/scxml/trunk: project.xml src/main/java/org/apache/commons/scxml/env/faces/ src/main/java/org/apache/commons/scxml/env/faces/SessionContext.java src/main/java/org/apache/commons/scxml/env/faces/package.html
Date Sun, 09 Oct 2005 05:12:25 GMT
Author: rahul
Date: Sat Oct  8 22:12:21 2005
New Revision: 307366

URL: http://svn.apache.org/viewcvs?rev=307366&view=rev
Log:
Add a faces package for JSF-based environments.

Added:
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/SessionContext.java
  (with props)
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/package.html
  (with props)
Modified:
    jakarta/commons/sandbox/scxml/trunk/project.xml

Modified: jakarta/commons/sandbox/scxml/trunk/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/project.xml?rev=307366&r1=307365&r2=307366&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/project.xml (original)
+++ jakarta/commons/sandbox/scxml/trunk/project.xml Sat Oct  8 22:12:21 2005
@@ -82,6 +82,11 @@
       <artifactId>jsp-api</artifactId> 
       <version>2.0</version>
     </dependency>
+    <dependency> 
+      <groupId>myfaces</groupId>
+      <artifactId>myfaces-all</artifactId> 
+      <version>1.1.0</version>
+    </dependency>
   </dependencies>
 
   <scm>

Added: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/SessionContext.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/SessionContext.java?rev=307366&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/SessionContext.java
(added)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/SessionContext.java
Sat Oct  8 22:12:21 2005
@@ -0,0 +1,112 @@
+/*
+ *
+ *   Copyright 2005 The Apache Software Foundation.
+ *
+ *  Licensed 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.commons.scxml.env.faces;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.apache.commons.scxml.Context;
+import org.apache.commons.scxml.env.SimpleContext;
+
+/**
+ * <p>A Faces Session Context.</p>
+ *
+ * <p>Since the &quot;session map&quot; is obtained from a
+ * <code>FacesContext</code> object using the environment agnostic
+ * <code>getExternalContext()</code>, this <code>Context</code>
+ * will be useful in Servlet as well as Portlet environments.</p>
+ *
+ */
+public class SessionContext extends SimpleContext {
+
+    /** The map of session scoped variables. */
+    private Map sessionMap;
+    /** Bark if FacesContext is null. */
+    private static final String ERR_HOST_FACES_CTX_NULL =
+        "Host FacesContext cannot be null";
+
+    /**
+     * Constructor.
+     *
+     * @param fc The current FacesContext
+     */
+    public SessionContext(final FacesContext fc) {
+        this(fc, null);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param fc The current FacesContext
+     * @param parent A parent Context, can be null
+     */
+    public SessionContext(final FacesContext fc, final Context parent) {
+        super(parent);
+        if (fc == null) {
+            LOG.error(ERR_HOST_FACES_CTX_NULL);
+            throw new IllegalArgumentException(ERR_HOST_FACES_CTX_NULL);
+        } else {
+          // only retain the session map
+          this.sessionMap = fc.getExternalContext().getSessionMap();
+        }
+
+    }
+
+    /**
+     * Get the value of the given variable in this Context.
+     *
+     * @param name The name of the variable
+     * @return The value (or null)
+     * @see org.apache.commons.scxml.Context#get(java.lang.String)
+     */
+    public Object get(final String name) {
+        Object value = vars.get(name);
+        if (value == null) {
+            value = sessionMap.get(name);
+        }
+        return value;
+    }
+
+    /**
+     * Does the given variable exist in this Context.
+     *
+     * @param name The name of the variable
+     * @return boolean true if the variable exists
+     * @see org.apache.commons.scxml.Context#has(java.lang.String)
+     */
+    public boolean has(final String name) {
+        return (sessionMap.containsKey(name) || vars.containsKey(name));
+    }
+
+    /**
+     * Get the Iterator.
+     *
+     * @return Iterator The read-write variables in this Context.
+     * @see org.apache.commons.scxml.Context#iterator()
+     */
+    public Iterator iterator() {
+        // The reason why this method body exists is to emphasize that
+        // read-only (scoped/managed beans) variables are not included in
+        // this Iterator.
+        return super.iterator();
+    }
+
+}
+

Propchange: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/SessionContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/SessionContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/package.html
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/package.html?rev=307366&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/package.html
(added)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/package.html
Sat Oct  8 22:12:21 2005
@@ -0,0 +1,31 @@
+<html>
+<!--
+ *
+ *
+ *   Copyright 2005 The Apache Software Foundation.
+ *
+ *  Licensed 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.
+ *
+ *
+ *
+-->
+<head>
+</head>
+<body>
+
+  <p>A collection of classes bridging the SCXML executor to the JSF-based
+     environments.</p>
+
+</body>
+</html>
+

Propchange: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/package.html
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/faces/package.html
------------------------------------------------------------------------------
    svn:mime-type = text/html



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message