Esempio n. 1
0
 protected void activate(ComponentContext ctxt) {
   // You may delete all references to metatype service if
   // your algorithm does not require parameters and return
   // null in the createParameters() method
   MetaTypeService mts = (MetaTypeService) ctxt.locateService("MTS");
   provider = mts.getMetaTypeInformation(ctxt.getBundleContext().getBundle());
 }
Esempio n. 2
0
  /** {@inheritDoc}. */
  @SuppressWarnings("unchecked")
  @Override
  public List<Map<String, Object>> getServices(String applicationID) {
    List<Map<String, Object>> services =
        configAdminExt.listServices(getDefaultFactoryLdapFilter(), getDefaultLdapFilter());
    List<Map<String, Object>> returnValues = new ArrayList<Map<String, Object>>();
    BundleContext context = getContext();

    if (!services.isEmpty()) {
      Application app = appService.getApplication(applicationID);
      MetaTypeService metatypeService = getMetaTypeService();

      if (app != null) {
        try {
          Set<BundleInfo> bundles = app.getBundles();

          Set<String> bundleLocations = new HashSet<String>();
          Set<MetaTypeInformation> metatypeInformation = new HashSet<MetaTypeInformation>();
          for (BundleInfo info : bundles) {
            bundleLocations.add(info.getLocation());
          }

          for (Bundle bundle : context.getBundles()) {
            for (BundleInfo info : bundles) {
              if (info.getLocation().equals(bundle.getLocation())) {
                metatypeInformation.add(metatypeService.getMetaTypeInformation(bundle));
              }
            }
          }

          for (Map<String, Object> service : services) {
            if (service.containsKey("configurations")) {
              List<Map<String, Object>> configurations =
                  (List<Map<String, Object>>) service.get("configurations");
              for (Map<String, Object> item : configurations) {
                if (item.containsKey("bundle_location")) {
                  String bundleLocation = (String) item.get("bundle_location");
                  if (bundleLocations.contains(bundleLocation)) {
                    returnValues.add(service);
                    break;
                  }
                }
              }
            } else {
              if (checkForMetaTypesForService(metatypeInformation, service)) {
                returnValues.add(service);
              }
            }
          }

        } catch (ApplicationServiceException e) {
          LOGGER.warn("There was an error while trying to access the application", e);
          return new ArrayList<Map<String, Object>>();
        }
      }
    }

    return returnValues;
  }
Esempio n. 3
0
 private ObjectClassDefinition getObjectClassDefinition(String symbolicName, String pid) {
   Bundle[] bundles = bundleCtx.getBundles();
   for (Bundle bundle : bundles) {
     if (symbolicName.equals(bundle.getSymbolicName())) {
       try {
         MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
         if (mti != null) {
           try {
             ObjectClassDefinition ocd =
                 mti.getObjectClassDefinition(pid, Locale.getDefault().toString());
             if (ocd != null) {
               return ocd;
             }
           } catch (IllegalArgumentException e) {
             // ignoring
           }
         }
       } catch (IllegalArgumentException iae) {
         // ignoring
       }
     }
   }
   return null;
 }
Esempio n. 4
0
 protected void activate(ComponentContext ctxt) {
   MetaTypeService mts = (MetaTypeService) ctxt.locateService("MTS");
   provider = mts.getMetaTypeInformation(ctxt.getBundleContext().getBundle());
 }