Author: pete.muir(a)jboss.org
Date: 2009-03-16 20:07:35 -0400 (Mon, 16 Mar 2009)
New Revision: 2060
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java
Log:
WBRI-174
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java 2009-03-16
23:01:12 UTC (rev 2059)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java 2009-03-17
00:07:35 UTC (rev 2060)
@@ -33,7 +33,7 @@
* @see javax.context.Conversation
*/
@RequestScoped
-(a)Named("javax.webbeans.conversation")
+(a)Named("javax.context.conversation")
@Standard
public class ConversationImpl implements Conversation
{
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
(rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java 2009-03-17 00:07:35
UTC (rev 2060)
@@ -0,0 +1,66 @@
+package org.jboss.webbeans.el;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A namespace for Seam component names.
+ *
+ * @author Gavin King
+ *
+ */
+public class Namespace
+{
+
+ private String name;
+ private Map<String, Namespace> children = new HashMap<String,
Namespace>();
+
+ public Namespace(String name)
+ {
+ this.name = name;
+ }
+
+ public Namespace getChild(String key)
+ {
+ Namespace result = children.get(key);
+ if (result==null)
+ {
+ result = new Namespace( getQualifiedName(key) + '.' );
+ children.put(name, result);
+ }
+ return result;
+ }
+
+ public String getQualifiedName(String key)
+ {
+ return name==null ? key : name + key;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return name==null ? 0 : name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if ( !(other instanceof Namespace) )
+ {
+ return false;
+ }
+ else
+ {
+ Namespace ns = (Namespace) other;
+ return this.name==ns.name ||
+ ( this.name!=null && this.name.equals(ns.name) );
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Namespace(" + ( name==null ? "Root" : name ) +
')';
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java
(rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java 2009-03-17
00:07:35 UTC (rev 2060)
@@ -0,0 +1,110 @@
+package org.jboss.webbeans.el;
+
+
+import javax.el.ELContext;
+import javax.inject.ExecutionException;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.context.DependentInstancesStore;
+import org.jboss.webbeans.context.DependentStorageRequest;
+
+class NamespacedResolver
+{
+
+ private final ELContext context;
+ private final String property;
+ private final Namespace namespace;
+ private Object value;
+
+ public NamespacedResolver(ELContext context, Namespace namespace, String property)
+ {
+ this.context = context;
+ this.property = property;
+ this.namespace = namespace;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public NamespacedResolver run()
+ {
+
+ try
+ {
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ value =
CurrentManager.rootManager().getInstanceByName(namespace.getQualifiedName(property));
+ if (value != null)
+ {
+ context.setPropertyResolved(true);
+ }
+ }
+
+ }.run();
+ }
+ catch (Exception e)
+ {
+ throw new ExecutionException("Error resolving EL " + property);
+ }
+
+ if (!context.isPropertyResolved())
+ {
+ // look for a namespace
+ value = namespace.getChild(property);
+ if (value != null)
+ {
+ context.setPropertyResolved(true);
+ }
+ }
+ return this;
+ }
+
+ static abstract class RunInDependentContext
+ {
+
+ private final DependentStorageRequest dependentStorageRequest;
+
+ public RunInDependentContext()
+ {
+ dependentStorageRequest = DependentStorageRequest.of(new
DependentInstancesStore(), new Object());
+ }
+
+ private void setup()
+ {
+ DependentContext.INSTANCE.setActive(true);
+ DependentContext.INSTANCE.startCollectingDependents(dependentStorageRequest);
+ }
+
+ private void cleanup()
+ {
+ DependentContext.INSTANCE.stopCollectingDependents(dependentStorageRequest);
+ // TODO kinky
+
dependentStorageRequest.getDependentInstancesStore().destroyDependentInstances(dependentStorageRequest.getKey());
+ DependentContext.INSTANCE.setActive(false);
+ }
+
+ protected abstract void execute() throws Exception;
+
+ public final void run() throws Exception
+ {
+ try
+ {
+ setup();
+ execute();
+ }
+ finally
+ {
+ cleanup();
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-03-16
23:01:12 UTC (rev 2059)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-03-17
00:07:35 UTC (rev 2060)
@@ -23,11 +23,6 @@
import javax.el.ELContext;
import javax.el.ELResolver;
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.context.DependentInstancesStore;
-import org.jboss.webbeans.context.DependentStorageRequest;
-
/**
* An EL-resolver against the named beans
*
@@ -36,6 +31,8 @@
public class WebBeansELResolver extends ELResolver
{
+ private static final Namespace ROOT = new Namespace(null);
+
/**
* @see javax.el.ELResolver#getCommonPropertyType(ELContext, Object)
*/
@@ -69,32 +66,18 @@
@Override
public Object getValue(ELContext context, Object base, Object property)
{
- if (base == null && property != null)
+ if (property != null)
{
- DependentStorageRequest dependentStorageRequest = DependentStorageRequest.of(new
DependentInstancesStore(), new Object());
- try
+ if (base == null)
{
- DependentContext.INSTANCE.setActive(true);
-
DependentContext.INSTANCE.startCollectingDependents(dependentStorageRequest);
- Object value =
CurrentManager.rootManager().getInstanceByName(property.toString());
- if (value != null)
- {
- context.setPropertyResolved(true);
- }
- return value;
+ return new NamespacedResolver(context, ROOT,
property.toString()).run().getValue();
}
- finally
+ else if (base instanceof Namespace)
{
- DependentContext.INSTANCE.stopCollectingDependents(dependentStorageRequest);
- // TODO kinky
-
dependentStorageRequest.getDependentInstancesStore().destroyDependentInstances(dependentStorageRequest.getKey());
- DependentContext.INSTANCE.setActive(false);
+ return new NamespacedResolver(context, (Namespace) base,
property.toString()).run().getValue();
}
}
- else
- {
- return null;
- }
+ return null;
}
/**
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java 2009-03-16
23:01:12 UTC (rev 2059)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java 2009-03-17
00:07:35 UTC (rev 2060)
@@ -66,7 +66,7 @@
assert found;
}
- @Test(groups = { "contexts", "ri-broken" })
+ @Test(groups = { "contexts" })
@SpecAssertion(section = "8.5.4", id = "ie")
public void testBeanWithNameJavaxContextConversation()
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java 2009-03-16
23:01:12 UTC (rev 2059)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java 2009-03-17
00:07:35 UTC (rev 2060)
@@ -1,7 +1,10 @@
package org.jboss.jsr299.tck.tests.lookup.el;
+import javax.context.Conversation;
+
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
/**
@@ -9,6 +12,7 @@
* Spec version: PRD2
*
*/
+@Artifact
public class ResolutionByNameTest extends AbstractJSR299Test
{
@@ -23,4 +27,11 @@
{
assert false;
}
+
+ @Test
+ @SpecAssertion(section="unknown", id="unknown")
+ public void testQualifiedNameLookup()
+ {
+ assert
getCurrentConfiguration().getEl().evaluateValueExpression("#{javax.context.conversation}",
Conversation.class) != null;
+ }
}
Show replies by date