From 55db28436540e1615a3520feacfe610a3430784a Mon Sep 17 00:00:00 2001 From: Nicolas Roduit Date: Tue, 23 Apr 2024 11:44:37 +0200 Subject: [PATCH] Share config and preferences with Core module --- weasis-core/pom.xml | 6 + .../org/weasis/core/api/service/UICore.java | 27 ++++ weasis-distributions/etc/config/base.json | 2 +- weasis-launcher/conf/base.json | 2 +- .../java/org/weasis/launcher/AppLauncher.java | 6 +- .../org/weasis/launcher/AutoProcessor.java | 3 +- .../java/org/weasis/launcher/FileUtil.java | 11 +- .../java/org/weasis/launcher/Singleton.java | 5 +- .../main/java/org/weasis/launcher/Utils.java | 4 - .../org/weasis/launcher/WeasisLauncher.java | 151 +++++++----------- .../org/weasis/launcher/WeasisMainFrame.java | 11 ++ .../weasis/launcher/WeasisMainFrameMBean.java | 3 + .../java/org/weasis/pref/AppPreferences.java | 35 ++-- .../weasis/{launcher => pref}/ConfigData.java | 112 ++++++++----- weasis-parent/pom.xml | 4 + 15 files changed, 211 insertions(+), 171 deletions(-) rename weasis-launcher/src/main/java/org/weasis/{launcher => pref}/ConfigData.java (87%) diff --git a/weasis-core/pom.xml b/weasis-core/pom.xml index 626ef6fa7..dae2d0065 100755 --- a/weasis-core/pom.xml +++ b/weasis-core/pom.xml @@ -61,6 +61,12 @@ + + org.weasis.launcher + weasis-launcher + ${project.parent.version} + provided + org.apache.felix org.apache.felix.gogo.command diff --git a/weasis-core/src/main/java/org/weasis/core/api/service/UICore.java b/weasis-core/src/main/java/org/weasis/core/api/service/UICore.java index 934293afe..24cc782cf 100644 --- a/weasis-core/src/main/java/org/weasis/core/api/service/UICore.java +++ b/weasis-core/src/main/java/org/weasis/core/api/service/UICore.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.IOException; import java.io.OutputStream; +import java.lang.management.ManagementFactory; import java.net.HttpURLConnection; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @@ -36,6 +37,10 @@ import java.util.Locale.Category; import java.util.Map; import java.util.Properties; +import javax.management.InstanceNotFoundException; +import javax.management.JMException; +import javax.management.MBeanServer; +import javax.management.ObjectName; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,6 +63,7 @@ import org.weasis.core.ui.util.Toolbar; import org.weasis.core.util.FileUtil; import org.weasis.core.util.StringUtil; +import org.weasis.pref.ConfigData; public final class UICore { public static final String P_FORMAT_CODE = "locale.format.code"; @@ -79,6 +85,7 @@ public final class UICore { private final WProperties systemPreferences; private final WProperties localPersistence; private final WProperties initialSystemPreferences; + private final ConfigData configData; private final HashMap pluginPersistenceMap; private final File propsFile; @@ -92,6 +99,7 @@ private UICore() { this.baseArea = dockingControl.getContentArea(); this.mainArea = dockingControl.createWorkingArea("mainArea"); this.toolbarContainer = new ToolBarContainer(); + this.configData = retrieveconfigData(); this.initialSystemPreferences = new WProperties(); this.systemPreferences = new WProperties(); this.pluginPersistenceMap = new HashMap<>(); @@ -139,6 +147,21 @@ public boolean willGainFocus(CDockable dockable) { FileUtil.readProperties(new File(dataFolder, "persistence.properties"), localPersistence); } + private static ConfigData retrieveconfigData() { + MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + try { + ObjectName objectName = ObjectName.getInstance("weasis:name=MainWindow"); // NON-NLS + Object preferences = server.getAttribute(objectName, "ConfigData"); + if (preferences instanceof ConfigData configData) { + return configData; + } + } catch (InstanceNotFoundException ignored) { + } catch (JMException e) { + LOGGER.debug("Error while receiving main window", e); + } + throw new IllegalStateException("Cannot retrieve ConfigData"); + } + /** * Thread safe singleton instance. * @@ -352,6 +375,10 @@ public List> getCodecPlugins() { return codecPlugins; } + public ConfigData getConfigData() { + return configData; + } + /** * This the persistence used at launch which can be stored remotely. These are the preferences * necessary for launching unlike the preferences associated with the plugins. diff --git a/weasis-distributions/etc/config/base.json b/weasis-distributions/etc/config/base.json index 25185be3c..68a17b390 100644 --- a/weasis-distributions/etc/config/base.json +++ b/weasis-distributions/etc/config/base.json @@ -2,7 +2,7 @@ "weasisPreferences": [ { "code": "framework.system.packages.extra.basic", - "value": "com.formdev.flatlaf, com.formdev.flatlaf.extras, com.formdev.flatlaf.extras.components, com.formdev.flatlaf.icons, com.formdev.flatlaf.ui, com.formdev.flatlaf.util, com.sun.awt, com.sun.image.codec.jpeg, com.sun.imageio.spi, javax.accessibility, javax.imageio, javax.imageio.event, javax.imageio.metadata, javax.imageio.plugins.jpeg, javax.imageio.spi, javax.imageio.stream, javax.media, javax.swing, javax.swing.border, javax.swing.event, javax.swing.filechooser, javax.swing.plaf, javax.swing.plaf.basic, javax.swing.plaf.metal, javax.swing.table, javax.swing.text, javax.swing.tree, javax.xml.bind, javax.xml.parsers, javax.xml.namespace, javax.xml.stream, javax.xml.transform, javax.xml.transform.stax, javax.xml.validation, net.miginfocom.layout, net.miginfocom.swing, org.w3c.dom, org.xml.sax, org.xml.sax.ext, org.xml.sax.helpers, sun.awt, sun.awt.geom, sun.awt.image, sun.awt.image.codec, sun.java2d.opengl, sun.security.action, sun.misc, sun.net.www.protocol.file, sun.reflect", + "value": "com.formdev.flatlaf, com.formdev.flatlaf.extras, com.formdev.flatlaf.extras.components, com.formdev.flatlaf.icons, com.formdev.flatlaf.ui, com.formdev.flatlaf.util, com.sun.awt, com.sun.image.codec.jpeg, com.sun.imageio.spi, javax.accessibility, javax.imageio, javax.imageio.event, javax.imageio.metadata, javax.imageio.plugins.jpeg, javax.imageio.spi, javax.imageio.stream, javax.media, javax.swing, javax.swing.border, javax.swing.event, javax.swing.filechooser, javax.swing.plaf, javax.swing.plaf.basic, javax.swing.plaf.metal, javax.swing.table, javax.swing.text, javax.swing.tree, javax.xml.bind, javax.xml.parsers, javax.xml.namespace, javax.xml.stream, javax.xml.transform, javax.xml.transform.stax, javax.xml.validation, net.miginfocom.layout, net.miginfocom.swing, org.w3c.dom, org.weasis.pref, org.xml.sax, org.xml.sax.ext, org.xml.sax.helpers, sun.awt, sun.awt.geom, sun.awt.image, sun.awt.image.codec, sun.java2d.opengl, sun.security.action, sun.misc, sun.net.www.protocol.file, sun.reflect", "description": "List of additional packages for Felix (by default only java.* is visible in main class loader)", "type": "A", "category": "FELIX_CONFIG" diff --git a/weasis-launcher/conf/base.json b/weasis-launcher/conf/base.json index c8a6a45b0..3cfa092dd 100644 --- a/weasis-launcher/conf/base.json +++ b/weasis-launcher/conf/base.json @@ -2,7 +2,7 @@ "weasisPreferences": [ { "code": "framework.system.packages.extra.basic", - "value": "ch.qos.logback.classic,ch.qos.logback.classic.encoder,ch.qos.logback.classic.spi,ch.qos.logback.core,ch.qos.logback.core.encoder,ch.qos.logback.core.rolling,ch.qos.logback.core.util,com.formdev.flatlaf, com.formdev.flatlaf.extras, com.formdev.flatlaf.extras.components, com.formdev.flatlaf.icons, com.formdev.flatlaf.ui, com.formdev.flatlaf.util, com.sun.awt, com.sun.image.codec.jpeg, com.sun.imageio.spi, javax.accessibility, javax.imageio, javax.imageio.event, javax.imageio.metadata, javax.imageio.plugins.jpeg, javax.imageio.spi, javax.imageio.stream, javax.media, javax.swing, javax.swing.border, javax.swing.event, javax.swing.filechooser, javax.swing.plaf, javax.swing.plaf.basic, javax.swing.plaf.metal, javax.swing.table, javax.swing.text, javax.swing.tree, javax.xml.bind, javax.xml.parsers, javax.xml.namespace, javax.xml.stream, javax.xml.transform, javax.xml.transform.stax, javax.xml.validation, net.miginfocom.layout, net.miginfocom.swing, org.slf4j, org.w3c.dom, org.xml.sax, org.xml.sax.ext, org.xml.sax.helpers, sun.awt, sun.awt.geom, sun.awt.image, sun.awt.image.codec, sun.java2d.opengl, sun.security.action, sun.misc, sun.net.www.protocol.file, sun.reflect", + "value": "ch.qos.logback.classic,ch.qos.logback.classic.encoder,ch.qos.logback.classic.spi,ch.qos.logback.core,ch.qos.logback.core.encoder,ch.qos.logback.core.rolling,ch.qos.logback.core.util,com.formdev.flatlaf, com.formdev.flatlaf.extras, com.formdev.flatlaf.extras.components, com.formdev.flatlaf.icons, com.formdev.flatlaf.ui, com.formdev.flatlaf.util, com.sun.awt, com.sun.image.codec.jpeg, com.sun.imageio.spi, javax.accessibility, javax.imageio, javax.imageio.event, javax.imageio.metadata, javax.imageio.plugins.jpeg, javax.imageio.spi, javax.imageio.stream, javax.media, javax.swing, javax.swing.border, javax.swing.event, javax.swing.filechooser, javax.swing.plaf, javax.swing.plaf.basic, javax.swing.plaf.metal, javax.swing.table, javax.swing.text, javax.swing.tree, javax.xml.bind, javax.xml.parsers, javax.xml.namespace, javax.xml.stream, javax.xml.transform, javax.xml.transform.stax, javax.xml.validation, net.miginfocom.layout, net.miginfocom.swing, org.slf4j, org.w3c.dom, org.weasis.pref, org.xml.sax, org.xml.sax.ext, org.xml.sax.helpers, sun.awt, sun.awt.geom, sun.awt.image, sun.awt.image.codec, sun.java2d.opengl, sun.security.action, sun.misc, sun.net.www.protocol.file, sun.reflect", "description": "List of additional packages for Felix (by default only java.* is visible in main class loader)", "type": "A", "category": "FELIX_CONFIG" diff --git a/weasis-launcher/src/main/java/org/weasis/launcher/AppLauncher.java b/weasis-launcher/src/main/java/org/weasis/launcher/AppLauncher.java index 6c00c48f7..21d1c2412 100755 --- a/weasis-launcher/src/main/java/org/weasis/launcher/AppLauncher.java +++ b/weasis-launcher/src/main/java/org/weasis/launcher/AppLauncher.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.Properties; import java.util.concurrent.TimeUnit; +import org.weasis.pref.ConfigData; public class AppLauncher extends WeasisLauncher implements Singleton.SingletonApp { @@ -72,10 +73,11 @@ private void waitWhenStarted() { @Override public boolean canStartNewActivation(Properties prop) { boolean sameUser = - configData.isPropertyValueSimilar(P_WEASIS_USER, prop.getProperty(P_WEASIS_USER)); + configData.isPropertyValueSimilar( + ConfigData.P_WEASIS_USER, prop.getProperty(ConfigData.P_WEASIS_USER)); boolean sameConfig = configData.isPropertyValueSimilar( - P_WEASIS_CONFIG_HASH, prop.getProperty(P_WEASIS_CONFIG_HASH)); + ConfigData.P_WEASIS_CONFIG_HASH, prop.getProperty(ConfigData.P_WEASIS_CONFIG_HASH)); return sameUser && sameConfig; } diff --git a/weasis-launcher/src/main/java/org/weasis/launcher/AutoProcessor.java b/weasis-launcher/src/main/java/org/weasis/launcher/AutoProcessor.java index fe49078ff..68c02b969 100755 --- a/weasis-launcher/src/main/java/org/weasis/launcher/AutoProcessor.java +++ b/weasis-launcher/src/main/java/org/weasis/launcher/AutoProcessor.java @@ -24,6 +24,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.tukaani.xz.XZInputStream; +import org.weasis.pref.ConfigData; /** * @author Richard S. Hall @@ -239,7 +240,7 @@ private static void loadTranslationBundle( String filename = p.toString(); String value = modulesi18n.getProperty(filename); if (value != null) { - String baseURL = System.getProperty(WeasisLauncher.P_WEASIS_I18N); + String baseURL = System.getProperty(ConfigData.P_WEASIS_I18N); if (baseURL != null) { String uri = baseURL + (baseURL.endsWith("/") ? filename : "/" + filename); String bundleName = getBundleNameFromLocation(filename); diff --git a/weasis-launcher/src/main/java/org/weasis/launcher/FileUtil.java b/weasis-launcher/src/main/java/org/weasis/launcher/FileUtil.java index 5d66189cd..370942dd2 100755 --- a/weasis-launcher/src/main/java/org/weasis/launcher/FileUtil.java +++ b/weasis-launcher/src/main/java/org/weasis/launcher/FileUtil.java @@ -210,21 +210,26 @@ public static URLConnection getAdaptedConnection(URL url, boolean useCaches) thr // Prevent caching of Java WebStart. connection.setUseCaches(useCaches); // Support for http proxy authentication. - String p = url.getProtocol(); + String protocol = url.getProtocol(); String pauth = System.getProperty("http.proxyAuth", null); - if (Utils.hasText(pauth) && ("http".equals(p) || "https".equals(p))) { // NON-NLS + if (hasProxyProperty(pauth, protocol)) { String base64 = Util.base64Encode(pauth); connection.setRequestProperty("Proxy-Authorization", "Basic " + base64); // NON-NLS } String auth = System.getProperty("http.authorization", null); - if (Utils.hasText(auth) && ("http".equals(p) || "https".equals(p))) { // NON-NLS + if (hasProxyProperty(auth, protocol)) { connection.setRequestProperty("Authorization", auth); } return connection; } + private static boolean hasProxyProperty(String propertyValue, String protocol) { + return Utils.hasText(propertyValue) + && ("http".equals(protocol) || "https".equals(protocol)); // NON-NLS + } + private static void copyZip(InputStream in, File file) throws IOException { if (in == null) { return; diff --git a/weasis-launcher/src/main/java/org/weasis/launcher/Singleton.java b/weasis-launcher/src/main/java/org/weasis/launcher/Singleton.java index 903f17356..d3da99b56 100755 --- a/weasis-launcher/src/main/java/org/weasis/launcher/Singleton.java +++ b/weasis-launcher/src/main/java/org/weasis/launcher/Singleton.java @@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.weasis.pref.ConfigData; public class Singleton { private static final Logger LOGGER = LoggerFactory.getLogger(Singleton.class); @@ -186,8 +187,8 @@ static boolean connectToServer(ConfigData configData) { out.println(SI_PROP); Properties p = configData.getProperties(); - printProperty(out, WeasisLauncher.P_WEASIS_USER, p); - printProperty(out, WeasisLauncher.P_WEASIS_CONFIG_HASH, p); + printProperty(out, ConfigData.P_WEASIS_USER, p); + printProperty(out, ConfigData.P_WEASIS_CONFIG_HASH, p); // indicate end of file transmission out.println(SI_EOF); diff --git a/weasis-launcher/src/main/java/org/weasis/launcher/Utils.java b/weasis-launcher/src/main/java/org/weasis/launcher/Utils.java index 8e048156c..0af4c5bd3 100755 --- a/weasis-launcher/src/main/java/org/weasis/launcher/Utils.java +++ b/weasis-launcher/src/main/java/org/weasis/launcher/Utils.java @@ -55,10 +55,6 @@ public static boolean hasLength(CharSequence str) { return str != null && !str.isEmpty(); } - public static boolean hasLength(String str) { - return hasLength((CharSequence) str); - } - public static boolean hasText(CharSequence str) { if (!hasLength(str)) { return false; diff --git a/weasis-launcher/src/main/java/org/weasis/launcher/WeasisLauncher.java b/weasis-launcher/src/main/java/org/weasis/launcher/WeasisLauncher.java index 26fcfa7db..aa15f2826 100755 --- a/weasis-launcher/src/main/java/org/weasis/launcher/WeasisLauncher.java +++ b/weasis-launcher/src/main/java/org/weasis/launcher/WeasisLauncher.java @@ -10,6 +10,17 @@ package org.weasis.launcher; import static java.time.temporal.ChronoUnit.DAYS; +import static org.weasis.pref.ConfigData.F_RESOURCES; +import static org.weasis.pref.ConfigData.P_GOSH_ARGS; +import static org.weasis.pref.ConfigData.P_WEASIS_CODEBASE_LOCAL; +import static org.weasis.pref.ConfigData.P_WEASIS_CODEBASE_URL; +import static org.weasis.pref.ConfigData.P_WEASIS_I18N; +import static org.weasis.pref.ConfigData.P_WEASIS_LOOK; +import static org.weasis.pref.ConfigData.P_WEASIS_PATH; +import static org.weasis.pref.ConfigData.P_WEASIS_RESOURCES_URL; +import static org.weasis.pref.ConfigData.P_WEASIS_RES_DATE; +import static org.weasis.pref.ConfigData.P_WEASIS_SOURCE_ID; +import static org.weasis.pref.ConfigData.P_WEASIS_VERSION; import com.formdev.flatlaf.FlatSystemProperties; import com.formdev.flatlaf.util.SystemInfo; @@ -66,6 +77,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.weasis.launcher.LookAndFeels.ReadableLookAndFeelInfo; +import org.weasis.pref.ConfigData; /** * @author Richard S. Hall @@ -104,56 +116,6 @@ public static String valueOf(int state) { } } - /** Switch for specifying bundle directory. */ - public static final String BUNDLE_DIR_SWITCH = "-b"; // NON-NLS - - /** The property name used to specify whether the launcher should install a shutdown hook. */ - public static final String SHUTDOWN_HOOK_PROP = "felix.shutdown.hook"; - - /** - * The property name used to specify a URL to the configuration property file to be used for the - * created the framework instance. - */ - public static final String CONFIG_PROPERTIES_PROP = "felix.config.properties"; - - /** The default name used for the configuration file. */ - public static final String CONFIG_PROPERTIES_FILE_VALUE = "base.json"; - - /** The property name used to specify a URL to the extended configuration file. */ - public static final String EXTENDED_PROPERTIES_PROP = "felix.extended.config.properties"; - - /** Name of the configuration directory. */ - public static final String CONFIG_DIRECTORY = "conf"; - - public static final String END_LINE = System.lineSeparator(); - public static final String APP_PROPERTY_FILE = "weasis.properties"; - public static final String P_WEASIS_VERSION = "weasis.version"; - public static final String P_WEASIS_PROFILE = "weasis.profile"; - public static final String P_WEASIS_NAME = "weasis.name"; - public static final String P_WEASIS_PATH = "weasis.path"; - public static final String P_WEASIS_RES_DATE = "weasis.resources.date"; - public static final String P_WEASIS_CODEBASE_LOCAL = "weasis.codebase.local"; - public static final String P_WEASIS_SOURCE_ID = "weasis.source.id"; - public static final String P_WEASIS_CODEBASE_URL = "weasis.codebase.url"; - public static final String P_WEASIS_CONFIG_HASH = "weasis.config.hash"; - public static final String P_WEASIS_PREFS_URL = "weasis.pref.url"; - public static final String P_WEASIS_CONFIG_URL = "weasis.config.url"; - public static final String P_WEASIS_USER = "weasis.user"; - public static final String P_WEASIS_SHOW_DISCLAIMER = "weasis.show.disclaimer"; - public static final String P_WEASIS_ACCEPT_DISCLAIMER = "weasis.accept.disclaimer"; - public static final String P_WEASIS_SHOW_RELEASE = "weasis.show.release"; - public static final String P_WEASIS_VERSION_RELEASE = "weasis.version.release"; - public static final String P_WEASIS_I18N = "weasis.i18n"; - public static final String P_OS_NAME = "os.name"; - public static final String P_WEASIS_LOOK = "weasis.theme"; - public static final String P_GOSH_ARGS = "gosh.args"; - public static final String P_WEASIS_CLEAN_CACHE = "weasis.clean.cache"; - public static final String P_HTTP_AUTHORIZATION = "http.authorization"; - public static final String P_NATIVE_LIB_SPEC = "native.library.spec"; - public static final String P_WEASIS_MIN_NATIVE_VERSION = "weasis.min.native.version"; - public static final String P_WEASIS_RESOURCES_URL = "weasis.resources.url"; - public static final String F_RESOURCES = "resources"; // NON-NLS - protected Felix mFelix = null; protected ServiceTracker mTracker = null; protected volatile boolean frameworkLoaded = false; @@ -181,11 +143,11 @@ public final void launch(Type type) throws Exception { WeasisLoader loader = loadProperties(serverProp, configData.getConfigOutput()); WeasisMainFrame mainFrame = loader.getMainFrame(); - String minVersion = System.getProperty(P_WEASIS_MIN_NATIVE_VERSION); + String minVersion = System.getProperty(ConfigData.P_WEASIS_MIN_NATIVE_VERSION); if (Utils.hasText(minVersion)) { EventQueue.invokeAndWait( () -> { - String appName = System.getProperty(P_WEASIS_NAME); + String appName = System.getProperty(ConfigData.P_WEASIS_NAME); int response = JOptionPane.showOptionDialog( mainFrame.getWindow(), @@ -228,7 +190,8 @@ public final void launch(Type type) throws Exception { loader.setFelix(serverProp, mFelix.getBundleContext(), modulesi18n); loader.writeLabel( String.format( - Messages.getString("WeasisLauncher.starting"), System.getProperty(P_WEASIS_NAME))); + Messages.getString("WeasisLauncher.starting"), + System.getProperty(ConfigData.P_WEASIS_NAME))); mTracker = new ServiceTracker( mFelix.getBundleContext(), "org.apache.felix.service.command.CommandProcessor", null); @@ -334,18 +297,19 @@ private static String getGoshArgs(Map serverProp) { } private static void displayStartingAsciiIcon() { - StringBuilder buf = new StringBuilder(); - buf.append(END_LINE); - buf.append("Starting OSGI Bundles..."); // NON-NLS - buf.append(END_LINE); - buf.append(END_LINE); - buf.append(" | | /| / /__ ___ ____ (_)__"); - buf.append(END_LINE); - buf.append(" | |/ |/ / -_) _ `(_- commandList, String goshArgs) { @@ -392,7 +356,7 @@ private static void resetBundleCache() { System.getProperty(P_WEASIS_SOURCE_ID) + ".properties"); // NON-NLS Properties localSourceProp = new Properties(); FileUtil.readProperties(sourceIdProps, localSourceProp); - localSourceProp.setProperty(P_WEASIS_CLEAN_CACHE, Boolean.TRUE.toString()); + localSourceProp.setProperty(ConfigData.P_WEASIS_CLEAN_CACHE, Boolean.TRUE.toString()); FileUtil.storeProperties(sourceIdProps, localSourceProp, null); } @@ -401,8 +365,8 @@ private void showMessage(final WeasisMainFrame mainFrame, Map se String versionNew = serverProp.getOrDefault(P_WEASIS_VERSION, "0.0.0"); // First time launch if (versionOld == null) { - String val = serverProp.get("prev." + P_WEASIS_SHOW_DISCLAIMER); // NON-NLS - String accept = serverProp.get(P_WEASIS_ACCEPT_DISCLAIMER); + String val = serverProp.get("prev." + ConfigData.P_WEASIS_SHOW_DISCLAIMER); // NON-NLS + String accept = serverProp.get(ConfigData.P_WEASIS_ACCEPT_DISCLAIMER); if (Utils.geEmptyToTrue(val) && !Utils.getEmptyToFalse(accept)) { EventQueue.invokeLater( @@ -411,7 +375,7 @@ private void showMessage(final WeasisMainFrame mainFrame, Map se Messages.getString("WeasisLauncher.ok"), Messages.getString("WeasisLauncher.no") }; - String appName = System.getProperty(P_WEASIS_NAME); + String appName = System.getProperty(ConfigData.P_WEASIS_NAME); int response = JOptionPane.showOptionDialog( mainFrame.getWindow(), @@ -427,7 +391,7 @@ private void showMessage(final WeasisMainFrame mainFrame, Map se // Write "false" in weasis.properties. It can be useful when preferences are store // remotely. // The user will accept the disclaimer only once. - System.setProperty(P_WEASIS_ACCEPT_DISCLAIMER, Boolean.TRUE.toString()); + System.setProperty(ConfigData.P_WEASIS_ACCEPT_DISCLAIMER, Boolean.TRUE.toString()); } else { File file = new File( @@ -441,13 +405,13 @@ private void showMessage(final WeasisMainFrame mainFrame, Map se }); } } else if (versionNew != null && !versionNew.equals(versionOld)) { - String val = serverProp.get("prev." + P_WEASIS_SHOW_RELEASE); // NON-NLS + String val = serverProp.get("prev." + ConfigData.P_WEASIS_SHOW_RELEASE); // NON-NLS if (Utils.geEmptyToTrue(val)) { try { Version vOld = getVersion(versionOld); Version vNew = getVersion(versionNew); if (vNew.compareTo(vOld) > 0) { - String lastTag = serverProp.get(P_WEASIS_VERSION_RELEASE); + String lastTag = serverProp.get(ConfigData.P_WEASIS_VERSION_RELEASE); if (lastTag != null) { vOld = getVersion(lastTag); if (vNew.compareTo(vOld) <= 0) { @@ -455,7 +419,7 @@ private void showMessage(final WeasisMainFrame mainFrame, Map se return; } } - System.setProperty(P_WEASIS_VERSION_RELEASE, vNew.toString()); + System.setProperty(ConfigData.P_WEASIS_VERSION_RELEASE, vNew.toString()); } } catch (Exception e2) { LOGGER.error("Cannot read version", e2); @@ -466,7 +430,7 @@ private void showMessage(final WeasisMainFrame mainFrame, Map se message.append( String.format( Messages.getString("WeasisLauncher.change.version"), - System.getProperty(P_WEASIS_NAME), + System.getProperty(ConfigData.P_WEASIS_NAME), versionOld, versionNew)); @@ -683,8 +647,8 @@ private static String getGeneralProperty( public WeasisLoader loadProperties(Map serverProp, StringBuilder conf) { String dir = configData.getProperty(P_WEASIS_PATH); - String profileName = configData.getProperty(P_WEASIS_PROFILE, "default"); // NON-NLS - String user = configData.getProperty(P_WEASIS_USER); + String profileName = configData.getProperty(ConfigData.P_WEASIS_PROFILE, "default"); // NON-NLS + String user = configData.getProperty(ConfigData.P_WEASIS_USER); // If proxy configuration, activate it configData.applyProxy( @@ -708,12 +672,12 @@ public WeasisLoader loadProperties(Map serverProp, StringBuilder serverProp.put("weasis.pref.dir", prefDir.getPath()); Properties currentProps = new Properties(); - FileUtil.readProperties(new File(prefDir, APP_PROPERTY_FILE), currentProps); + FileUtil.readProperties(new File(prefDir, ConfigData.APP_PROPERTY_FILE), currentProps); currentProps .stringPropertyNames() .forEach(key -> serverProp.put("wp.init." + key, currentProps.getProperty(key))); // NON-NLS - String remotePrefURL = configData.getProperty(WeasisLauncher.P_WEASIS_PREFS_URL); + String remotePrefURL = configData.getProperty(ConfigData.P_WEASIS_PREFS_URL); if (Utils.hasText(remotePrefURL)) { String storeLocalSession = "weasis.pref.store.local.session"; String defaultVal = configData.getProperty(storeLocalSession, null); @@ -797,7 +761,7 @@ public WeasisLoader loadProperties(Map serverProp, StringBuilder } String nativeLook; - String sysSpec = System.getProperty(P_NATIVE_LIB_SPEC, "unknown"); // NON-NLS + String sysSpec = System.getProperty(ConfigData.P_NATIVE_LIB_SPEC, "unknown"); // NON-NLS int index = sysSpec.indexOf('-'); if (index > 0) { nativeLook = "weasis.theme." + sysSpec.substring(0, index); // NON-NLS @@ -839,7 +803,8 @@ public WeasisLoader loadProperties(Map serverProp, StringBuilder } else if (SystemInfo.isMacOS) { // Enable screen menu bar - MUST BE initialized before UI components System.setProperty("apple.laf.useScreenMenuBar", "true"); - System.setProperty("apple.awt.application.name", System.getProperty(P_WEASIS_NAME)); + System.setProperty( + "apple.awt.application.name", System.getProperty(ConfigData.P_WEASIS_NAME)); System.setProperty( "apple.awt.application.appearance", lookAndFeelInfo.isDark() ? "NSAppearanceNameDarkAqua" : "NSAppearanceNameAqua"); @@ -877,6 +842,7 @@ public WeasisLoader loadProperties(Map serverProp, StringBuilder look = lookAndFeels.setLookAndFeel(lookAndFeelInfo); try { + mainFrame.setConfigData(configData); // Build a JFrame which will be used later in base.ui module ObjectName objectName2 = new ObjectName("weasis:name=MainWindow"); // NON-NLS mainFrame.setRootPaneContainer(new JFrame()); @@ -903,7 +869,7 @@ public WeasisLoader loadProperties(Map serverProp, StringBuilder serverProp.put("prev." + P_WEASIS_VERSION, versionOld); // NON-NLS } final String versionNew = serverProp.getOrDefault(P_WEASIS_VERSION, "0.0.0"); // NON-NLS - String cleanCacheAfterCrash = localSourceProp.getProperty(P_WEASIS_CLEAN_CACHE); + String cleanCacheAfterCrash = localSourceProp.getProperty(ConfigData.P_WEASIS_CLEAN_CACHE); boolean update = false; // Loads the resource files @@ -969,20 +935,25 @@ public WeasisLoader loadProperties(Map serverProp, StringBuilder } String showDisclaimer = getGeneralProperty( - P_WEASIS_SHOW_DISCLAIMER, + ConfigData.P_WEASIS_SHOW_DISCLAIMER, Boolean.TRUE.toString(), serverProp, currentProps, false, false); if (Utils.hasText(showDisclaimer)) { - serverProp.put("prev." + P_WEASIS_SHOW_DISCLAIMER, showDisclaimer); // NON-NLS + serverProp.put("prev." + ConfigData.P_WEASIS_SHOW_DISCLAIMER, showDisclaimer); // NON-NLS } String showRelease = getGeneralProperty( - P_WEASIS_SHOW_RELEASE, Boolean.TRUE.toString(), serverProp, currentProps, false, false); + ConfigData.P_WEASIS_SHOW_RELEASE, + Boolean.TRUE.toString(), + serverProp, + currentProps, + false, + false); if (Utils.hasText(showRelease)) { - serverProp.put("prev." + P_WEASIS_SHOW_RELEASE, showRelease); // NON-NLS + serverProp.put("prev." + ConfigData.P_WEASIS_SHOW_RELEASE, showRelease); // NON-NLS } // Clean cache if Weasis has crashed during the previous launch @@ -990,7 +961,7 @@ public WeasisLoader loadProperties(Map serverProp, StringBuilder if (Boolean.TRUE.toString().equals(cleanCacheAfterCrash)) { serverProp.put( Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT); - localSourceProp.remove(P_WEASIS_CLEAN_CACHE); + localSourceProp.remove(ConfigData.P_WEASIS_CLEAN_CACHE); update = true; LOGGER.info("Clean plug-in cache because Weasis has crashed during the previous launch"); } @@ -1021,14 +992,14 @@ else if (cleanCache && versionNew != null && !versionNew.equals(versionOld)) { conf.append("\n Current version = "); // NON-NLS conf.append(versionNew); conf.append("\n Application name = "); // NON-NLS - conf.append(configData.getProperty(P_WEASIS_NAME)); + conf.append(configData.getProperty(ConfigData.P_WEASIS_NAME)); conf.append("\n Application Source ID = "); // NON-NLS conf.append(System.getProperty(P_WEASIS_SOURCE_ID)); conf.append("\n Application Profile = "); // NON-NLS conf.append(profileName); conf.append(pevConf); conf.append("\n User = "); // NON-NLS - conf.append(System.getProperty(P_WEASIS_USER, "user")); // NON-NLS + conf.append(System.getProperty(ConfigData.P_WEASIS_USER, "user")); // NON-NLS conf.append("\n User home directory = "); // NON-NLS conf.append(dir); conf.append("\n Resources path = "); // NON-NLS @@ -1045,11 +1016,11 @@ else if (cleanCache && versionNew != null && !versionNew.equals(versionOld)) { conf.append("\n Languages available = "); // NON-NLS conf.append(System.getProperty("weasis.languages", "en")); // NON-NLS conf.append("\n OSGI native specs = "); // NON-NLS - conf.append(System.getProperty(P_NATIVE_LIB_SPEC)); + conf.append(System.getProperty(ConfigData.P_NATIVE_LIB_SPEC)); conf.append("\n HTTP user agent = "); // NON-NLS conf.append(System.getProperty("http.agent")); // NON-NLS conf.append("\n Operating system = "); // NON-NLS - conf.append(System.getProperty(P_OS_NAME)); + conf.append(System.getProperty(ConfigData.P_OS_NAME)); conf.append(' '); conf.append(System.getProperty("os.version")); conf.append(' '); diff --git a/weasis-launcher/src/main/java/org/weasis/launcher/WeasisMainFrame.java b/weasis-launcher/src/main/java/org/weasis/launcher/WeasisMainFrame.java index f9fa7cd1b..ac7f24d44 100755 --- a/weasis-launcher/src/main/java/org/weasis/launcher/WeasisMainFrame.java +++ b/weasis-launcher/src/main/java/org/weasis/launcher/WeasisMainFrame.java @@ -12,10 +12,12 @@ import java.awt.Window; import javax.swing.RootPaneContainer; import javax.swing.SwingUtilities; +import org.weasis.pref.ConfigData; public class WeasisMainFrame implements WeasisMainFrameMBean { private RootPaneContainer rootPaneContainer; + private ConfigData configData; public void setRootPaneContainer(RootPaneContainer rootPaneContainer) { this.rootPaneContainer = rootPaneContainer; @@ -26,6 +28,15 @@ public RootPaneContainer getRootPaneContainer() { return rootPaneContainer; } + @Override + public ConfigData getConfigData() { + return configData; + } + + public void setConfigData(ConfigData configData) { + this.configData = configData; + } + public Window getWindow() { if (rootPaneContainer == null) { return null; diff --git a/weasis-launcher/src/main/java/org/weasis/launcher/WeasisMainFrameMBean.java b/weasis-launcher/src/main/java/org/weasis/launcher/WeasisMainFrameMBean.java index 3b45bbe9c..90d45d3e7 100755 --- a/weasis-launcher/src/main/java/org/weasis/launcher/WeasisMainFrameMBean.java +++ b/weasis-launcher/src/main/java/org/weasis/launcher/WeasisMainFrameMBean.java @@ -10,8 +10,11 @@ package org.weasis.launcher; import javax.swing.RootPaneContainer; +import org.weasis.pref.ConfigData; public interface WeasisMainFrameMBean { RootPaneContainer getRootPaneContainer(); + + ConfigData getConfigData(); } diff --git a/weasis-launcher/src/main/java/org/weasis/pref/AppPreferences.java b/weasis-launcher/src/main/java/org/weasis/pref/AppPreferences.java index 1aa8b0cd0..534aa2465 100644 --- a/weasis-launcher/src/main/java/org/weasis/pref/AppPreferences.java +++ b/weasis-launcher/src/main/java/org/weasis/pref/AppPreferences.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import org.slf4j.LoggerFactory; import org.weasis.core.util.StringUtil; import org.weasis.launcher.FileUtil; @@ -71,21 +72,15 @@ public void readJson(URI uri) { } } - public String getProperty(String key) { - Preference p = get(key); - if (p != null) { - return p.getValue(); - } - return null; + public String getValue(String key) { + return Optional.ofNullable(get(key)).map(Preference::getValue).orElse(null); } - public String getProperty(String key, String defaultVal) { - String val = null; - Preference p = get(key); - if (p != null) { - val = p.getValue(); - } - return Utils.hasText(val) ? val : defaultVal; + public String getValue(String key, String defaultVal) { + return Optional.ofNullable(get(key)) + .map(Preference::getValue) + .filter(Utils::hasText) + .orElse(defaultVal); } public String substVars(String val, String currentKey, Map cycleMap) @@ -99,25 +94,17 @@ public String substVars(String val, String currentKey, Map cycle } int stopDelim = -1; - int startDelim = -1; + int startDelim; do { stopDelim = val.indexOf(DELIM_STOP, stopDelim + 1); if (stopDelim < 0) { return val; } - startDelim = val.indexOf(DELIM_START); + startDelim = val.lastIndexOf(DELIM_START, stopDelim); if (startDelim < 0) { return val; } - while (true) { - int idx = val.indexOf(DELIM_START, startDelim + DELIM_START.length()); - if ((idx < 0) || (idx > stopDelim)) { - break; - } else if (idx < stopDelim) { - startDelim = idx; - } - } } while (startDelim > stopDelim); String variable = val.substring(startDelim + DELIM_START.length(), stopDelim); @@ -126,7 +113,7 @@ public String substVars(String val, String currentKey, Map cycle throw new IllegalArgumentException("recursive variable reference: " + variable); } - String substValue = getProperty(variable); + String substValue = getValue(variable); if (substValue == null) { // Ignore unknown property values. substValue = System.getProperty(variable, ""); diff --git a/weasis-launcher/src/main/java/org/weasis/launcher/ConfigData.java b/weasis-launcher/src/main/java/org/weasis/pref/ConfigData.java similarity index 87% rename from weasis-launcher/src/main/java/org/weasis/launcher/ConfigData.java rename to weasis-launcher/src/main/java/org/weasis/pref/ConfigData.java index c5719d8ac..a5d78a418 100755 --- a/weasis-launcher/src/main/java/org/weasis/launcher/ConfigData.java +++ b/weasis-launcher/src/main/java/org/weasis/pref/ConfigData.java @@ -7,24 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 */ -package org.weasis.launcher; - -import static org.weasis.launcher.WeasisLauncher.CONFIG_DIRECTORY; -import static org.weasis.launcher.WeasisLauncher.CONFIG_PROPERTIES_FILE_VALUE; -import static org.weasis.launcher.WeasisLauncher.CONFIG_PROPERTIES_PROP; -import static org.weasis.launcher.WeasisLauncher.EXTENDED_PROPERTIES_PROP; -import static org.weasis.launcher.WeasisLauncher.P_HTTP_AUTHORIZATION; -import static org.weasis.launcher.WeasisLauncher.P_OS_NAME; -import static org.weasis.launcher.WeasisLauncher.P_WEASIS_CODEBASE_LOCAL; -import static org.weasis.launcher.WeasisLauncher.P_WEASIS_CODEBASE_URL; -import static org.weasis.launcher.WeasisLauncher.P_WEASIS_CONFIG_HASH; -import static org.weasis.launcher.WeasisLauncher.P_WEASIS_CONFIG_URL; -import static org.weasis.launcher.WeasisLauncher.P_WEASIS_NAME; -import static org.weasis.launcher.WeasisLauncher.P_WEASIS_PATH; -import static org.weasis.launcher.WeasisLauncher.P_WEASIS_PROFILE; -import static org.weasis.launcher.WeasisLauncher.P_WEASIS_SOURCE_ID; -import static org.weasis.launcher.WeasisLauncher.P_WEASIS_USER; -import static org.weasis.launcher.WeasisLauncher.P_WEASIS_VERSION; +package org.weasis.pref; import java.io.File; import java.io.FileInputStream; @@ -55,13 +38,56 @@ import org.osgi.framework.Constants; import org.osgi.framework.Version; import org.slf4j.LoggerFactory; +import org.weasis.launcher.FileUtil; +import org.weasis.launcher.Utils; import org.weasis.launcher.WeasisLauncher.Type; -import org.weasis.pref.AppPreferences; -import org.weasis.pref.Preference; public class ConfigData { private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ConfigData.class); + /** Name of the configuration directory. */ + public static final String CONFIG_DIRECTORY = "conf"; + + public static final String APP_PROPERTY_FILE = "weasis.properties"; + public static final String P_WEASIS_VERSION = "weasis.version"; + public static final String P_WEASIS_PROFILE = "weasis.profile"; + public static final String P_WEASIS_NAME = "weasis.name"; + public static final String P_WEASIS_PATH = "weasis.path"; + public static final String P_WEASIS_RES_DATE = "weasis.resources.date"; + public static final String P_WEASIS_CODEBASE_LOCAL = "weasis.codebase.local"; + public static final String P_WEASIS_SOURCE_ID = "weasis.source.id"; + public static final String P_WEASIS_CODEBASE_URL = "weasis.codebase.url"; + public static final String P_WEASIS_CONFIG_HASH = "weasis.config.hash"; + public static final String P_WEASIS_PREFS_URL = "weasis.pref.url"; + public static final String P_WEASIS_CONFIG_URL = "weasis.config.url"; + public static final String P_WEASIS_USER = "weasis.user"; + public static final String P_WEASIS_SHOW_DISCLAIMER = "weasis.show.disclaimer"; + public static final String P_WEASIS_ACCEPT_DISCLAIMER = "weasis.accept.disclaimer"; + public static final String P_WEASIS_SHOW_RELEASE = "weasis.show.release"; + public static final String P_WEASIS_VERSION_RELEASE = "weasis.version.release"; + public static final String P_WEASIS_I18N = "weasis.i18n"; + public static final String P_OS_NAME = "os.name"; + public static final String P_WEASIS_LOOK = "weasis.theme"; + public static final String P_GOSH_ARGS = "gosh.args"; + public static final String P_WEASIS_CLEAN_CACHE = "weasis.clean.cache"; + public static final String P_HTTP_AUTHORIZATION = "http.authorization"; + public static final String P_NATIVE_LIB_SPEC = "native.library.spec"; + public static final String P_WEASIS_MIN_NATIVE_VERSION = "weasis.min.native.version"; + public static final String P_WEASIS_RESOURCES_URL = "weasis.resources.url"; + public static final String F_RESOURCES = "resources"; // NON-NLS + + /** + * The property name used to specify a URL to the configuration property file to be used for the + * created the framework instance. + */ + public static final String CONFIG_PROPERTIES_PROP = "felix.config.properties"; + + /** The default name used for the configuration file. */ + public static final String CONFIG_PROPERTIES_FILE_VALUE = "base.json"; + + /** The property name used to specify a URL to the extended configuration file. */ + public static final String EXTENDED_PROPERTIES_PROP = "felix.extended.config.properties"; + // Params, see // https://nroduit.github.io/en/getting-started/weasis-protocol/#modify-the-launch-parameters public static final String PARAM_CONFIG_URL = "wcfg"; // NON-NLS @@ -76,6 +102,7 @@ public class ConfigData { private final StringBuilder configOutput = new StringBuilder(); private final Map felixProps = new HashMap<>(); + private final AppPreferences preferences = new AppPreferences(); public ConfigData(String[] args) { init(args); @@ -88,7 +115,7 @@ public void init(String[] args) { if (args != null) { for (int i = 0; i < args.length; i++) { - LOGGER.info("Main arg {0} = {1}", Integer.toString(i), args[i]); + LOGGER.info("Main arg {} = {}", i, args[i]); } int index = Utils.getWeasisProtocolIndex(args); @@ -120,7 +147,7 @@ public void init(String[] args) { applyConfigFromArguments(); // Load all the felix properties - AppPreferences preferences = loadConfigProperties(); + loadConfigProperties(); // Set "application config" properties, but has no effect on those already set initWeasisProperties(preferences); @@ -167,13 +194,13 @@ private void initWeasisProperties(AppPreferences preferences) { // current platform setOsgiNativeLibSpecification(); - String profile = preferences.getProperty(P_WEASIS_PROFILE, "default"); + String profile = preferences.getValue(P_WEASIS_PROFILE, "default"); addProperty(P_WEASIS_PROFILE, profile); - String name = preferences.getProperty(P_WEASIS_NAME, "Weasis"); // NON-NLS + String name = preferences.getValue(P_WEASIS_NAME, "Weasis"); // NON-NLS addProperty(P_WEASIS_NAME, name); - String version = preferences.getProperty(P_WEASIS_VERSION, "0.0.0"); + String version = preferences.getValue(P_WEASIS_VERSION, "0.0.0"); addProperty(P_WEASIS_VERSION, version); String codebase = properties.getProperty(P_WEASIS_CODEBASE_URL); @@ -193,7 +220,7 @@ private void initWeasisProperties(AppPreferences preferences) { if (portable != null) { LOGGER.info("Set default relative folders"); String pkey = "weasis.portable.dicom.directory"; - addProperty(pkey, preferences.getProperty(pkey, "dicom,DICOM,IMAGES,images")); // NON-NLS + addProperty(pkey, preferences.getValue(pkey, "dicom,DICOM,IMAGES,images")); // NON-NLS } // Set weasis properties to Java System Properties before variables substitution. @@ -215,7 +242,7 @@ private void filterConfigProperties(AppPreferences preferences) { // Only required for dev purposes (running the app in IDE) String mvnRepo = System.getProperty( - "maven.localRepository", preferences.getProperty("maven.local.repo")); // NON-NLS + "maven.localRepository", preferences.getValue("maven.local.repo")); // NON-NLS if (mvnRepo != null) { System.setProperty("maven.localRepository", Utils.adaptPathToUri(mvnRepo)); } @@ -274,7 +301,7 @@ private void applyConfigFromArguments() { configOutput.append(properties.getProperty(P_WEASIS_CODEBASE_URL)); } - private String applyLocalCodebase() { + private void applyLocalCodebase() { File localCodebase = findLocalCodebase(); String baseURI = localCodebase.toURI().toString(); if (baseURI.endsWith("/")) { @@ -288,7 +315,6 @@ private String applyLocalCodebase() { } catch (Exception e) { LOGGER.error("Apply Codebase", e); } - return baseURI; } private void applyConfigParams(Map> configParams) { @@ -299,9 +325,9 @@ private void applyConfigParams(Map> configParams) { configParams.forEach( (k, v) -> { switch (k) { - case PARAM_CONFIG_URL -> addProperty(P_WEASIS_CONFIG_URL, v.get(0)); - case PARAM_CODEBASE -> addProperty(P_WEASIS_CODEBASE_URL, v.get(0)); - case PARAM_AUTHORIZATION -> addProperty(P_HTTP_AUTHORIZATION, v.get(0)); + case PARAM_CONFIG_URL -> addProperty(P_WEASIS_CONFIG_URL, v.getFirst()); + case PARAM_CODEBASE -> addProperty(P_WEASIS_CODEBASE_URL, v.getFirst()); + case PARAM_AUTHORIZATION -> addProperty(P_HTTP_AUTHORIZATION, v.getFirst()); case PARAM_PROPERTY -> addProperties(v); case PARAM_ARGUMENT -> addArguments(v); default -> throw new IllegalStateException("Unexpected value: " + k); @@ -309,6 +335,10 @@ private void applyConfigParams(Map> configParams) { }); } + public AppPreferences getPreferences() { + return preferences; + } + public List getArguments() { return arguments; } @@ -605,9 +635,9 @@ private Map> readServiceConfigStream(XMLStreamReader xmler) * Reads application config files and compute WEASIS_CONFIG_HASH to check if those had been * updated. */ - public AppPreferences loadConfigProperties() { + public void loadConfigProperties() { URI propURI = getPropertiesURI(CONFIG_PROPERTIES_PROP, CONFIG_PROPERTIES_FILE_VALUE); - AppPreferences preferences = new AppPreferences(); + // Read the properties file if (propURI != null) { configOutput.append("\n Application configuration file = "); // NON-NLS @@ -636,20 +666,16 @@ public AppPreferences loadConfigProperties() { // Build a hash the properties just after reading. It will allow comparing with a new app // instance. properties.put(P_WEASIS_CONFIG_HASH, String.valueOf(preferences.hashCode())); - - return preferences; } private void checkMinimalVersion(AppPreferences preferences) { - String val = preferences.getProperty(WeasisLauncher.P_WEASIS_MIN_NATIVE_VERSION); + String val = preferences.getValue(P_WEASIS_MIN_NATIVE_VERSION); if (Utils.hasText(val) && getProperty(P_WEASIS_CODEBASE_LOCAL) == null) { try { URI propURI = getLocalPropertiesURI(CONFIG_PROPERTIES_FILE_VALUE); AppPreferences localPrefs = new AppPreferences(); localPrefs.readJson(propURI); - Version loc = - new Version( - localPrefs.getProperty(WeasisLauncher.P_WEASIS_VERSION).replaceFirst("-", ".")); + Version loc = new Version(localPrefs.getValue(P_WEASIS_VERSION).replaceFirst("-", ".")); Version min = new Version(val.replaceFirst("-", ".")); if (loc.compareTo(min) < 0) { LOGGER.warn( @@ -658,7 +684,7 @@ private void checkMinimalVersion(AppPreferences preferences) { min); preferences.clear(); preferences.putAll(localPrefs); - System.setProperty(WeasisLauncher.P_WEASIS_MIN_NATIVE_VERSION, val); + System.setProperty(P_WEASIS_MIN_NATIVE_VERSION, val); } } catch (Exception e) { LOGGER.error("Cannot check compatibility with remote package", e); @@ -710,7 +736,7 @@ private static String toHex(int val) { return String.valueOf(ch8); } - static File findLocalCodebase() { + public static File findLocalCodebase() { // Determine where the configuration directory is by figuring // out where weasis-launcher.jar is located on the system class path. String jarLocation = null; @@ -784,7 +810,7 @@ public static void setOsgiNativeLibSpecification() { } else { osArch = osArch.toLowerCase(); } - System.setProperty(WeasisLauncher.P_NATIVE_LIB_SPEC, osName + "-" + osArch); + System.setProperty(P_NATIVE_LIB_SPEC, osName + "-" + osArch); } } } diff --git a/weasis-parent/pom.xml b/weasis-parent/pom.xml index 9c7542276..2c4146f5b 100755 --- a/weasis-parent/pom.xml +++ b/weasis-parent/pom.xml @@ -576,6 +576,7 @@ + org.slf4j slf4j-api @@ -613,6 +614,8 @@ ${flatlaf.version} provided + + com.miglayout miglayout-swing @@ -625,6 +628,7 @@ ${miglayout.version} provided + org.weasis.core weasis-core-img