KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > classadapter > plugins > BasicClassAdapter


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.classadapter.plugins;
23
24 import java.util.List JavaDoc;
25
26 import org.jboss.classadapter.spi.ClassAdapter;
27 import org.jboss.classadapter.spi.ClassAdapterFactory;
28 import org.jboss.classadapter.spi.DependencyBuilder;
29 import org.jboss.joinpoint.spi.JoinpointFactory;
30 import org.jboss.joinpoint.spi.JoinpointFactoryBuilder;
31 import org.jboss.reflect.spi.ClassInfo;
32 import org.jboss.repository.spi.MetaDataContext;
33 import org.jboss.repository.spi.MetaDataContextFactory;
34 import org.jboss.util.JBossObject;
35
36 /**
37  * A class adapter.
38  *
39  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
40  */

41 public class BasicClassAdapter extends JBossObject implements ClassAdapter
42 {
43    /** The class adapter factory */
44    protected ClassAdapterFactory classAdapterFactory;
45    
46    /** The class info */
47    protected ClassInfo classInfo;
48
49    /** The metadata context */
50    protected MetaDataContext metaDataContext;
51    
52    /**
53     * Create a new reflected class adapter
54     *
55     * @param factory class adapter factory
56     * @param classInfo class info
57     */

58    public BasicClassAdapter(ClassAdapterFactory factory, ClassInfo classInfo)
59    {
60       this.classAdapterFactory = factory;
61       this.classInfo = classInfo;
62    }
63
64    public ClassInfo getClassInfo()
65    {
66       return classInfo;
67    }
68
69    public ClassAdapter getInstanceAdapter(ClassInfo classInfo)
70    {
71       BasicClassAdapter clone = (BasicClassAdapter) clone();
72       clone.classInfo = classInfo;
73       return clone;
74    }
75
76    public List JavaDoc<Object JavaDoc> getDependencies()
77    {
78       DependencyBuilder builder = classAdapterFactory.getConfiguration().getDependencyBuilder();
79       return builder.getDependencies(this);
80    }
81
82    public JoinpointFactory getJoinpointFactory()
83    {
84       JoinpointFactoryBuilder builder = classAdapterFactory.getConfiguration().getJoinpointFactoryBuilder();
85       return builder.createJoinpointFactory(classInfo, metaDataContext);
86    }
87
88    public ClassLoader JavaDoc getClassLoader()
89    {
90       return classInfo.getType().getClassLoader();
91    }
92
93    public MetaDataContextFactory getMetaDataContextFactory()
94    {
95       return classAdapterFactory.getConfiguration().getMetaDataContextFactory();
96    }
97
98
99    public MetaDataContext getMetaDataContext()
100    {
101       return metaDataContext;
102    }
103
104    public void setMetaDataContext(MetaDataContext metaCtx)
105    {
106       metaDataContext = metaCtx;
107    }
108 }
109
Popular Tags