001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.hibernate.ejb;
023:
024: import org.jboss.test.hibernate.model.User;
025: import org.jboss.test.hibernate.ProfileService;
026:
027: import javax.ejb.SessionBean;
028: import javax.ejb.EJBException;
029: import javax.ejb.SessionContext;
030: import java.rmi.RemoteException;
031: import java.util.List;
032:
033: import org.hibernate.HibernateException;
034:
035: /**
036: * An ejb to test the ejb method interception style of transparent
037: * session management.
038: *
039: * @author <a href="mailto:steve@hibernate.org">Steve Ebersole</a>
040: * @version $Revision: 57211 $
041: *
042: * @ejb:bean name="ProfileService"
043: * jndi-name="ProfileService"
044: * view-type="remote"
045: * type="Stateless"
046: */
047: public class ProfileBean implements SessionBean {
048: private ProfileService delegate = new ProfileService();
049:
050: /**
051: * @exception EJBException if an error occurs
052: * @ejb:interface-method
053: */
054: public User storeUser(User user) throws EJBException {
055: try {
056: return delegate.storeUser(user);
057: } catch (HibernateException e) {
058: throw new EJBException("Error performing store", e);
059: }
060: }
061:
062: /**
063: * @exception EJBException if an error occurs
064: * @ejb:interface-method
065: */
066: public User loadUser(long id) throws EJBException {
067: try {
068: return delegate.loadUser(id);
069: } catch (HibernateException e) {
070: throw new EJBException("Error performing load", e);
071: }
072: }
073:
074: /**
075: * @exception EJBException if an error occurs
076: * @ejb:interface-method
077: */
078: public User loadUser(Long id) throws EJBException {
079: try {
080: return delegate.loadUser(id);
081: } catch (HibernateException e) {
082: throw new EJBException("Error performing load", e);
083: }
084: }
085:
086: /**
087: * @exception EJBException if an error occurs
088: * @ejb:interface-method
089: */
090: public List listUsers() throws EJBException {
091: try {
092: return delegate.listUsers();
093: } catch (HibernateException e) {
094: throw new EJBException("Error performing list", e);
095: }
096: }
097:
098: /**
099: * @ejb:create-method
100: */
101: public void ejbCreate() {
102: }
103:
104: public void ejbActivate() throws EJBException, RemoteException {
105: }
106:
107: public void ejbPassivate() throws EJBException, RemoteException {
108: }
109:
110: public void ejbRemove() throws EJBException, RemoteException {
111: }
112:
113: public void setSessionContext(SessionContext ctx)
114: throws EJBException, RemoteException {
115: }
116: }
|