public String get(Object key) { if (!(key instanceof String)) return null; String sKey = (String) key; if (Constants.EXPORT_PACKAGE.equalsIgnoreCase(sKey) || Constants.PROVIDE_CAPABILITY.equalsIgnoreCase(sKey)) { String systemProvideHeader = getEquinoxContainer() .getConfiguration() .getConfiguration( EquinoxConfiguration.PROP_SYSTEM_PROVIDE_HEADER, EquinoxConfiguration.SYSTEM_PROVIDE_HEADER_SYSTEM_EXTRA); boolean useSystemExtra = systemProvideHeader.equals(EquinoxConfiguration.SYSTEM_PROVIDE_HEADER_SYSTEM_EXTRA); boolean useSystem = systemProvideHeader.equals(EquinoxConfiguration.SYSTEM_PROVIDE_HEADER_SYSTEM) || useSystemExtra; String systemProp = useSystem ? (Constants.EXPORT_PACKAGE.equalsIgnoreCase(sKey) ? Constants.FRAMEWORK_SYSTEMPACKAGES : Constants.FRAMEWORK_SYSTEMCAPABILITIES) : null; String systemExtraProp = useSystemExtra ? (Constants.EXPORT_PACKAGE.equalsIgnoreCase(sKey) ? Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA : Constants.FRAMEWORK_SYSTEMCAPABILITIES_EXTRA) : null; return getExtra(sKey, systemProp, systemExtraProp); } return headers.get(key); }
/** @param aProperties the updated properties. */ @SuppressWarnings("rawtypes") final void setProperties(final Dictionary aProperties) { final Map<String, String> newProps = new HashMap<String, String>(); Enumeration keys = aProperties.keys(); while (keys.hasMoreElements()) { final String key = (String) keys.nextElement(); if (!KNOWN_KEYS.contains(key) && !IGNORED_KEYS.contains(key)) { LOG.log(Level.WARNING, "Unknown/unsupported profile key: " + key); continue; } final String value = aProperties.get(key).toString(); newProps.put(key, value.trim()); } // Verify whether all known keys are defined... final List<String> checkedKeys = new ArrayList<String>(KNOWN_KEYS); checkedKeys.removeAll(newProps.keySet()); if (!checkedKeys.isEmpty()) { throw new IllegalArgumentException( "Profile settings not complete! Missing keys are: " + checkedKeys.toString()); } this.properties.putAll(newProps); LOG.log( Level.INFO, "New device profile settings applied for {1} ({0}) ...", // new Object[] {getType(), getDescription()}); }
public static void toJSON(ConfigurationAdmin admin, Writer osw, String filter) throws Exception { Configuration[] list = admin.listConfigurations(filter); Encoder encoder = codec.enc().to(osw); Protocol p = new Protocol(); p.version = 1; p.date = new Date(); p.size = list.length; encoder.put(p).append('\n'); if (list != null) for (Configuration c : list) { Dictionary<String, Object> d = c.getProperties(); Export export = new Export(); export.values = new HashMap<String, Object>(); export.factoryPid = c.getFactoryPid(); export.pid = c.getPid(); for (Enumeration<String> e = d.keys(); e.hasMoreElements(); ) { String k = e.nextElement(); Object v = d.get(k); if (!(v instanceof String)) { if (export.types == null) export.types = new HashMap<String, Type>(); Type type = new Type(); Class<?> clazz = v.getClass(); if (v instanceof Collection) { Collection<?> coll = (Collection<?>) v; clazz = String.class; if (coll.size() > 0) type.vectorOf = shortName(coll.iterator().next().getClass()); else type.vectorOf = shortName(String.class); } else if (v.getClass().isArray()) { type.arrayOf = shortName(clazz.getComponentType()); } else type.scalar = shortName(v.getClass()); export.types.put(k, type); } export.values.put(k, v); } encoder.mark().put(export); // encoder.put(encoder.digest()); encoder.append('\n'); } osw.flush(); }
/** * Compares the specified Object with this Dictionary for equality, * * @return true if the specified Object is equal to this Dictionary. */ public synchronized boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Dictionary)) return false; Dictionary dict = (Dictionary) o; int max = size(); if (dict.size() != max) return false; Enumeration k = keys(); Enumeration e = elements(); for (int i = 0; i < max; i++) { Object key = k.nextElement(); Object value = e.nextElement(); if (!value.equals(dict.get(key))) { return false; } } return true; }
private String getExtra(String header, String systemProp, String systemExtraProp) { String systemValue = systemProp != null ? getEquinoxContainer().getConfiguration().getConfiguration(systemProp) : null; String systemExtraValue = systemExtraProp != null ? getEquinoxContainer().getConfiguration().getConfiguration(systemExtraProp) : null; if (systemValue == null) systemValue = systemExtraValue; else if (systemExtraValue != null && systemExtraValue.trim().length() > 0) systemValue += ", " + systemExtraValue; // $NON-NLS-1$ String result = headers.get(header); if (systemValue != null && systemValue.trim().length() > 0) { if (result != null) result += ", " + systemValue; // $NON-NLS-1$ else result = systemValue; } return result; }
private static synchronized String getSymbolicName(String path) { if (fCachedLocations == null) fCachedLocations = new HashMap(); File file = new File(path); if (file.exists() && !fCachedLocations.containsKey(path)) { try { Dictionary dictionary = MinimalState.loadManifest(file); String value = (String) dictionary.get(Constants.BUNDLE_SYMBOLICNAME); if (value != null) { ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, value); String id = elements.length > 0 ? elements[0].getValue() : null; if (id != null) fCachedLocations.put(path, elements[0].getValue()); } } catch (IOException e) { } catch (BundleException e) { } } return (String) fCachedLocations.get(path); }
public Object getAttribute(String attributeName) { Dictionary<String, Object> attributes = proxyContext.getContextAttributes(httpContext); return attributes.get(attributeName); }