/** Check for permission to get a service. */
 private <A> void checkAdaptPermission(Class<A> adapterType) {
   SecurityManager sm = System.getSecurityManager();
   if (sm == null) {
     return;
   }
   sm.checkPermission(new AdaptPermission(adapterType.getName(), this, AdaptPermission.ADAPT));
 }
Ejemplo n.º 2
0
 private static Class<?> mapComponentType(Class<?> componentType) {
   if (componentType.isPrimitive()
       || componentType.isArray()
       || Object.class.equals(componentType)
       || Number.class.isAssignableFrom(componentType)
       || Boolean.class.isAssignableFrom(componentType)
       || Character.class.isAssignableFrom(componentType)
       || String.class.isAssignableFrom(componentType)
       || DTO.class.isAssignableFrom(componentType)) {
     return componentType;
   }
   if (Map.class.isAssignableFrom(componentType)) {
     return Map.class;
   }
   if (List.class.isAssignableFrom(componentType)) {
     return List.class;
   }
   if (Set.class.isAssignableFrom(componentType)) {
     return Set.class;
   }
   return String.class;
 }
 @Override
 public Class<?> loadClass(String name) throws ClassNotFoundException {
   try {
     equinoxContainer.checkAdminPermission(this, AdminPermission.CLASS);
   } catch (SecurityException e) {
     throw new ClassNotFoundException(name, e);
   }
   checkValid();
   if (isFragment()) {
     throw new ClassNotFoundException(
         "Can not load a class from a fragment bundle: " + this); // $NON-NLS-1$
   }
   try {
     ModuleClassLoader classLoader = getModuleClassLoader(true);
     if (classLoader != null) {
       if (name.length() > 0 && name.charAt(0) == '[')
         return Class.forName(name, false, classLoader);
       return classLoader.loadClass(name);
     }
   } catch (ClassNotFoundException e) {
     // This is an equinox-ism.  Not sure it is worth it to offer an option to disable ...
     // On failure attempt to activate lazy activating bundles.
     if (State.LAZY_STARTING.equals(module.getState())) {
       try {
         module.start(StartOptions.LAZY_TRIGGER);
       } catch (BundleException e1) {
         equinoxContainer
             .getLogServices()
             .log(EquinoxContainer.NAME, FrameworkLogEntry.WARNING, e.getMessage(), e);
       }
     }
     throw e;
   }
   throw new ClassNotFoundException(
       "No class loader available for the bundle: " + this); // $NON-NLS-1$
 }