KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > timerservice > quartz > jmx > EJB3TimerService


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.ejb3.timerservice.quartz.jmx;
23
24 import java.util.Properties JavaDoc;
25
26 import javax.management.ObjectName JavaDoc;
27
28 import org.jboss.ejb3.timerservice.quartz.QuartzTimerServiceFactory;
29 import org.jboss.system.ServiceMBeanSupport;
30
31 /**
32  * Comment
33  *
34  * @author <a HREF="mailto:carlo@nerdnet.nl">Carlo de Wolf</a>
35  * @version $Revision: 56169 $
36  */

37 public class EJB3TimerService extends ServiceMBeanSupport
38    implements EJB3TimerServiceMBean
39 {
40    private QuartzTimerServiceFactory delegate;
41    private ObjectName JavaDoc dataSource;
42    
43    public EJB3TimerService()
44    {
45       delegate = new QuartzTimerServiceFactory();
46    }
47    
48    @Override JavaDoc
49    protected void createService() throws Exception JavaDoc
50    {
51       super.createService();
52    }
53
54    @Override JavaDoc
55    protected void destroyService() throws Exception JavaDoc
56    {
57       //this.delegate.shutdown();
58
super.destroyService();
59    }
60    
61    /**
62     * @jmx:managed-attribute
63     *
64     * @return the object name of the data source to use
65     */

66    public ObjectName JavaDoc getDataSource()
67    {
68       return dataSource;
69    }
70    
71    /**
72     * @jmx:managed-attribute
73     */

74    public void setDataSource(ObjectName JavaDoc dataSource)
75    {
76       this.dataSource = dataSource;
77    }
78    
79    /**
80     * @jmx:managed-attribute
81     *
82     * @param props
83     */

84    public void setProperties(final Properties JavaDoc props)
85    {
86       delegate.setProperties(props);
87    }
88    
89    /**
90     * @jmx:managed-attribute
91     *
92     * @param props
93     */

94    public void setSqlProperties(Properties JavaDoc props)
95    {
96       delegate.setSqlProperties(props);
97    }
98    
99    @Override JavaDoc
100    protected void startService() throws Exception JavaDoc
101    {
102       super.startService();
103       String JavaDoc jndiName = (String JavaDoc) server.getAttribute(dataSource, "BindName");
104       delegate.setDataSource(jndiName);
105       delegate.start();
106    }
107    
108    @Override JavaDoc
109    protected void stopService() throws Exception JavaDoc
110    {
111       delegate.stop();
112       super.stopService();
113    }
114 }
115
Popular Tags