Java Class.getInterfaces Examples

Java Class.getInterfaces - 30 examples found. These are the top rated real world Java examples of Class.getInterfaces extracted from open source projects. You can rate examples to help us improve the quality of examples.
 private static Class<?>[] getObjectInterfaces(Class<?> objectClass, List<Class<?>> interfaces) {
   // Rq: object.getClass().getInterfaces() ne suffit pas pour Connection dans Tomcat
   // car la connection est une instance de PoolGuardConnectionWrapper
   // et connection.getClass().getInterfaces() est vide dans ce cas
   final List<Class<?>> myInterfaces;
   if (interfaces == null) {
     myInterfaces = new ArrayList<Class<?>>(Arrays.asList(objectClass.getInterfaces()));
     Class<?> classe = objectClass.getSuperclass();
     while (classe != null) {
       final Class<?>[] classInterfaces = classe.getInterfaces();
       if (classInterfaces.length > 0) {
         final List<Class<?>> superInterfaces = Arrays.asList(classInterfaces);
         // removeAll d'abord car il ne faut pas de doublon dans la liste
         myInterfaces.removeAll(superInterfaces);
         myInterfaces.addAll(superInterfaces);
       }
       classe = classe.getSuperclass();
     }
     // on ignore l'interface javax.naming.Referenceable car sinon le rebind sous jetty appelle
     // referenceable.getReference() et devient inutile
     myInterfaces.remove(Referenceable.class);
   } else {
     myInterfaces = interfaces;
   }
   return myInterfaces.toArray(new Class<?>[myInterfaces.size()]);
 }
Example #2
0
  private void extractClassIntoMaps(Class type, boolean foundName, Supplier supplier) {

    if (type == null) {
      return;
    }
    String named = null;

    Class superClass = type.getSuperclass();

    Class[] superTypes = type.getInterfaces();

    for (Class superType : superTypes) {
      this.supplierTypeMap.put(superType, supplier);
    }

    while (superClass != Object.class) {
      this.supplierTypeMap.put(superClass, supplier);

      if (!foundName) {
        named = NamedUtils.namedValueForClass(superClass);
        if (named != null) {
          supplierNameMap.put(named, new ProviderInfo(named, type, supplier, null));
          foundName = true;
        }
      }

      superTypes = type.getInterfaces();
      for (Class superType : superTypes) {
        this.supplierTypeMap.put(superType, supplier);
      }
      superClass = superClass.getSuperclass();
    }
  }
Example #3
0
 private static ArrayList<Class<?>> getAllInterfaces(Class<?> c) {
   ArrayList<Class<?>> allInterfaces = new ArrayList<Class<?>>();
   if (!c.isInterface() && c.getInterfaces().length == 0) {
     allInterfaces.addAll(getAllInterfaces(c.getSuperclass()));
   } else {
     allInterfaces.addAll(Arrays.asList(c.getInterfaces()));
   }
   return allInterfaces;
 }
Example #4
0
 public ModuleManager createModuleManagerProxy(
     PluginVersionReference pluginVersionReference, InvocationHandler invocationHandler)
     throws CantCreateProxyException {
   ModuleManager moduleManager = null;
   if (!openModules.containsKey(pluginVersionReference)) {
     try {
       ModuleManager moduleManagerBase =
           FermatSystem.getInstance().getModuleManager2(pluginVersionReference);
       if (moduleManagerBase == null)
         throw new RuntimeException(
             "Module manager null in platform, please check if your plugin is connected, pluginVersionReference: "
                 + pluginVersionReference.toString3());
       Class clazz = moduleManagerBase.getClass();
       moduleManager =
           (ModuleManager)
               Proxy.newProxyInstance(
                   clazz.getClassLoader(), clazz.getInterfaces(), invocationHandler);
       openModules.put(clazz, moduleManager);
     } catch (CantGetModuleManagerException e) {
       try {
         Class clazz = FermatSystem.getInstance().getModuleManager3(pluginVersionReference);
         if (clazz == null)
           throw new RuntimeException(
               "Module manager null in platform, please check if your plugin is connected, pluginVersionReference: "
                   + pluginVersionReference.toString3());
         moduleManager =
             (ModuleManager)
                 Proxy.newProxyInstance(
                     clazz.getClassLoader(), clazz.getInterfaces(), invocationHandler);
         openModules.put(clazz, moduleManager);
       } catch (Exception e2) {
         Log.e(
             TAG,
             "Cant get module manager in platform, please check if your plugin is connected, pluginVersionReference: "
                 + pluginVersionReference.toString3());
         throw new CantCreateProxyException(
             "Cant get module manager from system", e, "factory", "");
       }
     } catch (ModuleManagerNotFoundException e) {
       Log.e(
           TAG,
           "Cant get module manager in platform, please check if your plugin is connected, pluginVersionReference: "
               + pluginVersionReference.toString3());
       throw new CantCreateProxyException(
           "Cant fount module manager from system", e, "factory", "");
     }
   } else {
     moduleManager = openModules.get(pluginVersionReference);
   }
   //        Log.i(TAG,"interfaces: ");
   //        for (Class<?> aClass : moduleManager.getClass().getInterfaces()) {
   //            Log.i(TAG,aClass.getName());
   //        }
   return moduleManager;
 }
Example #5
0
 public ClassDefinition(Class<?> cls) {
   this.definedClass = cls;
   this.setClassName(cls.getCanonicalName());
   this.setSuperClass(cls.getSuperclass() != null ? cls.getSuperclass().getCanonicalName() : null);
   String[] interfaces = new String[cls.getInterfaces().length];
   int i = 0;
   for (Class<?> interfaze : cls.getInterfaces()) {
     interfaces[i++] = interfaze.getCanonicalName();
   }
   this.setInterfaces(interfaces);
 }
Example #6
0
 private boolean checkAnonymous(Class<?> target) {
   if (!target.isAnonymousClass()) {
     return false;
   }
   if (target.getSuperclass() != Object.class && target.getSuperclass() == javaClass) {
     return true;
   }
   if (target.getInterfaces().length == 1 && target.getInterfaces()[0] == javaClass) {
     return true;
   }
   return false;
 }