Skip to content

Commit

Permalink
knapsack: export shell port as a system property.
Browse files Browse the repository at this point in the history
  • Loading branch information
kgilmer committed Aug 2, 2011
1 parent 51e714c commit 8fb8715
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion org/knapsack/Bootstrap.java
Expand Up @@ -92,6 +92,7 @@ public static void main(String[] args) {
port = PORT_START + r.nextInt(MAX_PORT_RANGE);
createKnapsackScripts(baseDirectory, port, config);
}
System.setProperty(Config.SYSTEM_PROPERTY_KEY_SHELL_PORT, Integer.toString(port));

// Create activators that will start
List<BundleActivator> activators = new ArrayList<BundleActivator>();
Expand All @@ -103,7 +104,6 @@ public static void main(String[] args) {
activators.add(new ConfigurationManager());

// Create an internal logger that will be used for log output before LogService takes over.

activators.add(new org.knapsack.Activator(config, logger, port));

config.put(FELIX_LOGGER_INSTANCE, logger);
Expand Down Expand Up @@ -134,6 +134,9 @@ public void run() {
}
}

/**
* @return root directory that this instance of knapsack runs in.
*/
private static File getBaseDirectory() {
if (System.getProperty(Config.CONFIG_KEY_ROOT_DIR) != null)
return new File(System.getProperty(Config.CONFIG_KEY_ROOT_DIR));
Expand Down Expand Up @@ -174,6 +177,15 @@ private static void createKnapsackLayout(File baseDirectory, Logger logger) thro
FSHelper.validateFile(configAdminDir, true, true, false, true);
}

/**
* Create the transient script symlinks used to access the knapsack shell from the native environment.
*
* @param baseDirectory
* @param port
* @param config
* @throws IOException
* @throws URISyntaxException
*/
private static void createKnapsackScripts(File baseDirectory, int port, Config config) throws IOException, URISyntaxException {
scriptDir = new File(baseDirectory, Config.SCRIPT_DIRECTORY_NAME);
FSHelper.validateFile(scriptDir, true, true, false, true);
Expand Down
5 changes: 5 additions & 0 deletions org/knapsack/Config.java
Expand Up @@ -93,6 +93,11 @@ public class Config extends Properties {

public static final String CONFIG_KEY_SHELL_COMMAND = "org.knapsack.shell.command";

/**
* Port that the shell is listening on for commands, or -1 if shell is disabled.
*/
public static final String SYSTEM_PROPERTY_KEY_SHELL_PORT = "org.knapsack.shell.port";

/**
* Base directory where knapsack instance is running.
*/
Expand Down

0 comments on commit 8fb8715

Please sign in to comment.