KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > aop > bean > TxTester


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.aop.bean;
23
24 import javax.management.MBeanRegistration JavaDoc;
25 import javax.management.MBeanServer JavaDoc;
26 import javax.management.ObjectName JavaDoc;
27 import org.jboss.logging.Logger;
28 import org.jboss.system.ServiceMBeanSupport;
29 /**
30  *
31  * @see Monitorable
32  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
33  * @version $Revision: 37406 $
34  */

35 public class TxTester
36    extends ServiceMBeanSupport
37    implements TxTesterMBean, MBeanRegistration JavaDoc
38 {
39    // Constants ----------------------------------------------------
40
// Attributes ---------------------------------------------------
41
static Logger log = Logger.getLogger(TxTester.class);
42    MBeanServer JavaDoc m_mbeanServer;
43
44    // Static -------------------------------------------------------
45

46    // Constructors -------------------------------------------------
47
public TxTester()
48    {}
49    
50    // Public -------------------------------------------------------
51

52    // MBeanRegistration implementation -----------------------------------
53
public ObjectName JavaDoc preRegister(MBeanServer JavaDoc server, ObjectName JavaDoc name)
54    throws Exception JavaDoc
55    {
56       m_mbeanServer = server;
57       return name;
58    }
59    
60    public void postRegister(Boolean JavaDoc registrationDone)
61    {}
62    public void preDeregister() throws Exception JavaDoc
63    {}
64    public void postDeregister()
65    {}
66
67    protected void startService()
68       throws Exception JavaDoc
69    {
70    }
71
72    protected void stopService() {
73    }
74
75    public void testXml()
76    {
77       try{
78          log.info("TESTING Tx XML");
79          TxPOJO pojo = new TxPOJO();
80          log.info("TESTING Never");
81          pojo.callNever();
82          log.info("TESTING NotSupprted");
83          pojo.callNotSupported();
84          log.info("TESTING Supports");
85          pojo.callSupportsWithTx();
86          pojo.callSupportsWithoutTx();
87
88          log.info("TESTING Required");
89          pojo.required();
90
91          log.info("TESTING RequiresNew");
92          pojo.callRequiresNew();
93
94          log.info("TESTING Mandatory");
95          pojo.callMandatoryNoTx();
96          pojo.callMandatoryWithTx();
97       }
98       catch (Throwable JavaDoc ex)
99       {
100          log.error("failed", ex);
101          throw new RuntimeException JavaDoc(ex.getMessage());
102       }
103    }
104
105    public void testAnnotated()
106    {
107       try{
108          log.info("TESTING Tx Annotated");
109          AnnotatedTxPOJO pojo = new AnnotatedTxPOJO();
110          log.info("TESTING Never");
111          pojo.callNever();
112          log.info("TESTING NotSupprted");
113          pojo.callNotSupported();
114          log.info("TESTING Supports");
115          pojo.callSupportsWithTx();
116          pojo.callSupportsWithoutTx();
117
118          log.info("TESTING Required");
119          pojo.required();
120
121          log.info("TESTING RequiresNew");
122          pojo.callRequiresNew();
123
124          log.info("TESTING Mandatory");
125          pojo.callMandatoryNoTx();
126          pojo.callMandatoryWithTx();
127       }
128       catch (Throwable JavaDoc ex)
129       {
130          log.error("failed", ex);
131          throw new RuntimeException JavaDoc(ex);
132       }
133    }
134
135 }
136
137
Popular Tags