Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-05-02 08:00:05 -0400
committerEike Stepper2018-05-02 08:00:05 -0400
commit337b745af75ab864630044b9dc525096dbd95b51 (patch)
tree1a68bc6a7f5f3222e1ddc7b5087a2b071c2fa3cb
parent52a62ab5e7e7d8aff1e482a32a453fe67ff3bf62 (diff)
downloadcdo-337b745af75ab864630044b9dc525096dbd95b51.tar.gz
cdo-337b745af75ab864630044b9dc525096dbd95b51.tar.xz
cdo-337b745af75ab864630044b9dc525096dbd95b51.zip
[Releng] Add more typed OMPlatform.getProperty() methods
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorOpener.java3
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java3
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/bundle/OM.java15
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/tcp/ssl/SSLUtil.java3
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java50
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/LegacyUtil.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java20
8 files changed, 76 insertions, 22 deletions
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorOpener.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorOpener.java
index cdb935b364..b62de8a51b 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorOpener.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOModelEditorOpener.java
@@ -44,8 +44,7 @@ import org.eclipse.ui.IWorkbenchPart;
*/
public class CDOModelEditorOpener extends CDOEditorOpener.Default
{
- private static final boolean INTERACTIVE_CONFLICT_RESOLUTION = !"false"
- .equalsIgnoreCase(OMPlatform.INSTANCE.getProperty("cdo.interactive.conflict.resolution"));
+ private static final boolean INTERACTIVE_CONFLICT_RESOLUTION = OMPlatform.INSTANCE.isProperty("cdo.interactive.conflict.resolution", true);
public CDOModelEditorOpener()
{
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index c3b0736f6c..c206bb2220 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -64,7 +64,7 @@ public final class DBUtil
/**
* @since 4.2
*/
- public static final int MAX_BATCH_SIZE = Integer.parseInt(OMPlatform.INSTANCE.getProperty("org.eclipse.net4j.db.MAX_BATCH_SIZE", "2000"));
+ public static final int MAX_BATCH_SIZE = OMPlatform.INSTANCE.getProperty("org.eclipse.net4j.db.MAX_BATCH_SIZE", 2000);
/**
* A system property to enable noisy close, i.e. exception catch in close methods are thrown as {@link DBException} exception.
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
index 9247b31957..05181a3c27 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
@@ -38,8 +38,7 @@ import java.util.LinkedList;
*/
public final class DBDatabase extends SetContainer<IDBConnection> implements IDBDatabase
{
- private static final long TIMEOUT_SCHEMA_ACCESS = Long
- .parseLong(OMPlatform.INSTANCE.getProperty("org.eclipse.net4j.internal.db.DBDatabase.TIMEOUT_SCHEMA_ACCESS", "15000"));
+ private static final long TIMEOUT_SCHEMA_ACCESS = OMPlatform.INSTANCE.getProperty("org.eclipse.net4j.internal.db.DBDatabase.TIMEOUT_SCHEMA_ACCESS", 15000L);
private static final boolean DEBUG_SCHEMA_ACCESS = OMPlatform.INSTANCE.isProperty("org.eclipse.net4j.internal.db.DBDatabase.DEBUG_SCHEMA_ACCESS");
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/bundle/OM.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/bundle/OM.java
index 930d1d0083..3a7d16bd5c 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/bundle/OM.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/bundle/OM.java
@@ -45,20 +45,7 @@ public abstract class OM
public static int getDefaultPort()
{
- try
- {
- String property = BUNDLE.getPlatform().getProperty(DEFAULT_PORT_PROPERTY);
- if (property != null)
- {
- return Integer.valueOf(property);
- }
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
-
- return DEFAULT_PORT;
+ return BUNDLE.getPlatform().getProperty(DEFAULT_PORT_PROPERTY, DEFAULT_PORT);
}
/**
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/tcp/ssl/SSLUtil.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/tcp/ssl/SSLUtil.java
index 9013cee03e..98487ea677 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/tcp/ssl/SSLUtil.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/tcp/ssl/SSLUtil.java
@@ -187,8 +187,7 @@ public class SSLUtil
KeyManager[] keyManagers = null;
TrustManager[] trustManagers = null;
- String checkValidity = OMPlatform.INSTANCE.getProperty(SSLProperties.CHECK_VALIDITY_CERTIFICATE);
- boolean checkValidtyStatus = checkValidity == null || Boolean.valueOf(checkValidity);
+ boolean checkValidtyStatus = OMPlatform.INSTANCE.isProperty(SSLProperties.CHECK_VALIDITY_CERTIFICATE, true);
if (client)
{
// Initial key material(private key) for the client.
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java
index df23464be6..8e531c5f6b 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java
@@ -340,6 +340,56 @@ public abstract class AbstractPlatform implements OMPlatform
return System.getProperty(key, defaultValue);
}
+ public int getProperty(String key, int defaultValue)
+ {
+ String property = getProperty(key);
+ if (property == null)
+ {
+ return defaultValue;
+ }
+
+ return Integer.parseInt(property);
+ }
+
+ public long getProperty(String key, long defaultValue)
+ {
+ String property = getProperty(key);
+ if (property == null)
+ {
+ return defaultValue;
+ }
+
+ return Long.parseLong(property);
+ }
+
+ public <T extends Enum<T>> T getProperty(String key, Class<T> enumType)
+ {
+ String property = getProperty(key);
+ if (property != null)
+ {
+ for (T enumValue : enumType.getEnumConstants())
+ {
+ if (enumValue.name().equalsIgnoreCase(property))
+ {
+ return enumValue;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public <T extends Enum<T>> T getProperty(String key, T defaultValue)
+ {
+ T result = getProperty(key, defaultValue.getDeclaringClass());
+ if (result != null)
+ {
+ return result;
+ }
+
+ return defaultValue;
+ }
+
public boolean isProperty(String key)
{
return isProperty(key, false);
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/LegacyUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/LegacyUtil.java
index 503e0f68ef..3ca763d675 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/LegacyUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/LegacyUtil.java
@@ -35,7 +35,7 @@ public final class LegacyUtil
{
if (commandLineArgs == UNINITIALIZED)
{
- throw new IllegalStateException("Command line argumentshave not been set");
+ throw new IllegalStateException("Command line arguments have not been set");
}
return commandLineArgs;
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java
index b720b762b2..d5e3dde43d 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java
@@ -86,6 +86,26 @@ public interface OMPlatform
public String getProperty(String key, String defaultValue);
/**
+ * @since 3.8
+ */
+ public int getProperty(String key, int defaultValue);
+
+ /**
+ * @since 3.8
+ */
+ public long getProperty(String key, long defaultValue);
+
+ /**
+ * @since 3.8
+ */
+ public <T extends Enum<T>> T getProperty(String key, Class<T> enumType);
+
+ /**
+ * @since 3.8
+ */
+ public <T extends Enum<T>> T getProperty(String key, T defaultValue);
+
+ /**
* @since 3.7
*/
public boolean isProperty(String key);

Back to the top