[jboss-cvs] JBossAS SVN: r87529 - in projects/ejb3/trunk: core/src/main/java/org/jboss/ejb3/stateless and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Apr 19 00:11:11 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-04-19 00:11:10 -0400 (Sun, 19 Apr 2009)
New Revision: 87529
Added:
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationBase.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationRemote.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationStatefulBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationStatelessBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/unit/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/unit/DisableClusteredAnnotationUnitTestCase.java
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
Log:
[EJBTHREE-1346] Respect disabling @Clustered via jboss.xml
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java 2009-04-19 04:08:43 UTC (rev 87528)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java 2009-04-19 04:11:10 UTC (rev 87529)
@@ -83,6 +83,7 @@
import org.jboss.injection.Injector;
import org.jboss.injection.JndiPropertyInjector;
import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
import org.jboss.util.NotImplementedException;
@@ -922,6 +923,11 @@
public boolean isClustered()
{
+ JBossEnterpriseBeanMetaData md = getXml();
+ if (md instanceof JBossSessionBeanMetaData)
+ {
+ return ((JBossSessionBeanMetaData)md).isClustered();
+ }
return isAnnotationPresent(Clustered.class);
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2009-04-19 04:08:43 UTC (rev 87528)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2009-04-19 04:11:10 UTC (rev 87529)
@@ -75,6 +75,7 @@
import org.jboss.injection.WebServiceContextProxy;
import org.jboss.injection.lang.reflect.BeanProperty;
import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
import org.jboss.proxy.ejb.handle.HomeHandleImpl;
@@ -161,6 +162,11 @@
public boolean isClustered()
{
+ JBossEnterpriseBeanMetaData md = getXml();
+ if (md instanceof JBossSessionBeanMetaData)
+ {
+ return ((JBossSessionBeanMetaData)md).isClustered();
+ }
return isAnnotationPresent(Clustered.class);
}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationBase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationBase.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationBase.java 2009-04-19 04:11:10 UTC (rev 87529)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1346;
+
+import java.rmi.dgc.VMID;
+
+import javax.interceptor.Interceptors;
+
+import org.jboss.ejb3.test.clusteredsession.NodeAnswer;
+import org.jboss.ejb3.test.clusteredsession.util.ExplicitFailoverInterceptor;
+import org.jboss.logging.Logger;
+
+/**
+ * @author Brian Stansberry
+ *
+ * @version $Revision: 57207 $
+ */
+public class DisableClusteredAnnotationBase implements java.io.Serializable, DisableClusteredAnnotationRemote
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ private Logger log = Logger.getLogger(getClass());
+ public static final NodeAnswer myId = new NodeAnswer(new VMID(), "answer");
+
+ // Remote Interface implementation ----------------------------------------------
+
+ // Mimic explict failover
+ @Interceptors({ExplicitFailoverInterceptor.class})
+ public NodeAnswer getNodeState()
+ {
+ log.info("getNodeState, " + myId);
+ return myId;
+ }
+
+ public void setUpFailover(String failover) {
+ // To setup the failover property
+ log.info("Setting up failover property: " +failover);
+ System.setProperty ("JBossCluster-DoFail", failover);
+ }
+
+}
Property changes on: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationBase.java
___________________________________________________________________
Name: svn:keywords
+
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationRemote.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationRemote.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationRemote.java 2009-04-19 04:11:10 UTC (rev 87529)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1346;
+
+import org.jboss.ejb3.test.clusteredsession.NodeAnswer;
+
+/**
+ * Comment
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 61136 $
+ */
+public interface DisableClusteredAnnotationRemote
+{
+ NodeAnswer getNodeState();
+
+ public void setUpFailover(String failover);
+}
Property changes on: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationRemote.java
___________________________________________________________________
Name: svn:keywords
+
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationStatefulBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationStatefulBean.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationStatefulBean.java 2009-04-19 04:11:10 UTC (rev 87529)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1346;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.Clustered;
+
+/**
+ * Test for EJBTHREE-1346. The @Clustered is overridden via jboss.xml
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 67628 $
+ */
+ at Stateful(name="DisableClusteredAnnotationStateful")
+ at Clustered(partition="BogusPartition")
+ at Remote(DisableClusteredAnnotationRemote.class)
+public class DisableClusteredAnnotationStatefulBean extends DisableClusteredAnnotationBase
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ // Only difference from superclass is the added class-level annotations
+}
Property changes on: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationStatefulBean.java
___________________________________________________________________
Name: svn:keywords
+
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationStatelessBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationStatelessBean.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationStatelessBean.java 2009-04-19 04:11:10 UTC (rev 87529)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1346;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.Clustered;
+
+/**
+ * Test for EJBTHREE-1346. The @Clustered is overridden via jboss.xml
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 67628 $
+ */
+ at Stateless(name="DisableClusteredAnnotationStateless")
+ at Clustered(partition="BogusPartition")
+ at Remote(DisableClusteredAnnotationRemote.class)
+public class DisableClusteredAnnotationStatelessBean extends DisableClusteredAnnotationBase
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ // Only difference from superclass is the added class-level annotations
+}
Property changes on: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/DisableClusteredAnnotationStatelessBean.java
___________________________________________________________________
Name: svn:keywords
+
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/unit/DisableClusteredAnnotationUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/unit/DisableClusteredAnnotationUnitTestCase.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/unit/DisableClusteredAnnotationUnitTestCase.java 2009-04-19 04:11:10 UTC (rev 87529)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.ejbthree1346.unit;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.clusteredsession.NodeAnswer;
+import org.jboss.ejb3.test.ejbthree1346.DisableClusteredAnnotationRemote;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Tests the @Clustered beans with <clustered>false</clustered> in jboss.xml
+ * do not exhibit clustering behavior.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 83582 $
+ */
+public class DisableClusteredAnnotationUnitTestCase extends JBossClusteredTestCase
+{
+ public DisableClusteredAnnotationUnitTestCase (String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ final String jarName = "ejbthree1346.jar";
+ Test t1 = JBossClusteredTestCase.getDeploySetup(DisableClusteredAnnotationUnitTestCase.class,
+ jarName);
+ return t1;
+ }
+
+ protected InitialContext getInitialContext(int node) throws Exception {
+ // Connect to the server0 JNDI
+ String[] urls = getNamingURLs();
+ Properties env1 = new Properties();
+ env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ "org.jnp.interfaces.NamingContextFactory");
+ env1.setProperty(Context.PROVIDER_URL, urls[node]);
+ return new InitialContext(env1);
+ }
+
+ /** Validate the stateful bean is not clustered by having failover not work */
+ public void testStatefulBean() throws Exception
+ {
+ // Connect to the server0 JNDI
+ InitialContext ctx = getInitialContext(0);
+
+ DisableClusteredAnnotationRemote stateful = (DisableClusteredAnnotationRemote) ctx.lookup("DisableClusteredAnnotationStateful/remote");
+
+ NodeAnswer node1 = stateful.getNodeState ();
+ getLog ().debug ("Node 1 ID: " +node1);
+
+ // Now we switch to the other node, simulating a failure on node 1
+ //
+ stateful.setUpFailover("once");
+ try
+ {
+ stateful.getNodeState ();
+ fail("GenericClusteringException did not propagate");
+ }
+ catch (Exception good) {}
+ }
+
+ /** Test stateless bean by demonstrating no load balancing */
+ public void testStatelessBean() throws Exception
+ {
+ InitialContext ctx = getInitialContext(0);
+
+ DisableClusteredAnnotationRemote stateless =
+ (DisableClusteredAnnotationRemote) ctx.lookup("DisableClusteredAnnotationStateless/remote");
+
+ NodeAnswer node1 = stateless.getNodeState();
+ assertNotNull(node1);
+ getLog ().debug ("Node 1 ID: " +node1);
+
+ for (int i = 0; i < 20; i++)
+ {
+ assertEquals(node1, stateless.getNodeState());
+ }
+ }
+}
Property changes on: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1346/unit/DisableClusteredAnnotationUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+
More information about the jboss-cvs-commits
mailing list