commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1357447 [2/4] - in /commons/sandbox/classscan/trunk: ./ api/ api/src/ api/src/main/ api/src/main/java/ api/src/main/java/org/ api/src/main/java/org/apache/ api/src/main/java/org/apache/commons/ api/src/main/java/org/apache/commons/classsca...
Date Thu, 05 Jul 2012 02:48:38 GMT
Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/JarClassPathElement.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/JarClassPathElement.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/JarClassPathElement.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/JarClassPathElement.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,149 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.builtin;
+
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.regex.Pattern;
+
+import org.apache.commons.classscan.ClassFile;
+import org.apache.commons.classscan.ResourceFile;
+import org.apache.commons.classscan.spi.model.SpiClassPathElement;
+import org.apache.commons.classscan.spi.model.SpiMetaRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JarClassPathElement implements SpiClassPathElement {
+
+    private static final Logger logger = LoggerFactory.getLogger(JarClassPathElement.class);
+
+    final private URL location;
+    private URL[] classPathLocations;
+	
+	public JarClassPathElement(URL location) {
+		this.location = location;
+	}
+
+	@Override
+	public Iterator<ClassFile> iterator() {		
+		final JarFile jarFile= getJarFile();		
+        final Enumeration<JarEntry> jarEntries = jarFile.entries();
+        
+		return new ClassFileIterator() {			
+			ClassFile getNext() {
+				while(jarEntries.hasMoreElements()) {
+					JarClassFile jcf= new JarClassFile(jarFile, jarEntries.nextElement());
+					if(jcf.getClassName()!=null) {
+						return jcf;
+					}
+				}
+				try {
+					jarFile.close();
+				} catch (IOException ex) {
+		            logger.warn("Failed to close " + location, ex);
+				}
+				return null;
+			}
+		};
+	}
+
+	private JarFile getJarFile() {		
+        try {
+            JarURLConnection conn = (JarURLConnection) location.openConnection();
+            JarFile jf= conn.getJarFile();
+            extractClasspath(jf);
+            return jf;
+        }
+        catch (IOException ex) {
+            logger.warn("Failed to open " + location, ex);
+            return null;
+        }
+	}
+
+	private void extractClasspath(JarFile jf) throws IOException {
+		Manifest manifest = jf.getManifest();
+		if(manifest == null) {
+			return;
+		}
+		
+		URI resolveLocation;
+		try {
+			resolveLocation = location.toURI();
+		} catch (URISyntaxException e) {
+        	logger.warn("Could not create URI out of {}", location);
+        	return;
+		}
+		
+        Attributes attributes = manifest.getMainAttributes();
+        String classPath = attributes.getValue(Attributes.Name.CLASS_PATH);
+        if (classPath == null) {
+            return;
+        }
+        
+        List<URL> newLocations = new ArrayList<URL>();
+		for (String pathElement : PATH_SPLITTER.split(classPath)) {
+            URI resolvedLocation = resolveLocation.resolve(pathElement);
+            try {
+				URL newLocation = resolvedLocation.toURL();
+	            newLocations.add(newLocation);
+            } catch (MalformedURLException e) {
+            	logger.warn("Could not resolve Class-Path element {} relative to {}", pathElement, resolveLocation);
+			}
+        }
+        classPathLocations = newLocations.toArray(new URL[newLocations.size()]);
+	}
+
+    private static Pattern PATH_SPLITTER = Pattern.compile("\\s+");
+    
+	@Override
+	public String getLocation() {
+		return location.toExternalForm();
+	}
+
+	@Override
+	public Collection<SpiClassPathElement> getAdditionalLocations(SpiMetaRegistry registry) {
+		if(classPathLocations==null) {
+			return null;
+		}
+		return UrlClassPath.getClassPathElements(registry, classPathLocations);
+	}
+
+	@Override
+	public ResourceFile getResource(String fileName) {
+		JarFile jarFile= getJarFile();
+		JarEntry jarEntry = jarFile.getJarEntry(fileName);
+		if(jarEntry==null) {
+			try {
+				jarFile.close();
+			} catch (IOException e) {
+            	logger.info("ignoring exception on close", e);
+			}
+			return null;
+		}
+		return new JarResourceFile(jarFile, jarEntry);
+	}
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/JarResourceFile.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/JarResourceFile.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/JarResourceFile.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/JarResourceFile.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,51 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.builtin;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.apache.commons.classscan.ResourceFile;
+
+public class JarResourceFile implements ResourceFile {
+
+	final JarFile jarFile;
+	final JarEntry jarEntry;
+
+	public JarResourceFile(JarFile jarFile, JarEntry jarEntry) {
+		this.jarFile = jarFile;
+		this.jarEntry = jarEntry;
+	}
+
+	@Override
+	public InputStream getBytes() throws IOException {
+		final InputStream is = jarFile.getInputStream(jarEntry);
+		// close the jarFile when stream is closed
+		return new FilterInputStream(is) {
+			@Override
+			public void close() throws IOException {
+				super.close();
+				jarFile.close();
+			}
+		};
+	}
+
+	@Override
+	public String getFileName() {
+		return jarEntry.getName();
+	}
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/PrimitiveClass.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/PrimitiveClass.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/PrimitiveClass.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/PrimitiveClass.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,96 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.builtin;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.commons.classscan.MetaClassPathElement;
+import org.apache.commons.classscan.model.MetaAnnotation;
+import org.apache.commons.classscan.model.MetaClass;
+import org.apache.commons.classscan.model.MetaField;
+import org.apache.commons.classscan.model.MetaMethod;
+import org.apache.commons.classscan.spi.model.SpiMetaClass;
+import org.apache.commons.classscan.spi.model.SpiMetaClassLoader;
+
+public enum PrimitiveClass implements SpiMetaClass {
+
+	B(Byte.TYPE, Byte.class),
+	C(Character.TYPE, Character.class),
+	D(Double.TYPE, Double.class),
+	F(Float.TYPE, Float.class),
+	I(Integer.TYPE, Integer.class),
+	J(Long.TYPE, Long.class),
+	S(Short.TYPE, Short.class),
+	Z(Boolean.TYPE, Boolean.class),
+	V(Void.TYPE, Void.class);
+	
+    private final String primitiveName;
+    private final String wrapperName;
+
+	PrimitiveClass(Class<?> typeClass, Class<?> wrapperClass) {
+		primitiveName= typeClass.getCanonicalName();
+		wrapperName= wrapperClass.getCanonicalName();
+	}
+
+    @Override
+    public MetaClassPathElement getClassLocation() {
+        return null;
+    }
+
+    @Override
+    public String getName() {
+        return primitiveName;
+    }
+
+    @Override
+    public MetaClass getParent() {
+        return null;
+    }
+
+    @Override
+    public Set<MetaClass> getInterfaces() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public Set<? extends MetaAnnotation> getAnnotations() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public MetaAnnotation getAnnotation(String annotationName) {
+        return null;
+    }
+
+    @Override
+    public Set<MetaMethod> getMethods() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public Set<MetaField> getFields() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public boolean isAssignableFrom(MetaClass assignor) {
+        return equals(assignor) || assignor.getName().equals(wrapperName);
+    }
+
+	@Override
+	public boolean resolve(SpiMetaClassLoader classLoader) {
+		return true;
+	}
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/UrlClassPath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/UrlClassPath.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/UrlClassPath.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/UrlClassPath.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,103 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.builtin;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.classscan.ClassPathElement;
+import org.apache.commons.classscan.ResourceFile;
+import org.apache.commons.classscan.spi.model.SpiClassPath;
+import org.apache.commons.classscan.spi.model.SpiClassPathElement;
+import org.apache.commons.classscan.spi.model.SpiMetaClassLoader;
+import org.apache.commons.classscan.spi.model.SpiMetaRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UrlClassPath implements SpiClassPath {
+
+    private static final Logger logger = LoggerFactory.getLogger(UrlClassPath.class);
+
+    private final SpiMetaRegistry registry;
+	private final List<SpiClassPathElement> classPathElements;
+	
+	public UrlClassPath(SpiMetaRegistry registry, URLClassLoader urlClassLoader) {
+		this.registry = registry;
+		classPathElements = Collections.unmodifiableList(getClassPathElements(registry, urlClassLoader.getURLs()));
+	}
+
+	static List<SpiClassPathElement> getClassPathElements(SpiMetaRegistry registry, URL[] urls) {
+		List<SpiClassPathElement> elements = new ArrayList<SpiClassPathElement>();
+		Map<String, URL> locations = new HashMap<String, URL>();
+		for(URL url : urls) {
+			String baseLocation= url.toExternalForm();
+			if( locations.containsKey(baseLocation) ) {
+				continue;
+			}
+			locations.put(baseLocation, url);
+			
+			try {
+				SpiClassPathElement element= registry.createClassPathElement(url);
+				elements.add(element);
+			} catch (IOException e) {
+    			logger.info("Problem with URL "+url, e);
+			}
+		}
+		return elements;
+	}
+
+	@Override
+	public List<? extends ClassPathElement> getClassPathElements() {
+		return classPathElements;
+	}
+
+	@Override
+	public SpiMetaClassLoader createMetaClassLoader(SpiMetaRegistry registry, ClassLoader classLoader) {
+		return new UrlMetaClassLoader(registry, classLoader);
+	}
+
+	@Override
+	public Map<ClassPathElement, ResourceFile> getResources(String fileName) {
+		Map<ClassPathElement, ResourceFile> resources = new HashMap<ClassPathElement, ResourceFile>();
+		Map<String,ClassPathElement> visited = new HashMap<String,ClassPathElement>();
+		searchElements(visited, resources, classPathElements, fileName);
+		return resources;
+	}
+	
+	public void searchElements(Map<String,ClassPathElement> visited, Map<ClassPathElement, ResourceFile> resources, Collection<SpiClassPathElement> elements, String fileName) {
+		for(SpiClassPathElement element : elements) {
+			String location = element.getLocation();
+			if(visited.put(location, element)!=null) {
+				continue;
+			}
+
+			ResourceFile resource= element.getResource(fileName);
+			if(resource!=null) {
+				resources.put(element, resource);
+			}
+			
+			Collection<SpiClassPathElement> additionalLocations = element.getAdditionalLocations(registry);
+			if(additionalLocations!=null) {
+				searchElements(visited, resources, additionalLocations, fileName);
+			}
+		}
+	}
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/UrlMetaClassLoader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/UrlMetaClassLoader.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/UrlMetaClassLoader.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/UrlMetaClassLoader.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,281 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.builtin;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.NoSuchElementException;
+
+import org.apache.commons.classscan.ClassPath;
+import org.apache.commons.classscan.ClassPathElement;
+import org.apache.commons.classscan.MetaClassLoader;
+import org.apache.commons.classscan.MetaClassPathElement;
+import org.apache.commons.classscan.model.MetaArray;
+import org.apache.commons.classscan.model.MetaClass;
+import org.apache.commons.classscan.model.MetaType;
+import org.apache.commons.classscan.spi.model.SpiClassPathElement;
+import org.apache.commons.classscan.spi.model.SpiMetaClassLoader;
+import org.apache.commons.classscan.spi.model.SpiMetaClassPathElement;
+import org.apache.commons.classscan.spi.model.SpiMetaRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UrlMetaClassLoader implements SpiMetaClassLoader {
+
+    private static final Logger logger = LoggerFactory.getLogger(UrlMetaClassLoader.class);
+
+    private final SpiMetaClassLoader parent;
+    private Map<String, SpiMetaClassPathElement> locations;
+    
+	public UrlMetaClassLoader(SpiMetaRegistry registry, ClassLoader classLoader) {
+		parent= classLoader!= null ?(SpiMetaClassLoader)registry.getMetaClassLoader(classLoader.getParent()) :null;
+		// use LinkedHashMap to keep iteration over path elements in same order as definition
+		locations = new LinkedHashMap<String, SpiMetaClassPathElement>();
+		addLocations(registry, classLoader);
+		resolve();
+		locations = Collections.unmodifiableMap(locations);
+    }
+
+	void addLocations(SpiMetaRegistry registry, ClassLoader classLoader) {
+    	ClassPath classPath = registry.getClassPath(classLoader);
+		for(ClassPathElement pathElement : classPath.getClassPathElements()) {
+    		addLocation(registry, pathElement);
+    	}
+    }
+
+    /**
+     * Add a location
+     * 
+     * @param pathElement
+     *            The URI of a jar or folder
+     */
+	private void addLocation(SpiMetaRegistry registry, ClassPathElement pathElement) {
+    	String baseLocation= pathElement.getLocation();
+        if (!locations.containsKey(baseLocation)) {
+            SpiMetaClassPathElement mcl = registry.createMetaClassPathElement(pathElement);
+            if (mcl != null) {
+            	locations.put(baseLocation, mcl);    	
+            }
+        	Collection<SpiClassPathElement> additionalUrls= ((SpiClassPathElement)pathElement).getAdditionalLocations(registry);
+        	if(additionalUrls!=null) {
+        		for(SpiClassPathElement additionalUrl : additionalUrls) {
+        			addLocation(registry, additionalUrl);
+        		}
+        	}
+        }
+    }
+	
+    protected void addLocation(SpiMetaClassPathElement cpe) {
+    	locations.put(cpe.getName(), cpe);
+	}
+
+    // resolve string names into model entities instead of using resolution upon demand
+    // memory used by multiple string copies weighs more heavily than time spent resolving meta-class
+    // demand resolution would require clients to filter out classes which have un-resolvable dependencies
+    private void resolve() {
+    	Iterator<SpiMetaClassPathElement> metaClassPathElements= locations.values().iterator();
+    	while(metaClassPathElements.hasNext()) {
+    		SpiMetaClassPathElement metaClassPathElement= metaClassPathElements.next();
+    		if(!metaClassPathElement.resolve(this)) {
+    			metaClassPathElements.remove();
+    		}
+    	}
+	}
+
+    @Override
+    public MetaClassLoader getParent() {
+        return parent;
+    }
+
+    @Override
+    public Collection<? extends MetaClassPathElement> getClassLocations() {
+        return locations.values();
+    }
+
+    @Override
+    public MetaClassPathElement getClassLocation(String location) {
+        return locations.get(location);
+    }
+
+    @Override
+    public Iterator<? extends MetaClass> getMetaClasses() {     	
+    	Collection<? extends MetaClassPathElement> classLocations = getClassLocations();
+    	if(classLocations.isEmpty()) {
+    		List<? extends MetaClass> empty= Collections.emptyList();
+    		return empty.iterator();
+    	}
+    	
+		final Iterator<? extends MetaClassPathElement> locations= classLocations.iterator();
+    	
+    	return new Iterator<MetaClass>() {
+        	{
+        		nextInnerIterator();
+        	}
+        	Iterator<? extends MetaClass> metaClasses;
+
+        	private boolean nextInnerIterator() {
+        		if(!locations.hasNext()) {
+        			return false;
+        		}
+				MetaClassPathElement mcpe= locations.next();
+				metaClasses= mcpe.getMetaClasses().iterator();
+				return true;
+			}
+        	
+			@Override
+			public boolean hasNext() {
+    			while(!metaClasses.hasNext()) {        				
+        			if(!nextInnerIterator()) {
+        				return false;
+        			}
+    			}
+    			return true;
+			}
+
+			@Override
+			public MetaClass next() {
+    			while(!metaClasses.hasNext()) {        				
+        			if(!locations.hasNext()) {
+        				throw new NoSuchElementException();
+        			}
+		    		nextInnerIterator();
+    			}
+    			return metaClasses.next();
+			}
+
+			@Override
+			public void remove() {
+				throw new UnsupportedOperationException();
+			}
+    	};
+    }
+
+    @Override
+    public MetaClass getMetaClass(String className) {
+    	for(MetaClassPathElement location : locations.values()) {
+    		MetaClass mc = location.getMetaClass(className);
+    		if(mc != null) {
+    			return mc;
+    		}
+    	}
+        return null;
+    }
+
+    @Override
+    public MetaClass findMetaClass(String className) {
+        MetaClass mc = parent.findMetaClass(className);
+        if (mc != null) {
+            return mc;
+        }
+        return getMetaClass(className);
+    }
+
+    @Override
+    public MetaClass resolveMetaClass(String className) {
+        MetaClass mc = parent.resolveMetaClass(className);
+        if (mc != null) {
+            return mc;
+        }
+    	return resolveInPath(className);
+    }
+
+	MetaClass resolveInPath(String className) {
+		for(SpiMetaClassPathElement location : locations.values()) {
+			MetaClass mc = location.resolveMetaClass(this, className);
+    		if(mc != null) {
+    			return mc;
+    		}
+    	}
+        return null;
+	}
+
+    /**
+     * Get metadata representing a type from its byte code signature
+     * 
+     * @param fieldDescriptor
+     *            The field descriptor as defined in section 4.3.2 of The Java
+     *            Virtual Machine Specification
+     * @return The type metadata
+     */
+    /*
+     * FieldType: BaseType ObjectType ArrayType
+     * 
+     * BaseType: // see PrimitiveClass
+     * 
+     * ObjectType: L <classname> ;
+     * 
+     * ArrayType: [ ComponentType
+     */
+    @Override
+	public MetaType resolveTypeForDescriptor(String fieldDescriptor) {
+    	MetaType mt; 
+        char typeCode = fieldDescriptor.charAt(0);
+        switch (typeCode) {
+        case 'L':
+			mt = resolveObjectType(fieldDescriptor);
+			break;
+        case '[':
+            mt = resolveArrayType(fieldDescriptor.substring(1));
+            break;
+        default:
+        	mt = PrimitiveClass.valueOf(fieldDescriptor);
+        	break;
+        }
+        if(mt == null) {
+        	logger.info("Cannot resolve type "+fieldDescriptor);
+        }
+        return mt;
+    }
+
+	private MetaType resolveObjectType(String fieldDescriptor) {
+		String canonicalName = ClassNameHelper.internalToCanonicalName(fieldDescriptor);
+		return resolveMetaClass(canonicalName);
+	}
+
+    private MetaArray resolveArrayType(String fieldDescriptor) {
+        MetaType arrayType = resolveTypeForDescriptor(fieldDescriptor);
+        return new DefaultArrayType(arrayType);
+    }
+
+    @Override
+    public Collection<? extends MetaClass> findAllImplementors(String interfaceToFind) {
+        MetaClass mc = findMetaClass(interfaceToFind);
+
+        Collection<MetaClass> implementations = new ArrayList<MetaClass>();
+        MetaClassLoader classLoader = this;
+        do {       	
+            Iterator<? extends MetaClass> metaClasses = classLoader.getMetaClasses(); 
+            while(metaClasses.hasNext()) {
+            	MetaClass potentialImplementation = metaClasses.next();
+                try {
+                    if (!potentialImplementation.equals(mc) && mc.isAssignableFrom(potentialImplementation)) {
+                        implementations.add(potentialImplementation);
+                    }
+                }
+                catch (MissingResourceException mre) {
+                    continue;
+                }
+            }
+            classLoader = classLoader.getParent();
+        }
+        while (classLoader != null);
+        return implementations;
+    }
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/package-info.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/package-info.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/builtin/package-info.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,21 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * <p>This package contains builtin implementations of the {@link org.apache.commons.classscan.spi} providers.</p>
+ * <p>The {@link DefaultClassPathFactory} provider supports the URLClassLoader and Sun boostrap classLoader.</p>
+ * <p>The {@link DefaultClassPathElementFactory} provider supports "jar" and "file" URL schemes.</p>
+ * <p><b>The non-public methods in these classes are subject to change in any release.</b></p>
+ */
+package org.apache.commons.classscan.builtin;
+

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaAnnotation.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaAnnotation.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaAnnotation.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaAnnotation.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,77 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.model;
+
+import java.util.Set;
+
+import org.apache.commons.classscan.HasName;
+
+/**
+ * Metadata about an Annotation
+ */
+public interface MetaAnnotation extends HasName {
+    /**
+     * Get the name of the Annotation
+     */
+    String getName();
+
+    /**
+     * Get metadata about the properties of the corresponding Annotation
+     * 
+     * @return The read-only set of properties specified in the annotation
+     */
+    Set<? extends Property> getProperties();
+
+    /**
+     * Get a single property of the corresponding Annotation
+     * 
+     * @param propertyName
+     *            The name of the Property desired.
+     * @return The Property; or null, if the no Property exists with the given
+     *         name.
+     */
+    Property getProperty(String propertyName);
+
+    /**
+     * Metadata about an Annotation property
+     */
+    public interface Property extends HasName {
+        /**
+         * Get the property value. This will be
+         * <ul>
+         * <li>a String for String value,</li>
+         * <li>an Object of the wrapper type for primitive values,</li>
+         * <li>an {@link EnumValue} for Enum values,</li>
+         * <li>a MetaAnnotation for Annotations,</li>
+         * <li>an Object[] for any array value</li>
+         * </ul>
+         */
+        Object getValue();
+    }
+
+    /**
+     * Metadata about an Annotation Enum value
+     */
+    public interface EnumValue {
+        /**
+         * Get information about the Enumeration
+         */
+        MetaClass getEnumType();
+
+        /**
+         * Get the name of the enumeration instance
+         */
+        String getEnumValue();
+    }
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaArray.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaArray.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaArray.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaArray.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,21 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.model;
+
+/**
+ * Metadata about a method parameter or return value that is an array
+ */
+public interface MetaArray extends MetaType {
+    public MetaType getArrayType();
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaClass.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaClass.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaClass.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaClass.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,97 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.model;
+
+import java.util.Set;
+
+import org.apache.commons.classscan.HasName;
+import org.apache.commons.classscan.MetaClassPathElement;
+
+/**
+ * Metadata about a class or primitive type
+ */
+public interface MetaClass extends HasName, MetaType {
+    /**
+     * Get the ClassLocation from which the corresponding class came. For
+     * primitive types, this will return null.
+     */
+    MetaClassPathElement getClassLocation();
+
+    /**
+     * Get the canonical name of the corresponding Class. For primitive types,
+     * this will be the primitive type name. e.g. char
+     */
+    String getName();
+
+    /**
+     * Get metadata about the corresponding Class's parent
+     * 
+     * @return The MetaClass, or null if the corresponding Class is a primitive
+     *         type or Object.class
+     */
+    MetaClass getParent();
+
+    /**
+     * Get metadata about the interfaces which the corresponding Class
+     * implements. No inherited interfaces will be in the set.
+     * 
+     * @return A read-only set of the interface information
+     */
+    Set<? extends MetaClass> getInterfaces();
+
+    /**
+     * Get metadata about the annotations on the corresponding Class.
+     * 
+     * @return A read-only set of the annotation information
+     */
+    Set<? extends MetaAnnotation> getAnnotations();
+
+    /**
+     * Get metadata about a particular annotation on the corresponding Class.
+     * 
+     * @param annotationName
+     *            The name of the annotation desired
+     * 
+     * @return The annotation information, or null if not specified on the
+     *         corresponding Class
+     */
+    MetaAnnotation getAnnotation(String annotationName);
+
+    /**
+     * Get metadata about the corresponding Class's methods and constructors. No
+     * inherited methods will be in the set.
+     * 
+     * @return A read-only set of the method information
+     */
+    Set<? extends MetaMethod> getMethods();
+
+    /**
+     * Get metadata about the corresponding Class's methods and constructors. No
+     * inherited fields will be in the set.
+     * 
+     * @return A read-only set of the field information
+     */
+    Set<? extends MetaField> getFields();
+
+    /**
+     * Is the associated Class assignable from the class associated with the
+     * given MetaClass.
+     * 
+     * @param assignor
+     *            The non-null MetaClass (associated with class or interface)
+     * @return true, if and only if instances represented by implementor can be
+     *         assigned to instances represented by this MetaClass
+     */
+    boolean isAssignableFrom(MetaClass assignor);
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaField.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaField.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaField.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaField.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,56 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.model;
+
+import java.util.Set;
+
+import org.apache.commons.classscan.HasName;
+
+/**
+ * Metadata about a Class field
+ */
+public interface MetaField extends HasName {
+    /**
+     * Get the name of the method or constructor
+     */
+    String getName();
+
+    /**
+     * Get metadata about the annotations on the field.
+     * 
+     * @return A read-only set of annotations
+     */
+    Set<? extends MetaAnnotation> getAnnotations();
+
+    /**
+     * Get metadata about a particular annotation on the corresponding field.
+     * 
+     * @param annotationName
+     *            The name of the annotation desired
+     * 
+     * @return The annotation information, or null if not specified on the
+     *         corresponding field
+     */
+    MetaAnnotation getAnnotation(String annotationName);
+
+    /**
+     * Get whether the corresponding field is a static field
+     */
+    boolean isStatic();
+
+    /**
+     * Get metadata about the field's type
+     */
+    MetaType getType();
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaMethod.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaMethod.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaMethod.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaMethod.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,67 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.model;
+
+import java.util.Set;
+
+import org.apache.commons.classscan.HasName;
+
+/**
+ * Metadata about a class method or constructor
+ */
+public interface MetaMethod extends HasName {
+    /**
+     * Get the name of the method or constructor
+     */
+    String getName();
+
+    /**
+     * Get metadata about the annotations on the method or constructor.
+     * 
+     * @return A read-only set of annotations
+     */
+    Set<? extends MetaAnnotation> getAnnotations();
+
+    /**
+     * Get metadata about a particular annotation on the corresponding method.
+     * 
+     * @param annotationName
+     *            The name of the annotation desired
+     * 
+     * @return The annotation information, or null if not specified on the
+     *         corresponding method
+     */
+    MetaAnnotation getAnnotation(String annotationName);
+
+    /**
+     * Get whether the corresponding method or constructor is a static method or
+     * static class initializer
+     */
+    boolean isStatic();
+
+    /**
+     * Get metadata about the return type of the method or constructor
+     * 
+     * @return null, if the type is void return; otherwise, metadata about the
+     *         type
+     */
+    MetaType getType();
+
+    /**
+     * Get metadata about the parameters of the method or constructor
+     * 
+     * @return A read-only set of parameter information
+     */
+    Set<? extends MetaParameter> getParameters();
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaParameter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaParameter.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaParameter.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaParameter.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,44 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.model;
+
+import java.util.Set;
+
+/**
+ * Metadata about a method or constructor parameter
+ */
+public interface MetaParameter {
+    /**
+     * Get metadata about the annotations on the parameter.
+     * 
+     * @return A read-only set of annotations
+     */
+    Set<? extends MetaAnnotation> getAnnotations();
+
+    /**
+     * Get metadata about a particular annotation on the parameter.
+     * 
+     * @param annotationName
+     *            The name of the annotation desired
+     * 
+     * @return The annotation information, or null if not specified on the
+     *         corresponding parameter
+     */
+    MetaAnnotation getAnnotation(String annotationName);
+
+    /**
+     * Get metadata about the type of the parameter
+     */
+    MetaType getType();
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaType.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaType.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaType.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/MetaType.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,20 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.model;
+
+/**
+ * Metadata about a method parameter or return value
+ */
+public interface MetaType {
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/package-info.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/package-info.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/model/package-info.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,20 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * <p>The model package contains metadata classes which allow client programs to
+ * introspect class information about annotations, methods, and fields without having
+ * the jvm load and resolve the class.</p>
+ */
+package org.apache.commons.classscan.model;
+

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/package-info.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/package-info.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/package-info.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,31 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * <p><b>** Start Here **</b> The metadata package provides information about available classes without loading them.
+ *  The standard Java runtime hides many details about classes, particularly the location of classes which can potentially be loaded, and the details of unloaded classes.
+ *  An application may need to discover class information without loading the class in the following situations:</p>
+ *  <ul>
+ *  <li>When discovering the implementers of a particular interface</li>
+ *  <li>Determining which classes have a specific annotation (or set to a particular annotation value)</li>
+ *  <li>Determine which fields or methods are available on a class</li>
+ *  <li>Any of the above, limited by the location of the class (eg. only classes annotated with @Entity from a jar that has a META-INF/persistence.xml file</li>
+ *  </ul>
+ *  <p>An application using this package must first obtain a {@link org.apache.commons.classscan.MetaClassLoader MetaClassLoader} instance from 
+ *  the {@link org.apache.commons.classscan.MetaRegistry MetaRegistry}</p>
+ *  <code>
+    MetaClassLoader classLoader = MetaRegistry.DEFAULT_REGISTRY.getMetaClassLoader(getClass().getClassLoader());
+</code>
+ */
+package org.apache.commons.classscan;
+

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassDigesterFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassDigesterFactory.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassDigesterFactory.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassDigesterFactory.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,36 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi;
+
+import java.util.ServiceLoader;
+
+import org.apache.commons.classscan.MetaRegistry;
+import org.apache.commons.classscan.spi.model.SpiClassDigester;
+
+/**
+ * Provider to create a SpiClassDigester. Provider instances should be
+ * registered using the {@link ServiceLoader} facility. The provider class
+ * should have a public default constructor. The first instance of a provider
+ * class which is successfully instantiated will be used. The order in the
+ * classpath will determine which SpiClassDigester will be used.
+ */
+public interface ClassDigesterFactory {
+	/**
+	 * Create a SpiClassDigester.  The factory may throw an exception or error if unsuccessful in loading dependent jars.
+	 * 
+	 * @param metaRegistry The registry
+	 * @return A SpiClassDigester
+	 */
+	SpiClassDigester createDigester(MetaRegistry metaRegistry);
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassPathElementFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassPathElementFactory.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassPathElementFactory.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassPathElementFactory.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,38 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ServiceLoader;
+
+import org.apache.commons.classscan.MetaRegistry;
+import org.apache.commons.classscan.spi.model.SpiClassPathElement;
+
+/**
+ * Provider to create a ClassPathElement for a URL.  Provider instances should
+ * be registered using the {@link ServiceLoader} facility.  Each provider class
+ * should have a public default constructor.  A single instance of each provider
+ * class will be instantiated.
+ */
+public interface ClassPathElementFactory {
+	/**
+	 * Create a ClassPathElement for a URL
+	 * 
+	 * @param metaRegistry The registry 
+	 * @param url The url that is the base location of class files
+	 * @return null, if the URL scheme cannot be supported; otherwise a ClassPathElement for the URL
+	 */
+	SpiClassPathElement getClassPathElement(MetaRegistry metaRegistry, URL url) throws IOException;
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassPathFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassPathFactory.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassPathFactory.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/ClassPathFactory.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,36 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi;
+
+import java.util.ServiceLoader;
+
+import org.apache.commons.classscan.spi.model.SpiClassPath;
+import org.apache.commons.classscan.spi.model.SpiMetaRegistry;
+
+/**
+ * Provider to create SpiClassPath for a ClassLoader.  Provider instances should
+ * be registered using the {@link ServiceLoader} facility.  Each provider class
+ * should have a public default constructor.  A single instance of each provider
+ * class will be instantiated.
+ */
+public interface ClassPathFactory {
+	/**
+	 * Create a ClassPath for a ClassLoader
+	 * 
+	 * @param metaRegistry The registry
+	 * @param classLoader The classLoader
+	 * @return null, if the ClassLoader type cannot be supported; otherwise a ClassPath for the ClassLoader
+	 */
+    SpiClassPath getClassPath(SpiMetaRegistry metaRegistry, ClassLoader classLoader);
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/HasResolve.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/HasResolve.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/HasResolve.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/HasResolve.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,24 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+/**
+ * This marker interface indicates that instances must have MetaClass references resolved from names to instances.
+ */
+public interface HasResolve {
+    /**
+     * Resolve names into model entries
+     */
+	boolean resolve(SpiMetaClassLoader classLoader);
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassDigester.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassDigester.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassDigester.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassDigester.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,35 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.classscan.MetaClassPathElement;
+
+/**
+ * Digest class bytes.  
+ */
+public interface SpiClassDigester {
+	/**
+	 * Create class meta data from the byte stream
+	 * 
+	 * @param location The location of the class bytes
+	 * @param className The expected name of the class
+	 * @param byteStream The stream of bytes 
+	 * @return Information about the class
+	 * @throws IOException 
+	 */
+	SpiMetaClass createMetaClass(MetaClassPathElement location, String className, InputStream byteStream) throws IOException;
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassPath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassPath.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassPath.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassPath.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,31 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import org.apache.commons.classscan.ClassPath;
+
+/**
+ * Information about a ClassPath.
+ *   A ClassPath specifies a list of ClassElement(s).
+ *   A ClassElement specifies a list of ClassFiles(s).
+ */
+public interface SpiClassPath extends ClassPath {
+	/**
+	 * Create a MetaClassLoader that will inspect the classes specified by this ClassPath
+	 * @param registry
+	 * @param classLoader
+	 * @return
+	 */
+	SpiMetaClassLoader createMetaClassLoader(SpiMetaRegistry registry, ClassLoader classLoader);
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassPathElement.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassPathElement.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassPathElement.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiClassPathElement.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,33 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import java.util.Collection;
+
+import org.apache.commons.classscan.ClassPathElement;
+
+/**
+ * A single location in a ClassPath.  The location might be a jar or a directory.
+ * In enterprise application environments, the location might be an exploded ear or a war.
+ */
+public interface SpiClassPathElement extends ClassPathElement {
+	/**
+	 * Obtain any additional ClassPath elements specified within the metadata of this element.
+	 * e.g. The elements specified by the Class-Path attribute of a jar manifest
+	 * 
+	 * @param registry
+	 * @return null, or an iterator over additional path elements
+	 */
+	Collection<SpiClassPathElement> getAdditionalLocations(SpiMetaRegistry registry);
+}
\ No newline at end of file

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaAnnotation.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaAnnotation.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaAnnotation.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaAnnotation.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,25 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import org.apache.commons.classscan.model.MetaAnnotation;
+
+/**
+ * Metadata about an Annotation
+ */
+public interface SpiMetaAnnotation extends MetaAnnotation, HasResolve {
+
+	public interface SpiProperty extends MetaAnnotation.Property, HasResolve {
+	}
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaArray.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaArray.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaArray.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaArray.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,22 @@
+/*
+` * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import org.apache.commons.classscan.model.MetaArray;
+
+/**
+ * Metadata about a method parameter or return value that is an array
+ */
+public interface SpiMetaArray extends MetaArray, HasResolve {
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClass.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClass.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClass.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClass.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,22 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import org.apache.commons.classscan.model.MetaClass;
+
+/**
+ * Metadata about a class or primitive type
+ */
+public interface SpiMetaClass extends MetaClass, HasResolve {
+}
\ No newline at end of file

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClassLoader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClassLoader.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClassLoader.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClassLoader.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,37 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import org.apache.commons.classscan.MetaClassLoader;
+import org.apache.commons.classscan.model.MetaClass;
+import org.apache.commons.classscan.model.MetaType;
+
+/**
+ * Metadata about a ClassLoader. This includes the jars that a ClassLoader loads
+ * from and the Classes that are potentially available.
+ */
+public interface SpiMetaClassLoader extends MetaClassLoader {
+    
+    /**
+     * Get metadata representing a type from its byte code signature
+     * 
+     * @param fieldDescriptor
+     *            The field descriptor as defined in section 4.3.2 of The Java
+     *            Virtual Machine Specification
+     * @return The type metadata
+     */
+    MetaType resolveTypeForDescriptor(String fieldDescriptor);
+
+	MetaClass resolveMetaClass(String className);
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClassPathElement.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClassPathElement.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClassPathElement.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaClassPathElement.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,34 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import org.apache.commons.classscan.MetaClassPathElement;
+import org.apache.commons.classscan.model.MetaClass;
+
+/**
+ * Information about a code location. A code location may be a file folder, or a
+ * jar, or other packaged location
+ */
+public interface SpiMetaClassPathElement extends MetaClassPathElement, HasResolve {
+
+	/**
+	 * Find and resolve a MetaClass.  Resolving a MetaClass changes String classnames and types
+	 * into references to the MetaClasses.
+	 * 
+	 * @param classLoader The metadata locus for a ClassLoader
+	 * @param className The canonical name of the class to resolve
+	 * @return The completely resolved MetaClass; or null, if resolution was unsuccessful.
+	 */
+	MetaClass resolveMetaClass(SpiMetaClassLoader classLoader, String className);
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaField.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaField.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaField.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaField.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,22 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import org.apache.commons.classscan.model.MetaField;
+
+/**
+ * Metadata about a Class field
+ */
+public interface SpiMetaField extends MetaField, HasResolve {
+}
\ No newline at end of file

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaMethod.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaMethod.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaMethod.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaMethod.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,22 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import org.apache.commons.classscan.model.MetaMethod;
+
+/**
+ * Metadata about a class method or constructor
+ */
+public interface SpiMetaMethod extends MetaMethod, HasResolve {
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaParameter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaParameter.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaParameter.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaParameter.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,22 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import org.apache.commons.classscan.model.MetaParameter;
+
+/**
+ * Metadata about a method or constructor parameter
+ */
+public interface SpiMetaParameter extends MetaParameter, HasResolve {
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaRegistry.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaRegistry.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaRegistry.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/SpiMetaRegistry.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,64 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.spi.model;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.commons.classscan.ClassPathElement;
+import org.apache.commons.classscan.MetaClassPathElement;
+import org.apache.commons.classscan.MetaRegistry;
+import org.apache.commons.classscan.spi.ClassPathElementFactory;
+
+/**
+ * The entry point for providers to find/create information about the ClassPath and the classes 
+ * available from the ClassPath.
+ */
+public interface SpiMetaRegistry extends MetaRegistry {
+
+	/**
+	 * Create SpiMetaClassPathElement from a ClassPathElement.  The ClassPathElement has 
+	 * just the raw class path definition.  The SpiMetaClassPathElement contains the
+	 * metadata about classes available at the class path location.
+	 * 
+	 * @param pathElement A location in the class path
+	 * @return metadata for classes available at the given location 
+	 */
+	SpiMetaClassPathElement createMetaClassPathElement(ClassPathElement pathElement);
+
+	/**
+	 * Create SpiMetaClass from a MetaClassPathElement.  The MetaClassPathElement has 
+	 * the metadata about a base location.  The SpiMetaClass contains the
+	 * metadata about the class defined in a stream of bytes.
+	 * 
+	 * @param metaClassPathElement The location of a class
+	 * @param className The canonical name of the class
+	 * @param byteStream The byte stream containing the class definition.  This stream should be closed when finished.
+	 * @return The metadata about the class in the stream
+	 * 
+	 * @throws IOException
+	 */
+	SpiMetaClass createMetaClass(MetaClassPathElement metaClassPathElement, String className, InputStream byteStream) throws IOException;
+
+	/**
+	 * Create a ClassPathElement from a URL.  The registry will invoke {@link ClassPathElementFactory}(s)
+	 * sequentially until a factory returns a ClassPathElement for the given URL. 
+	 * 
+	 * @param url The base location of the class files
+	 * @return null, if no ClassPathElementFactory supports the given URL; otherwise, a ClassPathElement
+	 * @throws IOException
+	 */
+	SpiClassPathElement createClassPathElement(URL url) throws IOException;
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/package-info.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/package-info.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/model/package-info.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,19 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * <p>The spi.model package contains metadata classes which allow the providers to
+ * give class information about annotations, methods, and fields.</p>
+ */
+package org.apache.commons.classscan.spi.model;
+

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/package-info.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/package-info.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/spi/package-info.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,19 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * <p>The spi package supports plugging in providers to support additional ClassLoader
+ * types and URL schemes.</p>
+ */
+package org.apache.commons.classscan.spi;
+

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/util/CallStack.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/util/CallStack.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/util/CallStack.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/util/CallStack.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,74 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.util;
+
+public abstract class CallStack {
+    
+    interface GetCallerStrategy {
+        Class<?> getCallerClass(int callStackDepth);        
+    }
+    
+    private static GetCallerStrategy strategy;
+    
+    static class SunReflection implements GetCallerStrategy {
+        SunReflection() {
+            // cause load of sun.reflect.Reflection class
+            sun.reflect.Reflection.getCallerClass(0);
+        }
+
+        @Override
+        public Class<?> getCallerClass(int callStackDepth) {
+            return sun.reflect.Reflection.getCallerClass(callStackDepth);
+        }
+    }
+    
+    static class SecurityManagerMethod extends SecurityManager implements GetCallerStrategy {
+        @Override
+        public Class<?> getCallerClass(int callStackDepth) {
+            return getClassContext()[callStackDepth];
+        }
+    }
+    
+    static {
+        try {
+            strategy= new SunReflection();
+        }
+        catch(Throwable t) {
+            strategy= new SecurityManagerMethod();
+        }
+    }
+
+    /**
+     * Return the Class of the caller.
+     * @param callStackDepth The number of stack frames to skip.  
+     * A value of 0 will return the calling Class of this method.  
+     * A value of 1 will return the calling Class of the caller of this method. 
+     * @return The Class at callStackDepth down the call stack
+     */
+    public static Class<?> getCallerClass(int callStackDepth) {
+        return strategy.getCallerClass(callStackDepth+3);
+    }
+
+    /**
+     * Return the ClassLoader of the caller.
+     * @param callStackDepth The number of stack frames to skip.  
+     * A value of 0 will return the ClassLoader of the calling Class of this method.  
+     * A value of 1 will return the ClassLoader of the calling Class of the caller of this method. 
+     * @return The ClassLoader of the Class at callStackDepth down the call stack
+     */
+    public static ClassLoader getClassLoader(int callStackDepth) {
+        Class<?> rc= strategy.getCallerClass(callStackDepth+3);
+        return rc.getClassLoader();
+    }
+}

Added: commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/util/FactoryCache.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/util/FactoryCache.java?rev=1357447&view=auto
==============================================================================
--- commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/util/FactoryCache.java (added)
+++ commons/sandbox/classscan/trunk/api/src/main/java/org/apache/commons/classscan/util/FactoryCache.java Thu Jul  5 02:48:34 2012
@@ -0,0 +1,56 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.classscan.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ * A cache of service providers.
+ *
+ * @param <T> The interface of the service provider
+ */
+public class FactoryCache<T> implements Iterable<T>  {
+
+	final private Collection<T> readOnly;
+	
+	/**
+	 * Find service providers available to the given classLoader
+	 * 
+	 * @param serviceProvider The interface of the service provider
+	 * @param classLoader The ClassLoader to load the service provider instances
+	 */
+	public FactoryCache(Class<T> serviceProvider, ClassLoader classLoader) {
+
+		final ArrayList<T> instances = new ArrayList<T>();
+		
+		new ServiceVisitor<T>() {
+			@Override
+			protected boolean visit(T factory) {
+		    	instances.add(factory);
+		    	return true;
+			}
+		}.visitProviders(serviceProvider, classLoader);
+
+		instances.trimToSize();
+    	readOnly = Collections.unmodifiableCollection(instances);
+	}
+
+	@Override
+	public Iterator<T> iterator() {
+		return readOnly.iterator();
+	}
+}



Mime
View raw message