Author: nickarls
Date: 2008-10-27 06:00:39 -0400 (Mon, 27 Oct 2008)
New Revision: 173
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
Log:
Context hierarchy to new package
Stub for EL resolver
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java 2008-10-27
09:59:35 UTC (rev 172)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java 2008-10-27
10:00:39 UTC (rev 173)
@@ -1,113 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-
-import javax.webbeans.ContextNotActiveException;
-import javax.webbeans.manager.Bean;
-import javax.webbeans.manager.Context;
-import javax.webbeans.manager.Manager;
-
-import org.jboss.webbeans.util.MapWrapper;
-
-/**
- * Basic implementation of javax.webbeans.Context, backed by a HashMap
- *
- * @author Shane Bryzak
- * @author Nicklas Karlsson (nickarls(a)gmail.com)
- * @author Pete Muir
- *
- */
-public abstract class AbstractContext implements Context
-{
-
- private class BeanMap extends MapWrapper<Bean<? extends Object>, Object>
- {
-
- public BeanMap()
- {
- super(new HashMap<Bean<? extends Object>, Object>());
- }
-
- @SuppressWarnings("unchecked")
- public <T extends Object> T get(Bean<? extends T> key)
- {
- return (T) super.get(key);
- }
-
- }
-
- private BeanMap beans;
- private Class<? extends Annotation> scopeType;
- private boolean active;
-
- public AbstractContext(Class<? extends Annotation> scopeType)
- {
- this.scopeType = scopeType;
- beans = new BeanMap();
- active = true;
- }
-
- public <T> T get(Bean<T> bean, boolean create)
- {
- if (!active)
- {
- throw new ContextNotActiveException();
- }
-
- if (beans == null)
- {
- // Context has been destroyed
- return null;
- }
-
- T instance = beans.get(bean);
-
- if (instance != null)
- {
- return instance;
- }
-
- if (!create)
- {
- return null;
- }
-
- // TODO should bean creation be synchronized?
-
- instance = bean.create();
-
- beans.put(bean, instance);
- return instance;
- }
-
- public Class<? extends Annotation> getScopeType()
- {
- return scopeType;
- }
-
- private <T> void destroy(Manager manager, Bean<T> bean)
- {
- bean.destroy(beans.get(bean));
- }
-
- public void destroy(Manager manager)
- {
- for (Bean<? extends Object> bean : beans.keySet())
- {
- destroy(manager, bean);
- }
- beans = null;
- }
-
- public boolean isActive()
- {
- return active;
- }
-
- public void setActive(boolean active)
- {
- this.active = active;
- }
-
-}
Copied:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java (from
rev 171, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java 2008-10-27
10:00:39 UTC (rev 173)
@@ -0,0 +1,113 @@
+package org.jboss.webbeans.contexts;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+
+import javax.webbeans.ContextNotActiveException;
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Context;
+import javax.webbeans.manager.Manager;
+
+import org.jboss.webbeans.util.MapWrapper;
+
+/**
+ * Basic implementation of javax.webbeans.Context, backed by a HashMap
+ *
+ * @author Shane Bryzak
+ * @author Nicklas Karlsson (nickarls(a)gmail.com)
+ * @author Pete Muir
+ *
+ */
+public abstract class AbstractContext implements Context
+{
+
+ private class BeanMap extends MapWrapper<Bean<? extends Object>, Object>
+ {
+
+ public BeanMap()
+ {
+ super(new HashMap<Bean<? extends Object>, Object>());
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Object> T get(Bean<? extends T> key)
+ {
+ return (T) super.get(key);
+ }
+
+ }
+
+ private BeanMap beans;
+ private Class<? extends Annotation> scopeType;
+ private boolean active;
+
+ public AbstractContext(Class<? extends Annotation> scopeType)
+ {
+ this.scopeType = scopeType;
+ beans = new BeanMap();
+ active = true;
+ }
+
+ public <T> T get(Bean<T> bean, boolean create)
+ {
+ if (!active)
+ {
+ throw new ContextNotActiveException();
+ }
+
+ if (beans == null)
+ {
+ // Context has been destroyed
+ return null;
+ }
+
+ T instance = beans.get(bean);
+
+ if (instance != null)
+ {
+ return instance;
+ }
+
+ if (!create)
+ {
+ return null;
+ }
+
+ // TODO should bean creation be synchronized?
+
+ instance = bean.create();
+
+ beans.put(bean, instance);
+ return instance;
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return scopeType;
+ }
+
+ private <T> void destroy(Manager manager, Bean<T> bean)
+ {
+ bean.destroy(beans.get(bean));
+ }
+
+ public void destroy(Manager manager)
+ {
+ for (Bean<? extends Object> bean : beans.keySet())
+ {
+ destroy(manager, bean);
+ }
+ beans = null;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive(boolean active)
+ {
+ this.active = active;
+ }
+
+}
Property changes on:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java 2008-10-27
10:00:39 UTC (rev 173)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.contexts;
+
+import javax.webbeans.ApplicationScoped;
+
+public class ApplicationContext extends NormalContext {
+
+ public ApplicationContext()
+ {
+ super(ApplicationScoped.class);
+ }
+
+}
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java 2008-10-27
10:00:39 UTC (rev 173)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.contexts;
+
+import javax.webbeans.ConversationScoped;
+
+
+public class ConversationContext extends NormalContext {
+
+ public ConversationContext()
+ {
+ super(ConversationScoped.class);
+ }
+
+}
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java 2008-10-27
10:00:39 UTC (rev 173)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.contexts;
+
+import java.lang.annotation.Annotation;
+
+public class DependentContext extends AbstractContext
+{
+
+ public DependentContext(Class<? extends Annotation> scopeType)
+ {
+ super(scopeType);
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java 2008-10-27
10:00:39 UTC (rev 173)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.contexts;
+
+import java.lang.annotation.Annotation;
+
+public class NormalContext extends AbstractContext
+{
+
+ public NormalContext(Class<? extends Annotation> scopeType)
+ {
+ super(scopeType);
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java 2008-10-27
10:00:39 UTC (rev 173)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.contexts;
+
+import javax.webbeans.RequestScoped;
+
+public class RequestContext extends NormalContext {
+
+ public RequestContext()
+ {
+ super(RequestScoped.class);
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-10-27
10:00:39 UTC (rev 173)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.contexts;
+
+import javax.webbeans.SessionScoped;
+
+public class SessionContext extends NormalContext {
+
+ public SessionContext()
+ {
+ super(SessionScoped.class);
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2008-10-27
10:00:39 UTC (rev 173)
@@ -0,0 +1,53 @@
+package org.jboss.webbeans.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+public class WebBeansELResolver extends ELResolver
+{
+
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
Object base)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getValue(ELContext context, Object base, Object property)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setValue(ELContext context, Object base, Object property, Object value)
+ {
+ // TODO Auto-generated method stub
+ }
+
+}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java 2008-10-27
09:59:35 UTC (rev 172)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java 2008-10-27
10:00:39 UTC (rev 173)
@@ -8,11 +8,12 @@
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
-import javax.webbeans.RequestScoped;
import javax.webbeans.manager.Manager;
-import org.jboss.webbeans.AbstractContext;
+import org.jboss.webbeans.contexts.AbstractContext;
+import org.jboss.webbeans.contexts.RequestContext;
+
/**
*
* @author Shane Bryzak
@@ -30,7 +31,7 @@
public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain)
throws IOException, ServletException
{
- AbstractContext requestContext = new AbstractContext(RequestScoped.class) {};
+ AbstractContext requestContext = new RequestContext();
try
{