/** * Checks to see if there are any metatypes out there for a particular service. * * @param metatypeInformations - Where we'll look for metatypes that match our service from. * @param service - our service we want metatypes for. * @return true if there is, and the service should be added, or false if it shouldn't be. */ private boolean checkForMetaTypesForService( Set<MetaTypeInformation> metatypeInformations, Map<String, Object> service) { String id = (String) service.get("id"); boolean ifFactory = (Boolean) service.get("factory"); if (ifFactory) { for (MetaTypeInformation information : metatypeInformations) { if (information != null) { for (String pid : information.getFactoryPids()) { if (pid.equals(id)) { return true; } } } } } else { for (MetaTypeInformation information : metatypeInformations) { if (information != null) { for (String pid : information.getPids()) { if (pid.equals(id)) { return true; } } } } } return false; }
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; }