Seam SVN: r9719 - in trunk/examples: booking and 3 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-12-04 03:26:45 -0500 (Thu, 04 Dec 2008)
New Revision: 9719
Added:
trunk/examples/booking/resources/META-INF/jboss.xml
Modified:
trunk/examples/booking/readme.txt
trunk/examples/booking/resources/WEB-INF/components.xml
trunk/examples/booking/resources/WEB-INF/web.xml
trunk/examples/booking/resources/components.properties
trunk/examples/build.xml
Log:
JBSEAM-3397 add farm targets to example build and necessary configs to allow booking example to run in JBoss AS cluster
Modified: trunk/examples/booking/readme.txt
===================================================================
--- trunk/examples/booking/readme.txt 2008-12-04 08:25:03 UTC (rev 9718)
+++ trunk/examples/booking/readme.txt 2008-12-04 08:26:45 UTC (rev 9719)
@@ -7,4 +7,21 @@
This example runs on JBoss AS as an EAR or Tomcat with JBoss Embedded as a WAR.
-example.name=booking
+ example.name=booking
+
+To deploy this application to a cluster, first follow the steps 1-9 clustering-howto.txt in the root folder of the Seam distribution. Then execute the following command:
+
+ ant farm
+
+This command will deploy the archive to the farm directory of the "all" JBoss AS domain. To undeploy, run the following command:
+
+ ant unfarm
+
+HTTP session replication is enabled by default. You can disable it with the following commandline switch:
+
+ -Dsession.replication=false
+
+You can also toggle Seam's ManagedEntityInterceptor for any deployment with the following commandline switch:
+
+ -Ddistributable=false
+
Added: trunk/examples/booking/resources/META-INF/jboss.xml
===================================================================
--- trunk/examples/booking/resources/META-INF/jboss.xml (rev 0)
+++ trunk/examples/booking/resources/META-INF/jboss.xml 2008-12-04 08:26:45 UTC (rev 9719)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_2.dtd">
+<jboss>
+ <enterprise-beans>
+ <session>
+ <ejb-name>BookingListAction</ejb-name>
+ <clustered>@distributable@</clustered>
+ </session>
+ <session>
+ <ejb-name>HotelBookingAction</ejb-name>
+ <clustered>@distributable@</clustered>
+ </session>
+ <session>
+ <ejb-name>HotelSearchingAction</ejb-name>
+ <clustered>@distributable@</clustered>
+ </session>
+ </enterprise-beans>
+</jboss>
Modified: trunk/examples/booking/resources/WEB-INF/components.xml
===================================================================
--- trunk/examples/booking/resources/WEB-INF/components.xml 2008-12-04 08:25:03 UTC (rev 9718)
+++ trunk/examples/booking/resources/WEB-INF/components.xml 2008-12-04 08:26:45 UTC (rev 9719)
@@ -10,7 +10,7 @@
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">
- <core:init jndi-pattern="@jndiPattern@" debug="true"/>
+ <core:init jndi-pattern="@jndiPattern@" debug="true" distributable="@distributable@"/>
<core:manager conversation-timeout="120000"
concurrent-request-timeout="500"
Modified: trunk/examples/booking/resources/WEB-INF/web.xml
===================================================================
--- trunk/examples/booking/resources/WEB-INF/web.xml 2008-12-04 08:25:03 UTC (rev 9718)
+++ trunk/examples/booking/resources/WEB-INF/web.xml 2008-12-04 08:26:45 UTC (rev 9719)
@@ -3,7 +3,9 @@
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-
+
+ <!-- <distributable/> -->
+
<display-name>Seam Booking Example</display-name>
<!-- Seam -->
Modified: trunk/examples/booking/resources/components.properties
===================================================================
--- trunk/examples/booking/resources/components.properties 2008-12-04 08:25:03 UTC (rev 9718)
+++ trunk/examples/booking/resources/components.properties 2008-12-04 08:26:45 UTC (rev 9719)
@@ -1,3 +1,4 @@
# The pattern in components.xml is replaced by an application server specific value in the ant build. This value is used for running tests
-jndiPattern \#{ejbName}/local
\ No newline at end of file
+jndiPattern \#{ejbName}/local
+distributable true
Modified: trunk/examples/build.xml
===================================================================
--- trunk/examples/build.xml 2008-12-04 08:25:03 UTC (rev 9718)
+++ trunk/examples/build.xml 2008-12-04 08:26:45 UTC (rev 9719)
@@ -36,6 +36,7 @@
<!-- Deployment directories -->
<property name="deploy.dir" value="${jboss.home}/server/default/deploy" />
<property name="tomcat.deploy.dir" value="${tomcat.home}/webapps" />
+ <property name="farm.deploy.dir" value="${jboss.home}/server/all/farm" />
<property name="conf.dir" value="${jboss.home}/server/default/conf" />
<!-- Library directories -->
@@ -594,10 +595,15 @@
<copy todir="${jar.dir}">
<fileset refid="jar.resources" />
<fileset refid="jar.extras" />
+ <filterset>
+ <filter token="distributable" value="${distributable}" />
+ </filterset>
</copy>
</target>
- <target name="init.war" />
+ <target name="init.war">
+ <property name="distributable" value="false"/>
+ </target>
<!-- Build the exploded war -->
<target name="war" depends="compile, init.war">
@@ -652,19 +658,26 @@
<fileset refid="war.resources" />
<filterset>
<filter token="debug" value="${debug}" />
+ <filter token="distributable" value="${distributable}" />
<filter token="jndiPattern" value="${example.name}/#{ejbName}/local" />
- <filter token="embeddedEjb" value="false" />
<filter token="loadPersistenceUnits" value="${loadPersistenceUnits}" />
</filterset>
</copy>
</target>
+ <target name="distributable.war" if="use.session.replication">
+ <replace file="${war.dir}/WEB-INF/web.xml">
+ <replacetoken><![CDATA[<!-- <distributable/> -->]]></replacetoken>
+ <replacevalue><![CDATA[<distributable/>]]></replacevalue>
+ </replace>
+ </target>
+
<!-- Build the exploded ear -->
<target name="ear">
<copy todir="${ear.dir}">
<fileset refid="seam.jar" />
+ <fileset refid="ear.resources" />
<fileset refid="ear.extras" />
- <fileset refid="ear.resources" />
</copy>
<mkdir dir="${ear.dir}/lib" />
<copy todir="${ear.dir}/lib">
@@ -695,7 +708,7 @@
</copy>
</target>
- <target name="archive" depends="jar,jboss.war,ear" description="Package the archives">
+ <target name="archive" depends="jar,jboss.war,distributable.war,ear" description="Package the archives">
<jar jarfile="${dist.dir}/${example.name}.jar" basedir="${jar.dir}" />
<jar jarfile="${dist.dir}/${example.name}.war" basedir="${war.dir}" />
<jar jarfile="${dist.dir}/${example.name}.ear">
@@ -765,6 +778,41 @@
</copy>
</target>
+ <target name="init.distributable">
+ <property name="distributable" value="true"/>
+ <condition property="use.session.replication">
+ <or>
+ <not><isset property="session.replication"/></not>
+ <equals arg1="${session.replication}" arg2="true"/>
+ </or>
+ </condition>
+ </target>
+
+ <target name="farm-archive" depends="init.distributable,archive"/>
+
+ <!-- FIXME Set the deploy.dir dynamically to avoid the duplicate targets for farming -->
+
+ <target name="farm-datasource" description="Deploy the datasource to a JBoss AS cluster">
+ <fail unless="jboss.home">jboss.home not set</fail>
+ <copy todir="${farm.deploy.dir}">
+ <fileset dir="${resources.dir}">
+ <include name="${example.ds}" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="farm" depends="farm-archive,farm-datasource" description="Deploy the example to a JBoss AS cluster">
+ <fail unless="jboss.home">
+ jboss.home not set, update build.properties
+ </fail>
+ <copy file="${dist.dir}/${example.name}.ear" todir="${farm.deploy.dir}" />
+ </target>
+
+ <target name="unfarm" description="Undeploy the example from a JBoss AS cluster">
+ <delete file="${farm.deploy.dir}/${example.name}.ear" />
+ <delete file="${farm.deploy.dir}/${example.ds}" />
+ </target>
+
<target name="explode" depends="jar,jboss.war,ear,datasource, meldware" description="Deploy the exploded archive">
<fail unless="jboss.home">jboss.home not set</fail>
@@ -842,8 +890,8 @@
<fileset refid="war.resources" />
<filterset>
<filter token="debug" value="${debug}" />
+ <filter token="distributable" value="${distributable}" />
<filter token="jndiPattern" value="#{ejbName}/local" />
- <filter token="embeddedEjb" value="false" />
</filterset>
</copy>
</target>
@@ -914,14 +962,14 @@
<fileset refid="war.resources" />
<filterset>
<filter token="debug" value="${debug}" />
+ <filter token="distributable" value="${distributable}" />
<filter token="jndiPattern" value="#{ejbName}/local" />
- <filter token="embeddedEjb" value="false" />
<filter token="loadPersistenceUnits" value="${loadPersistenceUnits}" />
</filterset>
</copy>
</target>
- <target name="noejb.archive" depends="noejb.jar,noejb.war" description="Package the archives for non-ejb war">
+ <target name="noejb.archive" depends="noejb.jar,noejb.war,distributable.war" description="Package the archives for non-ejb war">
<jar jarfile="${dist.dir}/${example.name}.war">
<fileset dir="${war.dir}" />
<zipfileset dir="${dist.dir}" prefix="WEB-INF/lib">
@@ -942,6 +990,21 @@
<target name="jbosswar.undeploy" description="Undeploy the example from JBoss">
<delete file="${deploy.dir}/${example.name}.war" />
</target>
+
+ <target name="noejb.farm-archive" depends="init.distributable,noejb.archive"/>
+
+ <!-- FIXME Set the deploy.dir dynamically to avoid the duplicate targets for farming -->
+
+ <target name="jbosswar.farm" depends="noejb.farm-archive,farm-datasource" description="Deploy the example to a JBoss AS cluster">
+ <fail unless="jboss.home">
+ jboss.home not set, update build.properties
+ </fail>
+ <copy file="${dist.dir}/${example.name}.war" todir="${farm.deploy.dir}" />
+ </target>
+
+ <target name="jbosswar.unfarm" description="Undeploy the example from a JBoss AS cluster">
+ <delete file="${farm.deploy.dir}/${example.name}.war" />
+ </target>
<target name="jbosswar.explode" depends="noejb.jar, noejb.war, datasource" description="Deploy the example (exploded) to JBoss AS">
<fail unless="jboss.home">
15 years, 5 months
Seam SVN: r9718 - trunk.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-12-04 03:25:03 -0500 (Thu, 04 Dec 2008)
New Revision: 9718
Added:
trunk/clustering-howto.txt
Log:
JBSEAM-3397 the clustering how-to
Added: trunk/clustering-howto.txt
===================================================================
--- trunk/clustering-howto.txt (rev 0)
+++ trunk/clustering-howto.txt 2008-12-04 08:25:03 UTC (rev 9718)
@@ -0,0 +1,163 @@
+= Deploying a Seam application into a JBoss AS cluster using HTTP session replication =
+
+The procedure outlined in this tutorial has been validated with an seam-gen application and the Seam booking example.
+
+In the tutorial, I assume that the IP addresses of the master and slave servers are 192.168.1.2 and 192.168.1.3,
+respectively. I am intentionally not using the mod_jk load balancer so that it's easier to validate that both nodes are
+responding to requests and interchanging sessions.
+
+The log messages shown below were generated from the deployment of a WAR application named vehicles.war and its
+cooresponding datasource named vehiclesDatasource. The booking example fully supports this process and you can find instructions on how to deploy it to a cluster in the examples/booking/readme.txt file.
+
+I'm using the farm deployment method in these instructions, though you could also deploy the application normally and
+allow the two servers to negotiate a master/slave relationship based on startup order.
+
+All timestamps have been zeroed out to reduce noise.
+
+== A note about SELinux ==
+
+You might run into problems getting your nodes to see one another if they are on different machines and the machines are
+running RHEL/Fedora. JBoss AS clustering relies on UDP multicasting provided by jGroups. The SELinux configuration that
+ships with RHEL/Fedora blocks these packets by default. You can allow them to pass by modifying the iptables rules (as
+root). The following commands apply to an IP address that matches 192.168.1.x.
+
+ /sbin/iptables -I RH-Firewall-1-INPUT 5 -p udp -d 224.0.0.0/4 -j ACCEPT
+ /sbin/iptables -I RH-Firewall-1-INPUT 9 -p udp -s 192.168.1.0/24 -j ACCEPT
+ /sbin/iptables -I RH-Firewall-1-INPUT 10 -p tcp -s 192.168.1.0/24 -j ACCEPT
+ /etc/init.d/iptables save
+
+== A note about SFSBs ==
+
+If you are deploying an application with SFSBs and HTTP session replication to a JBoss AS cluster, you must ensure that your SFSB classes are annotated with @Clustered (from the JBoss EJB 3 annotation API) or marked as clustered in the jboss.xml descriptor. See the booking example for details.
+
+With that out of the way, it's time to get started.
+
+== Tutorial ==
+
+1. Create two instances of JBoss AS (just extract the zip twice)
+2. Deploy the JDBC driver to server/all/lib/ on both instances if not using HSQLDB
+3. Add <distributable/> as the first child element in WEB-INF/web.xml
+4. Set the distributable property on org.jboss.seam.core.init to true to enabled the ManagedEntityInterceptor
+ (i.e., <core:init distributable="true"/> in WEB-INF/components.xml)
+5. Bind a new IP address to the NIC
+
+ /sbin/ifconfig eth1:2 192.168.1.3
+
+replace eth1 with your interface name and make the IP address conform to your network
+
+6. Start the master JBoss AS instance on the first IP:
+
+ ./bin/run.sh -c all -b 192.168.1.2
+
+You should see the following in the log:
+
+00:00:00,000 INFO [DefaultPartition] Number of cluster members: 1
+00:00:00,000 INFO [DefaultPartition] Other members: 0
+00:00:00,000 INFO [DefaultPartition] Fetching state (will wait for 30000 milliseconds):
+00:00:00,000 INFO [DefaultPartition] State could not be retrieved (we are the first member in group)
+
+7. Verify that the server/all/farm directory is empty in the slave JBoss AS instance
+8. Start the slave JBoss AS on second the IP
+
+ ./bin/run.sh -c all -b 192.168.1.3
+
+Should see the following in the log:
+
+00:00:00,000 INFO [DefaultPartition] Number of cluster members: 2
+00:00:00,000 INFO [DefaultPartition] Other members: 1
+00:00:00,000 INFO [DefaultPartition] Fetching state (will wait for 30000 milliseconds):
+00:00:00,000 INFO [DefaultPartition] state was retrieved successfully (in 120 milliseconds)
+
+Back in the first instance's log you should see acknowledgement of the new member:
+
+00:00:00,000 INFO [DefaultPartition] I am (192.168.1.2:1099) received membershipChanged event:
+00:00:00,000 INFO [DefaultPartition] Dead members: 0 ([])
+00:00:00,000 INFO [DefaultPartition] New Members : 1 ([192.168.1.3:1099])
+00:00:00,000 INFO [DefaultPartition] All Members : 2 ([192.168.1.2:1099, 192.168.1.3:1099])
+
+9. Deploy the -ds.xml to server/all/farm of the master instance
+
+In the log of the master instance you should see acknowlegement of this deployment:
+
+00:00:00,000 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=vehiclesDatasource' to JNDI name 'java:vehiclesDatasource'
+00:00:00,000 INFO [ClusterFileTransfer] Start push of file vehicles-ds.xml to cluster.
+00:00:00,000 INFO [ClusterFileTransfer] Finished push of file vehicles-ds.xml to cluster.
+
+In the log of the slave instance you should see a complimentary message:
+
+00:00:00,000 INFO [FarmMemberService] farmDeployment(), deploy locally: farm/vehicles-ds.xml
+00:00:00,000 INFO [ConnectionFactoryBindingService] Unbound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=vehiclesDatasource' from JNDI name 'java:vehiclesDatasource'
+
+10. Deploy the application to the server/all/farm directory
+
+In the log of the master instance you should see acknowlegement of this deployment after the normal application startup
+messages have finished:
+
+00:00:00,000 INFO [ClusterFileTransfer] Start push of file vehicles.war to cluster.
+
+Wait ~3 minutes for the deployed archive to be transferred (I don't know why it takes so long)
+
+In the log of the master instance you should see acknowlegement of this deployment prior to the normal application
+startup messages:
+
+00:00:00,000 INFO [FarmMemberService] farmDeployment(), deploy locally: farm/vehicles.war
+
+Once the application is transfered, you should see confirmation in the log of the master instance:
+
+00:00:00,000 INFO [ClusterFileTransfer] Finished push of file vehicles.war to cluster.
+
+Then you should see the application startup messages appear in the slave instance.
+
+You're application is now running in a cluster with HTTP session replication! But, of course, you are going to want to
+validate that the clustering actually works.
+
+= Validating the distributable services of an application running in a cluster =
+
+It's all well and fine to see the application start successfully on two different JBoss AS servers, but seeing is
+believing. You likely want to validate that the two instances are exchanging HTTP sessions to allow the slave to take
+over when the master instance is stopped.
+
+Start off by visiting the application running on the master instance in your browser. That will produce the first HTTP
+session. Now, open up the JBoss AS JMX console on that instance and navigate to the following MBean:
+
+category: jboss.cache
+entry: service=TomcatClusteringCache
+method: printDetails()
+
+Invoke the printDetails() method. You will see a tree of active HTTP sessions. Verify that the session your browser is
+using corresponds to one of the sessions in this tree. Here is a shortcut for invoking that method:
+
+ http://192.168.1.2:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&nam...
+
+Now switch over to the slave instance and invoke the same method in the JMX console. You should see an identical list
+(at least underneath this application's context path). Here's the shortcut to that method.
+
+ http://192.168.1.3:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&nam...
+
+So you can see that at least both servers claim to have identical sessions. Now, time to test that the data is
+serializing and unserializing properly.
+
+Sign in using using the URL of the master instance. Then, construct a URL for the second instance by putting the
+;jsessionid=XXXX immediately after the servlet path and changing the IP address. You should see that the session has
+carried over to the other instance. Now kill the master instance and see that you can continue to use the application
+from the slave instance. Remove the deployments from the server/all/farm directory and start the instance again. Switch
+the IP in the URL back to that of the master instance and visit the URL. You'll see that the original session is still
+being used.
+
+One way to watch objects passivate and activate is to create a session- or conversation-scoped Seam component and
+implement the appropriate life-cycle methods. You can either use methods from the HttpSessionActivationListener
+interface (Seam automatically registers this interface on all non-EJB components):
+
+ public void sessionWillPassivate(HttpSessionEvent e);
+ public void sessionDidActivate(HttpSessionEvent e);
+
+or you can simply mark two no-argument public void methods with @PrePassivate and @PostActivate, respectively. Note that
+the passivation step occurs at the end of every request, while the activation step occurs when a node is called upon.
+
+The really nice part about Seam is that it is working very hard to make replication transparent by automatically keeping
+track of dirty object and ensuring that they are propagated. All you need to do is maintain a dirty flag on your
+session- or conversation-scoped component. Seam automatically takes care of JPA entity instances for you.
+
+= Notes and outstanding issues =
+
+* transient fields aren't always reinitialized, required a fix to SecurityInterceptor; might show up elsewhere
15 years, 5 months
Seam SVN: r9717 - in trunk/src: ioc/org/jboss/seam/ioc/spring and 10 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-12-04 03:09:30 -0500 (Thu, 04 Dec 2008)
New Revision: 9717
Added:
trunk/src/main/org/jboss/seam/web/HotDeployFilter.java
Removed:
trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java
Modified:
trunk/src/ioc/org/jboss/seam/ioc/spring/SeamScopePostProcessor.java
trunk/src/ioc/org/jboss/seam/ioc/spring/SeamTargetSource.java
trunk/src/ioc/org/jboss/seam/ioc/spring/SpringComponent.java
trunk/src/main/org/jboss/seam/Seam.java
trunk/src/main/org/jboss/seam/contexts/Lifecycle.java
trunk/src/main/org/jboss/seam/core-2.1.xsd
trunk/src/main/org/jboss/seam/core/Init.java
trunk/src/main/org/jboss/seam/exception/Exceptions.java
trunk/src/main/org/jboss/seam/init/Initialization.java
trunk/src/main/org/jboss/seam/navigation/Pages.java
trunk/src/main/org/jboss/seam/servlet/SeamFilter.java
trunk/src/main/org/jboss/seam/servlet/SeamResourceServlet.java
trunk/src/main/org/jboss/seam/web-2.1.xsd
trunk/src/test/unit/org/jboss/seam/test/unit/AbstractPageTest.java
trunk/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java
trunk/src/test/unit/org/jboss/seam/test/unit/bpm/TaskListTest.java
Log:
JBSEAM-3729
JBSEAM-3708
JBSEAM-3728
also change the mockApplication and unmockApplication methods to setupApplication and cleanupApplication
Deleted: trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java
===================================================================
--- trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -1,59 +0,0 @@
-package org.jboss.seam.debug.hot;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.jboss.seam.Seam;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.annotations.web.Filter;
-import org.jboss.seam.core.Init;
-import org.jboss.seam.init.Initialization;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.web.AbstractFilter;
-
-@Name("org.jboss.seam.debug.hotDeployFilter")
-@Install(debug=true, precedence=BUILT_IN)
-@BypassInterceptors
-@Scope(APPLICATION)
-@Filter
-public class HotDeployFilter extends AbstractFilter
-{
-
- private static LogProvider log = Logging.getLogProvider(HotDeployFilter.class);
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
- throws IOException, ServletException
- {
- if (request instanceof HttpServletRequest)
- {
- Init init = (Init) getServletContext().getAttribute(Seam.getComponentName(Init.class));
- if (init != null)
- {
- try
- {
- new Initialization(getServletContext()).redeploy((HttpServletRequest) request, init);
- }
- catch (InterruptedException e)
- {
- log.warn("Unable to redeploy, please try again");
- }
- }
- }
- chain.doFilter(request, response);
- }
-
-
-
-}
Modified: trunk/src/ioc/org/jboss/seam/ioc/spring/SeamScopePostProcessor.java
===================================================================
--- trunk/src/ioc/org/jboss/seam/ioc/spring/SeamScopePostProcessor.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/ioc/org/jboss/seam/ioc/spring/SeamScopePostProcessor.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -71,7 +71,7 @@
boolean unmockApplication = false;
if (!Contexts.isApplicationContextActive())
{
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
unmockApplication = true;
}
try
@@ -125,7 +125,7 @@
{
if (unmockApplication)
{
- Lifecycle.unmockApplication();
+ Lifecycle.cleanupApplication();
}
}
}
Modified: trunk/src/ioc/org/jboss/seam/ioc/spring/SeamTargetSource.java
===================================================================
--- trunk/src/ioc/org/jboss/seam/ioc/spring/SeamTargetSource.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/ioc/org/jboss/seam/ioc/spring/SeamTargetSource.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -162,7 +162,7 @@
boolean unmockApplication = false;
if (!Contexts.isApplicationContextActive())
{
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
unmockApplication = true;
}
try
@@ -179,7 +179,7 @@
{
if (unmockApplication)
{
- Lifecycle.unmockApplication();
+ Lifecycle.cleanupApplication();
}
}
}
Modified: trunk/src/ioc/org/jboss/seam/ioc/spring/SpringComponent.java
===================================================================
--- trunk/src/ioc/org/jboss/seam/ioc/spring/SpringComponent.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/ioc/org/jboss/seam/ioc/spring/SpringComponent.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -65,7 +65,7 @@
boolean unmockApplication = false;
if (!Contexts.isApplicationContextActive())
{
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
unmockApplication = true;
}
try
@@ -93,7 +93,7 @@
{
if (unmockApplication)
{
- Lifecycle.unmockApplication();
+ Lifecycle.cleanupApplication();
}
}
}
@@ -121,7 +121,7 @@
boolean unmockApplication = false;
if (!Contexts.isApplicationContextActive())
{
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
unmockApplication = true;
}
try
@@ -132,7 +132,7 @@
{
if (unmockApplication)
{
- Lifecycle.unmockApplication();
+ Lifecycle.cleanupApplication();
}
}
}
Modified: trunk/src/main/org/jboss/seam/Seam.java
===================================================================
--- trunk/src/main/org/jboss/seam/Seam.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/main/org/jboss/seam/Seam.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -295,14 +295,14 @@
}
else
{
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
try
{
return Component.forName(name);
}
finally
{
- Lifecycle.unmockApplication();
+ Lifecycle.cleanupApplication();
}
}
}
Modified: trunk/src/main/org/jboss/seam/contexts/Lifecycle.java
===================================================================
--- trunk/src/main/org/jboss/seam/contexts/Lifecycle.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/main/org/jboss/seam/contexts/Lifecycle.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -106,12 +106,28 @@
}
}
+ /**
+ * @deprecated Use {@link Lifecycle#setupApplication()}
+ */
public static void mockApplication()
{
+ setupApplication();
+ }
+
+ /**
+ * @deprecated Use {@link Lifecycle#cleanupApplication()}
+ */
+ public static void unmockApplication()
+ {
+ cleanupApplication();
+ }
+
+ public static void setupApplication()
+ {
Contexts.applicationContext.set( new ApplicationContext(getApplication()) );
}
- public static void unmockApplication()
+ public static void cleanupApplication()
{
Contexts.applicationContext.set(null);
}
Modified: trunk/src/main/org/jboss/seam/core/Init.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/Init.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/main/org/jboss/seam/core/Init.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -33,10 +33,12 @@
import org.jboss.seam.log.Logging;
import org.jboss.seam.persistence.EntityManagerProxyInterceptor;
import org.jboss.seam.persistence.HibernateSessionProxyInterceptor;
+import org.jboss.seam.persistence.ManagedEntityInterceptor;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.SecurityInterceptor;
import org.jboss.seam.transaction.RollbackInterceptor;
import org.jboss.seam.transaction.TransactionInterceptor;
+import org.jboss.seam.util.Resources;
import org.jboss.seam.webservice.WSSecurityInterceptor;
/**
@@ -81,6 +83,7 @@
private boolean debug;
private boolean myFacesLifecycleBug;
private boolean transactionManagementEnabled = true;
+ private boolean distributable = false;
private List<String> interceptors = new ArrayList<String>(DEFAULT_INTERCEPTORS);
@@ -432,6 +435,16 @@
this.debug = debug;
}
+ /**
+ * The debug page is considered available if debug JAR is on the classpath
+ * and Seam is running in debug mode (to prevent it from being enabling in
+ * the event the JAR is inadvertently packaged).
+ */
+ public boolean isDebugPageAvailable()
+ {
+ return debug && Resources.getResource("META-INF/debug.xhtml", null) != null;
+ }
+
public boolean isMyFacesLifecycleBug()
{
return myFacesLifecycleBug;
@@ -597,7 +610,17 @@
{
this.interceptors = interceptors;
}
-
+
+ public boolean isDistributable()
+ {
+ return distributable;
+ }
+
+ public void setDistributable(boolean distributable)
+ {
+ this.distributable = distributable;
+ }
+
/**
* Sanity check to warn users if they have disabled core interceptors
*/
@@ -610,6 +633,11 @@
log.warn("The built-in interceptor " + defaultInterceptor + " is missing. This application may not function as expected");
}
}
+
+ if (distributable && !interceptors.contains(ManagedEntityInterceptor.class.getName()))
+ {
+ interceptors.add(ManagedEntityInterceptor.class.getName());
+ }
}
}
Modified: trunk/src/main/org/jboss/seam/core-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/core-2.1.xsd 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/main/org/jboss/seam/core-2.1.xsd 2008-12-04 08:09:30 UTC (rev 9717)
@@ -17,7 +17,7 @@
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="interceptors" type="components:multiValuedProperty">
<xs:annotation>
- <xs:documentation>A list of interceptors that should be enabled for all components. You must specify all built-in interceptors as well as any extras interceptors.
+ <xs:documentation>A list of interceptors that should be enabled for all components. You must specify all built-in interceptors as well as any additional interceptors. Execution order is determined by the around and within attributes on the @Interceptor annotation.
These interceptors are enabled by default:
org.jboss.seam.core.SynchronizationInterceptor
@@ -34,7 +34,9 @@
org.jboss.seam.transaction.RollbackInterceptor
org.jboss.seam.transaction.TransactionInterceptor
org.jboss.seam.webservice.WSSecurityInterceptor
- org.jboss.seam.security.SecurityInterceptor</xs:documentation>
+ org.jboss.seam.security.SecurityInterceptor
+
+The distributable flag appends the ManagedEntityInterceptor to this list (applies only to conversation-scoped components).</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
@@ -45,6 +47,7 @@
<xs:attributeGroup name="attlist.init">
<xs:attribute name="debug" type="components:boolean" />
+ <xs:attribute name="distributable" type="components:boolean" />
<xs:attribute name="jndi-pattern" type="components:string" />
<xs:attribute name="security-enabled" type="components:boolean" />
<xs:attribute name="transaction-management-enabled" type="components:boolean"/>
Modified: trunk/src/main/org/jboss/seam/exception/Exceptions.java
===================================================================
--- trunk/src/main/org/jboss/seam/exception/Exceptions.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/main/org/jboss/seam/exception/Exceptions.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -126,7 +126,7 @@
addHandler(new AnnotationRedirectHandler());
addHandler(new AnnotationErrorHandler());
- if (Init.instance().isDebug())
+ if (Init.instance().isDebugPageAvailable())
{
addHandler(new DebugPageHandler());
}
Modified: trunk/src/main/org/jboss/seam/init/Initialization.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/Initialization.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/main/org/jboss/seam/init/Initialization.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -822,9 +822,9 @@
Pages pages = (Pages) ServletLifecycle.getServletContext().getAttribute(Seam.getComponentName(Pages.class));
if (pages != null) {
// application context is needed for creating expressions
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
pages.initialize(warRootDeploymentStrategy.getDotPageDotXmlFileNames());
- Lifecycle.unmockApplication();
+ Lifecycle.cleanupApplication();
}
ServletLifecycle.getServletContext().removeAttribute(Seam.getComponentName(Exceptions.class));
init.setWarTimestamp(warRootDeploymentStrategy.getTimestamp());
@@ -864,8 +864,7 @@
private boolean isHotDeployEnabled(Init init)
{
- return Resources.getResource("META-INF/debug.xhtml", null) != null;
- //return init.isDebug();
+ return init.isDebug();
}
private boolean isGroovyPresent()
Modified: trunk/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Pages.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/main/org/jboss/seam/navigation/Pages.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -1696,12 +1696,12 @@
private static boolean isDebugPage(String viewId)
{
- return Init.instance().isDebug() && viewId.startsWith("/debug.");
+ return Init.instance().isDebugPageAvailable() && viewId.startsWith("/debug.");
}
public static boolean isDebugPage()
{
- return Init.instance().isDebug() &&
+ return Init.instance().isDebugPageAvailable() &&
getCurrentViewId() != null &&
getCurrentViewId().startsWith("/debug.");
}
Modified: trunk/src/main/org/jboss/seam/servlet/SeamFilter.java
===================================================================
--- trunk/src/main/org/jboss/seam/servlet/SeamFilter.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/main/org/jboss/seam/servlet/SeamFilter.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -87,7 +87,7 @@
public void init(FilterConfig filterConfig) throws ServletException
{
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
try
{
filters = getSortedFilters();
@@ -99,7 +99,7 @@
}
finally
{
- Lifecycle.unmockApplication();
+ Lifecycle.cleanupApplication();
}
}
Modified: trunk/src/main/org/jboss/seam/servlet/SeamResourceServlet.java
===================================================================
--- trunk/src/main/org/jboss/seam/servlet/SeamResourceServlet.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/main/org/jboss/seam/servlet/SeamResourceServlet.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -44,7 +44,7 @@
{
try
{
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
for (String name : Init.instance().getResourceProviders())
{
@@ -58,7 +58,7 @@
}
finally
{
- Lifecycle.unmockApplication();
+ Lifecycle.cleanupApplication();
}
}
Copied: trunk/src/main/org/jboss/seam/web/HotDeployFilter.java (from rev 9679, trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java)
===================================================================
--- trunk/src/main/org/jboss/seam/web/HotDeployFilter.java (rev 0)
+++ trunk/src/main/org/jboss/seam/web/HotDeployFilter.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -0,0 +1,58 @@
+package org.jboss.seam.web;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.jboss.seam.Seam;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.annotations.web.Filter;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.init.Initialization;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+
+@Name("org.jboss.seam.web.hotDeployFilter")
+@Install(debug=true, precedence=BUILT_IN)
+@BypassInterceptors
+@Scope(APPLICATION)
+@Filter
+public class HotDeployFilter extends AbstractFilter
+{
+
+ private static LogProvider log = Logging.getLogProvider(HotDeployFilter.class);
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException
+ {
+ if (request instanceof HttpServletRequest)
+ {
+ Init init = (Init) getServletContext().getAttribute(Seam.getComponentName(Init.class));
+ if (init != null)
+ {
+ try
+ {
+ new Initialization(getServletContext()).redeploy((HttpServletRequest) request, init);
+ }
+ catch (InterruptedException e)
+ {
+ log.warn("Unable to redeploy, please try again");
+ }
+ }
+ }
+ chain.doFilter(request, response);
+ }
+
+
+
+}
Property changes on: trunk/src/main/org/jboss/seam/web/HotDeployFilter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Modified: trunk/src/main/org/jboss/seam/web-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/web-2.1.xsd 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/main/org/jboss/seam/web-2.1.xsd 2008-12-04 08:09:30 UTC (rev 9717)
@@ -4,6 +4,16 @@
xmlns:components="http://jboss.com/products/seam/components" attributeFormDefault="unqualified">
<xs:import namespace="http://jboss.com/products/seam/components" schemaLocation="components-2.1.xsd"/>
+ <xs:element name="hot-deploy-filter">
+ <xs:annotation>
+ <xs:documentation>This filter triggers a scan for hot deployable components and descriptor files on each request. The URL pattern should be set to the same pattern as used by the Faces Servlet. Note that this filter is automatically disabled when Seam debug mode is disabled.</xs:documentation>
+ </xs:annotation>
+ <xs:complexType mixed="true">
+ <xs:attributeGroup ref="components:attlist.component"/>
+ <xs:attributeGroup ref="web:attlist.filter"/>
+ </xs:complexType>
+ </xs:element>
+
<xs:element name="identity-filter">
<xs:annotation>
<xs:documentation>This filter provides integration between Servlet Security and the identity component.</xs:documentation>
Modified: trunk/src/test/unit/org/jboss/seam/test/unit/AbstractPageTest.java
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/AbstractPageTest.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/AbstractPageTest.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -51,14 +51,14 @@
Pages.instance();
// mark the application as started
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
}
@AfterMethod
public void tearDown()
{
Lifecycle.endApplication();
- Lifecycle.unmockApplication();
+ Lifecycle.cleanupApplication();
}
protected void installComponents(Context appContext)
Modified: trunk/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -48,7 +48,7 @@
Param param = new Param("param");
param.setValueExpression(Expressions.instance().createValueExpression("#{variable}"));
Lifecycle.beginApplication(new HashMap<String, Object>());
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
assert param.getConverter() == null;
Lifecycle.endApplication();
}
Modified: trunk/src/test/unit/org/jboss/seam/test/unit/bpm/TaskListTest.java
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/bpm/TaskListTest.java 2008-12-04 08:06:28 UTC (rev 9716)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/bpm/TaskListTest.java 2008-12-04 08:09:30 UTC (rev 9717)
@@ -26,7 +26,7 @@
{
Lifecycle.beginApplication(new HashMap<String, Object>());
new Initialization(new MockServletContext()).create().init();
- Lifecycle.mockApplication();
+ Lifecycle.setupApplication();
installComponent(Contexts.getApplicationContext(), Actor.class);
installComponent(Contexts.getApplicationContext(), PooledTaskInstanceList.class);
installComponent(Contexts.getApplicationContext(), MockRolledBackTransaction.class);
15 years, 5 months
Seam SVN: r9716 - trunk/src/main/org/jboss/seam/security.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-12-04 03:06:28 -0500 (Thu, 04 Dec 2008)
New Revision: 9716
Modified:
trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java
Log:
workaround a JVM bug by initializing the restrictions map lazily if it is found to be null; use the volatile keyword for thread safety
Modified: trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java 2008-12-04 08:00:42 UTC (rev 9715)
+++ trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java 2008-12-04 08:06:28 UTC (rev 9716)
@@ -30,7 +30,11 @@
{
private static final long serialVersionUID = -6567750187000766925L;
- private transient Map<Method,Restriction> restrictions = new HashMap<Method,Restriction>();
+ /**
+ * You may encounter a JVM bug where the field initializer is not evaluated for a transient field after deserialization.
+ * @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6252102
+ */
+ private transient volatile Map<Method,Restriction> restrictions = new HashMap<Method,Restriction>();
private class Restriction
{
@@ -159,10 +163,20 @@
private Restriction getRestriction(Method interfaceMethod) throws Exception
{
+ // see field declaration as to why this is done
+ if (restrictions == null)
+ {
+ synchronized(this)
+ {
+ restrictions = new HashMap<Method, Restriction>();
+ }
+ }
+
if (!restrictions.containsKey(interfaceMethod))
{
synchronized(restrictions)
{
+ // FIXME this logic should be abstracted rather than sitting in the middle of this interceptor
if (!restrictions.containsKey(interfaceMethod))
{
Restriction restriction = null;
15 years, 5 months
Seam SVN: r9715 - trunk/src/main/org/jboss/seam/intercept.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-12-04 03:00:42 -0500 (Thu, 04 Dec 2008)
New Revision: 9715
Modified:
trunk/src/main/org/jboss/seam/intercept/JavaBeanInterceptor.java
Log:
allow callbacks to HttpSessionActivationListener implementations to proceed (sessionWillPassivate, sessionDidActivate)
Modified: trunk/src/main/org/jboss/seam/intercept/JavaBeanInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/intercept/JavaBeanInterceptor.java 2008-12-04 07:57:58 UTC (rev 9714)
+++ trunk/src/main/org/jboss/seam/intercept/JavaBeanInterceptor.java 2008-12-04 08:00:42 UTC (rev 9715)
@@ -6,6 +6,7 @@
import javassist.util.proxy.MethodHandler;
import javassist.util.proxy.ProxyObject;
+import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionEvent;
import org.jboss.seam.Component;
@@ -70,12 +71,12 @@
if ( "sessionDidActivate".equals(methodName) )
{
callPostActivate();
- return null;
+ return (bean instanceof HttpSessionActivationListener) ? method.invoke(bean, params) : null;
}
else if ( "sessionWillPassivate".equals(methodName) )
{
callPrePassivate();
- return null;
+ return (bean instanceof HttpSessionActivationListener) ? method.invoke(bean, params) : null;
}
}
}
@@ -118,12 +119,18 @@
private void callPostConstruct()
{
- InvocationContext context = new RootInvocationContext( bean, getComponent().getPostConstructMethod(), new Object[0] )
+ final Component component = getComponent();
+ if (!component.hasPostConstructMethod())
{
+ return;
+ }
+
+ InvocationContext context = new RootInvocationContext( bean, component.getPostConstructMethod(), new Object[0] )
+ {
@Override
public Object proceed() throws Exception
{
- getComponent().callPostConstructMethod(bean);
+ component.callPostConstructMethod(bean);
return null;
}
@@ -133,12 +140,18 @@
private void callPrePassivate()
{
- InvocationContext context = new RootInvocationContext( bean, getComponent().getPrePassivateMethod(), new Object[0] )
+ final Component component = getComponent();
+ if (!component.hasPrePassivateMethod())
{
+ return;
+ }
+
+ InvocationContext context = new RootInvocationContext( bean, component.getPrePassivateMethod(), new Object[0] )
+ {
@Override
public Object proceed() throws Exception
{
- getComponent().callPrePassivateMethod(bean);
+ component.callPrePassivateMethod(bean);
return null;
}
@@ -148,12 +161,18 @@
private void callPostActivate()
{
- RootInvocationContext context = new RootInvocationContext(bean, getComponent().getPostActivateMethod(), new Object[0])
+ final Component component = getComponent();
+ if (!component.hasPostActivateMethod())
{
+ return;
+ }
+
+ RootInvocationContext context = new RootInvocationContext(bean, component.getPostActivateMethod(), new Object[0])
+ {
@Override
public Object proceed() throws Exception
{
- getComponent().callPostActivateMethod(bean);
+ component.callPostActivateMethod(bean);
return null;
}
15 years, 5 months
Seam SVN: r9714 - trunk/src/main/org/jboss/seam.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-12-04 02:57:58 -0500 (Thu, 04 Dec 2008)
New Revision: 9714
Modified:
trunk/src/main/org/jboss/seam/Component.java
Log:
todo note
Modified: trunk/src/main/org/jboss/seam/Component.java
===================================================================
--- trunk/src/main/org/jboss/seam/Component.java 2008-12-04 07:25:08 UTC (rev 9713)
+++ trunk/src/main/org/jboss/seam/Component.java 2008-12-04 07:57:58 UTC (rev 9714)
@@ -753,6 +753,7 @@
parameterSetters.add( new BijectedMethod(name, method, rp) );
}
+ // TODO: verify that these life-cycle methods have no arguments!
if ( method.isAnnotationPresent(PRE_PASSIVATE) )
{
prePassivateMethod = method;
15 years, 5 months
Seam SVN: r9713 - trunk/src/main/org/jboss/seam/jmx.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-12-04 02:25:08 -0500 (Thu, 04 Dec 2008)
New Revision: 9713
Modified:
trunk/src/main/org/jboss/seam/jmx/JBossClusterMonitor.java
Log:
javadoc
Modified: trunk/src/main/org/jboss/seam/jmx/JBossClusterMonitor.java
===================================================================
--- trunk/src/main/org/jboss/seam/jmx/JBossClusterMonitor.java 2008-12-04 07:22:51 UTC (rev 9712)
+++ trunk/src/main/org/jboss/seam/jmx/JBossClusterMonitor.java 2008-12-04 07:25:08 UTC (rev 9713)
@@ -22,6 +22,15 @@
import org.jboss.seam.log.Log;
import org.jboss.seam.log.Logging;
+/**
+ * The purpose of this component is to detect a clustered environment and
+ * to inform the HttpSessionListener whether the origin of a session destroyed
+ * event is the failover of a session from one node to the next. If a node
+ * is failing over, we don't want the SFSBs referenced by the session to be
+ * destroyed.
+ *
+ * @author Dan Allen
+ */
@Name("org.jboss.seam.jmx.jbossClusterMonitor")
@BypassInterceptors
@Scope(APPLICATION)
15 years, 5 months
Seam SVN: r9712 - in trunk/src/main/org/jboss/seam: jmx and 1 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-12-04 02:22:51 -0500 (Thu, 04 Dec 2008)
New Revision: 9712
Added:
trunk/src/main/org/jboss/seam/jmx/
trunk/src/main/org/jboss/seam/jmx/JBossClusterMonitor.java
Modified:
trunk/src/main/org/jboss/seam/servlet/SeamListener.java
Log:
JBSEAM-3172
Added: trunk/src/main/org/jboss/seam/jmx/JBossClusterMonitor.java
===================================================================
--- trunk/src/main/org/jboss/seam/jmx/JBossClusterMonitor.java (rev 0)
+++ trunk/src/main/org/jboss/seam/jmx/JBossClusterMonitor.java 2008-12-04 07:22:51 UTC (rev 9712)
@@ -0,0 +1,149 @@
+package org.jboss.seam.jmx;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.servlet.ServletContext;
+
+import org.jboss.seam.Seam;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.log.Logging;
+
+@Name("org.jboss.seam.jmx.jbossClusterMonitor")
+@BypassInterceptors
+@Scope(APPLICATION)
+@Startup
+@Install(precedence=BUILT_IN, classDependencies="org.jgroups.MembershipListener")
+public class JBossClusterMonitor
+{
+ private static Log log = Logging.getLog(JBossClusterMonitor.class);
+
+ private MBeanServer jbossMBeanServer;
+
+ private boolean clustered;
+
+ private ObjectName clusteringCacheObjectName;
+
+ private ObjectName serverObjectName;
+
+ @Create
+ public void create()
+ {
+ jbossMBeanServer = locateJBoss();
+
+ if (!isJBoss())
+ {
+ return;
+ }
+
+ try
+ {
+ clusteringCacheObjectName = new ObjectName("jboss.cache:service=TomcatClusteringCache");
+ serverObjectName = new ObjectName("jboss.system:type=Server");
+ }
+ catch (MalformedObjectNameException e)
+ {
+ log.warn("Invalid JMX name: " + e.getMessage());
+ }
+
+ try
+ {
+ jbossMBeanServer.getMBeanInfo(clusteringCacheObjectName);
+ clustered = true;
+ log.info("JBoss cluster detected");
+ }
+ catch (Exception e) {}
+ }
+
+ public boolean isClustered()
+ {
+ return clustered;
+ }
+
+ /**
+ * Consults the jboss.system:type=Server MBean to determine if this instance
+ * of JBoss AS is currently being shutdown. Note that the flag only returns
+ * true if the shutdown() method on this MBean is used. It does not detect a
+ * force halt via a process signal (i.e., CTRL-C).
+ */
+ public boolean nodeIsShuttingDown()
+ {
+ if (!isJBoss())
+ {
+ return false;
+ }
+
+ try
+ {
+ return (Boolean) jbossMBeanServer.getAttribute(serverObjectName, "InShutdown");
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+
+ public boolean isLastNode()
+ {
+ if (!clustered)
+ {
+ return true;
+ }
+
+ // other options
+ // object name => jboss.jgroups:cluster=DefaultPartition,type=channel
+ // object name => jboss.jgroups:cluster=Tomcat-Cluster,type=channel
+ // attribute => NumberOfTasksInTimer
+
+ try
+ {
+ return ((Vector) jbossMBeanServer.getAttribute(clusteringCacheObjectName, "Members")).size() == 1;
+ }
+ catch (Exception e) {
+ log.warn("Could not determine number of members in cluster", e);
+ return true;
+ }
+ }
+
+ public boolean failover()
+ {
+ return isClustered() && nodeIsShuttingDown() && !isLastNode();
+ }
+
+ public boolean isJBoss()
+ {
+ return jbossMBeanServer != null;
+ }
+
+ protected MBeanServer locateJBoss()
+ {
+ for (Iterator i = MBeanServerFactory.findMBeanServer(null).iterator(); i.hasNext(); )
+ {
+ MBeanServer server = (MBeanServer) i.next();
+ if (server.getDefaultDomain().equals("jboss"))
+ {
+ return server;
+ }
+ }
+ return null;
+ }
+
+ // FIXME my sense is that this could lookup could be more elegant or conforming
+ public static JBossClusterMonitor getInstance(ServletContext ctx)
+ {
+ return (JBossClusterMonitor) ctx.getAttribute(Seam.getComponentName(JBossClusterMonitor.class));
+ }
+}
Modified: trunk/src/main/org/jboss/seam/servlet/SeamListener.java
===================================================================
--- trunk/src/main/org/jboss/seam/servlet/SeamListener.java 2008-12-04 03:42:05 UTC (rev 9711)
+++ trunk/src/main/org/jboss/seam/servlet/SeamListener.java 2008-12-04 07:22:51 UTC (rev 9712)
@@ -14,6 +14,7 @@
import org.jboss.seam.Seam;
import org.jboss.seam.contexts.ServletLifecycle;
import org.jboss.seam.init.Initialization;
+import org.jboss.seam.jmx.JBossClusterMonitor;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
@@ -46,7 +47,16 @@
public void sessionDestroyed(HttpSessionEvent event)
{
- ServletLifecycle.endSession( event.getSession() );
+ JBossClusterMonitor monitor = JBossClusterMonitor.getInstance(event.getSession().getServletContext());
+ if (monitor != null && monitor.failover())
+ {
+ // If application is unfarmed or all nodes shutdown simultaneously, cluster cache may still fail to retrieve SFSBs to destroy
+ log.info("Detected fail-over, not destroying session context");
+ }
+ else
+ {
+ ServletLifecycle.endSession( event.getSession() );
+ }
}
}
15 years, 5 months
Seam SVN: r9711 - trunk/src/main/org/jboss/seam/contexts.
by seam-commits@lists.jboss.org
Author: youngm
Date: 2008-12-03 22:42:05 -0500 (Wed, 03 Dec 2008)
New Revision: 9711
Modified:
trunk/src/main/org/jboss/seam/contexts/ServerConversationContext.java
Log:
JBSEAM-3655 backed out the cache
Modified: trunk/src/main/org/jboss/seam/contexts/ServerConversationContext.java
===================================================================
--- trunk/src/main/org/jboss/seam/contexts/ServerConversationContext.java 2008-12-04 03:14:42 UTC (rev 9710)
+++ trunk/src/main/org/jboss/seam/contexts/ServerConversationContext.java 2008-12-04 03:42:05 UTC (rev 9711)
@@ -36,7 +36,6 @@
private final Set<String> removals = new HashSet<String>();
private final String id;
private final List<String> idStack;
- private final Map<String, Object> cache = new HashMap<String, Object>();
private List<String> getIdStack()
{
@@ -82,24 +81,9 @@
this.idStack = new LinkedList<String>();
idStack.add(id);
}
-
- public Object get(String name)
- {
- if (!cache.containsKey(name))
- {
- Object value = resolveValue(name);
- //Don't cache the value of components that have @PerNestedConverstion
- if(isPerNestedConversation(name))
- {
- return value;
- }
- cache.put(name, value);
- }
- return cache.get(name);
- }
-
- protected Object resolveValue(String name)
- {
+
+ public Object get(String name)
+ {
Object result = additions.get(name);
if (result!=null)
{
@@ -164,7 +148,6 @@
public void set(String name, Object value)
{
if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.preSetVariable." + name);
- cache.remove(name);
if (value==null)
{
//yes, we need this
@@ -202,7 +185,6 @@
public void remove(String name)
{
if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.preRemoveVariable." + name);
- cache.remove(name);
additions.remove(name);
removals.add(name);
if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.postRemoveVariable." + name);
@@ -263,7 +245,6 @@
public void clear()
{
- cache.clear();
additions.clear();
removals.addAll( getNamesFromSession() );
}
15 years, 5 months
Seam SVN: r9710 - trunk/src/main/org/jboss/seam/deployment.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-12-03 22:14:42 -0500 (Wed, 03 Dec 2008)
New Revision: 9710
Modified:
trunk/src/main/org/jboss/seam/deployment/ClassDescriptor.java
Log:
JBSEAM-3757 - oops, conditions weren't quite right
Modified: trunk/src/main/org/jboss/seam/deployment/ClassDescriptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/ClassDescriptor.java 2008-12-04 01:31:39 UTC (rev 9709)
+++ trunk/src/main/org/jboss/seam/deployment/ClassDescriptor.java 2008-12-04 03:14:42 UTC (rev 9710)
@@ -26,6 +26,9 @@
try
{
clazz = classLoader.loadClass(classname);
+ // IBM JVM will throw a TypeNotPresentException if any annotation on the class is not on
+ // the classpath, rendering the class virtually unusable (given Seam's heavy use of annotations)
+ clazz.getAnnotations();
}
catch (ClassNotFoundException cnfe)
{
@@ -35,13 +38,6 @@
{
log.debug("could not load class (missing dependency): " + classname, ncdfe);
}
-
- try
- {
- // IBM JVM will fail if an annotation used on the type is not on the classpath
- // rendering the class virtually unusable (given Seam's heavy use of annotations)
- clazz.getAnnotations();
- }
catch (TypeNotPresentException tnpe)
{
clazz = null;
15 years, 5 months