@Produces @BundleHeaders public Map<String, String> getBundleHeaders(BundleHolder holder, InjectionPoint p) { logger.trace("Entering OSGiUtilitiesProducer : getBundleHeaders() " + "with parameters {} | {}", new Object[] {holder,p}); Dictionary dict = getBundle(holder, p).getHeaders(); if (dict == null) { logger.warn("Returning null, unable to retrieve the dictionary headers" + " for bundle {}", getBundle(holder, p)); return null; } Map<String, String> headers = new HashMap<String, String>(); Enumeration<String> keys = dict.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); headers.put(key, (String) dict.get(key)); } logger.debug("Returning the headers {} " + "for bundle {}", headers, getBundle(holder, p)); return headers; }
@Produces @BundleDataFile("") public File getDataFile(BundleHolder holder, InjectionPoint p) { logger.trace("Entering OSGiUtilitiesProducer : getDataFile() " + "with parameters {} | {}", new Object[] {holder,p}); Set<Annotation> qualifiers = p.getQualifiers(); BundleDataFile file = null; for (Annotation qualifier : qualifiers) { if (qualifier.annotationType().equals(BundleDataFile.class)) { file = (BundleDataFile) qualifier; break; } } if (file.value().equals("")) { logger.warn("Returning null," + " the BundleDataFile annotation path was empty"); return null; } BundleContext context = getBundleContext(holder, p); if (context == null) { logger.warn("Returning null, unable to retrieve the BundleContext " + "for holder {} and injection point {}", holder, p); return null; } logger.debug("Returning the file {} from bundle context {}", file.value(), context); return context.getDataFile(file.value()); }
return null; Dictionary dict = getBundle(holder, p).getHeaders(); if (dict == null) { logger.warn("Returning null, unable to retrieve the dictionary headers" + " for bundle {}", getBundle(holder, p)); return null; + "for bundle {}", header, getBundle(holder, p)); return (String) dict.get(header.value());