Package cn.wensiqun.utils

Examples of cn.wensiqun.utils.HierarchyInfoContainer


      /*Map<Class<?>, Map<Class<?> , HierarchyInfo>> allHierarchyInfoMap = new HashMap<Class<?>, Map<Class<?> , HierarchyInfo>>();
      for(Class<?> p : parents){
        allHierarchyInfoMap.put(p, new HashMap<Class<?> , HierarchyInfo>());
      }*/
       
        HierarchyInfoContainer hierarchyInfoContainer = new HierarchyInfoContainer(parents);
   
       
    List<String> classNames = new ArrayList<String>();
        for (URL location : urls) {
            try {
                if (protocols.contains(location.getProtocol())) {
                    classNames.addAll(jar(location));
                } else if ("file".equals(location.getProtocol())) {
                    try {
                        // See if it's actually a jar
                        URL jarUrl = new URL("jar", "", location.toExternalForm() + "!/");
                        JarURLConnection juc = (JarURLConnection) jarUrl.openConnection();
                        juc.getJarFile();
                        classNames.addAll(jar(jarUrl));
                    } catch (IOException e) {
                        classNames.addAll(file(location));
                    }
                }
            } catch (Exception e) {
                if (LOG.isErrorEnabled())
                    LOG.error("Unable to read URL [" + location.toExternalForm() + "]", e);
            }
        }
       
        StringBuilder unableLoadClass = new StringBuilder("Unable to read class [");
        for (String className : classNames) {
          if(LOG.isDebugEnabled()){
              LOG.debug(" loop [" + className + "]");
          }
            try {
                if (classNameFilter == null || (classNameFilter != null && classNameFilter.test(className))){
                  if(LOG.isDebugEnabled()){
                      LOG.debug(" parse [" + className + "]");
                  }
                    readClassDef(className);
                    readClassHierarchyInfo(className, hierarchyInfoContainer);
                }
            } catch (Throwable e) {
                if (LOG.isErrorEnabled()){
                  classGrep.getNotLoadedClass().add(className);
                  unableLoadClass.append("\"").append(className).append("\",");
                }
            }
        }
        if(unableLoadClass.length() != "Unable to read class [".length()){
          unableLoadClass.deleteCharAt(unableLoadClass.length() - 1).append("]");
            LOG.error(unableLoadClass)
        }
       
        /*//buildHierarchyInfo
        for(Entry<Class<?>, Map<Class<?> , HierarchyInfo>> entry : hierarchyInfoMap.entrySet()){
          Class<?> top = entry.getKey();
          hierarchyInfoMap.put(top, buildHierarchyInfo(top, entry.getValue()));
        }*/
        hierarchyInfoMap = hierarchyInfoContainer.getExcept();
       
        //set original method or constructor to MethodInfo
        for(List<MethodInfo> methodInfos : getAnnotatedMethodInfoMap().values()){
          for(MethodInfo methodInfo : methodInfos){
            try {
View Full Code Here


      /*Map<Class<?>, Map<Class<?> , HierarchyInfo>> allHierarchyInfoMap = new HashMap<Class<?>, Map<Class<?> , HierarchyInfo>>();
      for(Class<?> p : parents){
        allHierarchyInfoMap.put(p, new HashMap<Class<?> , HierarchyInfo>());
      }*/
       
        HierarchyInfoContainer hierarchyInfoContainer = new HierarchyInfoContainer(parents);
   
       
    List<String> classNames = new ArrayList<String>();
        for (URL location : urls) {
            try {
                if (protocols.contains(location.getProtocol())) {
                    classNames.addAll(jar(location));
                } else if ("file".equals(location.getProtocol())) {
                    try {
                        // See if it's actually a jar
                        URL jarUrl = new URL("jar", "", location.toExternalForm() + "!/");
                        JarURLConnection juc = (JarURLConnection) jarUrl.openConnection();
                        juc.getJarFile();
                        classNames.addAll(jar(jarUrl));
                    } catch (IOException e) {
                        classNames.addAll(file(location));
                    }
                }
            } catch (Exception e) {
                if (LOG.isErrorEnabled())
                    LOG.error("Unable to read URL [" + location.toExternalForm() + "]", e);
            }
        }
       
        StringBuilder unableLoadClass = new StringBuilder("Unable to read class [");
        for (String className : classNames) {
          if(LOG.isDebugEnabled()){
              LOG.debug(" loop [" + className + "]");
          }
            try {
                if (classNameFilter == null || (classNameFilter != null && classNameFilter.test(className))){
                  if(LOG.isDebugEnabled()){
                      LOG.debug(" parse [" + className + "]");
                  }
                    readClassDef(className);
                    readClassHierarchyInfo(className, hierarchyInfoContainer);
                }
            } catch (Throwable e) {
                if (LOG.isErrorEnabled()){
                  classGrep.getNotLoadedClass().add(className);
                  unableLoadClass.append("\"").append(className).append("\",");
                }
            }
        }
        if(unableLoadClass.length() != "Unable to read class [".length()){
          unableLoadClass.deleteCharAt(unableLoadClass.length() - 1).append("]");
            LOG.error(unableLoadClass)
        }
       
        /*//buildHierarchyInfo
        for(Entry<Class<?>, Map<Class<?> , HierarchyInfo>> entry : hierarchyInfoMap.entrySet()){
          Class<?> top = entry.getKey();
          hierarchyInfoMap.put(top, buildHierarchyInfo(top, entry.getValue()));
        }*/
        hierarchyInfoMap = hierarchyInfoContainer.getExcept();
       
        //set original method or constructor to MethodInfo
        for(List<MethodInfo> methodInfos : getAnnotatedMethodInfoMap().values()){
          for(MethodInfo methodInfo : methodInfos){
            try {
View Full Code Here

TOP

Related Classes of cn.wensiqun.utils.HierarchyInfoContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.