01: /*
02: * Copyright (C) The Spice Group. All rights reserved.
03: *
04: * This software is published under the terms of the Spice
05: * Software License version 1.1, a copy of which has been included
06: * with this distribution in the LICENSE.txt file.
07: */
08: package org.codehaus.dna.tools.verifier;
09:
10: import org.codehaus.metaclass.introspector.MetaClassAccessor;
11: import org.codehaus.metaclass.introspector.MetaClassException;
12: import org.codehaus.metaclass.model.ClassDescriptor;
13: import java.util.Map;
14: import java.util.HashMap;
15:
16: /**
17: *
18: * @author Peter Donald
19: * @version $Revision: 1.1 $ $Date: 2004/04/18 20:13:44 $
20: */
21: public class RegistrationMetaClassAccessor implements MetaClassAccessor {
22: private final Map m_descriptors = new HashMap();
23:
24: public ClassDescriptor getClassDescriptor(final String classname,
25: final ClassLoader classLoader,
26: final MetaClassAccessor accessor) throws MetaClassException {
27: final ClassDescriptor descriptor = (ClassDescriptor) m_descriptors
28: .get(classname);
29: if (null == descriptor) {
30: final String message = "Missing descriptor for "
31: + classname;
32: throw new MetaClassException(message);
33: }
34: return descriptor;
35: }
36:
37: public void registerDescriptor(final ClassDescriptor descriptor) {
38: if (null == descriptor) {
39: throw new NullPointerException("descriptor");
40: }
41: m_descriptors.put(descriptor.getName(), descriptor);
42: }
43: }
|