[jboss-cvs] jboss-ejb3/src/test/org/jboss/ejb3/test/iiop ...

Carlo de Wolf carlo at nerdnet.nl
Fri Jul 28 04:04:34 EDT 2006


  User: wolfc   
  Date: 06/07/28 04:04:34

  Added:       src/test/org/jboss/ejb3/test/iiop        TxTesterBean.java
                        MySession.java MyStatefulHome.java MyStateful.java
                        MyStatefulBean.java TxTester.java
                        MySessionBean.java
  Log:
  EJBTHREE-667: work in progress
  
  Revision  Changes    Path
  1.1      date: 2006/07/28 08:04:33;  author: wolfc;  state: Exp;jboss-ejb3/src/test/org/jboss/ejb3/test/iiop/TxTesterBean.java
  
  Index: TxTesterBean.java
  ===================================================================
  /*
   * 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.ejb3.test.iiop;
  
  import javax.ejb.EJBException;
  import javax.ejb.Remote;
  import javax.ejb.Stateless;
  import javax.ejb.TransactionAttribute;
  import javax.ejb.TransactionAttributeType;
  import javax.ejb.TransactionManagement;
  import javax.ejb.TransactionManagementType;
  import javax.transaction.Status;
  import javax.transaction.SystemException;
  import javax.transaction.Transaction;
  import javax.transaction.TransactionManager;
  
  import org.apache.log4j.Logger;
  import org.jboss.annotation.JndiInject;
  import org.jboss.annotation.ejb.RemoteBinding;
  import org.jboss.ejb3.iiop.IORFactory;
  
  /**
   * Comment
   *
   * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
   * @version $Revision: 1.1 $
   */
  @Stateless
  @Remote(TxTester.class)
  @RemoteBinding(factory=IORFactory.class)
  @TransactionManagement(TransactionManagementType.CONTAINER)
  public class TxTesterBean
  {
     private static final Logger log = Logger.getLogger(TxTesterBean.class);
     
     @JndiInject(jndiName="java:/TransactionManager") TransactionManager tm;
     
     @TransactionAttribute(TransactionAttributeType.MANDATORY)
     public void txMandatoryMethod()
     {
        try
        {
           log.info("currentThread = " + Thread.currentThread());
           log.info("currentTransaction = " + tm.getTransaction());
           log.info("tm = " + tm);
           
           Transaction tx = tm.getTransaction();
           if(tx == null)
              throw new EJBException("no tx");
           
           if(tx.getStatus() != Status.STATUS_ACTIVE)
              throw new EJBException("tx not active");
        }
        catch(SystemException e)
        {
           throw new EJBException(e);
        }
     }
  }
  
  
  
  1.1      date: 2006/07/28 08:04:34;  author: wolfc;  state: Exp;jboss-ejb3/src/test/org/jboss/ejb3/test/iiop/MySession.java
  
  Index: MySession.java
  ===================================================================
  /*
    * 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.ejb3.test.iiop;
  
  import java.rmi.RemoteException;
  
  import javax.ejb.EJBObject;
  import javax.ejb.Remote;
  
  /**
   * Comment
   *
   * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
   * @version $Revision: 1.1 $
   */
  //@Remote
  public interface MySession extends EJBObject
  {
     String getWhoAmI() throws RemoteException;
     
     String sayHelloTo(String name) throws RemoteException;
  }
  
  
  
  1.1      date: 2006/07/28 08:04:34;  author: wolfc;  state: Exp;jboss-ejb3/src/test/org/jboss/ejb3/test/iiop/MyStatefulHome.java
  
  Index: MyStatefulHome.java
  ===================================================================
  /*
   * 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.ejb3.test.iiop;
  
  import java.rmi.RemoteException;
  
  import javax.ejb.CreateException;
  import javax.ejb.EJBHome;
  
  /**
   * Comment
   *
   * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
   * @version $Revision: 1.1 $
   */
  public interface MyStatefulHome extends EJBHome
  {
     MyStateful create() throws CreateException, RemoteException;
     MyStateful create(String name) throws CreateException, RemoteException;
  }
  
  
  
  1.1      date: 2006/07/28 08:04:34;  author: wolfc;  state: Exp;jboss-ejb3/src/test/org/jboss/ejb3/test/iiop/MyStateful.java
  
  Index: MyStateful.java
  ===================================================================
  /*
   * 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.ejb3.test.iiop;
  
  import java.rmi.RemoteException;
  
  import javax.ejb.EJBObject;
  
  /**
   * Comment
   *
   * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
   * @version $Revision: 1.1 $
   */
  public interface MyStateful extends EJBObject
  {
     String getName() throws RemoteException;
     
     String sayHello() throws RemoteException;
     
     void setName(String name) throws RemoteException;
  }
  
  
  
  1.1      date: 2006/07/28 08:04:34;  author: wolfc;  state: Exp;jboss-ejb3/src/test/org/jboss/ejb3/test/iiop/MyStatefulBean.java
  
  Index: MyStatefulBean.java
  ===================================================================
  /*
   * 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.ejb3.test.iiop;
  
  import java.rmi.RemoteException;
  
  import javax.ejb.CreateException;
  import javax.ejb.Init;
  import javax.ejb.Remote;
  import javax.ejb.RemoteHome;
  import javax.ejb.Stateful;
  
  import org.jboss.annotation.ejb.RemoteBinding;
  import org.jboss.ejb3.iiop.IORFactory;
  
  /**
   * Comment
   *
   * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
   * @version $Revision: 1.1 $
   */
  @Stateful
  @Remote(MyStateful.class)
  @RemoteHome(MyStatefulHome.class)
  @RemoteBinding(factory=IORFactory.class)
  public class MyStatefulBean
  {
     private String name;
     
     @Init
     public void ejbCreate() throws CreateException, RemoteException
     {
        name = "anonymous";
     }
     
     public void ejbCreate(String name) throws CreateException, RemoteException
     {
        this.name = name;
     }
     
     public String getName() throws RemoteException
     {
        return name;
     }
     
     public String sayHello() throws RemoteException
     {
        return "Hello " + name;
     }
     
     public void setName(String name) throws RemoteException
     {
        this.name = name;
     }
  }
  
  
  
  1.1      date: 2006/07/28 08:04:34;  author: wolfc;  state: Exp;jboss-ejb3/src/test/org/jboss/ejb3/test/iiop/TxTester.java
  
  Index: TxTester.java
  ===================================================================
  /*
   * 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.ejb3.test.iiop;
  
  import java.rmi.RemoteException;
  
  import javax.ejb.EJBObject;
  
  /**
   * Comment
   *
   * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
   * @version $Revision: 1.1 $
   */
  public interface TxTester extends EJBObject
  {
     void txMandatoryMethod() throws RemoteException;
  }
  
  
  
  1.1      date: 2006/07/28 08:04:34;  author: wolfc;  state: Exp;jboss-ejb3/src/test/org/jboss/ejb3/test/iiop/MySessionBean.java
  
  Index: MySessionBean.java
  ===================================================================
  /*
    * 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.ejb3.test.iiop;
  
  import javax.annotation.Resource;
  import javax.annotation.security.RolesAllowed;
  import javax.ejb.EJBException;
  import javax.ejb.Remote;
  import javax.ejb.SessionContext;
  import javax.ejb.Stateless;
  import javax.ejb.TransactionAttribute;
  import javax.ejb.TransactionAttributeType;
  import javax.transaction.Status;
  import javax.transaction.SystemException;
  import javax.transaction.UserTransaction;
  
  import org.jboss.annotation.ejb.IIOP;
  import org.jboss.annotation.ejb.RemoteBinding;
  import org.jboss.ejb3.iiop.IORFactory;
  
  /**
   * Comment
   *
   * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
   * @version $Revision: 1.1 $
   */
  @Stateless
  @Remote(MySession.class)
  @RemoteBinding(factory=IORFactory.class)
  @IIOP(interfaceRepositorySupported=false)
  public class MySessionBean
  {
     @Resource SessionContext ctx;
     
     @RolesAllowed({"user"})
     public String getWhoAmI()
     {
        return ctx.getCallerPrincipal().getName();
     }
     
     public String sayHelloTo(String name)
     {
        return "Hi " + name;
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list