[webbeans-commits] Webbeans SVN: r1378 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: bean and 9 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Mon Feb 2 02:55:34 EST 2009
Author: nickarls
Date: 2009-02-02 02:55:34 -0500 (Mon, 02 Feb 2009)
New Revision: 1378
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationIdGenerator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationManager.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationTerminator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/DefaultConversationManager.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/JavaSEConversationTerminator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/NumericConversationIdGenerator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ConversationBeanMap.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/ConversationContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/AnnotatedInjectionPoint.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Proxies.java
Log:
Infrastructure of conversations for review
DependentInstancesStore -> singleton for now
Relaxing of some bean validation (interfaces)
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -93,7 +93,7 @@
throw new AmbiguousDependencyException("The injection point " + injectionPoint + " has ambiguos dependencies for type " + type + " and binding types " + bindings + " in " + bean);
}
Bean<?> resolvedBean = (Bean<?>) resolvedBeans.iterator().next();
- if (MetaDataCache.instance().getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isClassProxyable(type))
+ if (MetaDataCache.instance().getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(type))
{
throw new UnproxyableDependencyException("The injection point " + injectionPoint + " has non-proxyable dependencies");
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -36,7 +36,6 @@
import javax.inject.manager.Bean;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.context.DependentInstancesStore;
import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotationStore.AnnotationMap;
@@ -62,7 +61,6 @@
private static Set<Class<?>> STANDARD_WEB_BEAN_CLASSES = new HashSet<Class<?>>(Arrays.asList(Event.class, ManagerImpl.class));
private boolean proxyable;
- protected DependentInstancesStore dependentInstancesStore;
/**
* Helper class for getting deployment type
@@ -122,7 +120,6 @@
super(manager);
this.manager = manager;
injectionPoints = new HashSet<AnnotatedInjectionPoint<?,?>>();
- dependentInstancesStore = new DependentInstancesStore();
}
/**
@@ -534,10 +531,6 @@
{
return proxyable;
}
- public DependentInstancesStore getDependentInstancesStore()
- {
- return dependentInstancesStore;
- }
public boolean isDependent()
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -39,6 +39,7 @@
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.context.DependentInstancesStore;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.MetaDataCache;
@@ -321,7 +322,7 @@
{
if (getDeclaringBean().isDependent())
{
- DependentContext.INSTANCE.setCurrentInjectionInstance(dependentCollector);
+ DependentContext.INSTANCE.startCollecting(dependentCollector);
}
DependentContext.INSTANCE.setActive(true);
T instance = produceInstance(creationalContext);
@@ -332,8 +333,8 @@
{
if (getDeclaringBean().isDependent())
{
- DependentContext.INSTANCE.clearCurrentInjectionInstance(dependentCollector);
- dependentInstancesStore.destroyDependentInstances(dependentCollector);
+ DependentContext.INSTANCE.stopCollecting(dependentCollector);
+ DependentInstancesStore.instance().destroyDependentInstances(dependentCollector);
}
DependentContext.INSTANCE.setActive(false);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -291,7 +291,7 @@
public void push(T incompleteInstance) {};
};
- DependentContext.INSTANCE.setCurrentInjectionInstance(instance);
+ DependentContext.INSTANCE.startCollecting(instance);
DependentContext.INSTANCE.setActive(true);
bindDecorators();
bindInterceptors();
@@ -300,7 +300,7 @@
}
finally
{
- DependentContext.INSTANCE.clearCurrentInjectionInstance(instance);
+ DependentContext.INSTANCE.stopCollecting(instance);
DependentContext.INSTANCE.setActive(false);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -33,6 +33,7 @@
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.context.DependentInstancesStore;
import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
import org.jboss.webbeans.injection.FieldInjectionPoint;
@@ -129,7 +130,7 @@
{
instance = constructor.newInstance(manager, creationalContext);
creationalContext.push(instance);
- DependentContext.INSTANCE.setCurrentInjectionInstance(instance);
+ DependentContext.INSTANCE.startCollecting(instance);
bindDecorators();
bindInterceptors();
injectEjbAndCommonFields(instance);
@@ -139,7 +140,7 @@
}
finally
{
- DependentContext.INSTANCE.clearCurrentInjectionInstance(instance);
+ DependentContext.INSTANCE.stopCollecting(instance);
}
return instance;
}
@@ -160,7 +161,7 @@
{
DependentContext.INSTANCE.setActive(true);
callPreDestroy(instance);
- dependentInstancesStore.destroyDependentInstances(instance);
+ DependentInstancesStore.instance().destroyDependentInstances(instance);
}
catch (Exception e)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -26,6 +26,9 @@
import org.jboss.webbeans.bean.standard.ManagerBean;
import org.jboss.webbeans.bootstrap.spi.EjbDiscovery;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.conversation.DefaultConversationManager;
+import org.jboss.webbeans.conversation.JavaSEConversationTerminator;
+import org.jboss.webbeans.conversation.NumericConversationIdGenerator;
import org.jboss.webbeans.ejb.spi.EjbResolver;
import org.jboss.webbeans.literal.DeployedLiteral;
import org.jboss.webbeans.literal.InitializedLiteral;
@@ -97,6 +100,9 @@
beanDeployer.addBean(ManagerBean.of(manager));
beanDeployer.addBean(InjectionPointBean.of(manager));
beanDeployer.addClass(Transaction.class);
+ beanDeployer.addClass(DefaultConversationManager.class);
+ beanDeployer.addClass(JavaSEConversationTerminator.class);
+ beanDeployer.addClass(NumericConversationIdGenerator.class);
beanDeployer.deploy();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/ConversationContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/ConversationContext.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/ConversationContext.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -19,28 +19,50 @@
import javax.context.ConversationScoped;
+import org.jboss.webbeans.context.beanmap.BeanMap;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
/**
* The conversation context
*
* @author Nicklas Karlsson
*/
-public class ConversationContext extends BasicContext
+public class ConversationContext extends AbstractBeanMapContext
{
+ private static LogProvider log = Logging.getLogProvider(ConversationContext.class);
+ public static ConversationContext INSTANCE = new ConversationContext();
+
+ private ThreadLocal<BeanMap> beanMap;
+
/**
* Constructor
*/
public ConversationContext()
{
super(ConversationScoped.class);
+ log.trace("Created conversation context");
+ this.beanMap = new ThreadLocal<BeanMap>();
}
@Override
+ protected BeanMap getBeanMap()
+ {
+ return beanMap.get();
+ }
+
+ public void setBeanMap(BeanMap beanMap)
+ {
+ this.beanMap.set(beanMap);
+ }
+
+ @Override
public String toString()
{
String active = isActive() ? "Active " : "Inactive ";
String beanMapInfo = getBeanMap() == null ? "" : getBeanMap().toString();
- return active + "conversation context " + beanMapInfo;
+ return active + "conversation context " + beanMapInfo;
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -24,8 +24,6 @@
import javax.context.CreationalContext;
import javax.context.Dependent;
-import org.jboss.webbeans.bean.AbstractClassBean;
-
/**
* The dependent context
*
@@ -37,7 +35,7 @@
private ThreadLocal<AtomicInteger> reentrantActiveCount;
// Key to collect instances under in DependentInstacesStore
- private ThreadLocal<Object> currentInjectionInstance;
+ private ThreadLocal<Object> dependentsKey;
/**
* Constructor
@@ -54,7 +52,7 @@
return new AtomicInteger(0);
}
};
- this.currentInjectionInstance = new ThreadLocal<Object>();
+ this.dependentsKey = new ThreadLocal<Object>();
}
/**
@@ -72,10 +70,9 @@
if (creationalContext != null)
{
T instance = contextual.create(creationalContext);
- if (contextual instanceof AbstractClassBean && (currentInjectionInstance.get() != null))
+ if (dependentsKey.get() != null)
{
- DependentInstancesStore dependentInstancesStore = ((AbstractClassBean<?>) contextual).getDependentInstancesStore();
- dependentInstancesStore.addDependentInstance(currentInjectionInstance.get(), ContextualInstance.of(contextual, instance));
+ DependentInstancesStore.instance().addDependentInstance(dependentsKey.get(), ContextualInstance.of(contextual, instance));
}
return instance;
}
@@ -120,14 +117,14 @@
* Sets the current injection instance. If there is already an instance
* registered, nothing is done.
*
- * @param instance The current injection instance to register
+ * @param dependentsKey The current injection instance to register
* dependent objects under
*/
- public void setCurrentInjectionInstance(Object instance)
+ public void startCollecting(Object dependentsKey)
{
- if (this.currentInjectionInstance.get() == null)
+ if (this.dependentsKey.get() == null)
{
- this.currentInjectionInstance.set(instance);
+ this.dependentsKey.set(dependentsKey);
}
}
@@ -135,13 +132,13 @@
* Clears the current injection instance. Can only be done by passing in the instance
* of the current instance.
*
- * @param instance The instance to free
+ * @param dependentsKey The instance to free
*/
- public void clearCurrentInjectionInstance(Object instance)
+ public void stopCollecting(Object dependentsKey)
{
- if (this.currentInjectionInstance.get() == instance)
+ if (this.dependentsKey.get() == dependentsKey)
{
- this.currentInjectionInstance.set(null);
+ this.dependentsKey.set(null);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -28,17 +28,29 @@
*/
public class DependentInstancesStore
{
+ private static DependentInstancesStore instance;
+
// A object -> List of contextual instances mapping
private Map<Object, List<ContextualInstance<?>>> dependentInstances;
/**
* Creates a new DependentInstancesStore
*/
- public DependentInstancesStore()
+ protected DependentInstancesStore()
{
dependentInstances = new ConcurrentHashMap<Object, List<ContextualInstance<?>>>();
}
+ static
+ {
+ instance = new DependentInstancesStore();
+ }
+
+ public static DependentInstancesStore instance()
+ {
+ return instance;
+ }
+
/**
* Adds a dependent instance under a given key
*
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationIdGenerator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationIdGenerator.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationIdGenerator.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -0,0 +1,22 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.conversation;
+
+public interface ConversationIdGenerator
+{
+ public abstract String nextId();
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.conversation;
+
+import javax.context.Conversation;
+
+public class ConversationImpl implements Conversation
+{
+ private String cid;
+ private boolean longRunning;
+ private long timeoutInMilliseconds;
+
+ protected ConversationImpl(String cid, long timeoutInMilliseconds)
+ {
+ this.timeoutInMilliseconds = timeoutInMilliseconds;
+ this.cid = cid;
+ }
+
+ public static ConversationImpl of(String cid, long timeoutInMilliseconds)
+ {
+ return new ConversationImpl(cid, timeoutInMilliseconds);
+ }
+
+ public void begin()
+ {
+ longRunning = true;
+ }
+
+ public void begin(String id)
+ {
+ longRunning = true;
+ cid = id;
+ }
+
+ public void end()
+ {
+ longRunning = false;
+ }
+
+ public String getId()
+ {
+ return cid;
+ }
+
+ public long getTimeout()
+ {
+ return timeoutInMilliseconds;
+ }
+
+ public boolean isLongRunning()
+ {
+ return longRunning;
+ }
+
+ public void setTimeout(long timeout)
+ {
+ this.timeoutInMilliseconds = timeout;
+ }
+
+ public void become(String cid, boolean longRunning, long timeout)
+ {
+ this.cid = cid;
+ this.longRunning = longRunning;
+ this.timeoutInMilliseconds = timeout;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ID: " + cid + ", long-running: " + longRunning + ", timeout: " + timeoutInMilliseconds;
+ }
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationManager.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationManager.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -0,0 +1,23 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.conversation;
+
+public interface ConversationManager
+{
+ public abstract void beginConversation(String cid);
+ public abstract void endConversation();
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationTerminator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationTerminator.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationTerminator.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -0,0 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.conversation;
+
+import java.util.concurrent.Future;
+
+public interface ConversationTerminator
+{
+ public abstract Future<?> scheduleForTermination(Runnable task);
+ public abstract long getTimeout();
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/DefaultConversationManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/DefaultConversationManager.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/DefaultConversationManager.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.conversation;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Future;
+
+import javax.context.Conversation;
+import javax.context.SessionScoped;
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.servlet.http.HttpSession;
+
+import org.jboss.webbeans.bootstrap.WebBeansBootstrap;
+import org.jboss.webbeans.context.ConversationContext;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.servlet.ConversationBeanMap;
+
+ at SessionScoped
+public class DefaultConversationManager implements ConversationManager, Serializable
+{
+ private static LogProvider log = Logging.getLogProvider(WebBeansBootstrap.class);
+
+ @Current
+ private ConversationIdGenerator conversationIdGenerator;
+ @Current
+ private ConversationTerminator conversationTerminator;
+ @Current
+ private Conversation currentConversation;
+
+ private Map<String, Future<?>> longRunningConversations;
+ private HttpSession session;
+
+ protected DefaultConversationManager()
+ {
+ log.trace("Created " + getClass());
+ longRunningConversations = new ConcurrentHashMap<String, Future<?>>();
+ session = null;
+ }
+
+ @Produces
+ public Conversation produceNewTransientConversation()
+ {
+ Conversation conversation = ConversationImpl.of(conversationIdGenerator.nextId(), conversationTerminator.getTimeout());
+ log.trace("Produced a new conversation: " + conversation);
+ return conversation;
+ }
+
+ public void setSession(HttpSession session)
+ {
+ log.trace("Conversation manager got session " + session.getId());
+ this.session = session;
+ }
+
+ public void beginConversation(String cid)
+ {
+ if (cid == null)
+ {
+ return;
+ }
+ if (!longRunningConversations.containsKey(cid))
+ {
+ log.info("Could not restore long-running conversation " + cid);
+ return;
+ }
+ if (!longRunningConversations.remove(cid).cancel(false))
+ {
+ log.info("Failed to cancel termination of conversation " + cid);
+ }
+ else
+ {
+ ((ConversationImpl) currentConversation).become(cid, true, conversationTerminator.getTimeout());
+ }
+ }
+
+ public void endConversation()
+ {
+ if (currentConversation.isLongRunning())
+ {
+ Runnable terminationTask = new TerminationTask(currentConversation.getId());
+ Future<?> terminationHandle = conversationTerminator.scheduleForTermination(terminationTask);
+ longRunningConversations.put(currentConversation.getId(), terminationHandle);
+ log.trace("Scheduling " + currentConversation + " for termination");
+ }
+ else
+ {
+ log.trace("Destroying transient conversation " + currentConversation);
+ ConversationContext.INSTANCE.destroy();
+ }
+ }
+
+ private class TerminationTask implements Runnable
+ {
+ private String cid;
+
+ public TerminationTask(String cid)
+ {
+ this.cid = cid;
+ }
+
+ public void run()
+ {
+ log.trace("Conversation " + cid + " timed out and was terminated");
+ ConversationContext terminationContext = new ConversationContext();
+ terminationContext.setBeanMap(new ConversationBeanMap(session, cid));
+ terminationContext.destroy();
+ longRunningConversations.remove(cid);
+ }
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/JavaSEConversationTerminator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/JavaSEConversationTerminator.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/JavaSEConversationTerminator.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.conversation;
+
+import java.io.Serializable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import javax.context.SessionScoped;
+
+ at SessionScoped
+public class JavaSEConversationTerminator implements ConversationTerminator, Serializable
+{
+ private ScheduledExecutorService terminator = Executors.newScheduledThreadPool(1);
+
+ public Future<?> scheduleForTermination(Runnable terminationTask)
+ {
+ return terminator.schedule(terminationTask, getTimeout(), TimeUnit.MILLISECONDS);
+ }
+
+ public long getTimeout()
+ {
+ return 10 * 60 * 1000;
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/NumericConversationIdGenerator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/NumericConversationIdGenerator.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/NumericConversationIdGenerator.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.conversation;
+
+import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.context.ApplicationScoped;
+
+ at ApplicationScoped
+public class NumericConversationIdGenerator implements ConversationIdGenerator, Serializable
+{
+ private AtomicInteger id;
+
+ public NumericConversationIdGenerator()
+ {
+ id = new AtomicInteger(1);
+ }
+
+ public String nextId()
+ {
+ return String.valueOf(id.getAndIncrement());
+ }
+
+}
Modified: 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 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -65,11 +65,12 @@
if (base == null && property != null)
{
// TODO Any other way than creating a dummy parent to collect the created dependent objects under?
+ // TODO temp disabled
Object dependentsCollector = new Object();
try
{
DependentContext.INSTANCE.setActive(true);
- DependentContext.INSTANCE.setCurrentInjectionInstance(dependentsCollector);
+ DependentContext.INSTANCE.startCollecting(dependentsCollector);
Object value = CurrentManager.rootManager().getInstanceByName(property.toString());
if (value != null)
{
@@ -79,7 +80,7 @@
}
finally
{
- DependentContext.INSTANCE.clearCurrentInjectionInstance(dependentsCollector);
+ DependentContext.INSTANCE.stopCollecting(dependentsCollector);
DependentContext.INSTANCE.setActive(false);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -39,10 +39,10 @@
import javax.transaction.SystemException;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.context.DependentInstancesStore;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
@@ -197,7 +197,7 @@
{
if (Dependent.class.equals(observerBean.getScopeType()) && observerBean instanceof RIBean)
{
- DependentContext.INSTANCE.setCurrentInjectionInstance(dependentsCollector);
+ DependentContext.INSTANCE.startCollecting(dependentsCollector);
}
// Get the most specialized instance of the component
instance = getInstance(observerBean);
@@ -218,8 +218,8 @@
{
if (Dependent.class.equals(observerBean.getScopeType()))
{
- ((AbstractBean<?, ?>) observerBean).getDependentInstancesStore().destroyDependentInstances(dependentsCollector);
- DependentContext.INSTANCE.clearCurrentInjectionInstance(instance);
+ DependentInstancesStore.instance().destroyDependentInstances(dependentsCollector);
+ DependentContext.INSTANCE.stopCollecting(instance);
}
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/AnnotatedInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/AnnotatedInjectionPoint.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/AnnotatedInjectionPoint.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -1,3 +1,19 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.injection;
import javax.inject.manager.InjectionPoint;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -1,3 +1,19 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.injection;
import static org.jboss.webbeans.injection.Exceptions.rethrowException;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -1,3 +1,19 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.injection;
import static org.jboss.webbeans.injection.Exceptions.rethrowException;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -1,3 +1,19 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.injection;
import java.lang.annotation.Annotation;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -244,7 +244,7 @@
*/
public boolean isProxyable()
{
- return Proxies.isClassProxyable(getType());
+ return Proxies.isTypeProxyable(getType());
}
public abstract S getDelegate();
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ConversationBeanMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ConversationBeanMap.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ConversationBeanMap.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.webbeans.servlet;
+
+import javax.servlet.http.HttpSession;
+
+import org.jboss.webbeans.context.ConversationContext;
+
+public class ConversationBeanMap extends SessionBeanMap
+{
+ private String cid;
+
+ public ConversationBeanMap(HttpSession session, String cid)
+ {
+ super(session);
+ this.cid = cid;
+ }
+
+ @Override
+ protected String getKeyPrefix()
+ {
+ return ConversationContext.class.getName() + "[" + cid + "]";
+ }
+
+}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -26,6 +26,7 @@
import org.jboss.webbeans.bootstrap.spi.EjbDiscovery;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.ApplicationContext;
+import org.jboss.webbeans.context.ConversationContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.context.RequestContext;
import org.jboss.webbeans.context.SessionContext;
@@ -73,6 +74,7 @@
getManager().addContext(RequestContext.INSTANCE);
getManager().addContext(SessionContext.INSTANCE);
getManager().addContext(ApplicationContext.INSTANCE);
+ getManager().addContext(ConversationContext.INSTANCE);
ApplicationContext.INSTANCE.setBeanMap(new ApplicationBeanMap(servletContext));
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -17,14 +17,20 @@
package org.jboss.webbeans.servlet;
+import javax.context.Conversation;
+import javax.inject.Current;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.context.ApplicationContext;
+import org.jboss.webbeans.context.ConversationContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.context.RequestContext;
import org.jboss.webbeans.context.SessionContext;
+import org.jboss.webbeans.conversation.ConversationManager;
+import org.jboss.webbeans.conversation.DefaultConversationManager;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -37,7 +43,7 @@
public class ServletLifecycle
{
private static LogProvider log = Logging.getLogProvider(ServletLifecycle.class);
-
+
/**
* Starts the application
*
@@ -49,16 +55,16 @@
{
new ServletBootstrap(servletContext).boot();
}
-
+
/**
* Ends the application
*/
- public static void endApplication()
+ public static void endApplication()
{
ApplicationContext.INSTANCE.destroy();
ApplicationContext.INSTANCE.setBeanMap(null);
}
-
+
/**
* Begins a session
*
@@ -67,42 +73,63 @@
public static void beginSession(HttpSession session)
{
}
-
+
/**
* Ends a session
*
* @param session The HTTP session
*/
- public static void endSession(HttpSession session)
+ public static void endSession(HttpSession session)
{
SessionContext.INSTANCE.setBeanMap(new SessionBeanMap(session));
SessionContext.INSTANCE.destroy();
SessionContext.INSTANCE.setBeanMap(null);
- }
-
+ }
+
/**
- * Begins a HTTP request
+ * Begins a HTTP request
*
* Sets the session into the session context
*
* @param request The request
*/
- public static void beginRequest(HttpServletRequest request)
+ public static void beginRequest(HttpServletRequest request)
{
SessionContext.INSTANCE.setBeanMap(new SessionBeanMap(request.getSession()));
+ beginConversation(request);
DependentContext.INSTANCE.setActive(true);
}
-
+
+ private static void beginConversation(HttpServletRequest request)
+ {
+ ConversationManager conversationManager = CurrentManager.rootManager().getInstanceByType(ConversationManager.class);
+ if (conversationManager instanceof DefaultConversationManager)
+ {
+ ((DefaultConversationManager) conversationManager).setSession(request.getSession());
+ }
+ conversationManager.beginConversation(request.getParameter("cid"));
+ Conversation conversation = CurrentManager.rootManager().getInstanceByType(Conversation.class);
+ ConversationContext.INSTANCE.setBeanMap(new ConversationBeanMap(request.getSession(), conversation.getId()));
+ }
+
/**
* Ends a HTTP request
*
* @param request The request
*/
- public static void endRequest(HttpServletRequest request)
+ public static void endRequest(HttpServletRequest request)
{
DependentContext.INSTANCE.setActive(false);
RequestContext.INSTANCE.destroy();
SessionContext.INSTANCE.setBeanMap(null);
+ endConversation();
+ ConversationContext.INSTANCE.setBeanMap(null);
}
-
+
+ private static void endConversation()
+ {
+ ConversationManager conversationManager = CurrentManager.rootManager().getInstanceByType(ConversationManager.class);
+ conversationManager.endConversation();
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -14,14 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.jboss.webbeans.servlet;
import java.util.Enumeration;
import javax.servlet.http.HttpSession;
-import org.jboss.webbeans.context.ApplicationContext;
+import org.jboss.webbeans.context.SessionContext;
import org.jboss.webbeans.context.beanmap.AbstractBeanMap;
/**
@@ -53,7 +52,7 @@
@Override
protected String getKeyPrefix()
{
- return ApplicationContext.class.getName();
+ return SessionContext.class.getName();
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -84,8 +84,7 @@
{
continue;
}
- boolean isClass = !((Class<?>) apiType).isInterface();
- if (isClass && !Proxies.isClassProxyable((Class<?>) apiType))
+ if (!Proxies.isTypeProxyable(apiType))
{
return false;
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Proxies.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Proxies.java 2009-02-01 22:32:29 UTC (rev 1377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Proxies.java 2009-02-02 07:55:34 UTC (rev 1378)
@@ -23,14 +23,12 @@
import javassist.util.proxy.ProxyFactory;
-
-
/**
* Utilties for working with Javassist proxies
*
* @author Nicklas Karlsson
* @author Pete Muir
- *
+ *
*/
public class Proxies
{
@@ -139,15 +137,20 @@
}
/**
- * Inidicates if a class is proxyable
+ * Indicates if a class is proxyable
*
- * @param clazz The class to test
+ * @param type The class to test
* @return True if proxyable, false otherwise
*/
- public static boolean isClassProxyable(Class<?> clazz)
+ public static boolean isTypeProxyable(Type type)
{
- if (Reflections.getConstructor(clazz) == null)
+ Class<?> clazz = (Class<?>) type;
+ if (clazz.isInterface())
{
+ return true;
+ }
+ else if (Reflections.getConstructor(clazz) == null)
+ {
return false;
}
else if (Reflections.isTypeOrAnyMethodFinal(clazz))
More information about the weld-commits
mailing list