[jboss-cvs] JBossAS SVN: r64243 - in trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic: bean and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 24 01:25:14 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-07-24 01:25:14 -0400 (Tue, 24 Jul 2007)
New Revision: 64243

Added:
   trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/
   trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/EntityPKBean.java
   trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/SessionToEntityBean.java
   trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/StatefulSessionBean.java
   trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/StatelessSessionBean.java
Log:
Add missing beans dir

Added: trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/EntityPKBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/EntityPKBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/EntityPKBean.java	2007-07-24 05:25:14 UTC (rev 64243)
@@ -0,0 +1,145 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.cluster.ejb2.basic.bean;
+
+
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.CreateException;
+import javax.ejb.RemoveException;
+
+import org.jboss.test.testbean.interfaces.AComplexPK;
+import org.jboss.logging.Logger;
+
+/** Tests of the cluster cache invalidation framework.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */ 
+public abstract class EntityPKBean implements EntityBean
+{
+   private static Logger log = Logger.getLogger(EntityPKBean.class);
+
+   private EntityContext entityContext;
+
+   public AComplexPK ejbCreate(boolean aBoolean, int anInt, long aLong,
+      double aDouble, String aString)
+      throws CreateException
+   {
+      log.debug("ejbCreate() called");
+      updateAllValues(new AComplexPK(aBoolean, anInt, aLong, aDouble, aString));
+      return null;
+   }
+
+   public AComplexPK ejbCreateMETHOD(boolean aBoolean, int anInt, long aLong,
+      double aDouble, String aString)
+      throws CreateException
+   {
+      log.debug("ejbCreateMETHOD() called");
+      updateAllValues(new AComplexPK(aBoolean, anInt, aLong, aDouble, aString));
+      return null;
+   }
+
+   public void ejbPostCreate(boolean aBoolean, int anInt, long aLong,
+      double aDouble, String aString)
+      throws CreateException
+   {
+      log.debug("ejbPostCreate(pk) called");
+   }
+
+   public void ejbPostCreateMETHOD(boolean aBoolean, int anInt, long aLong,
+      double aDouble, String aString)
+      throws CreateException
+   {
+      log.debug("ejbPostCreateMETHOD(pk) called");
+   }
+
+   public void ejbActivate()
+   {
+      log.debug("ejbActivate() called");
+   }
+
+   public void ejbLoad()
+   {
+      log.debug("ejbLoad() called");
+   }
+
+   public void ejbPassivate()
+   {
+      log.debug("ejbPassivate() called");
+   }
+
+   public void ejbRemove() throws RemoveException
+   {
+
+      log.debug("EntityPK.ejbRemove() called");
+   }
+   public void ejbStore()
+   {
+      log.debug("ejbStore() called");
+   }
+
+   public void setEntityContext(EntityContext context)
+   {
+      log.debug("setSessionContext() called");
+      entityContext = context;
+   }
+
+   public void unsetEntityContext()
+   {
+      log.debug("unsetSessionContext() called");
+      entityContext = null;
+   }
+
+   public void updateAllValues(AComplexPK aComplexPK)
+   {
+      setABoolean(aComplexPK.aBoolean);
+      setADouble(aComplexPK.aDouble);
+      setALong(aComplexPK.aLong);
+      setAnInt(aComplexPK.anInt);
+      setAString(aComplexPK.aString);
+   }
+
+   public AComplexPK readAllValues()
+   {
+      return new AComplexPK(getABoolean(), getAnInt(), getALong(), getADouble(),
+         getAString());
+   }
+
+   public abstract boolean getABoolean();
+   public abstract void setABoolean(boolean value);
+
+   public abstract double getADouble();
+   public abstract void setADouble(double value);
+
+   public abstract long getALong();
+   public abstract void setALong(long value);
+
+   public abstract int getAnInt();
+   public abstract void setAnInt(int value);
+
+   public abstract String getAString();
+   public abstract void setAString(String value);
+
+   public abstract int getOtherField();
+   public abstract void setOtherField(int newValue);
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/EntityPKBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/SessionToEntityBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/SessionToEntityBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/SessionToEntityBean.java	2007-07-24 05:25:14 UTC (rev 64243)
@@ -0,0 +1,168 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.cluster.ejb2.basic.bean;
+
+import java.rmi.RemoteException;
+import java.rmi.dgc.VMID;
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import javax.ejb.CreateException;
+import javax.ejb.SessionContext;
+import javax.ejb.SessionBean;
+import javax.ejb.FinderException;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.cluster.ejb2.basic.interfaces.EntityPK;
+import org.jboss.test.cluster.ejb2.basic.interfaces.EntityPKHome;
+import org.jboss.test.cluster.ejb2.basic.interfaces.NodeAnswer;
+import org.jboss.test.testbean.interfaces.AComplexPK;
+
+/**  A stateful session which access an entity bean used in testing the CIF.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */ 
+public class SessionToEntityBean implements SessionBean
+{
+   private static Logger log = Logger.getLogger(SessionToEntityBean.class);
+   private static VMID nodeID = new VMID();
+
+   private int accessCount;
+   private AComplexPK theKey;
+
+   public void ejbCreate(AComplexPK key) throws CreateException
+   {
+      log.debug("ejbCreate(AComplexPK) called, nodeID="+nodeID);
+      this.theKey = key;
+   }
+   public void ejbActivate()
+   {
+      log.debug("ejbActivate() called, nodeID="+nodeID);
+   }
+   public void ejbPassivate()
+   {
+      log.debug("ejbPassivate() called, nodeID="+nodeID);
+   }
+   public void ejbRemove()
+   {
+      log.debug("ejbRemove() called, nodeID="+nodeID);
+      try
+      {
+         InitialContext ctx = new InitialContext();
+         Context enc = (Context) ctx.lookup("java:comp/env");
+         EntityPKHome home = (EntityPKHome) enc.lookup("ejb/EntityPKHome");
+         home.remove(theKey);
+      }
+      catch(Exception e)
+      {
+         log.error("Failed to remove EntityPK", e);
+      }
+   }
+   public void setSessionContext(SessionContext context)
+   {
+   }
+
+   public String createEntity()
+      throws CreateException
+   {
+      String msg = null;
+      EntityPKHome home = null;
+      log.info("Enter createEntity, theKey="+theKey);
+      try
+      {
+         InitialContext ctx = new InitialContext();
+         Context enc = (Context) ctx.lookup("java:comp/env");
+         home = (EntityPKHome) enc.lookup("ejb/EntityPKHome");
+         EntityPK bean = home.findByPrimaryKey(theKey);
+         msg = "Found EntityPK, bean="+bean;
+         log.info(msg);
+      }
+      catch(FinderException e)
+      {
+         EntityPK bean = home.create(theKey.aBoolean, theKey.anInt, theKey.aLong,
+            theKey.aDouble, theKey.aString);
+         msg = "Created EntityPK, bean="+bean;
+         log.info(msg);
+      }
+      catch(Exception e)
+      {
+         log.error("Failed to create EntityPK", e);
+         throw new CreateException("Failed to create EntityPK: "+e.getMessage());
+      }
+      return msg;
+   }
+   public NodeAnswer accessEntity()
+   {
+      accessCount ++;
+      log.debug("Enter accessEntity(), accessCount="+accessCount);
+      int beanCount = 0;
+      try
+      {
+         InitialContext ctx = new InitialContext();
+         Context enc = (Context) ctx.lookup("java:comp/env");
+         EntityPKHome home = (EntityPKHome) enc.lookup("ejb/EntityPKHome");
+         EntityPK bean = home.findByPrimaryKey(theKey);
+         bean.setOtherField(accessCount);
+         log.debug("Set EntityPK.OtherField to: "+accessCount);
+         beanCount = bean.getOtherField();
+      }
+      catch(Exception e)
+      {
+         log.debug("failed", e);
+      }
+      log.debug("Exit accessEntity()");
+      return new NodeAnswer(nodeID, new Integer(beanCount));
+   }
+
+   public int getAccessCount()
+   {
+      return accessCount;
+   }
+   public NodeAnswer validateAccessCount(int count)
+      throws RemoteException
+   {
+      if( accessCount != count )
+         throw new RemoteException("AccessCount: " + accessCount + " != " + count);
+      
+      int beanCount = 0;
+      try
+      {
+         InitialContext ctx = new InitialContext();
+         Context enc = (Context) ctx.lookup("java:comp/env");
+         EntityPKHome home = (EntityPKHome) enc.lookup("ejb/EntityPKHome");
+         EntityPK bean = home.findByPrimaryKey(theKey);
+         beanCount = bean.getOtherField();
+         if( beanCount != count )
+            throw new RemoteException("BeanCount: " + beanCount + " != " + count);
+      }
+      catch(RemoteException e)
+      {
+         log.error("Failed to validate EntityPK", e);
+         throw e;
+      }
+      catch(Exception e)
+      {
+         log.error("Failed to validate EntityPK", e);
+         throw new RemoteException("Failed to validate EntityPK");
+      }
+      return new NodeAnswer(nodeID, new Integer(beanCount));
+   }
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/SessionToEntityBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/StatefulSessionBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/StatefulSessionBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/StatefulSessionBean.java	2007-07-24 05:25:14 UTC (rev 64243)
@@ -0,0 +1,107 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.cluster.ejb2.basic.bean;
+
+import javax.ejb.*;
+
+import java.rmi.RemoteException;
+import java.rmi.dgc.VMID;
+
+import org.jboss.test.cluster.ejb2.basic.interfaces.NodeAnswer;
+
+/**
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @version $Revision$
+ */
+public class StatefulSessionBean extends org.jboss.test.testbean.bean.StatefulSessionBean
+{
+
+   // Constants -----------------------------------------------------
+   
+   // Attributes ----------------------------------------------------
+   
+   public transient VMID myId = null; 
+   
+   // Static --------------------------------------------------------
+   
+   // Constructors --------------------------------------------------
+   
+   public void ejbCreate(String name) throws RemoteException, CreateException
+   {
+      super.ejbCreate(name);
+
+      this.myId = new VMID();
+      log.debug("My ID: " + this.myId);
+   }
+
+   public void ejbActivate() throws RemoteException
+   {
+      super.ejbActivate();
+      if (this.myId == null)
+      {
+         //it is a failover: we need to assign ourself an id
+         this.myId = new VMID();
+      }
+      log.debug("Activate. My ID: " + this.myId + " name: " + this.name);
+   }
+
+   public void ejbPassivate() throws RemoteException
+   {
+      super.ejbPassivate();
+      log.debug("Passivate. My ID: " + this.myId + " name: " + this.name);
+   }
+   // Public --------------------------------------------------------
+   
+   // Remote Interface implementation ----------------------------------------------
+   
+   public NodeAnswer getNodeState() throws RemoteException
+   {
+      NodeAnswer state = new NodeAnswer(this.myId, this.name);
+      log.debug("getNodeState, " + state);
+      return state;
+   }
+
+   public void setName(String name) throws RemoteException
+   {
+      this.name = name;
+      log.debug("Name set to " + name);
+   }
+
+   public void setNameOnlyOnNode(String name, VMID node) throws RemoteException
+   {
+      if (node.equals(this.myId))
+         this.setName(name);
+      else
+         throw new EJBException("Trying to assign value on node " + this.myId + " but this node expected: " + node);
+   }
+
+   // Y overrides ---------------------------------------------------
+   
+   // Package protected ---------------------------------------------
+   
+   // Protected -----------------------------------------------------
+   
+   // Private -------------------------------------------------------
+   
+   // Inner classes -------------------------------------------------
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/StatefulSessionBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/StatelessSessionBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/StatelessSessionBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/StatelessSessionBean.java	2007-07-24 05:25:14 UTC (rev 64243)
@@ -0,0 +1,112 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.cluster.ejb2.basic.bean;
+
+import java.rmi.RemoteException;
+import javax.ejb.SessionBean;
+import javax.ejb.EJBException;
+import javax.ejb.SessionContext;
+import javax.naming.InitialContext;
+
+import org.jboss.test.cluster.ejb2.basic.interfaces.StatelessSession;
+import org.jboss.test.cluster.ejb2.basic.interfaces.StatelessSessionHome;
+
+public class StatelessSessionBean implements SessionBean
+{
+   public static long numberOfCalls = 0;
+
+   public void ejbCreate()
+   {
+   }
+   public void ejbActivate() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbPassivate() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbRemove() throws EJBException, RemoteException
+   {
+   }
+
+   public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException
+   {
+   }
+
+   public void callBusinessMethodA()
+   {
+      numberOfCalls++;
+   }
+   
+   public String callBusinessMethodB(String jndiURL)
+   {
+      numberOfCalls++;
+      String rtn = "callBusinessMethodB-" + numberOfCalls;
+      testColocation(jndiURL);
+      return rtn;
+   }
+
+   public void testColocation(String jndiURL)
+   {
+      try
+      {
+         System.out.println("begin testColocation");
+         InitialContext ctx = new InitialContext();
+         if( jndiURL == null )
+            jndiURL = "jnp://" + System.getProperty("jboss.bind.address", "localhost") + ":1100/nextgen_StatelessSession";
+         StatelessSessionHome home = (StatelessSessionHome) ctx.lookup(jndiURL);
+         StatelessSession session = home.create();
+         session.callBusinessMethodA();
+         System.out.println("end testColocation");
+      }
+      catch (Exception ex)
+      {
+         ex.printStackTrace();
+      }
+
+   }
+   
+   public void resetNumberOfCalls ()
+   {
+      System.out.println("Number of calls has been reseted");
+      numberOfCalls = 0;
+   }
+   
+   public void makeCountedCall ()
+   {
+      System.out.println("makeCountedCall called");
+      numberOfCalls++;
+   }
+   
+   public long getCallCount ()
+   {
+      System.out.println("getCallCount called");
+      return numberOfCalls;
+   }
+   
+   public String getBindAddress()
+   {
+      return System.getProperty("jboss.bind.address");
+   }
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/ejb2/basic/bean/StatelessSessionBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list