deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-485 InjectableWindowContext
Date Thu, 02 Jan 2014 21:46:09 GMT
Updated Branches:
  refs/heads/master 02b78e988 -> 4e33427a1


DELTASPIKE-485 InjectableWindowContext


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/4e33427a
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/4e33427a
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/4e33427a

Branch: refs/heads/master
Commit: 4e33427a1682bdba67186fe1fa0fab0b952736f3
Parents: 02b78e9
Author: gpetracek <gpetracek@apache.org>
Authored: Thu Jan 2 22:45:16 2014 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Thu Jan 2 22:45:16 2014 +0100

----------------------------------------------------------------------
 .../core/spi/scope/window/WindowContext.java    |  4 +-
 .../scope/window/InjectableWindowContext.java   | 65 ++++++++++++++++++++
 .../scope/window/WindowContextProducer.java     |  2 +-
 3 files changed, 69 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4e33427a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/scope/window/WindowContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/scope/window/WindowContext.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/scope/window/WindowContext.java
index 14663c5..c22659b 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/scope/window/WindowContext.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/scope/window/WindowContext.java
@@ -18,6 +18,8 @@
  */
 package org.apache.deltaspike.core.spi.scope.window;
 
+import java.io.Serializable;
+
 /**
  * <p>We support the general notion of multiple 'windows'
  * That might be different parallel edit pages in a
@@ -36,7 +38,7 @@ package org.apache.deltaspike.core.spi.scope.window;
  * is the interface which allows resolving the current <i>windowId</i>
  * associated with this very Thread.</p>
  */
-public interface WindowContext
+public interface WindowContext extends Serializable
 {
     /**
      * @return the <i>windowId</i> associated with the very Thread or <code>null</code>.

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4e33427a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/window/InjectableWindowContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/window/InjectableWindowContext.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/window/InjectableWindowContext.java
new file mode 100644
index 0000000..4263c8e
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/window/InjectableWindowContext.java
@@ -0,0 +1,65 @@
+/*
+ * 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.deltaspike.core.impl.scope.window;
+
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.core.spi.scope.window.WindowContext;
+
+import javax.enterprise.inject.Typed;
+
+@Typed()
+class InjectableWindowContext implements WindowContext
+{
+    private static final long serialVersionUID = -3606786361833889628L;
+
+    private transient volatile WindowContext windowContext;
+
+    InjectableWindowContext(WindowContext windowContext)
+    {
+        this.windowContext = windowContext;
+    }
+
+    private WindowContext getWindowContext()
+    {
+        if (this.windowContext == null)
+        {
+            this.windowContext =
+                BeanProvider.getContextualReference(DeltaSpikeContextExtension.class).getWindowContext();
+        }
+        return this.windowContext;
+    }
+
+    @Override
+    public String getCurrentWindowId()
+    {
+        return getWindowContext().getCurrentWindowId();
+    }
+
+    @Override
+    public void activateWindow(String windowId)
+    {
+        getWindowContext().activateWindow(windowId);
+    }
+
+    @Override
+    public boolean closeWindow(String windowId)
+    {
+        return getWindowContext().closeWindow(windowId);
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4e33427a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/window/WindowContextProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/window/WindowContextProducer.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/window/WindowContextProducer.java
index 54ca5cb..2f1e686 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/window/WindowContextProducer.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/window/WindowContextProducer.java
@@ -41,6 +41,6 @@ public class WindowContextProducer
     @Dependent
     public WindowContext getWindowContext()
     {
-        return deltaSpikeContextExtension.getWindowContext();
+        return new InjectableWindowContext(deltaSpikeContextExtension.getWindowContext());
     }
 }


Mime
View raw message