KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tm > recovery > BatchRecoveryLoggerService


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.tm.recovery;
23
24 import javax.management.ObjectName JavaDoc;
25
26 import org.jboss.system.ServiceMBeanSupport;
27 import org.jboss.tm.XidFactoryMBean;
28
29 /**
30  * Service MBean that provides recovery logger functionality. The
31  * <code>BatchRecoveryLoggerService</code> is simply an MBean wrapper for a
32  * <code>BatchRecoveryLogger</code> instance, which does the real work.
33  *
34  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
35  * @version $Revision: 37459 $
36  */

37 public class BatchRecoveryLoggerService
38       extends ServiceMBeanSupport
39       implements BatchRecoveryLoggerServiceMBean
40 {
41    /** The actual recovery logger. */
42    protected BatchRecoveryLogger logger;
43    
44    /** The recovery logger's Xid factory. */
45    private ObjectName JavaDoc xidFactory;
46
47    /**
48     * Constructs a <code>BatchRecoveryLoggerService</code>.
49     */

50    public BatchRecoveryLoggerService()
51    {
52       logger = createLogger();
53    }
54    
55    /**
56     * To be overrided by subclasses that create a logger derived from
57     * <code>BatchRecoveryLogger</code> for testing purposes.
58     */

59    protected BatchRecoveryLogger createLogger()
60    {
61       return new BatchRecoveryLogger();
62    }
63
64    // ServiceMBeanSupport overrides ---------------------------------
65

66    /**
67     * @see org.jboss.system.ServiceMBeanSupport#startService()
68     */

69    public void startService() throws Exception JavaDoc
70    {
71       super.startService();
72       XidFactoryMBean xidFactoryObj =
73          (XidFactoryMBean) getServer().getAttribute(xidFactory, "Instance");
74       logger.setXidFactory(xidFactoryObj);
75       logger.start();
76    }
77
78    /**
79     * @see org.jboss.system.ServiceMBeanSupport#stopService()
80     */

81    public void stopService() throws Exception JavaDoc
82    {
83       super.stopService();
84       logger.stop();
85    }
86
87    // RecoveryLoggerInstance implementation -------------------------
88

89    /**
90     * @see org.jboss.tm.recovery.RecoveryLoggerInstance#getInstance()
91     */

92    public RecoveryLogger getInstance()
93    {
94       return logger;
95    }
96
97    // BatchRecoveryLoggerServiceMBean implementation ----------------
98

99    /**
100     * @see org.jboss.tm.recovery.BatchRecoveryLoggerServiceMBean#getDirectoryList()
101     */

102    public String JavaDoc[] getDirectoryList()
103    {
104       return logger.getDirectoryList();
105    }
106
107    /**
108     * @see org.jboss.tm.recovery.BatchRecoveryLoggerServiceMBean#setDirectoryList(
109     * java.lang.String[])
110     */

111    public void setDirectoryList(String JavaDoc[] directoryList)
112    {
113       logger.setDirectoryList(directoryList);
114    }
115
116    /**
117     * @see org.jboss.tm.recovery.BatchRecoveryLoggerServiceMBean#getLogFileSize()
118     */

119    public int getLogFileSize()
120    {
121       return logger.getLogFileSize();
122    }
123
124    /**
125     * @see org.jboss.tm.recovery.BatchRecoveryLoggerServiceMBean#setLogFileSize(
126     * int)
127     */

128    public void setLogFileSize(int logFileSize)
129    {
130       logger.setLogFileSize(logFileSize);
131    }
132
133    /**
134     * @see org.jboss.tm.recovery.BatchRecoveryLoggerServiceMBean#getHeuristicStatusLogDirectory()
135     */

136    public String JavaDoc getHeuristicStatusLogDirectory()
137    {
138       return logger.getHeuristicStatusLogDirectory();
139    }
140
141    /**
142     * @see org.jboss.tm.recovery.BatchRecoveryLoggerServiceMBean#setHeuristicStatusLogDirectory(
143     * java.lang.String)
144     */

145    public void setHeuristicStatusLogDirectory(String JavaDoc directory)
146    {
147       logger.setHeuristicStatusLogDirectory(directory);
148    }
149
150    /**
151     * @see org.jboss.tm.recovery.BatchRecoveryLoggerServiceMBean#getXidFactory()
152     */

153    public ObjectName JavaDoc getXidFactory()
154    {
155       return xidFactory;
156    }
157    
158    /**
159     * @see org.jboss.tm.recovery.BatchRecoveryLoggerServiceMBean#setXidFactory(
160     * javax.management.ObjectName)
161     */

162    public void setXidFactory(ObjectName JavaDoc xidFactory)
163    {
164       this.xidFactory = xidFactory;
165    }
166    
167 }
168
Popular Tags