protected Properties getPortalProperties(String settingsId) { Properties portalProperties = _propertiesMap.get(settingsId); if (portalProperties != null) { return portalProperties; } portalProperties = PropsUtil.getProperties(); _propertiesMap.put(settingsId, portalProperties); return portalProperties; }
/** * Returns a properties map representing the {@link OSGiBeanProperties} instance. * * @param osgiBeanProperties the instance of {@link OSGiBeanProperties} read for properties * @return a properties map representing the {@link OSGiBeanProperties} instance. The map will * be empty if the {@link OSGiBeanProperties} instance has no properties. */ public static Map<String, Object> toMap(OSGiBeanProperties osgiBeanProperties) { Map<String, Object> properties = new HashMap<>(); for (String property : osgiBeanProperties.property()) { String[] parts = property.split(StringPool.EQUAL, 2); if (parts.length <= 1) { continue; } String key = parts[0]; String className = String.class.getSimpleName(); if (key.indexOf(StringPool.COLON) != -1) { String[] keyParts = StringUtil.split(key, StringPool.COLON); key = keyParts[0]; className = keyParts[1]; } String value = parts[1]; _put(key, value, className, properties); } String portalPropertyPrefix = osgiBeanProperties.portalPropertyPrefix(); if (Validator.isNotNull(portalPropertyPrefix)) { Properties portalProperties = PropsUtil.getProperties( portalPropertyPrefix, osgiBeanProperties.portalPropertiesRemovePrefix()); properties.putAll(PropertiesUtil.toMap(portalProperties)); } return properties; }
private Map<String, String> _buildFrameworkProperties(Class<?> clazz) { Map<String, String> properties = new HashMap<String, String>(); properties.put(Constants.BUNDLE_DESCRIPTION, ReleaseInfo.getReleaseInfo()); properties.put(Constants.BUNDLE_NAME, ReleaseInfo.getName()); properties.put(Constants.BUNDLE_VENDOR, ReleaseInfo.getVendor()); properties.put(Constants.BUNDLE_VERSION, ReleaseInfo.getVersion()); properties.put(FrameworkPropsKeys.FELIX_FILEINSTALL_DIR, _getFelixFileInstallDir()); properties.put(FrameworkPropsKeys.FELIX_FILEINSTALL_LOG_LEVEL, _getFelixFileInstallLogLevel()); properties.put( FrameworkPropsKeys.FELIX_FILEINSTALL_POLL, String.valueOf(PropsValues.MODULE_FRAMEWORK_AUTO_DEPLOY_INTERVAL)); properties.put( FrameworkPropsKeys.FELIX_FILEINSTALL_TMPDIR, SystemProperties.get(SystemProperties.TMP_DIR)); properties.put( Constants.FRAMEWORK_BEGINNING_STARTLEVEL, String.valueOf(PropsValues.MODULE_FRAMEWORK_BEGINNING_START_LEVEL)); properties.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_APP); properties.put(Constants.FRAMEWORK_STORAGE, PropsValues.MODULE_FRAMEWORK_STATE_DIR); properties.put("eclipse.security", null); properties.put("java.security.manager", null); properties.put("org.osgi.framework.security", null); ProtectionDomain protectionDomain = clazz.getProtectionDomain(); CodeSource codeSource = protectionDomain.getCodeSource(); URL codeSourceURL = codeSource.getLocation(); properties.put(FrameworkPropsKeys.OSGI_FRAMEWORK, codeSourceURL.toExternalForm()); File frameworkFile = new File(codeSourceURL.getFile()); properties.put(FrameworkPropsKeys.OSGI_INSTALL_AREA, frameworkFile.getParent()); Properties extraProperties = PropsUtil.getProperties(PropsKeys.MODULE_FRAMEWORK_PROPERTIES, true); for (Map.Entry<Object, Object> entry : extraProperties.entrySet()) { String key = (String) entry.getKey(); String value = (String) entry.getValue(); // We need to support an empty string and a null value distinctly. // This is due to some different behaviors between OSGi // implementations. If a property is passed as xyz= it will be // treated as an empty string. Otherwise, xyz=null will be treated // as an explicit null value. if (value.equals(StringPool.NULL)) { value = null; } properties.put(key, value); } String systemPackagesExtra = _getSystemPackagesExtra(); properties.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, systemPackagesExtra); return properties; }