From f36b851b0d35d1e7e2782e330bec23b01bddae34 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Wed, 6 Mar 2013 15:13:22 +0000 Subject: [PATCH] SP-534, BIS-139: DssPropertyParametersUtil.main() moved to new class AutoSymlink. SVN: 28541 --- datastore_server/dist/autosymlink.sh | 2 +- .../dss/generic/shared/utils/AutoSymlink.java | 85 +++++++++++++++++++ .../utils/DssPropertyParametersUtil.java | 52 +----------- 3 files changed, 87 insertions(+), 52 deletions(-) create mode 100644 datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/AutoSymlink.java diff --git a/datastore_server/dist/autosymlink.sh b/datastore_server/dist/autosymlink.sh index e6d90822411..69deef338c2 100755 --- a/datastore_server/dist/autosymlink.sh +++ b/datastore_server/dist/autosymlink.sh @@ -1,6 +1,6 @@ #!/bin/bash pushd . > /dev/null cd `dirname $0` -java -cp "lib/datastore_server.jar:lib/*" ch.systemsx.cisd.openbis.dss.generic.shared.utils.DssPropertyParametersUtil 2>&1 |grep -v log4j +java -cp "lib/datastore_server.jar:lib/*" ch.systemsx.cisd.openbis.dss.generic.shared.utils.AutoSymlink 2>&1 |grep -v log4j popd > /dev/null diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/AutoSymlink.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/AutoSymlink.java new file mode 100644 index 00000000000..3182379dbac --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/AutoSymlink.java @@ -0,0 +1,85 @@ +/* + * Copyright 2013 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.dss.generic.shared.utils; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +import ch.systemsx.cisd.base.unix.Unix; +import ch.systemsx.cisd.common.properties.ExtendedProperties; +import ch.systemsx.cisd.openbis.generic.shared.coreplugin.CorePluginScanner.ScannerType; +import ch.systemsx.cisd.openbis.generic.shared.coreplugin.CorePluginsInjector; +import ch.systemsx.cisd.openbis.generic.shared.coreplugin.CorePluginsUtils; + +/** + * Helper application which creates symbolic links for JAR files in DSS core plugins in folder lib. + * + * @author Franz-Josef Elmer + */ +public class AutoSymlink +{ + + public static void main(String[] args) + { + ExtendedProperties properties = + DssPropertyParametersUtil + .loadProperties(DssPropertyParametersUtil.SERVICE_PROPERTIES_FILE); + CorePluginsUtils.addCorePluginsProperties(properties, ScannerType.DSS); + ExtendedProperties serviceProperties = + DssPropertyParametersUtil.extendProperties(properties); + CorePluginsInjector injector = + new CorePluginsInjector(ScannerType.DSS, DssPluginType.values()); + Map<String, File> pluginFolders = + injector.injectCorePlugins(serviceProperties); + + try + { + File libDir = new File("lib"); + for (File link : libDir.listFiles()) + { + if (link.getName().startsWith("autolink-")) + { + link.delete(); + } + } + + for (String key : pluginFolders.keySet()) + { + File pluginLibFolder = new File(pluginFolders.get(key).getCanonicalPath() + "/lib"); + if (pluginLibFolder.exists()) + { + for (File jar : pluginLibFolder.listFiles()) + { + if (jar.isFile() && jar.getName().endsWith(".jar")) + { + String link = + libDir.getAbsolutePath() + "/autolink-" + key + "-" + + jar.getName(); + Unix.createSymbolicLink(jar.getAbsolutePath(), link); + } + } + } + + } + } catch (IOException ex) + { + ex.printStackTrace(); + } + } + +} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/DssPropertyParametersUtil.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/DssPropertyParametersUtil.java index 4834bfe7ca6..c01e4cb97df 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/DssPropertyParametersUtil.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/DssPropertyParametersUtil.java @@ -17,7 +17,6 @@ package ch.systemsx.cisd.openbis.dss.generic.shared.utils; import java.io.File; -import java.io.IOException; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; @@ -25,7 +24,6 @@ import java.util.Set; import ch.ethz.cisd.hotdeploy.PluginContainer; import ch.rinn.restrictions.Private; -import ch.systemsx.cisd.base.unix.Unix; import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; import ch.systemsx.cisd.common.filesystem.FileOperations; import ch.systemsx.cisd.common.filesystem.FileUtilities; @@ -133,7 +131,7 @@ public class DssPropertyParametersUtil return extendProperties(PropertyIOUtils.loadProperties(filePath)); } - private static ExtendedProperties extendProperties(Properties properties) + static ExtendedProperties extendProperties(Properties properties) { Properties systemProperties = System.getProperties(); ExtendedProperties dssSystemProperties = @@ -268,52 +266,4 @@ public class DssPropertyParametersUtil ConfigurationFailureException e = new ConfigurationFailureException(template.createText()); return e; } - - public static void main(String[] args) - { - ExtendedProperties properties = - DssPropertyParametersUtil - .loadProperties(DssPropertyParametersUtil.SERVICE_PROPERTIES_FILE); - CorePluginsUtils.addCorePluginsProperties(properties, ScannerType.DSS); - ExtendedProperties serviceProperties = - DssPropertyParametersUtil.extendProperties(properties); - CorePluginsInjector injector = - new CorePluginsInjector(ScannerType.DSS, DssPluginType.values()); - Map<String, File> pluginFolders = - injector.injectCorePlugins(serviceProperties); - - try - { - File libDir = new File("lib"); - for (File link : libDir.listFiles()) - { - if (link.getName().startsWith("autolink-")) - { - link.delete(); - } - } - - for (String key : pluginFolders.keySet()) - { - File pluginLibFolder = new File(pluginFolders.get(key).getCanonicalPath() + "/lib"); - if (pluginLibFolder.exists()) - { - for (File jar : pluginLibFolder.listFiles()) - { - if (jar.isFile() && jar.getName().endsWith(".jar")) - { - String link = - libDir.getAbsolutePath() + "/autolink-" + key + "-" - + jar.getName(); - Unix.createSymbolicLink(jar.getAbsolutePath(), link); - } - } - } - - } - } catch (IOException ex) - { - ex.printStackTrace(); - } - } } -- GitLab