KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateless > containermanaged > callbacklogger > SLSBCallbackLoggerAccess


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: SLSBCallbackLoggerAccess.java 692 2006-06-20 09:17:57Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger;
26
27 import javax.ejb.Remote JavaDoc;
28 import javax.ejb.Stateless JavaDoc;
29 import javax.persistence.EntityManager;
30 import javax.persistence.EntityManagerFactory;
31 import javax.persistence.PersistenceUnit;
32
33 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackLogger;
34 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType;
35
36 /**
37  * Accesses the entity bean that is responsible for registering the callback events.
38  * @author Gisele Pinheiro Souza
39  * @author Eduardo Studzinski Estima de Castro
40  *
41  */

42 @Stateless JavaDoc(name="SLSBCallbackLoggerAccess")
43 @Remote JavaDoc(ItfCallbackLoggerAccess.class)
44 public class SLSBCallbackLoggerAccess extends CallbackLoggerAccessBase implements ItfCallbackLoggerAccess{
45
46     /**
47      * The Entity Manager Factory used during the tests.
48      */

49     @PersistenceUnit
50     private EntityManagerFactory entityManagerFactory;
51
52
53     /**
54      * Creates an instance of CallbackLogger with the parameters and the current
55      * time.
56      * @param className the class for which the callback event was called.
57      * @param callbackEvent the callback event name.
58      * @param callbackClassName the name of the class that contains the callback
59      * method.
60      */

61     public void insertCallbackLogger(final String JavaDoc className,
62             final CallbackType callbackEvent, final String JavaDoc callbackClassName) {
63         EntityManager entityManager = entityManagerFactory.createEntityManager();
64
65         CallbackLogger logger = new CallbackLogger();
66         logger.setCallbackClassName(callbackClassName);
67         logger.setCallbackEvent(callbackEvent);
68         logger.setClassName(className);
69         logger.setInsertionDate(getTime());
70         entityManager.persist(logger);
71         entityManager.flush();
72     }
73 }
74
Popular Tags