KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > beans > metadata > plugins > AbstractClassLoaderMetaData


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.beans.metadata.plugins;
23
24 import java.util.Collections JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.ArrayList JavaDoc;
28
29 import org.jboss.beans.metadata.spi.*;
30 import org.jboss.dependency.spi.ControllerState;
31 import org.jboss.util.JBossObject;
32 import org.jboss.util.JBossStringBuilder;
33
34 /**
35  * A classloader.
36  *
37  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
38  * @version $Revision: 56505 $
39  */

40 public class AbstractClassLoaderMetaData extends JBossObject implements ClassLoaderMetaData, BeanMetaDataFactory
41 {
42    /** The classloader */
43    protected ValueMetaData classloader;
44
45    /**
46     * Create a new classloader
47     */

48    public AbstractClassLoaderMetaData()
49    {
50    }
51
52    /**
53     * Create a new classloader
54     *
55     * @param classloader the classloader value
56     */

57    public AbstractClassLoaderMetaData(ValueMetaData classloader)
58    {
59       this.classloader = classloader;
60    }
61
62    /**
63     * Set the classloader
64     *
65     * @param classloader the classloader value
66     */

67    public void setClassLoader(ValueMetaData classloader)
68    {
69       this.classloader = classloader;
70       flushJBossObjectCache();
71    }
72
73    public ValueMetaData getClassLoader()
74    {
75       return classloader;
76    }
77
78    public List JavaDoc<BeanMetaData> getBeans()
79    {
80       if (classloader instanceof BeanMetaDataFactory)
81       {
82          return ((BeanMetaDataFactory)classloader).getBeans();
83       }
84       else if (classloader instanceof BeanMetaData)
85       {
86          return Collections.singletonList((BeanMetaData)classloader);
87       }
88       return new ArrayList JavaDoc<BeanMetaData>();
89    }
90
91    public void initialVisit(MetaDataVisitor visitor)
92    {
93       visitor.setContextState(ControllerState.DESCRIBED);
94       visitor.initialVisit(this);
95    }
96
97    public void describeVisit(MetaDataVisitor vistor)
98    {
99       // todo - any context setting?
100
vistor.describeVisit(this);
101    }
102
103    public Iterator JavaDoc<? extends MetaDataVisitorNode> getChildren()
104    {
105       if (classloader != null)
106          return Collections.singletonList(classloader).iterator();
107       return null;
108    }
109
110    public void toString(JBossStringBuilder buffer)
111    {
112       buffer.append("classloader=").append(classloader);
113    }
114
115    public void toShortString(JBossStringBuilder buffer)
116    {
117       buffer.append(classloader);
118    }
119 }
120
Popular Tags