KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > kernel > plugins > deployment > AbstractKernelDeployment


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.deployment;
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26
27 import org.jboss.beans.metadata.spi.BeanMetaData;
28 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
29 import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
30 import org.jboss.kernel.spi.dependency.KernelControllerContext;
31 import org.jboss.kernel.spi.deployment.KernelDeployment;
32 import org.jboss.util.JBossObject;
33 import org.jboss.util.JBossStringBuilder;
34 import org.jboss.util.collection.CollectionsFactory;
35
36 /**
37  * An abstract kernel deployment.
38  *
39  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
40  * @version $Revision: 57133 $
41  */

42 public class AbstractKernelDeployment extends JBossObject implements KernelDeployment
43 {
44    /** The name of the deployment */
45    protected String JavaDoc name;
46
47    /** Whether it is installed */
48    protected boolean installed;
49
50    /** The installed contexts */
51    protected List JavaDoc<KernelControllerContext> installedContexts = CollectionsFactory.createCopyOnWriteList();
52
53    /** The beans List<BeanMetaDataFactory> */
54    protected List JavaDoc<BeanMetaDataFactory> beanFactories;
55
56    /** The ClassLoader */
57    protected ClassLoaderMetaData classLoader;
58
59    /**
60     * Create a new kernel deployment
61     */

62    public AbstractKernelDeployment()
63    {
64    }
65
66    /**
67     * Set the bean factories.
68     *
69     * @deprecated use setBeanFactories
70     * @param beans a List<BeanMetaData>.
71     */

72    @SuppressWarnings JavaDoc("unchecked")
73    public void setBeans(List JavaDoc beans)
74    {
75       this.beanFactories = beans;
76       flushJBossObjectCache();
77    }
78
79    /**
80     * Set the bean factories.
81     *
82     * @param beanFactories a List<BeanMetaDataFactory>.
83     */

84    public void setBeanFactories(List JavaDoc<BeanMetaDataFactory> beanFactories)
85    {
86       this.beanFactories = beanFactories;
87       flushJBossObjectCache();
88    }
89
90    public String JavaDoc getName()
91    {
92       return name;
93    }
94
95    public void setName(String JavaDoc name)
96    {
97       this.name = name;
98       flushJBossObjectCache();
99    }
100
101    public boolean isInstalled()
102    {
103       return installed;
104    }
105
106    public void setInstalled(boolean installed)
107    {
108       this.installed = installed;
109       flushJBossObjectCache();
110    }
111
112    public void addInstalledContext(KernelControllerContext context)
113    {
114       installedContexts.add(context);
115       flushJBossObjectCache();
116    }
117
118    public List JavaDoc<KernelControllerContext> getInstalledContexts()
119    {
120       return installedContexts;
121    }
122
123    public void removeInstalledContext(KernelControllerContext context)
124    {
125       installedContexts.remove(context);
126       flushJBossObjectCache();
127    }
128
129    public List JavaDoc<BeanMetaData> getBeans()
130    {
131       if (beanFactories == null || beanFactories.size() == 0)
132          return null;
133       List JavaDoc<BeanMetaData> result = new ArrayList JavaDoc<BeanMetaData>(beanFactories.size());
134       for (int i = 0; i < beanFactories.size(); ++i)
135       {
136          BeanMetaDataFactory factory = beanFactories.get(i);
137          List JavaDoc<BeanMetaData> beans = factory.getBeans();
138          result.addAll(beans);
139       }
140       return result;
141    }
142
143    public List JavaDoc<BeanMetaDataFactory> getBeanFactories()
144    {
145       return beanFactories;
146    }
147
148    public ClassLoaderMetaData getClassLoader()
149    {
150       return classLoader;
151    }
152
153    /**
154     * Set the classloader
155     *
156     * @param classLoader the classloader metadata
157     */

158    public void setClassLoader(ClassLoaderMetaData classLoader)
159    {
160       this.classLoader = classLoader;
161    }
162
163    public void toString(JBossStringBuilder buffer)
164    {
165       buffer.append("name=").append(name);
166       buffer.append(" installed=").append(installed);
167       if (classLoader != null)
168          buffer.append(" classLoader=").append(classLoader);
169       if (beanFactories != null)
170          buffer.append(" beanFactories=").append(beanFactories);
171    }
172
173    public void toShortString(JBossStringBuilder buffer)
174    {
175       buffer.append(name);
176    }
177 }
Popular Tags