Weld SVN: r5727 - in core/trunk: impl/src/main/java/org/jboss/weld/conversation and 5 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-04 13:30:11 -0500 (Thu, 04 Feb 2010)
New Revision: 5727
Added:
core/trunk/impl/src/main/java/org/jboss/weld/context/BusyConversationException.java
core/trunk/impl/src/main/java/org/jboss/weld/context/NonexistentConversationException.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/
core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ClientConversationContextTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/Cloud.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ConversationTestPhaseListener.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/.faces-config.xml.jsfdia
core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/cloud.jsf
core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/faces-config.xml
core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/web.xml
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java
core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java
Log:
WELD-387
Added: core/trunk/impl/src/main/java/org/jboss/weld/context/BusyConversationException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/BusyConversationException.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/BusyConversationException.java 2010-02-04 18:30:11 UTC (rev 5727)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc., 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.weld.context;
+
+import org.jboss.weld.exceptions.WeldExceptionMessage;
+
+/**
+ * A localized message version of the
+ * {@link javax.enterprise.context.NonexistentConversationException}.
+ *
+ * @author David Allen
+ */
+public class BusyConversationException extends javax.enterprise.context.BusyConversationException
+{
+
+ private static final long serialVersionUID = 2L;
+
+ private WeldExceptionMessage message;
+
+ public BusyConversationException(Throwable throwable)
+ {
+ super(throwable.getLocalizedMessage(), throwable);
+ }
+
+ public <E extends Enum<?>> BusyConversationException(E key, Object... args)
+ {
+ message = new WeldExceptionMessage(key, args);
+ }
+
+ @Override
+ public String getLocalizedMessage()
+ {
+ return getMessage();
+ }
+
+ @Override
+ public String getMessage()
+ {
+ return message.getAsString();
+ }
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/context/BusyConversationException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/impl/src/main/java/org/jboss/weld/context/NonexistentConversationException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/NonexistentConversationException.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/NonexistentConversationException.java 2010-02-04 18:30:11 UTC (rev 5727)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc., 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.weld.context;
+
+import org.jboss.weld.exceptions.WeldExceptionMessage;
+
+/**
+ * A localized message version of the
+ * {@link javax.enterprise.context.NonexistentConversationException}.
+ *
+ * @author David Allen
+ */
+public class NonexistentConversationException extends javax.enterprise.context.NonexistentConversationException
+{
+
+ private static final long serialVersionUID = 2L;
+
+ private WeldExceptionMessage message;
+
+ public NonexistentConversationException(Throwable throwable)
+ {
+ super(throwable.getLocalizedMessage(), throwable);
+ }
+
+ public <E extends Enum<?>> NonexistentConversationException(E key, Object... args)
+ {
+ message = new WeldExceptionMessage(key, args);
+ }
+
+ @Override
+ public String getLocalizedMessage()
+ {
+ return getMessage();
+ }
+
+ @Override
+ public String getMessage()
+ {
+ return message.getAsString();
+ }
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/context/NonexistentConversationException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java 2010-02-04 16:58:35 UTC (rev 5726)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java 2010-02-04 18:30:11 UTC (rev 5727)
@@ -49,8 +49,10 @@
import javax.inject.Inject;
import org.jboss.weld.Container;
+import org.jboss.weld.context.BusyConversationException;
import org.jboss.weld.context.ContextLifecycle;
import org.jboss.weld.context.ConversationContext;
+import org.jboss.weld.context.NonexistentConversationException;
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.resources.spi.ScheduledExecutorServiceFactory;
import org.slf4j.cal10n.LocLogger;
@@ -102,8 +104,7 @@
// We got an incoming conversation ID but it was not in the map of
// known ones, nothing to do. Log and return to continue with a
// transient conversation
- log.warn(UNABLE_TO_RESTORE_CONVERSATION, cid, "id not known");
- return;
+ throw new NonexistentConversationException(UNABLE_TO_RESTORE_CONVERSATION, cid, "id not known");
}
ConversationEntry resumedConversationEntry = longRunningConversations.get(cid);
// Try to get a lock to the requested conversation, log and return to
@@ -112,14 +113,13 @@
{
if (!resumedConversationEntry.lock(concurrentAccessTimeout))
{
- return;
+ throw new BusyConversationException(CONVERSATION_LOCK_UNAVAILABLE);
}
}
catch (InterruptedException e)
{
- log.debug(CONVERSATION_LOCK_UNAVAILABLE);
Thread.currentThread().interrupt();
- return;
+ throw new BusyConversationException(CONVERSATION_LOCK_UNAVAILABLE);
}
// If we can't cancel the termination, release the lock, return and
// continue
@@ -127,6 +127,7 @@
if (!resumedConversationEntry.cancelTermination())
{
resumedConversationEntry.unlock();
+ throw new BusyConversationException(CONVERSATION_LOCK_UNAVAILABLE);
}
else
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java 2010-02-04 16:58:35 UTC (rev 5726)
+++ core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java 2010-02-04 18:30:11 UTC (rev 5727)
@@ -163,15 +163,21 @@
private void initiateSessionAndConversation(FacesContext facesContext)
{
ServletContext servletContext = getServletContext(facesContext);
+ AbstractConversationManager conversationManager = (AbstractConversationManager) conversationManager(servletContext);
HttpSession session = getHttpSession(facesContext);
httpSessionManager(servletContext).setSession(session);
- AbstractConversationManager conversationManager = (AbstractConversationManager) conversationManager(servletContext);
- conversationManager.beginOrRestoreConversation(getConversationId(facesContext));
- String cid = conversation(servletContext).getUnderlyingId();
-
- ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
- conversationContext.setBeanStore(conversationManager.getBeanStore(cid));
- conversationContext.setActive(true);
+ try
+ {
+ conversationManager.beginOrRestoreConversation(getConversationId(facesContext));
+ }
+ finally
+ {
+ String cid = conversation(servletContext).getUnderlyingId();
+
+ ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
+ conversationContext.setBeanStore(conversationManager.getBeanStore(cid));
+ conversationContext.setActive(true);
+ }
}
/**
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ClientConversationContextTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ClientConversationContextTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ClientConversationContextTest.java 2010-02-04 18:30:11 UTC (rev 5727)
@@ -0,0 +1,77 @@
+package org.jboss.weld.tests.contexts.conversation;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.
+ */
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.testharness.impl.packaging.war.WebXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.WebClient;
+
+/**
+ * @author Nicklas Karlsson
+ * @author Dan Allen
+ */
+@Artifact(addCurrentPackage = false)
+@Classes( { ConversationTestPhaseListener.class, Cloud.class })
+@IntegrationTest(runLocally = true)
+@Resources( {
+ @Resource(destination = "cloud.jspx", source = "cloud.jsf"),
+ @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
+})
+@WebXml("web.xml")
+public class ClientConversationContextTest extends AbstractWeldTest
+{
+
+ public static final String CID_REQUEST_PARAMETER_NAME = "cid";
+
+ public static final String CID_HEADER_NAME = "org.jboss.jsr299.tck.cid";
+
+ public static final String LONG_RUNNING_HEADER_NAME = "org.jboss.jsr299.tck.longRunning";
+
+ @Test(groups = { "contexts" })
+ public void testConversationPropagationToNonExistentConversationLeadsException() throws Exception
+ {
+ WebClient client = new WebClient();
+ client.setThrowExceptionOnFailingStatusCode(false);
+ Page page = client.getPage(getPath("/cloud.jsf", "org.jboss.jsr299"));
+ assert page.getWebResponse().getStatusCode() == 500;
+ }
+
+ protected Boolean isLongRunning(Page page)
+ {
+ return Boolean.valueOf(page.getWebResponse().getResponseHeaderValue(LONG_RUNNING_HEADER_NAME));
+ }
+
+ protected String getPath(String viewId, String cid)
+ {
+ return getContextPath() + viewId + "?" + CID_REQUEST_PARAMETER_NAME + "=" + cid;
+ }
+
+ protected String getCid(Page page)
+ {
+ return page.getWebResponse().getResponseHeaderValue(CID_HEADER_NAME);
+ }
+
+}
\ No newline at end of file
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ClientConversationContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/Cloud.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/Cloud.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/Cloud.java 2010-02-04 18:30:11 UTC (rev 5727)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.weld.tests.contexts.conversation;
+
+import java.io.Serializable;
+
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Default;
+import javax.inject.Named;
+
+@Named @Default
+@ConversationScoped
+public class Cloud implements Serializable
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5765109971012677278L;
+
+ public static final String NAME = Cloud.class.getName() + ".Pete";
+
+ public static final String RAINED_HEADER_NAME = Cloud.class.getName() + ".rained";
+
+ private static boolean destroyed = false;
+
+ private boolean rained;
+
+ @PreDestroy
+ public void destroy()
+ {
+ destroyed = true;
+ }
+
+ public static boolean isDestroyed()
+ {
+ return destroyed;
+ }
+
+ public static void setDestroyed(boolean destroyed)
+ {
+ Cloud.destroyed = destroyed;
+ }
+
+ public String getName()
+ {
+ return NAME;
+ }
+
+ public void rain()
+ {
+ rained = true;
+ System.out.println("rain!");
+ }
+
+ public boolean isRained()
+ {
+ return rained;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/Cloud.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ConversationTestPhaseListener.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ConversationTestPhaseListener.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ConversationTestPhaseListener.java 2010-02-04 18:30:11 UTC (rev 5727)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.weld.tests.contexts.conversation;
+
+import javax.enterprise.context.ContextNotActiveException;
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.weld.jsf.JsfHelper;
+import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.servlet.ServletHelper;
+import org.jboss.weld.test.Utils;
+
+public class ConversationTestPhaseListener implements PhaseListener
+{
+
+ public static final String CID_REQUEST_PARAMETER_NAME = "cid";
+
+ public static final String CID_HEADER_NAME = "org.jboss.jsr299.tck.cid";
+
+ public static final String LONG_RUNNING_HEADER_NAME = "org.jboss.jsr299.tck.longRunning";
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1197355854770726526L;
+
+ public static final String ACTIVE_BEFORE_APPLY_REQUEST_VALUES_HEADER_NAME = "org.jboss.jsr299.tck.activeBeforeApplyRequestValues";
+
+ private boolean activeBeforeApplyRequestValues;
+
+ public void afterPhase(PhaseEvent event)
+ {
+ }
+
+ public void beforePhase(PhaseEvent event)
+ {
+ BeanManagerImpl beanManager = ServletHelper.getModuleBeanManager(JsfHelper.getServletContext(event.getFacesContext()));
+ if (event.getPhaseId().equals(PhaseId.APPLY_REQUEST_VALUES))
+ {
+ try
+ {
+ beanManager.getContext(ConversationScoped.class);
+ activeBeforeApplyRequestValues = true;
+ }
+ catch (ContextNotActiveException e)
+ {
+ activeBeforeApplyRequestValues = false;
+ }
+ }
+ if (event.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
+ {
+ Conversation conversation = Utils.getReference(beanManager, Conversation.class);
+ HttpServletResponse response = (HttpServletResponse) event.getFacesContext().getExternalContext().getResponse();
+ response.addHeader(CID_HEADER_NAME, conversation.getId() == null ? " null" : conversation.getId());
+ response.addHeader(LONG_RUNNING_HEADER_NAME, String.valueOf(!conversation.isTransient()));
+ response.addHeader(Cloud.RAINED_HEADER_NAME, new Boolean(Utils.getReference(beanManager, Cloud.class).isRained()).toString());
+ response.addHeader(ACTIVE_BEFORE_APPLY_REQUEST_VALUES_HEADER_NAME, new Boolean(activeBeforeApplyRequestValues).toString());
+ }
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.ANY_PHASE;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ConversationTestPhaseListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/.faces-config.xml.jsfdia
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/.faces-config.xml.jsfdia (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/.faces-config.xml.jsfdia 2010-02-04 18:30:11 UTC (rev 5727)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PROCESS model-entity="JSFProcess"/>
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/cloud.jsf
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/cloud.jsf (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/cloud.jsf 2010-02-04 18:30:11 UTC (rev 5727)
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ xmlns="http://www.w3.org/1999/xhtml"
+ version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+ doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
+ <jsp:directive.page contentType="text/html"/>
+ <html>
+ <head>
+ </head>
+ <body>
+ <f:view>
+ <h:outputText value="#{cloud.name}" id="cloudName" />
+ </f:view>
+ </body>
+ </html>
+</jsp:root>
+
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/cloud.jsf
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/faces-config.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/faces-config.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/faces-config.xml 2010-02-04 18:30:11 UTC (rev 5727)
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<faces-config version="1.2"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+
+ <lifecycle>
+ <phase-listener>org.jboss.weld.tests.contexts.conversation.ConversationTestPhaseListener</phase-listener>
+ </lifecycle>
+
+</faces-config>
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/web.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/web.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/web.xml 2010-02-04 18:30:11 UTC (rev 5727)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <display-name>JSR-299 TCK</display-name>
+
+ <!-- JSF -->
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.jspx</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>org.jboss.testharness.impl.runner.servlet.HarnessServletListener</listener-class>
+ </listener>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+
+</web-app>
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 1 month
Weld SVN: r5726 - core/trunk/impl/src/main/java/org/jboss/weld/servlet.
by weld-commits@lists.jboss.org
Author: dallen6
Date: 2010-02-04 11:58:35 -0500 (Thu, 04 Feb 2010)
New Revision: 5726
Removed:
core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpRequestSessionBeanStore.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java
core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java
Log:
WELD-403 Cleanup
Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java 2010-02-04 16:20:38 UTC (rev 5725)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java 2010-02-04 16:58:35 UTC (rev 5726)
@@ -34,6 +34,10 @@
public ConversationBeanStore(HttpSession session, boolean sessionInvalidated, String cid)
{
this.namingScheme = new NamingScheme(ConversationContext.class.getName() + "[" + cid + "]", "#");
+ if (sessionInvalidated)
+ {
+ invalidate();
+ }
attachToSession(session);
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java 2010-02-04 16:20:38 UTC (rev 5725)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java 2010-02-04 16:58:35 UTC (rev 5726)
@@ -37,7 +37,7 @@
* A BeanStore that maintains Contextuals in a hash map and writes them through
* to a HttpSession. When this BeanStore is attached to a session, it will load
* all the existing contextuals from the session within the naming scheme for
- * this BeanStore. All read operations are directly against the local map.
+ * this BeanStore. All read operations are directly against the local map.
*
* @author David Allen
*/
@@ -118,11 +118,21 @@
protected void loadFromSession(HttpSession newSession)
{
log.trace("Loading bean store " + this + " map from session " + newSession.getId());
- for (String id : this.getFilteredAttributeNames())
+ try
{
- delegateBeanStore.put(id, (ContextualInstance<?>) super.getAttribute(id));
- log.trace("Added contextual " + super.getAttribute(id) + " under ID " + id);
+ for (String id : this.getFilteredAttributeNames())
+ {
+ delegateBeanStore.put(id, (ContextualInstance<?>) super.getAttribute(id));
+ log.trace("Added contextual " + super.getAttribute(id) + " under ID " + id);
+ }
}
+ catch (IllegalStateException e)
+ {
+ // There's not a lot to do here if the session is invalidated while
+ // loading this map. These beans will not be destroyed since the
+ // references are lost.
+ delegateBeanStore.clear();
+ }
}
@Override
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpRequestSessionBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpRequestSessionBeanStore.java 2010-02-04 16:20:38 UTC (rev 5725)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpRequestSessionBeanStore.java 2010-02-04 16:58:35 UTC (rev 5726)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat, Inc., 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.weld.servlet;
-
-import java.util.Collections;
-import java.util.Enumeration;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.jboss.weld.context.SessionContext;
-import org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore;
-import org.jboss.weld.context.beanstore.NamingScheme;
-
-/**
- * Abstracts the servlet API specific session context
- * as a BeanStore. Actual sessions are created lazily.
- *
- * @author Gavin King
- */
-public class HttpRequestSessionBeanStore extends AbstractAttributeBackedBeanStore
-{
- // The HTTP session context to use as backing map
- private final HttpServletRequest request;
- private static final NamingScheme NAMING_SCHEME = new NamingScheme(SessionContext.class.getName(), "#");
-
- /**
- * Constructor
- *
- * @param session The HTTP session
- */
- public HttpRequestSessionBeanStore(HttpServletRequest request)
- {
- super();
- this.request = request;
- }
-
- /**
- * @see org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore#getAttribute()
- */
- @Override
- protected Object getAttribute(String key)
- {
- HttpSession session = request.getSession(false);
- return session==null ? null : session.getAttribute( key );
- }
-
- /**
- * @see org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore#getAttributeNames()
- */
- @SuppressWarnings("unchecked")
- @Override
- protected Enumeration<String> getAttributeNames()
- {
- HttpSession session = request.getSession(false);
- if (session != null)
- {
- return session.getAttributeNames();
- }
- else
- {
- return Collections.enumeration(Collections.EMPTY_LIST);
- }
- }
-
- /**
- * @see org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore#removeAttributes()
- */
- @Override
- protected void removeAttribute(String key)
- {
- HttpSession session = request.getSession(false);
- if (session != null)
- {
- session.removeAttribute( key );
- }
- }
-
- /**
- * @see org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore#setAttribute()
- */
- @Override
- protected void setAttribute(String key, Object instance)
- {
- HttpSession session = request.getSession(true);
- session.setAttribute(key, instance);
- }
-
- @Override
- protected NamingScheme getNamingScheme()
- {
- return NAMING_SCHEME;
- }
-
-}
\ No newline at end of file
15 years, 1 month
Weld SVN: r5725 - cdi-tck/branches/1.0/impl/src/main/resources.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-04 11:20:38 -0500 (Thu, 04 Feb 2010)
New Revision: 5725
Modified:
cdi-tck/branches/1.0/impl/src/main/resources/tck-tests.xml
Log:
Update excludes
Modified: cdi-tck/branches/1.0/impl/src/main/resources/tck-tests.xml
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/resources/tck-tests.xml 2010-02-04 16:20:09 UTC (rev 5724)
+++ cdi-tck/branches/1.0/impl/src/main/resources/tck-tests.xml 2010-02-04 16:20:38 UTC (rev 5725)
@@ -15,44 +15,59 @@
</packages>
<classes>
- <!-- Issues in Weld (the RI) -->
+ <!-- Issues in the TCK -->
- <!-- WELD-393 -->
- <class name="org.jboss.jsr299.tck.interceptors.tests.definition.DefinitionTest">
+ <!-- CDITCK-109 -->
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationBeginTest">
<methods>
- <exclude name="testInterceptorMethodDefinedOnTargetClass" />
+ <exclude name="testBeginAlreadyLongRunningConversationThrowsException" />
+ <exclude name="testConversationBeginMakesConversationLongRunning" />
</methods>
</class>
-
- <!-- WELD-390 -->
- <class name="org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.order.InvocationOrderTest">
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationContextTest">
<methods>
- <exclude name="testInvocationOrder" />
+ <exclude name="testDefaultConversationIsTransient" />
+ <exclude name="testTransientConversationHasNullId" />
</methods>
</class>
- <!-- WELD-269 -->
- <class name="org.jboss.jsr299.tck.tests.decorators.custom.CustomDecoratorTest">
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationEndTest">
<methods>
- <exclude name="testCustomImplementationOfDecoratorInterface" />
+ <exclude name="testConversationEndMakesConversationTransient" />
+ <exclude name="testEndTransientConversationThrowsException" />
</methods>
</class>
- <!-- WELD-272 -->
- <class name="org.jboss.jsr299.tck.tests.decorators.definition.broken.finalBeanClass.FinalBeanClassTest">
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationIdSetByApplicationTest">
<methods>
- <exclude name="testAppliesToFinalManagedBeanClass" />
+ <exclude name="testConversationIdMayBeSetByApplication" />
</methods>
</class>
- <class name="org.jboss.jsr299.tck.tests.decorators.definition.broken.finalBeanMethod.FinalBeanMethodTest">
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationIdSetByContainerTest">
<methods>
- <exclude name="testAppliesToFinalMethodOnManagedBeanClass" />
+ <exclude name="testConversationBeginMakesConversationLongRunning" />
</methods>
</class>
- <!-- WELD-377 -->
- <class name="org.jboss.jsr299.tck.tests.decorators.invocation.EJBDecoratorInvocationTest">
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationTimeoutTest">
<methods>
- <exclude name="testEJBDecoratorInvocation" />
+ <exclude name="testConversationHasDefaultTimeout" />
+ <exclude name="testSetConversationTimeoutOverride" />
</methods>
</class>
+
+ <!-- Issues in Weld (the RI) -->
+
+ <!-- WELD-269 -->
+ <class name="org.jboss.jsr299.tck.tests.decorators.custom.CustomDecoratorTest">
+ <methods>
+ <exclude name="testCustomImplementationOfDecoratorInterface" />
+ </methods>
+ </class>
+
+ <!-- WELD-401 -->
+ <class name="org.jboss.jsr299.tck.tests.event.broken.observer.notBusinessMethod.EJBObserverMethodNotBusinessMethodTest">
+ <methods>
+ <exclude name="testObserverMethodOnEnterpriseBeanNotBusinessMethodOrStaticFails" />
+ </methods>
+ </class>
</classes>
</test>
15 years, 1 month
Weld SVN: r5724 - in core/trunk: jboss-tck-runner/src/test/resources and 3 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-04 11:20:09 -0500 (Thu, 04 Feb 2010)
New Revision: 5724
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java
core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml
core/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java
core/trunk/tests/src/main/java/org/jboss/weld/test/harness/AbstractStandaloneContainersImpl.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ContextTest.java
Log:
WELD-348
Modified: core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java 2010-02-04 13:14:08 UTC (rev 5723)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java 2010-02-04 16:20:09 UTC (rev 5724)
@@ -18,6 +18,7 @@
import static org.jboss.weld.logging.Category.CONVERSATION;
import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import static org.jboss.weld.logging.messages.BeanManagerMessage.CONTEXT_NOT_ACTIVE;
import static org.jboss.weld.logging.messages.ConversationMessage.BEGIN_CALLED_ON_LONG_RUNNING_CONVERSATION;
import static org.jboss.weld.logging.messages.ConversationMessage.DEMOTED_LRC;
import static org.jboss.weld.logging.messages.ConversationMessage.END_CALLED_ON_TRANSIENT_CONVERSATION;
@@ -32,6 +33,9 @@
import javax.inject.Inject;
import javax.inject.Named;
+import org.jboss.weld.Container;
+import org.jboss.weld.context.ContextLifecycle;
+import org.jboss.weld.context.ContextNotActiveException;
import org.jboss.weld.exceptions.ForbiddenStateException;
import org.slf4j.cal10n.LocLogger;
@@ -66,8 +70,14 @@
/**
* Creates a new conversation
*/
- public ConversationImpl()
+ public ConversationImpl() {}
+
+ protected void checkConversationActive()
{
+ if (!Container.instance().services().get(ContextLifecycle.class).getConversationContext().isActive())
+ {
+ throw new ContextNotActiveException(CONTEXT_NOT_ACTIVE, "@ConversationScoped");
+ }
}
/**
@@ -98,6 +108,7 @@
public void begin()
{
+ checkConversationActive();
if (!isTransient())
{
throw new ForbiddenStateException(BEGIN_CALLED_ON_LONG_RUNNING_CONVERSATION);
@@ -108,6 +119,7 @@
public void begin(String id)
{
+ checkConversationActive();
// Store away the (first) change to the conversation ID. If the original
// conversation was long-running,
// we might have to place it back for termination once the request is
@@ -122,6 +134,7 @@
public void end()
{
+ checkConversationActive();
if (isTransient())
{
throw new ForbiddenStateException(END_CALLED_ON_TRANSIENT_CONVERSATION);
@@ -132,6 +145,7 @@
public String getId()
{
+ checkConversationActive();
if (!isTransient())
{
return id;
@@ -155,11 +169,13 @@
public long getTimeout()
{
+ checkConversationActive();
return timeout;
}
public void setTimeout(long timeout)
{
+ checkConversationActive();
this.timeout = timeout;
}
@@ -172,9 +188,9 @@
public void switchTo(ConversationImpl conversation)
{
log.debug(SWITCHED_CONVERSATION, this, conversation);
- id = conversation.getUnderlyingId();
- this._transient = conversation.isTransient();
- timeout = conversation.getTimeout();
+ id = conversation.id;
+ this._transient = conversation._transient;
+ timeout = conversation.timeout;
}
@Override
@@ -215,6 +231,9 @@
public boolean isTransient()
{
+ checkConversationActive();
return _transient;
}
+
+
}
Modified: core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml
===================================================================
--- core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml 2010-02-04 13:14:08 UTC (rev 5723)
+++ core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml 2010-02-04 16:20:09 UTC (rev 5724)
@@ -57,6 +57,42 @@
</methods>
</class>
+ <!-- CDITCK-109 -->
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationBeginTest">
+ <methods>
+ <exclude name="testBeginAlreadyLongRunningConversationThrowsException" />
+ <exclude name="testConversationBeginMakesConversationLongRunning" />
+ </methods>
+ </class>
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationContextTest">
+ <methods>
+ <exclude name="testDefaultConversationIsTransient" />
+ <exclude name="testTransientConversationHasNullId" />
+ </methods>
+ </class>
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationEndTest">
+ <methods>
+ <exclude name="testConversationEndMakesConversationTransient" />
+ <exclude name="testEndTransientConversationThrowsException" />
+ </methods>
+ </class>
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationIdSetByApplicationTest">
+ <methods>
+ <exclude name="testConversationIdMayBeSetByApplication" />
+ </methods>
+ </class>
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationIdSetByContainerTest">
+ <methods>
+ <exclude name="testConversationBeginMakesConversationLongRunning" />
+ </methods>
+ </class>
+ <class name="org.jboss.jsr299.tck.tests.context.conversation.ConversationTimeoutTest">
+ <methods>
+ <exclude name="testConversationHasDefaultTimeout" />
+ <exclude name="testSetConversationTimeoutOverride" />
+ </methods>
+ </class>
+
<!-- Issues in Weld (the RI) -->
<!-- WELD-390 fixed, but TCK test is broken in 1.0.1-CR1 -->
Modified: core/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java
===================================================================
--- core/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java 2010-02-04 13:14:08 UTC (rev 5723)
+++ core/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java 2010-02-04 16:20:09 UTC (rev 5724)
@@ -21,6 +21,7 @@
import java.util.Collection;
import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.context.ConversationContext;
import org.jboss.weld.manager.BeanManagerImpl;
/**
@@ -129,6 +130,10 @@
{
getLifecycle().beginSession();
}
+ if (!getLifecycle().isConversationActive())
+ {
+ ((ConversationContext) getLifecycle().getConversationContext()).setActive(true);
+ }
if (!getLifecycle().isRequestActive())
{
getLifecycle().beginRequest();
@@ -146,6 +151,10 @@
{
getLifecycle().endRequest();
}
+ if (getLifecycle().isConversationActive())
+ {
+ ((ConversationContext) getLifecycle().getConversationContext()).setActive(false);
+ }
if (getLifecycle().isSessionActive())
{
getLifecycle().endSession();
Modified: core/trunk/tests/src/main/java/org/jboss/weld/test/harness/AbstractStandaloneContainersImpl.java
===================================================================
--- core/trunk/tests/src/main/java/org/jboss/weld/test/harness/AbstractStandaloneContainersImpl.java 2010-02-04 13:14:08 UTC (rev 5723)
+++ core/trunk/tests/src/main/java/org/jboss/weld/test/harness/AbstractStandaloneContainersImpl.java 2010-02-04 16:20:09 UTC (rev 5724)
@@ -44,8 +44,7 @@
this.deploymentException = new DeploymentException("Error deploying beans", e);
return false;
}
- testContainer.getLifecycle().beginSession();
- testContainer.getLifecycle().beginRequest();
+ testContainer.ensureRequestActive();
return true;
}
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ContextTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ContextTest.java 2010-02-04 13:14:08 UTC (rev 5723)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ContextTest.java 2010-02-04 16:20:09 UTC (rev 5724)
@@ -16,21 +16,132 @@
*/
package org.jboss.weld.tests.contexts;
+import javax.enterprise.context.ContextNotActiveException;
+import javax.enterprise.context.Conversation;
+
import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.weld.Container;
+import org.jboss.weld.context.ContextLifecycle;
import org.jboss.weld.test.AbstractWeldTest;
import org.testng.annotations.Test;
@Artifact
-@IntegrationTest
public class ContextTest extends AbstractWeldTest
{
- // WBRI-155
- @Test(description="WBRI155", groups="stub")
- public void testSessionContextActiveForMultipleSimultaneousThreads()
+
+ @Test(description = "WELD-348")
+ public void testCallToConversationWithContextNotActive()
{
- // TODO impl
- assert false;
+ boolean alreadyActive = false;
+ try
+ {
+ alreadyActive = Container.instance().services().get(ContextLifecycle.class).isConversationActive();
+ if (alreadyActive)
+ {
+ Container.instance().services().get(ContextLifecycle.class).getConversationContext().setActive(false);
+ }
+ try
+ {
+ getReference(Conversation.class).getId();
+ assert false;
+ }
+ catch (ContextNotActiveException e)
+ {
+ // Expected
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ try
+ {
+ getReference(Conversation.class).getTimeout();
+ assert false;
+ }
+ catch (ContextNotActiveException e)
+ {
+ // Expected
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ try
+ {
+ getReference(Conversation.class).begin();
+ assert false;
+ }
+ catch (ContextNotActiveException e)
+ {
+ // Expected
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ try
+ {
+ getReference(Conversation.class).begin("foo");
+ assert false;
+ }
+ catch (ContextNotActiveException e)
+ {
+ // Expected
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ try
+ {
+ getReference(Conversation.class).end();
+ assert false;
+ }
+ catch (ContextNotActiveException e)
+ {
+ // Expected
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ try
+ {
+ getReference(Conversation.class).isTransient();
+ assert false;
+ }
+ catch (ContextNotActiveException e)
+ {
+ // Expected
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ try
+ {
+ getReference(Conversation.class).setTimeout(0);
+ assert false;
+ }
+ catch (ContextNotActiveException e)
+ {
+ // Expected
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ }
+ finally
+ {
+ if (alreadyActive)
+ {
+ Container.instance().services().get(ContextLifecycle.class).getConversationContext().setActive(true);
+ }
+ }
+
}
+
+
}
15 years, 1 month
Weld SVN: r5723 - cdi-tck/trunk/impl/src/main/resources.
by weld-commits@lists.jboss.org
Author: jharting
Date: 2010-02-04 08:14:08 -0500 (Thu, 04 Feb 2010)
New Revision: 5723
Modified:
cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
Log:
Match tests with assertions.
Modified: cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
===================================================================
--- cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2010-02-04 12:02:24 UTC (rev 5722)
+++ cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2010-02-04 13:14:08 UTC (rev 5723)
@@ -2471,7 +2471,7 @@
<text>The container must guarantee that when any valid injected reference to a bean of normal scope is invoked, the invocation is always processed by the current instance of the injected bean.</text>
</assertion>
- <assertion id="e">
+ <assertion id="e" testable="false">
<text>Client proxies may be shared between multiple injection points.</text>
</assertion>
</section>
@@ -2574,9 +2574,21 @@
</section>
<section id="5.5.1" title="Injection using the bean constructor">
- <assertion id="a">
- <text>When the container instantiates a managed bean or session bean with a constructor annotated |@Inject|, the container calls this constructor, passing an injectable reference to each parameter. If there is no constructor annotated |@Inject|, the container calls the constructor with no parameters.</text>
+ <group>
+ <text>When the container instantiates a managed bean or session bean with a constructor annotated |@Inject|, the container calls this constructor, passing an injectable reference to each parameter. If there is no constructor annotated |@Inject|, the container calls the constructor with no parameters.</text>
+ <assertion id="aa">
+ <text>Test managed bean with a constructor annotated |@Inject|.</text>
</assertion>
+ <assertion id="ab">
+ <text>Test session bean with a constructor annotated |@Inject|.</text>
+ </assertion>
+ <assertion id="ba">
+ <text>Test constructor with no parameters is used for a managed bean</text>
+ </assertion>
+ <assertion id="bb">
+ <text>Test constructor with no parameters is used for a session bean</text>
+ </assertion>
+ </group>
</section>
<section id="5.5.2" title="Injection of fields and initializer methods">
15 years, 1 month
Weld SVN: r5722 - servlet/trunk.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-04 07:02:24 -0500 (Thu, 04 Feb 2010)
New Revision: 5722
Modified:
servlet/trunk/pom.xml
Log:
newer parent
Modified: servlet/trunk/pom.xml
===================================================================
--- servlet/trunk/pom.xml 2010-02-04 08:19:11 UTC (rev 5721)
+++ servlet/trunk/pom.xml 2010-02-04 12:02:24 UTC (rev 5722)
@@ -8,7 +8,7 @@
<parent>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-parent</artifactId>
- <version>7</version>
+ <version>8</version>
</parent>
<name>Weld Servlet support build aggregator</name>
15 years, 1 month
Weld SVN: r5721 - core/trunk/jboss-tck-runner.
by weld-commits@lists.jboss.org
Author: mgencur(a)redhat.com
Date: 2010-02-04 03:19:11 -0500 (Thu, 04 Feb 2010)
New Revision: 5721
Modified:
core/trunk/jboss-tck-runner/pom.xml
Log:
changed java.io.tmpdir for TCK tests
Modified: core/trunk/jboss-tck-runner/pom.xml
===================================================================
--- core/trunk/jboss-tck-runner/pom.xml 2010-02-04 06:10:55 UTC (rev 5720)
+++ core/trunk/jboss-tck-runner/pom.xml 2010-02-04 08:19:11 UTC (rev 5721)
@@ -235,6 +235,10 @@
<suiteXmlFile>src/test/resources/tck-tests.xml</suiteXmlFile>
</suiteXmlFiles>
<systemProperties>
+ <property>
+ <name>java.io.tmpdir</name>
+ <value>${project.build.outputDirectory}</value>
+ </property>
<property>
<name>org.jboss.testharness.standalone</name>
<value>false</value>
15 years, 1 month
Weld SVN: r5720 - in core/trunk: impl/src/main/java/org/jboss/weld/bean and 4 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2010-02-04 01:10:55 -0500 (Thu, 04 Feb 2010)
New Revision: 5720
Added:
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptionMetadataService.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldClassReference.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldInterceptorMetadata.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMetadataReader.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMethodReference.java
Modified:
core/trunk/bom/pom.xml
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/interceptors/InterceptorExtensionTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java
Log:
WELD-312
Modified: core/trunk/bom/pom.xml
===================================================================
--- core/trunk/bom/pom.xml 2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/bom/pom.xml 2010-02-04 06:10:55 UTC (rev 5720)
@@ -78,7 +78,7 @@
<javassist.version>3.11.0.GA</javassist.version>
<cdi.tck.version>1.0.1-CR1</cdi.tck.version>
<atinject.tck.version>1.0.0-PFD-3</atinject.tck.version>
- <jboss.interceptor.version>1.0.0-CR10</jboss.interceptor.version>
+ <jboss.interceptor.version>1.0.0-CR11</jboss.interceptor.version>
<slf4j.version>1.5.10</slf4j.version>
<cal10n.version>0.7.2</cal10n.version>
</properties>
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -50,10 +50,11 @@
import org.jboss.interceptor.model.InterceptionModel;
import org.jboss.interceptor.model.InterceptionModelBuilder;
-import org.jboss.interceptor.model.InterceptorClassMetadata;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
+import org.jboss.interceptor.model.InterceptorMetadata;
import org.jboss.interceptor.util.InterceptionUtils;
import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
+import org.jboss.weld.bean.interceptor.InterceptionMetadataService;
+import org.jboss.weld.bean.interceptor.WeldClassReference;
import org.jboss.weld.bean.proxy.DecorationHelper;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
import org.jboss.weld.context.SerializableContextualImpl;
@@ -572,7 +573,7 @@
}
}
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(getType(), true);
+ InterceptorMetadata interceptorClassMetadata = beanManager.getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(WeldClassReference.of(getWeldAnnotated()), true);
hasSerializationOrInvocationInterceptorMethods = !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.AROUND_INVOKE).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.AROUND_TIMEOUT).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.PRE_PASSIVATE).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.POST_ACTIVATE).isEmpty();
if (interceptionModel.getAllInterceptors().size() > 0 || hasSerializationOrInvocationInterceptorMethods)
{
@@ -581,7 +582,7 @@
}
else
{
- InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(getType(), true);
+ InterceptorMetadata interceptorClassMetadata = beanManager.getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(WeldClassReference.of(getWeldAnnotated()), true);
hasSerializationOrInvocationInterceptorMethods = !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.AROUND_INVOKE).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.AROUND_TIMEOUT).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.PRE_PASSIVATE).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.POST_ACTIVATE).isEmpty();
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java 2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -28,9 +28,10 @@
import javax.enterprise.inject.spi.Interceptor;
import javax.interceptor.InvocationContext;
-import org.jboss.interceptor.model.InterceptorClassMetadata;
+import org.jboss.interceptor.model.InterceptorMetadata;
import org.jboss.interceptor.proxy.DirectClassInterceptionHandler;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
+import org.jboss.weld.bean.interceptor.InterceptionMetadataService;
+import org.jboss.weld.bean.interceptor.WeldClassReference;
import org.jboss.weld.exceptions.DeploymentException;
import org.jboss.weld.exceptions.WeldException;
import org.jboss.weld.introspector.WeldClass;
@@ -43,7 +44,7 @@
public class InterceptorImpl<T> extends ManagedBean<T> implements Interceptor<T>
{
- private final InterceptorClassMetadata interceptorClassMetadata;
+ private final InterceptorMetadata interceptorClassMetadata;
private final Set<Annotation> interceptorBindingTypes;
@@ -57,7 +58,7 @@
protected InterceptorImpl(WeldClass<T> type, BeanManagerImpl beanManager)
{
super(type, new StringBuilder().append(Interceptor.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(type.getName()).toString(), beanManager);
- this.interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(type.getJavaClass());
+ this.interceptorClassMetadata = beanManager.getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(WeldClassReference.of(type));
this.serializable = type.isSerializable();
this.interceptorBindingTypes = new HashSet<Annotation>();
interceptorBindingTypes.addAll(flattenInterceptorBindings(beanManager, getWeldAnnotated().getAnnotations()));
@@ -84,7 +85,7 @@
{
try
{
- return new DirectClassInterceptionHandler<T>(instance, getType()).invoke(ctx.getTarget(), org.jboss.interceptor.model.InterceptionType.valueOf(type.name()), ctx);
+ return new DirectClassInterceptionHandler<T>(instance, interceptorClassMetadata).invoke(ctx.getTarget(), org.jboss.interceptor.model.InterceptionType.valueOf(type.name()), ctx);
} catch (Exception e)
{
throw new WeldException(e);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -50,6 +50,8 @@
import org.jboss.weld.Container;
import org.jboss.weld.bean.interceptor.CdiInterceptorHandlerFactory;
import org.jboss.weld.bean.interceptor.ClassInterceptionHandlerFactory;
+import org.jboss.weld.bean.interceptor.InterceptionMetadataService;
+import org.jboss.weld.bean.interceptor.WeldClassReference;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
import org.jboss.weld.exceptions.DefinitionException;
import org.jboss.weld.exceptions.DeploymentException;
@@ -577,8 +579,8 @@
if (interceptionRegistries.size() > 0)
{
InterceptorProxyCreatorImpl interceptorProxyCreator = new InterceptorProxyCreatorImpl(interceptionRegistries, interceptionHandlerFactories);
- MethodHandler methodHandler = new CleanableMethodHandler(interceptorProxyCreator.getMethodHandler(instance, getType()));
- instance = interceptorProxyCreator.createProxyInstance(InterceptorProxyCreatorImpl.createProxyClassWithHandler(getType(), methodHandler), methodHandler);
+ MethodHandler methodHandler = new CleanableMethodHandler(interceptorProxyCreator.createMethodHandler(instance, getType(), getBeanManager().getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(WeldClassReference.of(getWeldAnnotated()), true)));
+ instance = interceptorProxyCreator.createProxyInstance(InterceptionUtils.createProxyClassWithHandler(getType(), methodHandler), methodHandler);
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java 2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -20,6 +20,7 @@
import javax.enterprise.inject.spi.Interceptor;
+import org.jboss.interceptor.model.InterceptorMetadata;
import org.jboss.interceptor.proxy.AbstractClassInterceptionHandler;
import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
@@ -33,9 +34,9 @@
private final SerializableContextualInstance<Interceptor<T>, T> serializableContextualInstance;
- public CdiInterceptorHandler(SerializableContextualInstance<Interceptor<T>, T> serializableContextualInstance, Class<?> clazz)
+ public CdiInterceptorHandler(SerializableContextualInstance<Interceptor<T>, T> serializableContextualInstance, Class<?> clazz, InterceptorMetadata interceptorMetadata)
{
- super(clazz);
+ super(interceptorMetadata);
this.serializableContextualInstance = serializableContextualInstance;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java 2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -20,6 +20,8 @@
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Interceptor;
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.ReflectiveClassReference;
import org.jboss.interceptor.proxy.InterceptionHandler;
import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
import org.jboss.weld.context.SerializableContextualInstanceImpl;
@@ -48,7 +50,8 @@
public InterceptionHandler createFor(final SerializableContextual<Interceptor<T>, T> serializableContextual)
{
T instance = (T) getManager().getReference(serializableContextual.get(), creationalContext, false);
- return new CdiInterceptorHandler<T>(new SerializableContextualInstanceImpl<Interceptor<T>, T>(serializableContextual, instance, creationalContext), serializableContextual.get().getBeanClass());
+ InterceptorMetadata interceptionMetadata = getManager().getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(ReflectiveClassReference.of(serializableContextual.get().getBeanClass()), false);
+ return new CdiInterceptorHandler<T>(new SerializableContextualInstanceImpl<Interceptor<T>, T>(serializableContextual, instance, creationalContext), serializableContextual.get().getBeanClass(), interceptionMetadata);
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java 2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -21,6 +21,8 @@
import javax.enterprise.context.spi.CreationalContext;
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.ReflectiveClassReference;
import org.jboss.interceptor.proxy.DirectClassInterceptionHandler;
import org.jboss.interceptor.proxy.InterceptionHandler;
import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
@@ -51,7 +53,8 @@
T interceptorInstance = SecureReflections.ensureAccessible(constructor).newInstance();
// inject
manager.createInjectionTarget(manager.createAnnotatedType(clazz)).inject(interceptorInstance, creationalContext);
- return new DirectClassInterceptionHandler<T>(interceptorInstance, clazz);
+ InterceptorMetadata interceptionMetadata = manager.getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(ReflectiveClassReference.of(clazz), false);
+ return new DirectClassInterceptionHandler<T>(interceptorInstance, interceptionMetadata);
}
catch (Exception e)
{
Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptionMetadataService.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptionMetadataService.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptionMetadataService.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.weld.bean.interceptor;
+
+import org.jboss.interceptor.registry.InterceptorMetadataRegistry;
+import org.jboss.weld.bootstrap.api.Service;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class InterceptionMetadataService implements Service
+{
+ private InterceptorMetadataRegistry interceptorMetadataRegistry;
+
+ public InterceptionMetadataService()
+ {
+ interceptorMetadataRegistry = new InterceptorMetadataRegistry(new WeldMetadataReader());
+ }
+
+ public InterceptorMetadataRegistry getInterceptorMetadataRegistry()
+ {
+ return interceptorMetadataRegistry;
+ }
+
+ public void cleanup()
+ {
+ interceptorMetadataRegistry.cleanup();
+ }
+}
Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldClassReference.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldClassReference.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldClassReference.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.weld.bean.interceptor;
+
+import java.util.Iterator;
+
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.model.metadata.ImmutableIteratorWrapper;
+import org.jboss.interceptor.model.metadata.MethodReference;
+import org.jboss.weld.introspector.WeldClass;
+import org.jboss.weld.introspector.WeldMethod;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class WeldClassReference implements ClassReference
+{
+ private WeldClass<?> weldClass;
+
+ private WeldClassReference(WeldClass<?> weldClass)
+ {
+ this.weldClass = weldClass;
+ }
+
+ public static ClassReference of(WeldClass<?> weldClass)
+ {
+ return new WeldClassReference(weldClass);
+ }
+
+ public String getClassName()
+ {
+ return weldClass.getName();
+ }
+
+ public Iterable<MethodReference> getDeclaredMethods()
+ {
+ return new Iterable<MethodReference>()
+ {
+ public Iterator<MethodReference> iterator()
+ {
+ return new ImmutableIteratorWrapper<WeldMethod<?,?>>(weldClass.getDeclaredWeldMethods().iterator())
+ {
+ @Override protected MethodReference wrapObject(WeldMethod<?,?> weldMethod)
+ {
+ return WeldMethodReference.of(weldMethod);
+ }
+ };
+ }
+ };
+ }
+
+ public Class<?> getJavaClass()
+ {
+ return weldClass.getJavaClass();
+ }
+
+ public ClassReference getSuperclass()
+ {
+ WeldClass<?> weldSuperclass = weldClass.getWeldSuperclass();
+ if (weldSuperclass != null)
+ {
+ return WeldClassReference.of(weldSuperclass);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldInterceptorMetadata.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldInterceptorMetadata.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldInterceptorMetadata.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.weld.bean.interceptor;
+
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.AbstractInterceptorMetadata;
+import org.jboss.interceptor.model.metadata.AbstractInterceptorMetadataSerializationProxy;
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.model.metadata.MethodReference;
+import org.jboss.weld.Container;
+import org.jboss.weld.exceptions.WeldException;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class WeldInterceptorMetadata extends AbstractInterceptorMetadata
+{
+ public WeldInterceptorMetadata(ClassReference interceptorClass, boolean targetClass)
+ {
+ super(interceptorClass, targetClass);
+ }
+
+ private Object writeReplace()
+ {
+ return createSerializableProxy();
+ }
+
+ @Override protected Object createSerializableProxy()
+ {
+ return new WeldInterceptorMetadataSerializationProxy(getInterceptorClass().getClassName(), isTargetClass());
+ }
+
+ public static class WeldInterceptorMetadataSerializationProxy extends AbstractInterceptorMetadataSerializationProxy
+ {
+ protected WeldInterceptorMetadataSerializationProxy(String className, boolean interceptionTargetClass)
+ {
+ super(className, interceptionTargetClass);
+ }
+
+ @Override protected InterceptorMetadata loadInterceptorMetadata() throws ClassNotFoundException
+ {
+ //Class<?> clazz = Container.instance().services().get(ResourceLoader.class).classForName(getClassName());
+
+ return Container.instance().services().get(InterceptionMetadataService.class)
+ .getInterceptorMetadataRegistry().getInterceptorClassMetadata(new ClassReferenceStub(), isInterceptionTargetClass());
+ }
+
+ private Object readResolve()
+ {
+ try
+ {
+ return loadInterceptorMetadata();
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new WeldException(e);
+ }
+ }
+
+ /**
+ * ClassReference stub - we are assuming that the interceptor metadata is loaded already
+ */
+ private class ClassReferenceStub implements ClassReference
+ {
+ public String getClassName()
+ {
+ return WeldInterceptorMetadataSerializationProxy.this.getClassName();
+ }
+
+ public Iterable<MethodReference> getDeclaredMethods()
+ {
+ throw new UnsupportedOperationException("");
+ }
+
+ public Class<?> getJavaClass()
+ {
+ throw new UnsupportedOperationException("");
+ }
+
+ public ClassReference getSuperclass()
+ {
+ throw new UnsupportedOperationException("");
+ }
+ }
+ }
+}
Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMetadataReader.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMetadataReader.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMetadataReader.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.weld.bean.interceptor;
+
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.registry.ClassMetadataReader;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class WeldMetadataReader implements ClassMetadataReader
+{
+ public InterceptorMetadata getInterceptorMetadata(ClassReference clazz, boolean isTargetClass)
+ {
+ return new WeldInterceptorMetadata(clazz, isTargetClass);
+ }
+}
Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMethodReference.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMethodReference.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/WeldMethodReference.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.weld.bean.interceptor;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.model.metadata.MethodReference;
+import org.jboss.interceptor.model.metadata.ReflectiveClassReference;
+import org.jboss.weld.introspector.WeldMethod;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class WeldMethodReference implements MethodReference
+{
+ private WeldMethod<?,?> weldMethod;
+
+ public WeldMethodReference(WeldMethod<?,?> weldMethod)
+ {
+ this.weldMethod = weldMethod;
+ }
+
+ public static MethodReference of(WeldMethod<?,?> weldMethod)
+ {
+ return new WeldMethodReference(weldMethod);
+ }
+
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass)
+ {
+ return weldMethod.getAnnotation(annotationClass);
+ }
+
+ public Method getJavaMethod()
+ {
+ return weldMethod.getJavaMember();
+ }
+
+ public ClassReference getReturnType()
+ {
+ return ReflectiveClassReference.of(weldMethod.getJavaMember().getReturnType());
+ }
+}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -41,6 +41,7 @@
import org.jboss.weld.Container;
import org.jboss.weld.ContainerState;
import org.jboss.weld.bean.builtin.BeanManagerBean;
+import org.jboss.weld.bean.interceptor.InterceptionMetadataService;
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Environment;
import org.jboss.weld.bootstrap.api.Lifecycle;
@@ -321,6 +322,7 @@
services.add(ContextualStore.class, new ContextualStoreImpl());
services.add(ServiceLoaderFactory.class, new DefaultServiceLoaderFactory());
services.add(JavassistCleaner.class, new JavassistCleaner());
+ services.add(InterceptionMetadataService.class, new InterceptionMetadataService());
services.add(CurrentInjectionPoint.class, new CurrentInjectionPoint());
return services;
}
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/interceptors/InterceptorExtensionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/interceptors/InterceptorExtensionTest.java 2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/interceptors/InterceptorExtensionTest.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -43,7 +43,7 @@
@Classes(packages = { "org.jboss.weld.tests.util.annotated" })
public class InterceptorExtensionTest extends AbstractWeldTest
{
- @Test(groups={"broken"})
+ @Test
public void testInterceptorCalled()
{
NumberSource ng = getReference(NumberSource.class);
@@ -51,7 +51,7 @@
assert IncrementingInterceptor.isDoAroundCalled();
}
- @Test(groups={"broken"})
+ @Test
@SuppressWarnings("unchecked")
public void testLifecycleInterceptor()
{
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java 2010-02-03 21:05:45 UTC (rev 5719)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java 2010-02-04 06:10:55 UTC (rev 5720)
@@ -23,6 +23,7 @@
import org.jboss.weld.Container;
import org.jboss.weld.bean.ManagedBean;
import org.jboss.weld.bean.RIBean;
+import org.jboss.weld.bean.interceptor.InterceptionMetadataService;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
@@ -51,6 +52,8 @@
this.services = new SimpleServiceRegistry();
this.services.add(MetaAnnotationStore.class, new MetaAnnotationStore(classTransformer));
this.services.add(ContextualStore.class, new ContextualStoreImpl());
+ this.services.add(InterceptionMetadataService.class, new InterceptionMetadataService());
+ this.services.add(ClassTransformer.class, classTransformer);
}
private void addBean(BeanManagerImpl manager, Class<?> c)
15 years, 1 month
Weld SVN: r5719 - core/trunk/impl/src/main/java/org/jboss/weld/servlet.
by weld-commits@lists.jboss.org
Author: dallen6
Date: 2010-02-03 16:05:45 -0500 (Wed, 03 Feb 2010)
New Revision: 5719
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java
core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruOnDemandSessionBeanStore.java
core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java
core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpSessionBeanStore.java
Log:
WELD-403 Removed concurrency issues with the pass through bean store.
Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java 2010-02-03 17:15:58 UTC (rev 5718)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java 2010-02-03 21:05:45 UTC (rev 5719)
@@ -29,14 +29,12 @@
public class ConversationBeanStore extends HttpPassThruSessionBeanStore
{
- private final String cid;
private final NamingScheme namingScheme;
public ConversationBeanStore(HttpSession session, boolean sessionInvalidated, String cid)
{
- attachToSession(session);
- this.cid = cid;
this.namingScheme = new NamingScheme(ConversationContext.class.getName() + "[" + cid + "]", "#");
+ attachToSession(session);
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruOnDemandSessionBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruOnDemandSessionBeanStore.java 2010-02-03 17:15:58 UTC (rev 5718)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruOnDemandSessionBeanStore.java 2010-02-03 21:05:45 UTC (rev 5719)
@@ -33,6 +33,10 @@
public HttpPassThruOnDemandSessionBeanStore(HttpServletRequest request)
{
this.request = request;
+ if (request.getSession(false) != null)
+ {
+ attachToSession(request.getSession());
+ }
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java 2010-02-03 17:15:58 UTC (rev 5718)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java 2010-02-03 21:05:45 UTC (rev 5719)
@@ -17,31 +17,45 @@
package org.jboss.weld.servlet;
+import static org.jboss.weld.logging.Category.CONTEXT;
+import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
+import java.util.List;
import javax.servlet.http.HttpSession;
import org.jboss.weld.context.api.ContextualInstance;
-import org.jboss.weld.context.api.helpers.ConcurrentHashMapBeanStore;
+import org.jboss.weld.context.beanstore.HashMapBeanStore;
+import org.jboss.weld.context.beanstore.NamingScheme;
+import org.jboss.weld.util.collections.EnumerationList;
+import org.slf4j.cal10n.LocLogger;
/**
* A BeanStore that maintains Contextuals in a hash map and writes them through
- * to a HttpSession. It also has the capability to reload the hash map from an
- * existing session or to rewrite the map entries into a session.
+ * to a HttpSession. When this BeanStore is attached to a session, it will load
+ * all the existing contextuals from the session within the naming scheme for
+ * this BeanStore. All read operations are directly against the local map.
*
* @author David Allen
*/
public class HttpPassThruSessionBeanStore extends HttpSessionBeanStore
{
- private static final long serialVersionUID = 8923580660774253915L;
+ private static final long serialVersionUID = 8923580660774253915L;
+ private static final LocLogger log = loggerFactory().getLogger(CONTEXT);
- private ConcurrentHashMapBeanStore delegateBeanStore = new ConcurrentHashMapBeanStore();
- private boolean attachedToSession = false;
- private boolean invalidated = false;
- private static final String SESSION_ATTRIBUTE_NAME = HttpPassThruSessionBeanStore.class.getName() + ".sessionBeanStore";
+ private HashMapBeanStore delegateBeanStore = new HashMapBeanStore();
+ private boolean attachedToSession = false;
+ private boolean invalidated = false;
+ public HttpPassThruSessionBeanStore()
+ {
+ log.trace("New bean store created: " + this);
+ }
+
/**
* Attaches this pass-through bean store to the given session.
*
@@ -50,8 +64,8 @@
public void attachToSession(HttpSession session)
{
super.attachToSession(session);
+ attachedToSession = true;
loadFromSession(session);
- attachedToSession = true;
}
/**
@@ -72,6 +86,7 @@
{
detachFromSession();
invalidated = true;
+ log.trace("Bean store " + this + " is invalidated");
}
/**
@@ -95,24 +110,19 @@
}
/**
- * Loads the map from the given session into this map store, if it already
- * exists in this session. If it does not already exist, then a new map is
- * created since the session does not already have any contextuals stored in
- * it.
+ * Loads the map with all contextuals currently stored in the session for
+ * this bean store.
*
* @param newSession a new HttpSession being attached
*/
protected void loadFromSession(HttpSession newSession)
{
- Object map = newSession.getAttribute(SESSION_ATTRIBUTE_NAME);
- if (map != null)
+ log.trace("Loading bean store " + this + " map from session " + newSession.getId());
+ for (String id : this.getFilteredAttributeNames())
{
- delegateBeanStore = (ConcurrentHashMapBeanStore) map;
+ delegateBeanStore.put(id, (ContextualInstance<?>) super.getAttribute(id));
+ log.trace("Added contextual " + super.getAttribute(id) + " under ID " + id);
}
- else
- {
- newSession.setAttribute(SESSION_ATTRIBUTE_NAME, delegateBeanStore);
- }
}
@Override
@@ -132,7 +142,14 @@
{
if (attachedToSession && !isInvalidated())
{
- super.removeAttribute(key);
+ try
+ {
+ super.removeAttribute(key);
+ }
+ catch (IllegalStateException e)
+ {
+ invalidate();
+ }
}
delegateBeanStore.delegate().remove(key);
}
@@ -143,8 +160,44 @@
{
if (attachedToSession && !isInvalidated())
{
- super.setAttribute(key, instance);
+ try
+ {
+ super.setAttribute(key, instance);
+ log.trace("***** Added " + key + " to session " + this.getSession().getId());
+ }
+ catch (IllegalStateException e)
+ {
+ invalidate();
+ }
}
delegateBeanStore.put(key, (ContextualInstance<? extends Object>) instance);
+ log.trace("Added instance for key " + key);
}
+
+ /**
+ * Gets the list of attribute names that is held by the bean store
+ *
+ * @return The list of attribute names
+ */
+ private List<String> getFilteredAttributeNames()
+ {
+ List<String> attributeNames = new ArrayList<String>();
+ NamingScheme namingScheme = getNamingScheme();
+ try
+ {
+ for (String attributeName : new EnumerationList<String>(super.getAttributeNames()))
+ {
+ if (namingScheme.acceptKey(attributeName))
+ {
+ attributeNames.add(attributeName);
+ }
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ invalidate();
+ }
+ return attributeNames;
+ }
+
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpSessionBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpSessionBeanStore.java 2010-02-03 17:15:58 UTC (rev 5718)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpSessionBeanStore.java 2010-02-03 21:05:45 UTC (rev 5719)
@@ -29,7 +29,6 @@
*
* @author Nicklas Karlsson
* @author David Allen
- *
* @see org.jboss.weld.context.AbstractApplicationContext
*/
public class HttpSessionBeanStore extends AbstractAttributeBackedBeanStore
@@ -38,7 +37,7 @@
private static final NamingScheme NAMING_SCHEME = new NamingScheme(SessionContext.class.getName(), "#");
// The HTTP session context to use as backing map
- protected HttpSession session;
+ private HttpSession session;
/**
* Attaches this bean store to a session dynamically. This allows the session
@@ -72,6 +71,11 @@
return session.getAttributeNames();
}
+ protected HttpSession getSession()
+ {
+ return session;
+ }
+
/**
* @see org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore#removeAttributes()
*/
15 years, 1 month
Weld SVN: r5718 - cdi-tck/branches/1.0/impl/src/main/resources.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-03 12:15:58 -0500 (Wed, 03 Feb 2010)
New Revision: 5718
Modified:
cdi-tck/branches/1.0/impl/src/main/resources/cdi-api.sig
Log:
CDITCK-105, CDITCK-106
Modified: cdi-tck/branches/1.0/impl/src/main/resources/cdi-api.sig
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/resources/cdi-api.sig 2010-02-03 16:57:56 UTC (rev 5717)
+++ cdi-tck/branches/1.0/impl/src/main/resources/cdi-api.sig 2010-02-03 17:15:58 UTC (rev 5718)
@@ -164,6 +164,7 @@
CLSS public abstract interface !annotation javax.enterprise.context.ConversationScoped
anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Inherited()
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE, METHOD, FIELD])
anno 0 javax.enterprise.context.NormalScope(boolean passivating=true)
@@ -486,7 +487,7 @@
CLSS public abstract interface javax.enterprise.inject.spi.BeforeBeanDiscovery
meth public abstract !varargs void addStereotype(java.lang.Class<? extends java.lang.annotation.Annotation>,java.lang.annotation.Annotation[])
meth public abstract void addAnnotatedType(javax.enterprise.inject.spi.AnnotatedType<?>)
-meth public abstract void addInterceptorBinding(java.lang.Class<? extends java.lang.annotation.Annotation>)
+meth public abstract !varargs void addInterceptorBinding(java.lang.Class<? extends java.lang.annotation.Annotation>,java.lang.annotation.Annotation[])
meth public abstract void addQualifier(java.lang.Class<? extends java.lang.annotation.Annotation>)
meth public abstract void addScope(java.lang.Class<? extends java.lang.annotation.Annotation>,boolean,boolean)
15 years, 1 month