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.aop.bean;
023:
024: import org.jboss.logging.Logger;
025: import org.jboss.system.ServiceMBeanSupport;
026:
027: import javax.management.MBeanRegistration;
028: import javax.management.MBeanServer;
029: import javax.management.ObjectName;
030:
031: /**
032: *
033: * @see Monitorable
034: * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
035: * @version $Revision: 57211 $
036: */
037: public class TxTester extends ServiceMBeanSupport implements
038: TxTesterMBean, MBeanRegistration {
039: // Constants ----------------------------------------------------
040: // Attributes ---------------------------------------------------
041: static Logger log = Logger.getLogger(TxTester.class);
042: MBeanServer m_mbeanServer;
043:
044: // Static -------------------------------------------------------
045:
046: // Constructors -------------------------------------------------
047: public TxTester() {
048: }
049:
050: // Public -------------------------------------------------------
051:
052: // MBeanRegistration implementation -----------------------------------
053: public ObjectName preRegister(MBeanServer server, ObjectName name)
054: throws Exception {
055: m_mbeanServer = server;
056: return name;
057: }
058:
059: public void postRegister(Boolean registrationDone) {
060: }
061:
062: public void preDeregister() throws Exception {
063: }
064:
065: public void postDeregister() {
066: }
067:
068: protected void startService() throws Exception {
069: }
070:
071: protected void stopService() {
072: }
073:
074: public void testXml() {
075: try {
076: log.info("TESTING Tx XML");
077: TxPOJO pojo = new TxPOJO();
078: log.info("TESTING Never");
079: pojo.callNever();
080: log.info("TESTING NotSupprted");
081: pojo.callNotSupported();
082: log.info("TESTING Supports");
083: pojo.callSupportsWithTx();
084: pojo.callSupportsWithoutTx();
085:
086: log.info("TESTING Required");
087: pojo.required();
088:
089: log.info("TESTING RequiresNew");
090: pojo.callRequiresNew();
091:
092: log.info("TESTING Mandatory");
093: pojo.callMandatoryNoTx();
094: pojo.callMandatoryWithTx();
095: } catch (Throwable ex) {
096: log.error("failed", ex);
097: throw new RuntimeException(ex.getMessage());
098: }
099: }
100:
101: public void testAnnotated() {
102: try {
103: log.info("TESTING Tx Annotated");
104: AnnotatedTxPOJO pojo = new AnnotatedTxPOJO();
105: log.info("TESTING Never");
106: pojo.callNever();
107: log.info("TESTING NotSupprted");
108: pojo.callNotSupported();
109: log.info("TESTING Supports");
110: pojo.callSupportsWithTx();
111: pojo.callSupportsWithoutTx();
112:
113: log.info("TESTING Required");
114: pojo.required();
115:
116: log.info("TESTING RequiresNew");
117: pojo.callRequiresNew();
118:
119: log.info("TESTING Mandatory");
120: pojo.callMandatoryNoTx();
121: pojo.callMandatoryWithTx();
122: } catch (Throwable ex) {
123: log.error("failed", ex);
124: throw new RuntimeException(ex.getMessage());
125: }
126: }
127:
128: }
|