Seam SVN: r8923 - in trunk/src: main/org/jboss/seam/deployment and 1 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-09-05 12:52:07 -0400 (Fri, 05 Sep 2008)
New Revision: 8923
Modified:
trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java
trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java
trunk/src/main/org/jboss/seam/init/Initialization.java
Log:
JBSEAM-3366
Modified: trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java
===================================================================
--- trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java 2008-09-05 12:12:51 UTC (rev 8922)
+++ trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java 2008-09-05 16:52:07 UTC (rev 8923)
@@ -54,7 +54,6 @@
}
//TODO: check the timestamp, for a minor optimization
-
// instead
Pages pages = (Pages) getServletContext().getAttribute(Seam.getComponentName(Pages.class));
if (pages!= null) {
Modified: trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java 2008-09-05 12:12:51 UTC (rev 8922)
+++ trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java 2008-09-05 16:52:07 UTC (rev 8923)
@@ -70,13 +70,17 @@
{
try
{
- if (hotDeployDirectory.exists())
+ if (hotDeployDirectory != null)
{
URL url = hotDeployDirectory.toURL();
URL[] urls = { url };
hotDeployClassLoader = new URLClassLoader(urls, classLoader);
getFiles().add(hotDeployDirectory);
}
+ else
+ {
+ hotDeployClassLoader = classLoader;
+ }
}
catch (MalformedURLException mue)
Modified: trunk/src/main/org/jboss/seam/init/Initialization.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/Initialization.java 2008-09-05 12:12:51 UTC (rev 8922)
+++ trunk/src/main/org/jboss/seam/init/Initialization.java 2008-09-05 16:52:07 UTC (rev 8923)
@@ -627,10 +627,6 @@
}
init.checkDefaultInterceptors();
init.setTimestamp( System.currentTimeMillis() );
- if (hotDeploymentStrategy != null)
- {
- init.setHotDeployPaths( hotDeploymentStrategy.getHotDeploymentPaths() );
- }
addSpecialComponents(init);
// Make the deployment strategies available in the contexts. This gives
@@ -645,6 +641,9 @@
{
hotDeploymentStrategy.scan();
installHotDeployableComponents();
+ // TODO Hack
+ hotDeploymentStrategy.getFiles().add(warRootDirectory);
+ init.setHotDeployPaths( hotDeploymentStrategy.getHotDeploymentPaths() );
}
for (String globalImport: globalImports)
@@ -682,7 +681,6 @@
hotDeploymentStrategy.scan();
installHotDeployableComponents();
Contexts.getEventContext().set(HotDeploymentStrategy.NAME, hotDeploymentStrategy);
- // Add the WAR root to the hot deploy path to pick up .page.xml
Pages.instance().setHotDotPageDotXmlFileNames(DotPageDotXmlDeploymentHandler.hotInstance().getFiles());
init.setTimestamp( System.currentTimeMillis() );
init.setHotDeployPaths(hotDeploymentStrategy.getHotDeploymentPaths());
@@ -702,7 +700,7 @@
private HotDeploymentStrategy createHotDeployment(ClassLoader classLoader)
{
- if ( isDebugEnabled() && hotDeployDirectory != null )
+ if ( isDebugEnabled() )
{
if (isGroovyPresent())
{
@@ -1040,7 +1038,7 @@
descriptor.getJndiName()
);
context.set(componentName, component);
- if ( hotDeploymentStrategy != null && hotDeploymentStrategy.isFromHotDeployClassLoader( descriptor.getComponentClass() ) )
+ if ( hotDeploymentStrategy != null && !hotDeploymentStrategy.getClassLoader().equals(getClass().getClassLoader()) && hotDeploymentStrategy.isFromHotDeployClassLoader( descriptor.getComponentClass() ) )
{
Init.instance().addHotDeployableComponent( component.getName() );
}
15 years, 8 months
Seam SVN: r8922 - branches/Seam_2_0/build.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2008-09-05 08:12:51 -0400 (Fri, 05 Sep 2008)
New Revision: 8922
Modified:
branches/Seam_2_0/build/ui.pom.xml
Log:
JBSEAM-3292 backport
Modified: branches/Seam_2_0/build/ui.pom.xml
===================================================================
--- branches/Seam_2_0/build/ui.pom.xml 2008-09-05 11:59:24 UTC (rev 8921)
+++ branches/Seam_2_0/build/ui.pom.xml 2008-09-05 12:12:51 UTC (rev 8922)
@@ -190,6 +190,12 @@
<version>5.1</version>
<scope>test</scope>
<classifier>jdk15</classifier>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
15 years, 8 months
Seam SVN: r8921 - branches/Seam_2_0/build.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-09-05 07:59:24 -0400 (Fri, 05 Sep 2008)
New Revision: 8921
Modified:
branches/Seam_2_0/build/root.pom.xml
Log:
fix build
Modified: branches/Seam_2_0/build/root.pom.xml
===================================================================
--- branches/Seam_2_0/build/root.pom.xml 2008-09-05 11:44:10 UTC (rev 8920)
+++ branches/Seam_2_0/build/root.pom.xml 2008-09-05 11:59:24 UTC (rev 8921)
@@ -220,12 +220,6 @@
</exclusion>
</exclusions>
</dependency>
-
- <dependency>
- <groupId>commons-digester</groupId>
- <artifactId>commons-digester</artifactId>
- <version>1.7</version>
- </dependency>
<dependency>
<groupId>org.jbpm</groupId>
@@ -336,12 +330,49 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <version>1.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
</dependency>
+
+ <!-- Should be 1.0.5.GA-jboss, to be in sync with AS but doesn't exist in Maven -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>javax.persistence</groupId>
15 years, 8 months
Seam SVN: r8920 - trunk/src/main/org/jboss/seam.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-09-05 07:44:10 -0400 (Fri, 05 Sep 2008)
New Revision: 8920
Modified:
trunk/src/main/org/jboss/seam/pages-2.1.xsd
Log:
Some fixes to the xsd from Arron Ferguson
Modified: trunk/src/main/org/jboss/seam/pages-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/pages-2.1.xsd 2008-09-05 10:49:51 UTC (rev 8919)
+++ trunk/src/main/org/jboss/seam/pages-2.1.xsd 2008-09-05 11:44:10 UTC (rev 8920)
@@ -9,20 +9,18 @@
<xs:documentation>The root of a pages.xml file</xs:documentation>
</xs:annotation>
<xs:complexType>
- <xs:sequence>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="pages:conversation"/>
- <xs:element ref="pages:page"/>
- </xs:choice>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="pages:conversation"/>
+ <xs:element ref="pages:page"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="pages:exception"/>
- </xs:sequence>
+ </xs:choice>
<xs:attributeGroup ref="pages:attlist.pages"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="attlist.pages">
- <xs:attribute name="no-conversation-view-id" />
- <xs:attribute name="login-view-id" />
+ <xs:attribute name="no-conversation-view-id" type="pages:view-id" />
+ <xs:attribute name="login-view-id" type="pages:view-id"/>
<xs:attribute name="http-port" />
<xs:attribute name="https-port" />
</xs:attributeGroup>
@@ -90,7 +88,7 @@
</xs:element>
<xs:attributeGroup name="attlist.page">
<xs:attribute name="action"/>
- <xs:attribute name="view-id"/>
+ <xs:attribute name="view-id" type="pages:view-id"/>
<xs:attribute name="switch" default="enabled">
<xs:simpleType>
<xs:restriction base="xs:token">
@@ -99,7 +97,7 @@
</xs:restriction>
</xs:simpleType>
</xs:attribute>
- <xs:attribute name="no-conversation-view-id"/>
+ <xs:attribute name="no-conversation-view-id" type="pages:view-id" />
<xs:attribute name="conversation-required" default="false">
<xs:simpleType>
<xs:restriction base="xs:token">
@@ -503,7 +501,7 @@
</xs:complexType>
</xs:element>
<xs:attributeGroup name="attlist.render">
- <xs:attribute name="view-id"/>
+ <xs:attribute name="view-id" type="pages:view-id" />
</xs:attributeGroup>
<xs:element name="redirect">
@@ -520,7 +518,7 @@
</xs:complexType>
</xs:element>
<xs:attributeGroup name="attlist.redirect">
- <xs:attribute name="view-id"/>
+ <xs:attribute name="view-id" type="pages:view-id" />
<xs:attribute name="url"/>
</xs:attributeGroup>
@@ -536,7 +534,7 @@
</xs:complexType>
</xs:element>
<xs:attributeGroup name="attlist.http-error">
- <xs:attribute name="error-code"/>
+ <xs:attribute name="error-code" use="required"/>
</xs:attributeGroup>
<xs:element name="message">
@@ -565,6 +563,12 @@
</xs:attribute>
</xs:attributeGroup>
+ <xs:simpleType name="view-id">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="(/.*)|\*"/>
+ </xs:restriction>
+ </xs:simpleType>
+
<xs:element name="description" type="xs:string">
<xs:annotation>
<xs:documentation>A page description for workflow switching</xs:documentation>
15 years, 8 months
Seam SVN: r8919 - in trunk/src/main/org/jboss/seam: persistence and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-09-05 06:49:51 -0400 (Fri, 05 Sep 2008)
New Revision: 8919
Added:
trunk/src/main/org/jboss/seam/persistence/ManagedEntityInterceptor.java
trunk/src/main/org/jboss/seam/persistence/ManagedEntityWrapper.java
Removed:
trunk/src/main/org/jboss/seam/persistence/ManagedEntityIdentityInterceptor.java
trunk/src/main/org/jboss/seam/persistence/ManagedEntityStateManager.java
Modified:
trunk/src/main/org/jboss/seam/contexts/PassivatedEntity.java
Log:
Slight refactor of MEII, add logging
Modified: trunk/src/main/org/jboss/seam/contexts/PassivatedEntity.java
===================================================================
--- trunk/src/main/org/jboss/seam/contexts/PassivatedEntity.java 2008-09-05 10:43:40 UTC (rev 8918)
+++ trunk/src/main/org/jboss/seam/contexts/PassivatedEntity.java 2008-09-05 10:49:51 UTC (rev 8919)
@@ -17,7 +17,7 @@
* id and persistence context name.
*
* @see EntityBean
- * @see org.jboss.seam.persistence.ManagedEntityIdentityInterceptor
+ * @see org.jboss.seam.persistence.ManagedEntityInterceptor
*
* @author Gavin King
*
Deleted: trunk/src/main/org/jboss/seam/persistence/ManagedEntityIdentityInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/persistence/ManagedEntityIdentityInterceptor.java 2008-09-05 10:43:40 UTC (rev 8918)
+++ trunk/src/main/org/jboss/seam/persistence/ManagedEntityIdentityInterceptor.java 2008-09-05 10:49:51 UTC (rev 8919)
@@ -1,73 +0,0 @@
-package org.jboss.seam.persistence;
-
-import static org.jboss.seam.ScopeType.CONVERSATION;
-
-import org.jboss.seam.annotations.intercept.AroundInvoke;
-import org.jboss.seam.annotations.intercept.Interceptor;
-import org.jboss.seam.core.BijectionInterceptor;
-import org.jboss.seam.intercept.AbstractInterceptor;
-import org.jboss.seam.intercept.InvocationContext;
-import org.jboss.seam.transaction.Transaction;
-
-/**
- * Swizzles entity references around each invocation, maintaining referential
- * integrity even across passivation of the stateful bean or Seam-managed
- * extended persistence context, and allowing for more efficient replication.
- *
- * @author Gavin King
- *
- */
-@Interceptor(around = BijectionInterceptor.class)
-public class ManagedEntityIdentityInterceptor extends AbstractInterceptor
-{
-
- private static ManagedEntityStateManager managedEntityStateManager = new ManagedEntityStateManager();
-
- private boolean reentrant;
-
- // TODO: cache the non-ignored fields, probably on Component
-
- public boolean isInterceptorEnabled()
- {
- return getComponent().getScope() == CONVERSATION;
- }
-
- @AroundInvoke
- public Object aroundInvoke(InvocationContext ctx) throws Exception
- {
- if (reentrant)
- {
- return ctx.proceed();
- }
- else
- {
- reentrant = true;
- managedEntityStateManager.entityIdsToRefs(ctx.getTarget(), getComponent());
- try
- {
- return ctx.proceed();
- }
- finally
- {
- if (!isTransactionRolledBackOrMarkedRollback())
- {
- managedEntityStateManager.entityRefsToIds(ctx.getTarget(), getComponent());
- reentrant = false;
- }
- }
- }
- }
-
- private static boolean isTransactionRolledBackOrMarkedRollback()
- {
- try
- {
- return Transaction.instance().isRolledBackOrMarkedRollback();
- }
- catch (Exception e)
- {
- return false;
- }
- }
-
-}
Copied: trunk/src/main/org/jboss/seam/persistence/ManagedEntityInterceptor.java (from rev 8912, trunk/src/main/org/jboss/seam/persistence/ManagedEntityIdentityInterceptor.java)
===================================================================
--- trunk/src/main/org/jboss/seam/persistence/ManagedEntityInterceptor.java (rev 0)
+++ trunk/src/main/org/jboss/seam/persistence/ManagedEntityInterceptor.java 2008-09-05 10:49:51 UTC (rev 8919)
@@ -0,0 +1,91 @@
+package org.jboss.seam.persistence;
+
+import static org.jboss.seam.ScopeType.CONVERSATION;
+
+import java.io.Serializable;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.ComponentType;
+import org.jboss.seam.annotations.intercept.AroundInvoke;
+import org.jboss.seam.annotations.intercept.Interceptor;
+import org.jboss.seam.annotations.intercept.PostActivate;
+import org.jboss.seam.annotations.intercept.PrePassivate;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.BijectionInterceptor;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.intercept.AbstractInterceptor;
+import org.jboss.seam.intercept.InvocationContext;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.transaction.Transaction;
+import org.jboss.seam.web.Session;
+
+/**
+ * Swizzles entity references around each invocation, maintaining referential
+ * integrity even across passivation of the stateful bean or Seam-managed
+ * extended persistence context, and allowing for more efficient replication.
+ *
+ * @author Gavin King
+ * @author Pete Muir
+ *
+ */
+@Interceptor(around = BijectionInterceptor.class)
+public class ManagedEntityInterceptor extends AbstractInterceptor
+{
+
+ private static LogProvider log = Logging.getLogProvider(ManagedEntityInterceptor.class);
+
+ private static ManagedEntityWrapper managedEntityWrapper = new ManagedEntityWrapper();
+
+ private boolean reentrant;
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ if (reentrant)
+ {
+ return ctx.proceed();
+ }
+ else
+ {
+ reentrant = true;
+ log.trace("Attempting to activate " + getComponent().getName() + " component");
+ managedEntityWrapper.deserialize(ctx.getTarget(), getComponent());
+ log.debug("Activated " + getComponent().getName() + " component");
+ try
+ {
+ return ctx.proceed();
+ }
+ finally
+ {
+ if (!isTransactionRolledBackOrMarkedRollback())
+ {
+ log.trace("Attempting to passivate " + getComponent().getName() + " component");
+ managedEntityWrapper.wrap(ctx.getTarget(), getComponent());
+ reentrant = false;
+ log.debug("Passivated " + getComponent().getName() + " component");
+ }
+ }
+ }
+ }
+
+
+
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().getScope() == CONVERSATION;
+ }
+
+ private static boolean isTransactionRolledBackOrMarkedRollback()
+ {
+ try
+ {
+ return Transaction.instance().isRolledBackOrMarkedRollback();
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+
+}
Property changes on: trunk/src/main/org/jboss/seam/persistence/ManagedEntityInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/src/main/org/jboss/seam/persistence/ManagedEntityStateManager.java
===================================================================
--- trunk/src/main/org/jboss/seam/persistence/ManagedEntityStateManager.java 2008-09-05 10:43:40 UTC (rev 8918)
+++ trunk/src/main/org/jboss/seam/persistence/ManagedEntityStateManager.java 2008-09-05 10:49:51 UTC (rev 8919)
@@ -1,162 +0,0 @@
-package org.jboss.seam.persistence;
-
-import static org.jboss.seam.util.JSF.DATA_MODEL;
-import static org.jboss.seam.util.JSF.getWrappedData;
-import static org.jboss.seam.util.JSF.setWrappedData;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.Seam;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.util.Reflections;
-
-/**
- * @author Gavin King
- * @author Pete Muir
- * @author Norman Richards
- *
- */
-public class ManagedEntityStateManager
-{
-
- public void entityRefsToIds(Object controllerBean, Component component) throws Exception
- {
- if ( touchedContextsExist() )
- {
- Class beanClass = controllerBean.getClass();
- for (; beanClass!=Object.class; beanClass=beanClass.getSuperclass())
- {
- for ( Field field: beanClass.getDeclaredFields() )
- {
- if ( !ignore(field) )
- {
- Object value = getFieldValue(controllerBean, field);
- if (value!=null)
- {
- Object dataModel = null;
- if ( DATA_MODEL.isInstance(value) )
- {
- dataModel = value;
- value = getWrappedData(dataModel);
- }
- if ( isRef(value) )
- {
- saveWrapper(controllerBean, component, field, dataModel, value);
- }
- else
- {
- clearWrapper(component, field);
- }
- }
- else
- {
- clearWrapper(component, field);
- }
- }
- }
- }
- }
- }
-
- public void entityIdsToRefs(Object controllerBean, Component component) throws Exception
- {
- if ( touchedContextsExist() )
- {
- Class beanClass = controllerBean.getClass();
- for (; beanClass!=Object.class; beanClass=beanClass.getSuperclass())
- {
- for ( Field field: beanClass.getDeclaredFields() )
- {
- if ( !ignore(field) )
- {
- Object value = getFieldValue(controllerBean, field);
- Object dataModel = null;
- if (value!=null && DATA_MODEL.isInstance(value) )
- {
- dataModel = value;
- }
- //TODO: be more selective
- getFromWrapper(controllerBean, component, field, dataModel);
- }
- }
- }
- }
- }
-
- private boolean isRef(Object value)
- {
- //TODO: could do better by checking if the
- // collection really contains an entity
- return value instanceof List ||
- value instanceof Map ||
- value instanceof Set ||
- Seam.getEntityClass(value.getClass()) != null;
- }
-
- private Object getFieldValue(Object bean, Field field) throws Exception
- {
- if ( !field.isAccessible() ) field.setAccessible(true);
- Object value = Reflections.get(field, bean);
- return value;
- }
-
- private boolean ignore(Field field)
- {
- return Modifier.isTransient( field.getModifiers() ) ||
- Modifier.isStatic( field.getModifiers() )
- || field.isAnnotationPresent(In.class);
- }
-
- private boolean touchedContextsExist()
- {
- PersistenceContexts touchedContexts = PersistenceContexts.instance();
- return touchedContexts!=null && touchedContexts.getTouchedContexts().size()>0;
- }
-
- private String getFieldId(Component component, Field field)
- {
- return component.getName() + '.' + field.getName();
- }
-
- private void saveWrapper(Object bean, Component component, Field field, Object dataModel, Object value) throws Exception
- {
- Contexts.getConversationContext().set( getFieldId(component, field), value );
- if (dataModel==null)
- {
- Reflections.set(field, bean, null);
- }
- else
- {
- setWrappedData(dataModel, null);
- }
- }
-
- private void clearWrapper(Component component, Field field) throws Exception
- {
- Contexts.getConversationContext().remove( getFieldId(component, field) );
- }
-
- private void getFromWrapper(Object bean, Component component, Field field, Object dataModel) throws Exception
- {
- Object value =Contexts.getConversationContext().get( getFieldId(component, field) );
- if (value!=null)
- {
- if (dataModel==null)
- {
- Reflections.set(field, bean, value);
- }
- else
- {
- setWrappedData(dataModel, value);
- }
- }
- }
-
-
-}
Copied: trunk/src/main/org/jboss/seam/persistence/ManagedEntityWrapper.java (from rev 8910, trunk/src/main/org/jboss/seam/persistence/ManagedEntityStateManager.java)
===================================================================
--- trunk/src/main/org/jboss/seam/persistence/ManagedEntityWrapper.java (rev 0)
+++ trunk/src/main/org/jboss/seam/persistence/ManagedEntityWrapper.java 2008-09-05 10:49:51 UTC (rev 8919)
@@ -0,0 +1,188 @@
+package org.jboss.seam.persistence;
+
+import static org.jboss.seam.util.JSF.DATA_MODEL;
+import static org.jboss.seam.util.JSF.getWrappedData;
+import static org.jboss.seam.util.JSF.setWrappedData;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.Seam;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.util.Reflections;
+
+/**
+ * @author Gavin King
+ * @author Pete Muir
+ * @author Norman Richards
+ *
+ */
+public class ManagedEntityWrapper
+{
+
+ private static LogProvider log = Logging.getLogProvider(ManagedEntityWrapper.class);
+
+ public void wrap(Object target, Component component) throws Exception
+ {
+ if ( touchedContextsExist() )
+ {
+ Class beanClass = target.getClass();
+ for (; beanClass!=Object.class; beanClass=beanClass.getSuperclass())
+ {
+ log.trace("Examining fields on " + beanClass);
+ for ( Field field: beanClass.getDeclaredFields() )
+ {
+ if ( !ignore(field) )
+ {
+ Object value = getFieldValue(target, field);
+ if (value!=null)
+ {
+ Object dataModel = null;
+ if ( DATA_MODEL.isInstance(value) )
+ {
+ dataModel = value;
+ value = getWrappedData(dataModel);
+ }
+ if ( isRef(value) )
+ {
+ log.trace("Attempting to save wrapper for " + field + " (" + value + ")");
+ saveWrapper(target, component, field, dataModel, value);
+ }
+ else
+ {
+ log.trace("Clearing wrapper for " + field + " (" + value + ") as it isn't a entity reference");
+ clearWrapper(component, field);
+ }
+ }
+ else
+ {
+ log.trace("Clearing wrapper for " + field + " as it is null");
+ clearWrapper(component, field);
+ }
+ }
+ else
+ {
+ log.trace("Ignoring field " + field + " as it is static, transient or annotated with @In");
+ }
+ }
+ }
+ }
+ else
+ {
+ log.trace("No touched persistence contexts");
+ }
+ }
+
+ public void deserialize(Object controllerBean, Component component) throws Exception
+ {
+ if ( touchedContextsExist() )
+ {
+ Class beanClass = controllerBean.getClass();
+ for (; beanClass!=Object.class; beanClass=beanClass.getSuperclass())
+ {
+ log.trace("Examining fields on " + beanClass);
+ for ( Field field: beanClass.getDeclaredFields() )
+ {
+ if ( !ignore(field) )
+ {
+ Object value = getFieldValue(controllerBean, field);
+ Object dataModel = null;
+ if (value!=null && DATA_MODEL.isInstance(value) )
+ {
+ dataModel = value;
+ }
+ log.trace("Attempting to restore wrapper for " + field + " (" + value + ")");
+ //TODO: be more selective
+ getFromWrapper(controllerBean, component, field, dataModel);
+ }
+ else
+ {
+ log.trace("Ignoring field " + field + " as it is static, transient or annotated with @In");
+ }
+ }
+ }
+ }
+ else
+ {
+ log.trace("No touched persistence contexts");
+ }
+ }
+
+ private boolean isRef(Object value)
+ {
+ //TODO: could do better by checking if the
+ // collection really contains an entity
+ return value instanceof List ||
+ value instanceof Map ||
+ value instanceof Set ||
+ Seam.getEntityClass(value.getClass()) != null;
+ }
+
+ private Object getFieldValue(Object bean, Field field) throws Exception
+ {
+ if ( !field.isAccessible() ) field.setAccessible(true);
+ Object value = Reflections.get(field, bean);
+ return value;
+ }
+
+ private boolean ignore(Field field)
+ {
+ return Modifier.isTransient( field.getModifiers() ) ||
+ Modifier.isStatic( field.getModifiers() )
+ || field.isAnnotationPresent(In.class);
+ }
+
+ private boolean touchedContextsExist()
+ {
+ PersistenceContexts touchedContexts = PersistenceContexts.instance();
+ return touchedContexts!=null && touchedContexts.getTouchedContexts().size()>0;
+ }
+
+ private String getFieldId(Component component, Field field)
+ {
+ return component.getName() + '.' + field.getName();
+ }
+
+ private void saveWrapper(Object bean, Component component, Field field, Object dataModel, Object value) throws Exception
+ {
+ Contexts.getConversationContext().set( getFieldId(component, field), value );
+ if (dataModel==null)
+ {
+ Reflections.set(field, bean, null);
+ }
+ else
+ {
+ setWrappedData(dataModel, null);
+ }
+ }
+
+ private void clearWrapper(Component component, Field field) throws Exception
+ {
+ Contexts.getConversationContext().remove( getFieldId(component, field) );
+ }
+
+ private void getFromWrapper(Object bean, Component component, Field field, Object dataModel) throws Exception
+ {
+ Object value =Contexts.getConversationContext().get( getFieldId(component, field) );
+ if (value!=null)
+ {
+ if (dataModel==null)
+ {
+ Reflections.set(field, bean, value);
+ }
+ else
+ {
+ setWrappedData(dataModel, value);
+ }
+ }
+ }
+
+
+}
Property changes on: trunk/src/main/org/jboss/seam/persistence/ManagedEntityWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 8 months
Seam SVN: r8918 - in trunk/src/main/org/jboss/seam: intercept and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-09-05 06:43:40 -0400 (Fri, 05 Sep 2008)
New Revision: 8918
Added:
trunk/src/main/org/jboss/seam/annotations/intercept/PostActivate.java
trunk/src/main/org/jboss/seam/annotations/intercept/PrePassivate.java
Modified:
trunk/src/main/org/jboss/seam/intercept/Interceptor.java
trunk/src/main/org/jboss/seam/intercept/OptimizedInterceptor.java
Log:
Add pree EE5 synonyms for PostActivate and PrePassivate
Added: trunk/src/main/org/jboss/seam/annotations/intercept/PostActivate.java
===================================================================
--- trunk/src/main/org/jboss/seam/annotations/intercept/PostActivate.java (rev 0)
+++ trunk/src/main/org/jboss/seam/annotations/intercept/PostActivate.java 2008-09-05 10:43:40 UTC (rev 8918)
@@ -0,0 +1,20 @@
+//$Id: AroundInvoke.java 5522 2007-06-25 22:28:50Z gavin $
+package org.jboss.seam.annotations.intercept;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Synonym for {@link javax.ejb.PostActivate}, for
+ * use in a pre Java EE 5 environment.
+ *
+ * @author Pete Muir
+ */
+@Target(METHOD)
+@Retention(RUNTIME)
+@Documented
+public @interface PostActivate {}
Property changes on: trunk/src/main/org/jboss/seam/annotations/intercept/PostActivate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/main/org/jboss/seam/annotations/intercept/PrePassivate.java
===================================================================
--- trunk/src/main/org/jboss/seam/annotations/intercept/PrePassivate.java (rev 0)
+++ trunk/src/main/org/jboss/seam/annotations/intercept/PrePassivate.java 2008-09-05 10:43:40 UTC (rev 8918)
@@ -0,0 +1,20 @@
+//$Id: AroundInvoke.java 5522 2007-06-25 22:28:50Z gavin $
+package org.jboss.seam.annotations.intercept;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Synonym for {@link javax.ejb.PrePassivate}, for
+ * use in a pre Java EE 5 environment.
+ *
+ * @author Pete Muir
+ */
+@Target(METHOD)
+@Retention(RUNTIME)
+@Documented
+public @interface PrePassivate {}
Property changes on: trunk/src/main/org/jboss/seam/annotations/intercept/PrePassivate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/src/main/org/jboss/seam/intercept/Interceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/intercept/Interceptor.java 2008-09-05 10:11:52 UTC (rev 8917)
+++ trunk/src/main/org/jboss/seam/intercept/Interceptor.java 2008-09-05 10:43:40 UTC (rev 8918)
@@ -13,6 +13,8 @@
import org.jboss.seam.Component;
import org.jboss.seam.annotations.intercept.AroundInvoke;
import org.jboss.seam.annotations.intercept.InterceptorType;
+import org.jboss.seam.annotations.intercept.PostActivate;
+import org.jboss.seam.annotations.intercept.PrePassivate;
import org.jboss.seam.util.Reflections;
/**
@@ -137,11 +139,11 @@
{
preDestroyMethod = method;
}
- if ( method.isAnnotationPresent(PRE_PASSIVATE) )
+ if ( method.isAnnotationPresent(PRE_PASSIVATE) || method.isAnnotationPresent(PrePassivate.class) )
{
prePassivateMethod = method;
}
- if ( method.isAnnotationPresent(POST_ACTIVATE) )
+ if ( method.isAnnotationPresent(POST_ACTIVATE) || method.isAnnotationPresent(PostActivate.class) )
{
postActivateMethod = method;
}
@@ -232,7 +234,14 @@
{
Reflections.invokeAndWrap(annotationInjectorMethod, statelessUserInterceptorInstance, annotation);
}
- return ((Boolean) Reflections.invokeAndWrap(interceptorEnabledMethod, statelessUserInterceptorInstance));
+ if (isOptimized())
+ {
+ return ( (OptimizedInterceptor) statelessUserInterceptorInstance ).isInterceptorEnabled();
+ }
+ else
+ {
+ return ((Boolean) Reflections.invokeAndWrap(interceptorEnabledMethod, statelessUserInterceptorInstance));
+ }
}
else
{
Modified: trunk/src/main/org/jboss/seam/intercept/OptimizedInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/intercept/OptimizedInterceptor.java 2008-09-05 10:11:52 UTC (rev 8917)
+++ trunk/src/main/org/jboss/seam/intercept/OptimizedInterceptor.java 2008-09-05 10:43:40 UTC (rev 8918)
@@ -5,9 +5,20 @@
* interceptor, to make the stacktrace smaller.
*
* @author Gavin King
+ * @author Pete Muir
*
*/
public interface OptimizedInterceptor
{
+
public Object aroundInvoke(InvocationContext ic) throws Exception;
+
+ /**
+ * Returns true if this interceptor should be enabled. The component and the
+ * annotation will be injected into the interceptor instance before this
+ * method is called, and can be used to decide whether the interceptor should
+ * be enabled
+ */
+ public boolean isInterceptorEnabled();
+
}
15 years, 8 months
Seam SVN: r8917 - trunk/src/main/org/jboss/seam/cache.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-09-05 06:11:52 -0400 (Fri, 05 Sep 2008)
New Revision: 8917
Modified:
trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java
Log:
Don't install JBossCache2 without explicit configuration
Modified: trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java
===================================================================
--- trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java 2008-09-05 09:42:43 UTC (rev 8916)
+++ trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java 2008-09-05 10:11:52 UTC (rev 8917)
@@ -1,7 +1,7 @@
package org.jboss.seam.cache;
import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.FRAMEWORK;
+import static org.jboss.seam.annotations.Install.BUILT_IN;
import java.lang.reflect.Method;
@@ -31,7 +31,7 @@
@Name("org.jboss.seam.cache.cacheProvider")
@Scope(APPLICATION)
@BypassInterceptors
-@Install(precedence = FRAMEWORK, classDependencies={"org.jboss.cache.Cache", "org.jgroups.MembershipListener"})
+@Install(value=false, precedence = BUILT_IN, classDependencies={"org.jboss.cache.Cache", "org.jgroups.MembershipListener"})
@AutoCreate
public class JbossCache2Provider extends AbstractJBossCacheProvider<Cache>
{
15 years, 8 months
Seam SVN: r8916 - trunk/build.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2008-09-05 05:42:43 -0400 (Fri, 05 Sep 2008)
New Revision: 8916
Modified:
trunk/build/ui.pom.xml
Log:
JBSEAM-3292
Modified: trunk/build/ui.pom.xml
===================================================================
--- trunk/build/ui.pom.xml 2008-09-05 09:18:47 UTC (rev 8915)
+++ trunk/build/ui.pom.xml 2008-09-05 09:42:43 UTC (rev 8916)
@@ -193,7 +193,10 @@
<scope>test</scope>
<classifier>jdk15</classifier>
<exclusions>
- <exclusion></exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
</exclusions>
</dependency>
15 years, 8 months
Seam SVN: r8915 - trunk/src/main/org/jboss/seam/cache.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-09-05 05:18:47 -0400 (Fri, 05 Sep 2008)
New Revision: 8915
Modified:
trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java
Log:
can't have two components of the same precedence even if class deps are mutually exclusive
Modified: trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java
===================================================================
--- trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java 2008-09-04 22:38:33 UTC (rev 8914)
+++ trunk/src/main/org/jboss/seam/cache/JbossCache2Provider.java 2008-09-05 09:18:47 UTC (rev 8915)
@@ -1,7 +1,7 @@
package org.jboss.seam.cache;
import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
import java.lang.reflect.Method;
@@ -31,7 +31,7 @@
@Name("org.jboss.seam.cache.cacheProvider")
@Scope(APPLICATION)
@BypassInterceptors
-@Install(precedence = BUILT_IN, classDependencies={"org.jboss.cache.Cache", "org.jgroups.MembershipListener"})
+@Install(precedence = FRAMEWORK, classDependencies={"org.jboss.cache.Cache", "org.jgroups.MembershipListener"})
@AutoCreate
public class JbossCache2Provider extends AbstractJBossCacheProvider<Cache>
{
15 years, 8 months
Seam SVN: r8914 - in trunk: ui/src/main/java/org/jboss/seam/ui/renderkit and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-09-04 18:38:33 -0400 (Thu, 04 Sep 2008)
New Revision: 8914
Modified:
trunk/src/main/org/jboss/seam/cache/CacheProvider.java
trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/CacheRendererBase.java
Log:
JBSEAM-3382, thanks to Przemyslaw Jaskierski
Modified: trunk/src/main/org/jboss/seam/cache/CacheProvider.java
===================================================================
--- trunk/src/main/org/jboss/seam/cache/CacheProvider.java 2008-09-04 22:34:17 UTC (rev 8913)
+++ trunk/src/main/org/jboss/seam/cache/CacheProvider.java 2008-09-04 22:38:33 UTC (rev 8914)
@@ -71,7 +71,7 @@
* @param key - a key to identify the object.
* @return - the object if found or null if not
*/
- public abstract Object get(String key, String region);
+ public abstract Object get(String region, String key);
/**
* Put an object into the cache. The object is placed in the default cache
Modified: trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/CacheRendererBase.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/CacheRendererBase.java 2008-09-04 22:34:17 UTC (rev 8913)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/CacheRendererBase.java 2008-09-04 22:38:33 UTC (rev 8914)
@@ -36,7 +36,7 @@
if (cache.isEnabled())
{
String key = cache.getKey();
- String cachedContent = (String) cache.getCacheProvider().get(key, cache.getRegion());
+ String cachedContent = (String) cache.getCacheProvider().get(cache.getRegion(), key);
if (cachedContent == null)
{
log.debug("rendering from scratch: " + key);
@@ -47,7 +47,7 @@
context.setResponseWriter(writer);
String output = stringWriter.getBuffer().toString();
writer.write(output);
- cache.getCacheProvider().put(key, cache.getRegion(), output);
+ cache.getCacheProvider().put(cache.getRegion(), key, output);
}
else
{
15 years, 8 months