KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > kernel > plugins > bootstrap > AbstractBootstrap


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.kernel.plugins.bootstrap;
23
24 import org.jboss.kernel.Kernel;
25 import org.jboss.kernel.KernelFactory;
26 import org.jboss.kernel.plugins.AbstractKernelObject;
27 import org.jboss.kernel.spi.config.KernelConfig;
28
29 /**
30  * Abstract Bootstrap of the kernel.
31  *
32  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
33  * @author <a HREF="mailto:les.hazlewood@jboss.org">Les A. Hazlewood</a>
34  * @version $Revision: 57035 $
35  */

36 public abstract class AbstractBootstrap extends AbstractKernelObject implements Runnable JavaDoc
37 {
38    /** The kernel configuration */
39    protected KernelConfig config;
40
41    /**
42     * The kernel created by the bootstrap implementation during the
43     * bootstrap process.
44     */

45    protected Kernel kernel;
46
47    /**
48     * Create a new abstract bootstrap
49     */

50    public AbstractBootstrap()
51    {
52    }
53
54    /**
55     * Get the kernel configuration
56     *
57     * @return the kernel configuration
58     */

59    public KernelConfig getConfig()
60    {
61       Kernel.checkAccess();
62       return config;
63    }
64
65    /**
66     * Set the kernel configuration
67     *
68     * @param config the kernel configuration
69     */

70    public void setConfig(KernelConfig config)
71    {
72       Kernel.checkConfigure();
73       this.config = config;
74    }
75
76    /**
77     * Returns the Kernel object created during the bootstrap process.
78     * @return the kernel instance created during bootstrap.
79     */

80    public Kernel getKernel()
81    {
82       return this.kernel;
83    }
84
85    public void run()
86    {
87       try
88       {
89          bootstrap();
90       }
91       catch (RuntimeException JavaDoc e)
92       {
93          log.trace("RuntimeException during JBoss Kernel Bootstrap.", e);
94          throw e;
95       }
96       catch (Exception JavaDoc e)
97       {
98          log.trace("Exception during JBoss Kernel Bootstrap.", e);
99          throw new RuntimeException JavaDoc("Exception during Bootstrap", e);
100       }
101       catch (Error JavaDoc e)
102       {
103          log.trace("Error during JBoss Kernel Bootstrap.", e);
104          throw e;
105       }
106       catch (Throwable JavaDoc t)
107       {
108          log.trace("Error during JBoss Kernel Bootstrap.", t);
109          throw new RuntimeException JavaDoc("Error during Bootstrap", t);
110       }
111    }
112
113    /**
114     * Bootstrap the kernel
115     *
116     * @throws Throwable for any error
117     */

118    protected void bootstrap() throws Throwable JavaDoc
119    {
120       kernel = KernelFactory.newInstance(config);
121    }
122 }
123
Popular Tags