Seam SVN: r13497 - in modules/persistence/trunk/impl/src: main/java/org/jboss/seam/persistence/transaction and 2 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-24 23:50:38 -0400 (Sat, 24 Jul 2010)
New Revision: 13497
Added:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java
Removed:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Naming.java
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java
Log:
update to work with latest weldx
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-07-25 03:50:38 UTC (rev 13497)
@@ -34,7 +34,6 @@
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
-import org.jboss.weld.extensions.bean.BeanImpl;
import org.jboss.weld.extensions.bean.BeanLifecycle;
/**
@@ -81,7 +80,7 @@
/**
* creates the proxy
*/
- public EntityManager create(BeanImpl<EntityManager> bean, CreationalContext<EntityManager> arg0)
+ public EntityManager create(Bean<EntityManager> bean, CreationalContext<EntityManager> arg0)
{
try
{
@@ -97,7 +96,7 @@
}
}
- public void destroy(BeanImpl<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
+ public void destroy(Bean<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
{
em.close();
arg1.release();
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-07-25 03:50:38 UTC (rev 13497)
@@ -46,7 +46,6 @@
* turn them into Seam Managed Persistence Contexts.
*
*
- *
* @author Stuart Douglas
*
*/
@@ -72,7 +71,7 @@
{
if (modifiedType == null)
{
- modifiedType = AnnotatedTypeBuilder.newInstance(event.getAnnotatedType()).mergeAnnotations(event.getAnnotatedType(), true);
+ modifiedType = new AnnotatedTypeBuilder().readFromType(event.getAnnotatedType());
}
Set<Annotation> qualifiers = new HashSet<Annotation>();
Class<? extends Annotation> scope = Dependent.class;
@@ -99,15 +98,13 @@
modifiedType.removeFromField(f.getJavaMember(), scope);
}
// create the new bean to be registerd later
- AnnotatedTypeBuilder<EntityManager> typeBuilder = AnnotatedTypeBuilder.newInstance(EntityManager.class);
- BeanBuilder<EntityManager> builder = new BeanBuilder<EntityManager>(typeBuilder.create(), manager);
- builder.defineBeanFromAnnotatedType();
+ AnnotatedTypeBuilder<EntityManager> typeBuilder = new AnnotatedTypeBuilder().setJavaClass(EntityManager.class);
+ BeanBuilder<EntityManager> builder = new BeanBuilder<EntityManager>(manager).defineBeanFromAnnotatedType(typeBuilder.create());
builder.setQualifiers(qualifiers);
builder.setScope(scope);
builder.setBeanLifecycle(new ManagedPersistenceContextBeanLifecycle(qualifiers, manager));
beans.add(builder.create());
}
-
}
if (modifiedType != null)
{
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java 2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java 2010-07-25 03:50:38 UTC (rev 13497)
@@ -25,6 +25,8 @@
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
+import org.jboss.seam.persistence.util.Naming;
+
/**
* utility class to look up the EJBContext
*
Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Naming.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Naming.java 2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Naming.java 2010-07-25 03:50:38 UTC (rev 13497)
@@ -1,104 +0,0 @@
-/*
- * 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.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.persistence.transaction;
-
-import java.util.Hashtable;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * this has been ported to seam and hacked to make it work
- *
- * we need to figure out what we are doing with JNDI in seam 3 and make this go
- * away
- *
- * @author stuart
- *
- */
-public final class Naming
-{
- private static final Logger log = LoggerFactory.getLogger(Naming.class);
- private static Hashtable initialContextProperties;
-
- private static InitialContext initialContext;
-
- public static InitialContext getInitialContext(Hashtable<String, String> props) throws NamingException
- {
- if (props == null)
- {
- // throw new
- // IllegalStateException("JNDI properties not initialized, Seam was not started correctly");
- }
- props = new Hashtable<String, String>();
-
- if (log.isDebugEnabled())
- {
- log.debug("JNDI InitialContext properties:" + props);
- }
-
- try
- {
- return props.size() == 0 ? new InitialContext() : new InitialContext(props);
- }
- catch (NamingException e)
- {
- log.debug("Could not obtain initial context");
- throw e;
- }
-
- }
-
- public static InitialContext getInitialContext() throws NamingException
- {
- if (initialContext == null)
- initInitialContext();
-
- return initialContext;
- }
-
- private static synchronized void initInitialContext() throws NamingException
- {
- if (initialContext == null)
- {
- initialContext = getInitialContext(initialContextProperties);
- }
- }
-
- private Naming()
- {
- }
-
- public static void setInitialContextProperties(Hashtable initialContextProperties)
- {
- Naming.initialContextProperties = initialContextProperties;
- initialContext = null;
- }
-
- public static Hashtable getInitialContextProperties()
- {
- return initialContextProperties;
- }
-}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java 2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java 2010-07-25 03:50:38 UTC (rev 13497)
@@ -10,6 +10,7 @@
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
+import org.jboss.seam.persistence.util.Naming;
import org.jboss.weld.extensions.literal.DefaultLiteral;
/**
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java 2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java 2010-07-25 03:50:38 UTC (rev 13497)
@@ -22,6 +22,7 @@
package org.jboss.seam.persistence.util;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
import org.jboss.weld.extensions.util.Reflections;
@@ -91,17 +92,29 @@
public static String name(Annotation annotation)
{
- return (String) Reflections.invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "name"), annotation);
+ return (String) invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "name"), annotation);
}
public static Class[] value(Annotation annotation)
{
- return (Class[]) Reflections.invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "value"), annotation);
+ return (Class[]) invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "value"), annotation);
}
public static boolean rollback(Annotation annotation)
{
- return (Boolean) Reflections.invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "rollback"), annotation);
+ return (Boolean) invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "rollback"), annotation);
}
+ private static Object invokeAndWrap(Method method, Object instance, Object... parameters)
+ {
+ try
+ {
+ return method.invoke(instance, parameters);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
}
Copied: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java (from rev 13495, modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Naming.java)
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java 2010-07-25 03:50:38 UTC (rev 13497)
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.util;
+
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * this has been ported to seam and hacked to make it work
+ *
+ * we need to figure out what we are doing with JNDI in seam 3 and make this go
+ * away
+ *
+ * @author stuart
+ *
+ */
+public final class Naming
+{
+ private static final Logger log = LoggerFactory.getLogger(Naming.class);
+ private static Hashtable initialContextProperties;
+
+ private static InitialContext initialContext;
+
+ public static InitialContext getInitialContext(Hashtable<String, String> props) throws NamingException
+ {
+ if (props == null)
+ {
+ // throw new
+ // IllegalStateException("JNDI properties not initialized, Seam was not started correctly");
+ }
+ props = new Hashtable<String, String>();
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("JNDI InitialContext properties:" + props);
+ }
+
+ try
+ {
+ return props.size() == 0 ? new InitialContext() : new InitialContext(props);
+ }
+ catch (NamingException e)
+ {
+ log.debug("Could not obtain initial context");
+ throw e;
+ }
+
+ }
+
+ public static InitialContext getInitialContext() throws NamingException
+ {
+ if (initialContext == null)
+ initInitialContext();
+
+ return initialContext;
+ }
+
+ private static synchronized void initInitialContext() throws NamingException
+ {
+ if (initialContext == null)
+ {
+ initialContext = getInitialContext(initialContextProperties);
+ }
+ }
+
+ private Naming()
+ {
+ }
+
+ public static void setInitialContextProperties(Hashtable initialContextProperties)
+ {
+ Naming.initialContextProperties = initialContextProperties;
+ initialContext = null;
+ }
+
+ public static Hashtable getInitialContextProperties()
+ {
+ return initialContextProperties;
+ }
+}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java 2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java 2010-07-25 03:50:38 UTC (rev 13497)
@@ -12,8 +12,6 @@
*/
public class MavenArtifactResolver
{
- private static final String LOCAL_MAVEN_REPO = System.getProperty("user.home") + File.separatorChar + ".m2" + File.separatorChar + "repository";
-
public static File resolve(String groupId, String artifactId)
{
String classPath = System.getProperty("java.class.path");
13 years, 9 months
Seam SVN: r13496 - modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-24 21:28:57 -0400 (Sat, 24 Jul 2010)
New Revision: 13496
Modified:
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java
Log:
update maven artifact resolver so that version numbers are inferred from the pom
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java 2010-07-23 14:16:46 UTC (rev 13495)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java 2010-07-25 01:28:57 UTC (rev 13496)
@@ -2,7 +2,7 @@
public class ArtifactNames
{
- public static final String WELD_EXTENSIONS = "org.jboss.weld:weld-extensions:1.0.0-SNAPSHOT";
- public static final String SEAM_PERSISTENCE_API = "org.jboss.seam.persistence:seam-persistence-api:3.0.0-SNAPSHOT";
+ public static final String WELD_EXTENSIONS = "org.jboss.weld:weld-extensions";
+ public static final String SEAM_PERSISTENCE_API = "org.jboss.seam.persistence:seam-persistence-api";
}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java 2010-07-23 14:16:46 UTC (rev 13495)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java 2010-07-25 01:28:57 UTC (rev 13496)
@@ -1,25 +1,46 @@
package org.jboss.seam.transactions.test.util;
import java.io.File;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+/**
+ * Resolves a maven artifact present on the test classpath.
+ *
+ * @author Stuart Douglas
+ *
+ */
public class MavenArtifactResolver
{
- private static final String LOCAL_MAVEN_REPO =
- System.getProperty("user.home") + File.separatorChar +
- ".m2" + File.separatorChar + "repository";
+ private static final String LOCAL_MAVEN_REPO = System.getProperty("user.home") + File.separatorChar + ".m2" + File.separatorChar + "repository";
- public static File resolve(String groupId, String artifactId, String version)
+ public static File resolve(String groupId, String artifactId)
{
- return new File(LOCAL_MAVEN_REPO + File.separatorChar +
- groupId.replace(".", File.separator) + File.separatorChar +
- artifactId + File.separatorChar +
- version + File.separatorChar +
- artifactId + "-" + version + ".jar");
+ String classPath = System.getProperty("java.class.path");
+ // first look for an artefact from the repo
+ String pathString = groupId.replace('.', File.separatorChar) + File.separatorChar + artifactId;
+ String regex = "[^:]*" + Pattern.quote(pathString) + "[^:]*";
+ Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
+ Matcher matches = p.matcher(classPath);
+
+ if (!matches.find())
+ {
+ // find a resource from the local build
+ String localResource = Pattern.quote("target" + File.separatorChar + artifactId);
+ regex = "[^:]*" + localResource + "[^:]*";
+ p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
+ matches = p.matcher(classPath);
+ if (!matches.find())
+ {
+ throw new RuntimeException("Unable to find maven archive " + groupId + ":" + artifactId + " on the test classpath");
+ }
+ }
+ return new File(matches.group(0));
}
public static File resolve(String qualifiedArtifactId)
{
String[] segments = qualifiedArtifactId.split(":");
- return resolve(segments[0], segments[1], segments[2]);
+ return resolve(segments[0], segments[1]);
}
}
13 years, 9 months
Seam SVN: r13495 - branches/enterprise/JBPAPP_5_0/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium.
by seam-commits@lists.jboss.org
Author: plenyi(a)redhat.com
Date: 2010-07-23 10:16:46 -0400 (Fri, 23 Jul 2010)
New Revision: 13495
Modified:
branches/enterprise/JBPAPP_5_0/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java
Log:
JBPAPP-4296 Fixed Seamdiscs ftest failing in Internet Explorer.
Modified: branches/enterprise/JBPAPP_5_0/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java 2010-07-23 13:41:08 UTC (rev 13494)
+++ branches/enterprise/JBPAPP_5_0/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java 2010-07-23 14:16:46 UTC (rev 13495)
@@ -23,6 +23,8 @@
import java.text.MessageFormat;
+import com.thoughtworks.selenium.SeleniumException;
+
import org.jboss.seam.example.common.test.selenium.SeamSeleniumTest;
import org.testng.annotations.BeforeMethod;
@@ -128,8 +130,11 @@
assertTrue("This is not expected (" + expectedDiscTitle + ") album (" + actualDiscTitle + ")!", actualDiscTitle.equals(expectedDiscTitle));
String actualReleaseDate = "";
- if (browser.isElementPresent(MessageFormat.format(ARTIST_NTH_DISC_YEAR, tableRow) + "/attribute::value")) {
+ if (browser.isElementPresent(MessageFormat.format(ARTIST_NTH_DISC_YEAR, tableRow))) {
+ try {
actualReleaseDate = browser.getAttribute(MessageFormat.format(ARTIST_NTH_DISC_YEAR, tableRow) + "@value");
+ }
+ catch (SeleniumException ex) { /* intentionally left blank */ }
assertTrue("This is not expected (" + expectedReleaseDate + ") release date (" + actualReleaseDate + ")!", actualReleaseDate.equals(expectedReleaseDate));
}
13 years, 9 months
Seam SVN: r13494 - in branches/enterprise/JBPAPP_5_0/src: main/org/jboss/seam/navigation and 1 other directories.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-23 09:41:08 -0400 (Fri, 23 Jul 2010)
New Revision: 13494
Modified:
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/mock/MockExternalContext.java
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/navigation/Pages.java
branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java
Log:
JBPAPP-4685
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/mock/MockExternalContext.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/mock/MockExternalContext.java 2010-07-23 13:17:20 UTC (rev 13493)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/mock/MockExternalContext.java 2010-07-23 13:41:08 UTC (rev 13494)
@@ -528,7 +528,15 @@
response.sendRedirect(url);
FacesContext.getCurrentInstance().responseComplete();
}
+
+
+ @Override
+ public void setRequest(Object myrequest)
+ {
+ this.request = (HttpServletRequest) myrequest;
+ }
+
/**
* @since 1.2
*/
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/navigation/Pages.java 2010-07-23 13:17:20 UTC (rev 13493)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/navigation/Pages.java 2010-07-23 13:41:08 UTC (rev 13494)
@@ -6,6 +6,7 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -19,8 +20,8 @@
import java.util.TreeSet;
import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
import javax.faces.application.ViewHandler;
-import javax.faces.application.FacesMessage.Severity;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.convert.ConverterException;
@@ -42,12 +43,12 @@
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Events;
import org.jboss.seam.core.Expressions;
+import org.jboss.seam.core.Expressions.MethodExpression;
+import org.jboss.seam.core.Expressions.ValueExpression;
import org.jboss.seam.core.Init;
import org.jboss.seam.core.Interpolator;
import org.jboss.seam.core.Manager;
import org.jboss.seam.core.ResourceLoader;
-import org.jboss.seam.core.Expressions.MethodExpression;
-import org.jboss.seam.core.Expressions.ValueExpression;
import org.jboss.seam.deployment.DotPageDotXmlDeploymentHandler;
import org.jboss.seam.deployment.FileDescriptor;
import org.jboss.seam.faces.FacesMessages;
@@ -678,6 +679,16 @@
String outcome = facesContext.getExternalContext()
.getRequestParameterMap().get("actionOutcome");
String fromAction = outcome;
+
+ String decodedOutcome = null;
+ if (outcome != null)
+ {
+ decodedOutcome = URLDecoder.decode(outcome);
+ }
+
+ if (decodedOutcome != null && (decodedOutcome.indexOf('#') >= 0 || decodedOutcome.indexOf('{') >= 0) ){
+ throw new IllegalArgumentException("EL expressions are not allowed in actionOutcome parameter");
+ }
if (outcome==null)
{
Modified: branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java 2010-07-23 13:17:20 UTC (rev 13493)
+++ branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java 2010-07-23 13:41:08 UTC (rev 13494)
@@ -10,6 +10,8 @@
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Expressions;
import org.jboss.seam.core.Validators;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.navigation.Pages;
import org.jboss.seam.navigation.Param;
import org.testng.annotations.Test;
@@ -32,6 +34,27 @@
}
/**
+ * Verify EL expression disability in actionOutcome parameter
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class )
+ public void testGetCallAction()
+ {
+ EnhancedMockHttpServletRequest request = new EnhancedMockHttpServletRequest();
+ request.addParameter("actionOutcome", "#{variable}");
+ FacesContext.getCurrentInstance().getExternalContext().setRequest(request);
+ Pages.instance().preRender(FacesContext.getCurrentInstance());
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class )
+ public void testGetCallActionEscaped()
+ {
+ EnhancedMockHttpServletRequest request = new EnhancedMockHttpServletRequest();
+ request.addParameter("actionOutcome", "%3d%23%7dvariable%7b");
+ FacesContext.getCurrentInstance().getExternalContext().setRequest(request);
+ Pages.instance().preRender(FacesContext.getCurrentInstance());
+ }
+
+ /**
* Verify that converter is null when the parameter value is a value expression and
* we are operating outside of a FacesContext.
* @jira JBSEAM-3674
13 years, 9 months
Seam SVN: r13493 - in branches/community/Seam_2_2: src/main/org/jboss/seam/servlet and 1 other directory.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-23 09:17:20 -0400 (Fri, 23 Jul 2010)
New Revision: 13493
Modified:
branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java
branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/ContextualHttpServletRequest.java
Log:
JBSEAM-4542
Modified: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java 2010-07-23 12:52:42 UTC (rev 13492)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java 2010-07-23 13:17:20 UTC (rev 13493)
@@ -184,7 +184,7 @@
}.run();
}
- // @Test
+ @Test
// JBPAPP-3713
public void synchronizationsLookup() throws Exception
{
Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/ContextualHttpServletRequest.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/ContextualHttpServletRequest.java 2010-07-23 12:52:42 UTC (rev 13492)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/ContextualHttpServletRequest.java 2010-07-23 13:17:20 UTC (rev 13493)
@@ -1,6 +1,7 @@
package org.jboss.seam.servlet;
import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -17,6 +18,7 @@
* Perform work in a full set of Seam contexts
*
* @author Gavin King
+ * @author Marek Novotny
*
*/
public abstract class ContextualHttpServletRequest
@@ -25,51 +27,70 @@
private final HttpServletRequest request;
+ private static ThreadLocal<AtomicInteger> count = new ThreadLocal<AtomicInteger>();
+
public ContextualHttpServletRequest(HttpServletRequest request)
{
- this.request = request;
+ this.request = request;
}
public abstract void process() throws Exception;
public void run() throws ServletException, IOException
- {
- log.debug("beginning request");
+ {
+ log.debug("beginning request");
+
// Force creation of the session
if (request.getSession(false) == null)
{
request.getSession(true);
}
- ServletLifecycle.beginRequest(request);
- ServletContexts.instance().setRequest(request);
- restoreConversationId();
- Manager.instance().restoreConversation();
- ServletLifecycle.resumeConversation(request);
- handleConversationPropagation();
+ // Begin request and Seam life cycle only if it is not nested
+ // ContextualHttpServletRequest
+ if (getCounterValue() == 0)
+ {
+ ServletLifecycle.beginRequest(request);
+ ServletContexts.instance().setRequest(request);
+ restoreConversationId();
+ Manager.instance().restoreConversation();
+ ServletLifecycle.resumeConversation(request);
+ handleConversationPropagation();
+ }
-
try
{
- process();
- //TODO: conversation timeout
- Manager.instance().endRequest( new ServletRequestSessionMap(request) );
- ServletLifecycle.endRequest(request);
+ incrementCounterValue();
+
+ process();
+
+ decrementCounterValue();
+
+ // End request only if it is not nested ContextualHttpServletRequest
+ if (getCounterValue() == 0)
+ {
+ //TODO: conversation timeout
+ Manager.instance().endRequest( new ServletRequestSessionMap(request) );
+ ServletLifecycle.endRequest(request);
+ }
}
catch (IOException ioe)
{
+ removeCounter();
Lifecycle.endRequest();
log.debug("ended request due to exception");
throw ioe;
}
catch (ServletException se)
{
+ removeCounter();
Lifecycle.endRequest();
log.debug("ended request due to exception");
throw se;
}
catch (Exception e)
{
+ removeCounter();
Lifecycle.endRequest();
log.debug("ended request due to exception");
throw new ServletException(e);
@@ -90,4 +111,65 @@
ConversationPropagation.instance().restoreConversationId( request.getParameterMap() );
}
+ /*
+ * Getter for ThreadLocal counter value
+ */
+ private int getCounterValue()
+ {
+ AtomicInteger i = count.get();
+ if (i == null || i.intValue() < 0)
+ {
+ log.trace("Getting 0" );
+ return 0;
+ }
+ else
+ {
+ log.trace("Getting " + i.intValue());
+ return i.intValue();
+ }
+ }
+
+ /*
+ * Increments ThreadLocal counter value
+ */
+ private void incrementCounterValue()
+ {
+ AtomicInteger i = count.get();
+ if (i == null || i.intValue() < 0)
+ {
+ i = new AtomicInteger(0);
+ count.set(i);
+ }
+ i.incrementAndGet();
+ log.trace("Incrementing to " + count.get());
+ }
+
+ /*
+ * Decrements ThreadLocal counter value
+ */
+ private void decrementCounterValue()
+ {
+ AtomicInteger i = count.get();
+ if (i == null)
+ {
+ log.trace("OOps, something removed counter befor end of request!");
+ // we should never get here...
+ throw new IllegalStateException("Counter for nested ContextualHttpServletRequest was removed before it should be!");
+ }
+ if (i.intValue() > 0)
+ {
+ i.decrementAndGet();
+ log.trace("Decrementing to " + count.get());
+ }
+ }
+
+ /*
+ * Removes ThreadLocal counter
+ */
+ private void removeCounter()
+ {
+ log.trace("Removing ThreadLocal counter");
+ count.remove();
+ }
+
}
13 years, 9 months
Seam SVN: r13492 - branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/webdriver.
by seam-commits@lists.jboss.org
Author: mgencur(a)redhat.com
Date: 2010-07-23 08:52:42 -0400 (Fri, 23 Jul 2010)
New Revision: 13492
Modified:
branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/webdriver/DelegatedWebElement.java
Log:
removed old api
Modified: branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/webdriver/DelegatedWebElement.java
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/webdriver/DelegatedWebElement.java 2010-07-23 12:43:13 UTC (rev 13491)
+++ branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/webdriver/DelegatedWebElement.java 2010-07-23 12:52:42 UTC (rev 13492)
@@ -120,12 +120,12 @@
return element.getAttribute(name);
}
- @Deprecated
- // @Override
- public String getElementName()
- {
- return element.getElementName();
- }
+ //@Deprecated
+ //// @Override
+ //public String getElementName()
+ //{
+ // return element.getElementName();
+ //}
// @Override
public String getTagName()
13 years, 9 months
Seam SVN: r13491 - branches/community/Seam_2_2/src/main/org/jboss/seam/util.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-23 08:43:13 -0400 (Fri, 23 Jul 2010)
New Revision: 13491
Modified:
branches/community/Seam_2_2/src/main/org/jboss/seam/util/Work.java
Log:
JBSEAM-4677
Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/util/Work.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/util/Work.java 2010-07-23 12:38:47 UTC (rev 13490)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/util/Work.java 2010-07-23 12:43:13 UTC (rev 13491)
@@ -76,10 +76,18 @@
}
catch (Exception e)
{
- if (newTransactionRequired && userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION && isRollbackRequired(e, true))
+ if (newTransactionRequired && userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION )
{
- log.debug("rolling back transaction");
- userTransaction.rollback();
+ if(isRollbackRequired(e, true))
+ {
+ log.debug("rolling back transaction");
+ userTransaction.rollback();
+ }
+ else
+ {
+ log.debug("committing transaction after ApplicationException(rollback=false):" + e.getMessage());
+ userTransaction.commit();
+ }
}
throw e;
}
13 years, 9 months
Seam SVN: r13490 - in branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam: web and 1 other directory.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-23 08:38:47 -0400 (Fri, 23 Jul 2010)
New Revision: 13490
Modified:
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/servlet/ContextualHttpServletRequest.java
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/web/AuthenticationFilter.java
Log:
JBPAPP-3985, JBPAPP-3713 modified AuthenticationFilter and ContextualHttpServletRequest
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/servlet/ContextualHttpServletRequest.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/servlet/ContextualHttpServletRequest.java 2010-07-23 12:23:58 UTC (rev 13489)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/servlet/ContextualHttpServletRequest.java 2010-07-23 12:38:47 UTC (rev 13490)
@@ -1,6 +1,7 @@
package org.jboss.seam.servlet;
import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -17,6 +18,7 @@
* Perform work in a full set of Seam contexts
*
* @author Gavin King
+ * @author Marek Novotny
*
*/
public abstract class ContextualHttpServletRequest
@@ -25,6 +27,8 @@
private final HttpServletRequest request;
+ private static ThreadLocal<AtomicInteger> count = new ThreadLocal<AtomicInteger>();
+
public ContextualHttpServletRequest(HttpServletRequest request)
{
this.request = request;
@@ -35,13 +39,19 @@
public void run() throws ServletException, IOException
{
log.debug("beginning request");
- ServletLifecycle.beginRequest(request);
- ServletContexts.instance().setRequest(request);
- restoreConversationId();
- Manager.instance().restoreConversation();
- ServletLifecycle.resumeConversation(request);
- handleConversationPropagation();
+ // Begin request and Seam life cycle only if it is not nested
+ // ContextualHttpServletRequest
+ if (getCounterValue() == 0)
+ {
+ ServletLifecycle.beginRequest(request);
+ ServletContexts.instance().setRequest(request);
+ restoreConversationId();
+ Manager.instance().restoreConversation();
+ ServletLifecycle.resumeConversation(request);
+ handleConversationPropagation();
+ }
+
// Force creation of the session
if (request.getSession(false) == null)
{
@@ -50,25 +60,37 @@
try
{
+ incrementCounterValue();
+
process();
- //TODO: conversation timeout
- Manager.instance().endRequest( new ServletRequestSessionMap(request) );
- ServletLifecycle.endRequest(request);
+
+ decrementCounterValue();
+
+ // End request only if it is not nested ContextualHttpServletRequest
+ if (getCounterValue() == 0)
+ {
+ //TODO: conversation timeout
+ Manager.instance().endRequest( new ServletRequestSessionMap(request) );
+ ServletLifecycle.endRequest(request);
+ }
}
catch (IOException ioe)
{
+ removeCounter();
Lifecycle.endRequest();
log.debug("ended request due to exception");
throw ioe;
}
catch (ServletException se)
{
+ removeCounter();
Lifecycle.endRequest();
log.debug("ended request due to exception");
throw se;
}
catch (Exception e)
{
+ removeCounter();
Lifecycle.endRequest();
log.debug("ended request due to exception");
throw new ServletException(e);
@@ -89,4 +111,65 @@
ConversationPropagation.instance().restoreConversationId( request.getParameterMap() );
}
+ /*
+ * Getter for ThreadLocal counter value
+ */
+ private int getCounterValue()
+ {
+ AtomicInteger i = count.get();
+ if (i == null || i.intValue() < 0)
+ {
+ log.trace("Getting 0" );
+ return 0;
+ }
+ else
+ {
+ log.trace("Getting " + i.intValue());
+ return i.intValue();
+ }
+ }
+
+ /*
+ * Increments ThreadLocal counter value
+ */
+ private void incrementCounterValue()
+ {
+ AtomicInteger i = count.get();
+ if (i == null || i.intValue() < 0)
+ {
+ i = new AtomicInteger(0);
+ count.set(i);
+ }
+ i.incrementAndGet();
+ log.trace("Incrementing to " + count.get());
+ }
+
+ /*
+ * Decrements ThreadLocal counter value
+ */
+ private void decrementCounterValue()
+ {
+ AtomicInteger i = count.get();
+ if (i == null)
+ {
+ log.trace("OOps, something removed counter befor end of request!");
+ // we should never get here...
+ throw new IllegalStateException("Counter for nested ContextualHttpServletRequest was removed before it should be!");
+ }
+ if (i.intValue() > 0)
+ {
+ i.decrementAndGet();
+ log.trace("Decrementing to " + count.get());
+ }
+ }
+
+ /*
+ * Removes ThreadLocal counter
+ */
+ private void removeCounter()
+ {
+ log.trace("Removing ThreadLocal counter");
+ count.remove();
+ }
+
}
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/web/AuthenticationFilter.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/web/AuthenticationFilter.java 2010-07-23 12:23:58 UTC (rev 13489)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/web/AuthenticationFilter.java 2010-07-23 12:38:47 UTC (rev 13490)
@@ -21,8 +21,6 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.annotations.web.Filter;
-import org.jboss.seam.contexts.Context;
-import org.jboss.seam.contexts.SessionContext;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
@@ -31,7 +29,6 @@
import org.jboss.seam.security.digest.DigestUtils;
import org.jboss.seam.security.digest.DigestValidationException;
import org.jboss.seam.servlet.ContextualHttpServletRequest;
-import org.jboss.seam.servlet.ServletRequestSessionMap;
import org.jboss.seam.util.Base64;
/**
@@ -103,41 +100,46 @@
this.nonceValiditySeconds = value;
}
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
- throws IOException, ServletException
+ public void doFilter(ServletRequest request, ServletResponse response, final FilterChain chain) throws IOException, ServletException
{
- if (!(request instanceof HttpServletRequest))
+ if (!(request instanceof HttpServletRequest))
{
throw new ServletException("This filter can only process HttpServletRequest requests");
}
-
- HttpServletRequest httpRequest = (HttpServletRequest) request;
- HttpServletResponse httpResponse = (HttpServletResponse) response;
-
+
+ final HttpServletRequest httpRequest = (HttpServletRequest) request;
+ final HttpServletResponse httpResponse = (HttpServletResponse) response;
+
// Force session creation
httpRequest.getSession();
- if (AUTH_TYPE_BASIC.equals(authType))
- processBasicAuth(httpRequest, httpResponse, chain);
- else if (AUTH_TYPE_DIGEST.equals(authType))
- processDigestAuth(httpRequest, httpResponse, chain);
- else
- throw new ServletException("Invalid authentication type");
+ new ContextualHttpServletRequest(httpRequest)
+ {
+ @Override
+ public void process() throws ServletException, IOException, LoginException
+ {
+ if (AUTH_TYPE_BASIC.equals(authType))
+ processBasicAuth(httpRequest, httpResponse, chain);
+ else if (AUTH_TYPE_DIGEST.equals(authType))
+ processDigestAuth(httpRequest, httpResponse, chain);
+ else
+ throw new ServletException("Invalid authentication type");
+ }
+ }.run();
}
private void processBasicAuth(HttpServletRequest request,
HttpServletResponse response, FilterChain chain)
throws IOException, ServletException
{
- Context ctx = new SessionContext( new ServletRequestSessionMap(request) );
- Identity identity = (Identity) ctx.get(Identity.class);
+ Identity identity = Identity.instance();
if (identity == null)
{
throw new ServletException("Identity not found - please ensure that the Identity component is created on startup.");
}
- Credentials credentials = (Credentials) ctx.get(Credentials.class);
+ Credentials credentials = identity.getCredentials();
boolean requireAuth = false;
@@ -202,15 +204,14 @@
HttpServletResponse response, FilterChain chain)
throws IOException, ServletException
{
- Context ctx = new SessionContext( new ServletRequestSessionMap(request) );
- Identity identity = (Identity) ctx.get(Identity.class);
+ Identity identity = Identity.instance();
if (identity == null)
{
throw new ServletException("Identity not found - please ensure that the Identity component is created on startup.");
}
- Credentials credentials = (Credentials) ctx.get(Credentials.class);
+ Credentials credentials = identity.getCredentials();
boolean requireAuth = false;
boolean nonceExpired = false;
@@ -301,19 +302,11 @@
}
}
- private void authenticate(HttpServletRequest request, final String username)
- throws ServletException, IOException
+ private void authenticate(HttpServletRequest request, final String username) throws ServletException, IOException, LoginException
{
- new ContextualHttpServletRequest(request)
- {
- @Override
- public void process() throws ServletException, IOException, LoginException
- {
- Identity identity = Identity.instance();
- identity.getCredentials().setUsername(username);
- identity.authenticate();
- }
- }.run();
+ Identity identity = Identity.instance();
+ identity.getCredentials().setUsername(username);
+ identity.authenticate();
}
private String[] split(String toSplit, String delimiter)
13 years, 9 months
Seam SVN: r13489 - in modules/persistence/trunk/impl/src: test/java/org/jboss/seam/persistence/test and 1 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-23 08:23:58 -0400 (Fri, 23 Jul 2010)
New Revision: 13489
Added:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionBeanLifecycle.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java
Removed:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Transaction.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionQualifier.java
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java
Log:
change implementaion of the default SeamTransaction bean
Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Transaction.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Transaction.java 2010-07-23 11:52:57 UTC (rev 13488)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Transaction.java 2010-07-23 12:23:58 UTC (rev 13489)
@@ -1,110 +0,0 @@
-/*
- * 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.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.persistence.transaction;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.weld.extensions.managedproducer.ManagedProducer;
-
-/**
- * Supports injection of a Seam UserTransaction object that wraps the current
- * JTA transaction or EJB container managed transaction.
- *
- * @author Mike Youngstrom
- * @author Gavin King
- * @author Stuart Douglas
- *
- */
-@ApplicationScoped
-public class Transaction
-{
-
- @Inject
- Synchronizations synchronizations;
-
- @ManagedProducer
- @TransactionQualifier
- public SeamTransaction getTransaction() throws NamingException
- {
- try
- {
- return createUTTransaction();
- }
- catch (NameNotFoundException nnfe)
- {
- try
- {
- return createCMTTransaction();
- }
- catch (NameNotFoundException nnfe2)
- {
- return createNoTransaction();
- }
- }
- }
-
- protected SeamTransaction createNoTransaction()
- {
- return new NoTransaction();
- }
-
- protected SeamTransaction createCMTTransaction() throws NamingException
- {
- return new CMTTransaction(EJB.getEJBContext(), synchronizations);
- }
-
- protected SeamTransaction createUTTransaction() throws NamingException
- {
- return new UTTransaction(getUserTransaction(), synchronizations);
- }
-
- protected javax.transaction.UserTransaction getUserTransaction() throws NamingException
- {
- InitialContext context = Naming.getInitialContext();
- try
- {
- return (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction");
- }
- catch (NameNotFoundException nnfe)
- {
- try
- {
- // Embedded JBoss has no java:comp/UserTransaction
- javax.transaction.UserTransaction ut = (javax.transaction.UserTransaction) context.lookup("UserTransaction");
- ut.getStatus(); // for glassfish, which can return an unusable UT
- return ut;
- }
- catch (Exception e)
- {
- throw nnfe;
- }
- }
- }
-
-}
-
-
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionBeanLifecycle.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionBeanLifecycle.java 2010-07-23 12:23:58 UTC (rev 13489)
@@ -0,0 +1,66 @@
+/**
+ *
+ */
+package org.jboss.seam.persistence.transaction;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.weld.extensions.bean.BeanImpl;
+import org.jboss.weld.extensions.bean.BeanLifecycle;
+
+/**
+ * BeanLifecycle for the default SeamTransaction bean
+ *
+ * @author Stuart Douglas
+ *
+ */
+class TransactionBeanLifecycle implements BeanLifecycle<SeamTransaction>
+{
+ /**
+ * proxy class for SeamTransaction
+ */
+ private static final Class proxy = Proxy.getProxyClass(SeamTransaction.class.getClassLoader(), SeamTransaction.class);
+
+ private static final Constructor<SeamTransaction> proxyConstructor;
+
+ static
+ {
+ try
+ {
+ proxyConstructor = proxy.getConstructor(InvocationHandler.class);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private final BeanManager manager;
+
+ public TransactionBeanLifecycle(BeanManager manager)
+ {
+ this.manager = manager;
+ }
+
+ public SeamTransaction create(BeanImpl<SeamTransaction> bean, CreationalContext<SeamTransaction> ctx)
+ {
+ try
+ {
+ return proxyConstructor.newInstance(new TransactionInvocationHandler(manager));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void destroy(BeanImpl<SeamTransaction> bean, SeamTransaction arg0, CreationalContext<SeamTransaction> arg1)
+ {
+ arg1.release();
+ }
+}
\ No newline at end of file
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java 2010-07-23 11:52:57 UTC (rev 13488)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java 2010-07-23 12:23:58 UTC (rev 13489)
@@ -21,9 +21,7 @@
*/
package org.jboss.seam.persistence.transaction;
-import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
@@ -31,8 +29,6 @@
import org.jboss.seam.persistence.transaction.literal.DefaultTransactionLiteral;
import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
import org.jboss.weld.extensions.bean.BeanBuilder;
-import org.jboss.weld.extensions.bean.BeanImpl;
-import org.jboss.weld.extensions.bean.BeanLifecycle;
import org.jboss.weld.extensions.defaultbean.DefaultBeanExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,52 +58,10 @@
AnnotatedTypeBuilder<SeamTransaction> utbuilder = AnnotatedTypeBuilder.newInstance(SeamTransaction.class);
BeanBuilder<SeamTransaction> builder = new BeanBuilder<SeamTransaction>(utbuilder.create(), manager);
builder.defineBeanFromAnnotatedType();
- builder.setBeanLifecycle(new TransactionLifecycle(manager));
+ builder.setBeanLifecycle(new TransactionBeanLifecycle(manager));
builder.getQualifiers().clear();
builder.getQualifiers().add(DefaultTransactionLiteral.INSTANCE);
DefaultBeanExtension.addDefaultBean(SeamTransaction.class, builder.create());
}
- private static class TransactionLifecycle implements BeanLifecycle<SeamTransaction>
- {
-
- private final BeanManager manager;
-
- private Bean<?> transactionBean;
-
- public TransactionLifecycle(BeanManager manager)
- {
- this.manager = manager;
- }
-
- public SeamTransaction create(BeanImpl<SeamTransaction> bean, CreationalContext<SeamTransaction> ctx)
- {
- if (transactionBean == null)
- {
- // this does not need to be thread safe, it does not matter if this
- // is initialised twice
- setupBeanDefinition();
- }
- return (SeamTransaction) manager.getReference(transactionBean, SeamTransaction.class, ctx);
- }
-
- public void destroy(BeanImpl<SeamTransaction> bean, SeamTransaction arg0, CreationalContext<SeamTransaction> arg1)
- {
- arg1.release();
- }
-
- /**
- * we need to init the bean definition lazily
- */
- private void setupBeanDefinition()
- {
- transactionBean = (Bean) manager.resolve(manager.getBeans(SeamTransaction.class, new TransactionQualifier.TransactionQualifierLiteral()));
- if (transactionBean == null)
- {
- throw new RuntimeException("Could not find SeamTransaction bean with qualifier " + DefaultTransaction.class.getName());
- }
- }
-
- }
-
}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java 2010-07-23 12:23:58 UTC (rev 13489)
@@ -0,0 +1,94 @@
+package org.jboss.seam.persistence.transaction;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jboss.weld.extensions.literal.DefaultLiteral;
+
+/**
+ * Invocation handler for the default SeamTransaction proxy
+ *
+ * Supports injection of a Seam UserTransaction object that wraps the current
+ * JTA transaction or EJB container managed transaction.
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class TransactionInvocationHandler implements InvocationHandler
+{
+
+ private final Synchronizations synchronizations;
+
+ public TransactionInvocationHandler(BeanManager manager)
+ {
+ Bean<Synchronizations> bean = (Bean) manager.resolve(manager.getBeans(Synchronizations.class, DefaultLiteral.INSTANCE));
+ CreationalContext<Synchronizations> ctx = manager.createCreationalContext(bean);
+ synchronizations = (Synchronizations) manager.getReference(bean, Synchronizations.class, ctx);
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ SeamTransaction instance;
+ try
+ {
+ instance = createUTTransaction();
+ }
+ catch (NameNotFoundException nnfe)
+ {
+ try
+ {
+ instance = createCMTTransaction();
+ }
+ catch (NameNotFoundException nnfe2)
+ {
+ instance = createNoTransaction();
+ }
+ }
+ return method.invoke(instance, args);
+ }
+
+ protected SeamTransaction createNoTransaction()
+ {
+ return new NoTransaction();
+ }
+
+ protected SeamTransaction createCMTTransaction() throws NamingException
+ {
+ return new CMTTransaction(EJB.getEJBContext(), synchronizations);
+ }
+
+ protected SeamTransaction createUTTransaction() throws NamingException
+ {
+ return new UTTransaction(getUserTransaction(), synchronizations);
+ }
+
+ protected javax.transaction.UserTransaction getUserTransaction() throws NamingException
+ {
+ InitialContext context = Naming.getInitialContext();
+ try
+ {
+ return (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction");
+ }
+ catch (NameNotFoundException nnfe)
+ {
+ try
+ {
+ // Embedded JBoss has no java:comp/UserTransaction
+ javax.transaction.UserTransaction ut = (javax.transaction.UserTransaction) context.lookup("UserTransaction");
+ ut.getStatus(); // for glassfish, which can return an unusable UT
+ return ut;
+ }
+ catch (Exception e)
+ {
+ throw nnfe;
+ }
+ }
+ }
+}
Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionQualifier.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionQualifier.java 2010-07-23 11:52:57 UTC (rev 13488)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionQualifier.java 2010-07-23 12:23:58 UTC (rev 13489)
@@ -1,44 +0,0 @@
-/*
- * 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.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.persistence.transaction;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Qualifier;
-
-/**
- * Internal qualifier that is used to stop some beans from being exposed to the
- * user
- *
- * @author Stuart Douglas
- *
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-@Qualifier
-@interface TransactionQualifier
-{
- public static class TransactionQualifierLiteral extends AnnotationLiteral<TransactionQualifier> implements TransactionQualifier
- {
- }
-}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionalInterceptorBinding.java 2010-07-23 12:23:58 UTC (rev 13489)
@@ -0,0 +1,22 @@
+package org.jboss.seam.persistence.transaction;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * Interceptor binding for {@link Transactional} beans
+ *
+ * @author Stuart Douglas
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+@InterceptorBinding
+@Target( { ElementType.TYPE, ElementType.METHOD })
+public @interface TransactionalInterceptorBinding
+{
+
+}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-07-23 11:52:57 UTC (rev 13488)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-07-23 12:23:58 UTC (rev 13489)
@@ -17,7 +17,7 @@
import org.jboss.seam.persistence.PersistenceContextExtension;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.Transaction;
+import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
@@ -38,7 +38,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(Transaction.class.getPackage());
+ war.addPackage(TransactionExtension.class.getPackage());
war.addPackage(PersistenceContextExtension.class.getPackage());
war.addClasses(ManagedPersistenceContextTest.class, Hotel.class, ManagedPersistenceContextProvider.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-07-23 11:52:57 UTC (rev 13488)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-07-23 12:23:58 UTC (rev 13489)
@@ -38,7 +38,7 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.Transaction;
+import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.persistence.transaction.TransactionInterceptor;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.DontRollBackException;
@@ -68,7 +68,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(Transaction.class.getPackage());
+ war.addPackage(TransactionExtension.class.getPackage());
war.addClasses(TransactionInterceptorTest.class, TransactionManagedBean.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java 2010-07-23 11:52:57 UTC (rev 13488)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java 2010-07-23 12:23:58 UTC (rev 13489)
@@ -15,7 +15,7 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.Transaction;
+import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.Hotel;
@@ -36,7 +36,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(Transaction.class.getPackage());
+ war.addPackage(TransactionExtension.class.getPackage());
war.addPackage(TransactionScopeExtension.class.getPackage());
war.addClasses(TransactionScopedTest.class, Hotel.class, TransactionScopedObject.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java 2010-07-23 11:52:57 UTC (rev 13488)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java 2010-07-23 12:23:58 UTC (rev 13489)
@@ -17,7 +17,7 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.Transaction;
+import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
@@ -37,7 +37,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(Transaction.class.getPackage());
+ war.addPackage(TransactionExtension.class.getPackage());
war.addClasses(UserTransactionTest.class, Hotel.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
13 years, 9 months
Seam SVN: r13488 - branches/community/Seam_2_2/src/test/ftest/examples.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-23 07:52:57 -0400 (Fri, 23 Jul 2010)
New Revision: 13488
Modified:
branches/community/Seam_2_2/src/test/ftest/examples/build.xml
Log:
upgrade of selenium-server a client to 1.0.3 and 1.0.2
Modified: branches/community/Seam_2_2/src/test/ftest/examples/build.xml
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/examples/build.xml 2010-07-23 11:48:34 UTC (rev 13487)
+++ branches/community/Seam_2_2/src/test/ftest/examples/build.xml 2010-07-23 11:52:57 UTC (rev 13488)
@@ -360,13 +360,13 @@
<target name="copy.selenium" unless="copy.selenium.done">
<copyInlineDependencies id="selenium.server" scope="compile" todir="${ftest.lib.dir}">
- <dependency groupId="org.seleniumhq.selenium.server" artifactId="selenium-server" version="1.0.1" classifier="standalone">
+ <dependency groupId="org.seleniumhq.selenium.server" artifactId="selenium-server" version="1.0.3" classifier="standalone">
<exclusion groupId="org.seleniumhq.selenium.core" artifactId="selenium-core" />
<exclusion groupId="org.seleniumhq.selenium.server" artifactId="selenium-server-coreless" />
<exclusion groupId="org.apache.ant" artifactId="ant-trax" />
<exclusion groupId="org.apache.ant" artifactId="ant-nodeps" />
</dependency>
- <dependency groupId="org.seleniumhq.selenium.client-drivers" artifactId="selenium-java-client-driver" version="1.0.1">
+ <dependency groupId="org.seleniumhq.selenium.client-drivers" artifactId="selenium-java-client-driver" version="1.0.2">
<exclusion groupId="org.codehaus.groovy.maven.runtime" artifactId="gmaven-runtime-default" />
</dependency>
<dependency groupId="org.subethamail" artifactId="subethasmtp-smtp" version="1.2" >
13 years, 9 months