Skip to content
Snippets Groups Projects
Commit f36b851b authored by felmer's avatar felmer
Browse files

SP-534, BIS-139: DssPropertyParametersUtil.main() moved to new class AutoSymlink.

SVN: 28541
parent 4ea30bb6
No related branches found
No related tags found
No related merge requests found
#!/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
/*
* 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();
}
}
}
......@@ -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();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment