[infinispan-commits] Infinispan SVN: r540 - in trunk/tools/src/main/java/org/infinispan/tools: doclet/html and 1 other directory.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Thu Jul 9 09:30:10 EDT 2009
Author: vblagojevic at jboss.com
Date: 2009-07-09 09:30:10 -0400 (Thu, 09 Jul 2009)
New Revision: 540
Removed:
trunk/tools/src/main/java/org/infinispan/tools/ClassFinder.java
Modified:
trunk/tools/src/main/java/org/infinispan/tools/doclet/html/ConfigHtmlGenerator.java
Log:
use ClassFinder from core
Deleted: trunk/tools/src/main/java/org/infinispan/tools/ClassFinder.java
===================================================================
--- trunk/tools/src/main/java/org/infinispan/tools/ClassFinder.java 2009-07-09 13:15:00 UTC (rev 539)
+++ trunk/tools/src/main/java/org/infinispan/tools/ClassFinder.java 2009-07-09 13:30:10 UTC (rev 540)
@@ -1,133 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.infinispan.tools;
-
-import java.io.File;
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import org.infinispan.util.Util;
-
-/**
- * Find infinispan classes utility
- *
- */
-public class ClassFinder {
-
- public static List<Class<?>> withAnnotationPresent(List<Class<?>> classes, Class<? extends Annotation> c) {
- List<Class<?>> clazzes = new ArrayList<Class<?>>();
- for (Class<?> clazz : classes) {
- if (clazz.isAnnotationPresent(c)) {
- clazzes.add(clazz);
- }
- }
- return clazzes;
- }
-
- public static List<Class<?>> isAssignableFrom(List<Class<?>> classes, Class<?> clazz) {
- List<Class<?>> clazzes = new ArrayList<Class<?>>();
- for (Class<?> c : classes) {
- if (clazz.isAssignableFrom(c)) {
- clazzes.add(c);
- }
- }
- return clazzes;
- }
-
- public static List<Class<?>> withAnnotationPresent(Class<? extends Annotation> ann) throws Exception {
- return withAnnotationPresent(infinispanClasses(), ann);
- }
-
- public static List<Class<?>> isAssignableFrom(Class<?> clazz) throws Exception {
- return isAssignableFrom(infinispanClasses(), clazz);
- }
-
- public static List<Class<?>> infinispanClasses() throws Exception {
- List<File> files = new ArrayList<File>();
- String javaClassPath = System.getProperty("java.class.path");
-
- // either infinispan jar or a directory of output classes contains infinispan classes
- for (String path : javaClassPath.split(File.pathSeparator)) {
- if ((path.contains("infinispan") && path.endsWith("jar")) || !path.endsWith("jar")) {
- files.add(new File(path));
- }
- }
- if (files.isEmpty())
- return Collections.emptyList();
- else if (files.size() == 1)
- return findClassesOnPath(files.get(0));
- else {
- Set<Class<?>> classFiles = new HashSet<Class<?>>();
- for (File file : files) {
- classFiles.addAll(findClassesOnPath(file));
- }
- return new ArrayList<Class<?>>(classFiles);
- }
- }
-
- private static List<Class<?>> findClassesOnPath(File path) throws Exception {
- List<Class<?>> classes = new ArrayList<Class<?>>();
- if (path.isDirectory()) {
- List<File> classFiles = new ArrayList<File>();
- dir(classFiles, path);
- for (File cf : classFiles) {
- Class<?> claz = Util.loadClass(toClassName(cf.getAbsolutePath().toString()));
- classes.add(claz);
- }
- } else {
- if (path.isFile() && path.getName().endsWith("jar") && path.canRead()) {
- JarFile jar = new JarFile(path);
- Enumeration<JarEntry> en = jar.entries();
- while (en.hasMoreElements()) {
- JarEntry entry = en.nextElement();
- if (entry.getName().endsWith("class")) {
- Class<?> claz = Util.loadClass(toClassName(entry.getName()));
- classes.add(claz);
- }
- }
- }
- }
- return classes;
- }
-
- private static void dir(List<File> files, File dir) {
- File[] entries = dir.listFiles();
- for (File entry : entries) {
- if (entry.isDirectory()) {
- dir(files, entry);
- } else if (entry.getName().endsWith("class")) {
- files.add(entry);
- }
- }
- }
-
- private static String toClassName(String fileName) {
- return fileName.substring(fileName.lastIndexOf("org"), fileName.length() - 6).replaceAll(File.separator, ".");
- }
-}
\ No newline at end of file
Modified: trunk/tools/src/main/java/org/infinispan/tools/doclet/html/ConfigHtmlGenerator.java
===================================================================
--- trunk/tools/src/main/java/org/infinispan/tools/doclet/html/ConfigHtmlGenerator.java 2009-07-09 13:15:00 UTC (rev 539)
+++ trunk/tools/src/main/java/org/infinispan/tools/doclet/html/ConfigHtmlGenerator.java 2009-07-09 13:30:10 UTC (rev 540)
@@ -11,7 +11,7 @@
import org.infinispan.config.ConfigurationElements;
import org.infinispan.config.ConfigurationProperties;
import org.infinispan.config.ConfigurationProperty;
-import org.infinispan.tools.ClassFinder;
+import org.infinispan.util.ClassFinder;
public class ConfigHtmlGenerator extends HtmlGenerator {
More information about the infinispan-commits
mailing list