Author: cziegeler
Date: Tue Dec 29 14:16:48 2009
New Revision: 894395
URL: http://svn.apache.org/viewvc?rev=894395&view=rev
Log:
Just code cleanup - no functional changes.
Modified:
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/BootstrapCommandFile.java
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/UninstallBundleCommand.java
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/Loader.java
Modified:
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/BootstrapCommandFile.java
URL:
http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/BootstrapCommandFile.java?rev=894395&r1=894394&r2=894395&view=diff
==============================================================================
---
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/BootstrapCommandFile.java
(original)
+++
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/BootstrapCommandFile.java
Tue Dec 29 14:16:48 2009
@@ -34,24 +34,24 @@
public class BootstrapCommandFile {
/** Name of file used to store our execution timestamp */
public static final String DATA_FILENAME =
BootstrapCommandFile.class.getSimpleName() + "_timestamp.txt";
-
+
/** Prefix for comments in command files */
public static final String COMMENT_PREFIX = "#";
-
+
private final File commandFile;
private final Logger logger;
-
+
private static final List<Command> commandPrototypes = new
ArrayList<Command>();
static {
commandPrototypes.add(new UninstallBundleCommand());
}
-
+
/** Will load our commands from specified file, if found */
public BootstrapCommandFile(Logger logger, File cmdFile) {
this.logger = logger;
this.commandFile = cmdFile;
}
-
+
/** True if we have a command file that needs to be executed, based on its
* file timestamp and stored timstamp
*/
@@ -66,21 +66,21 @@
logger.log(Logger.LOG_INFO, "IOException reading timestamp",
ioe);
}
if(cmdTs > lastExecution) {
- logger.log(Logger.LOG_INFO,
- "Command file timestamp > stored timestamp, need to
execute commands ("
+ logger.log(Logger.LOG_INFO,
+ "Command file timestamp > stored timestamp, need to
execute commands ("
+ commandFile.getAbsolutePath() + ")");
result = true;
}
}
if(!result) {
- logger.log(Logger.LOG_INFO,
- "Command file absent or older than last execution
timestamp, nothing to execute ("
+ logger.log(Logger.LOG_INFO,
+ "Command file absent or older than last execution
timestamp, nothing to execute ("
+ commandFile.getAbsolutePath() + ")");
}
return result;
}
-
- /** Execute commands if needed, and store execution timestamp
+
+ /** Execute commands if needed, and store execution timestamp
* @return number of commands executed */
public int execute(BundleContext ctx) throws IOException {
int count = 0;
@@ -107,7 +107,7 @@
}
}
}
-
+
try {
storeTimestamp(ctx);
} catch(IOException ioe) {
@@ -116,7 +116,7 @@
}
return count;
}
-
+
/** Parse commands from supplied input stream.
* Does not close the stream */
List<Command> parse(InputStream is) throws IOException {
@@ -133,11 +133,10 @@
break;
}
}
- if(toAdd == null) {
+ if (toAdd == null) {
throw new Command.ParseException("Invalid command '" +
line + "'");
- } else {
- result.add(toAdd);
}
+ result.add(toAdd);
}
}
return result;
@@ -147,7 +146,7 @@
private File getTimestampFile(BundleContext ctx) {
return ctx.getDataFile(DATA_FILENAME);
}
-
+
/** Return our stored timestamp */
private long loadTimestamp(BundleContext ctx) throws IOException {
long result = 0;
@@ -169,7 +168,7 @@
}
return result;
}
-
+
private void storeTimestamp(BundleContext ctx) throws IOException {
final File f = getTimestampFile(ctx);
FileOutputStream fos = null;
Modified:
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/UninstallBundleCommand.java
URL:
http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/UninstallBundleCommand.java?rev=894395&r1=894394&r2=894395&view=diff
==============================================================================
---
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/UninstallBundleCommand.java
(original)
+++
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/UninstallBundleCommand.java
Tue Dec 29 14:16:48 2009
@@ -23,11 +23,11 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-/** A Command that uninstalls a bundle, see
+/** A Command that uninstalls a bundle, see
* {...@link UninstallBundleCommandTest} for examples
*/
class UninstallBundleCommand implements Command {
-
+
public static String CMD_PREFIX = "uninstall ";
private final String bundleSymbolicName;
private final VersionRange versionRange;
@@ -37,28 +37,28 @@
bundleSymbolicName = null;
versionRange = null;
}
-
+
/** Used to create an actual command */
private UninstallBundleCommand(String bundleSymbolicName, String
versionRangeStr) {
this.bundleSymbolicName = bundleSymbolicName;
-
+
// If versionRangeStr is not a range, make it strict
if(!versionRangeStr.contains(",")) {
versionRangeStr = "[" + versionRangeStr + "," + versionRangeStr +
"]";
}
this.versionRange = VersionRange.parse(versionRangeStr);
}
-
+
public void execute(Logger logger, BundleContext ctx) throws Exception {
// Uninstall all instances of our bundle within our version range
for(Bundle b : ctx.getBundles()) {
if(b.getSymbolicName().equals(bundleSymbolicName)) {
if(versionRange.isInRange(b.getVersion())) {
- logger.log(Logger.LOG_INFO,
+ logger.log(Logger.LOG_INFO,
this + ": uninstalling bundle version " +
b.getVersion());
b.uninstall();
} else {
- logger.log(Logger.LOG_INFO,
+ logger.log(Logger.LOG_INFO,
this + ": bundle version (" + b.getVersion()+ "
not in range, ignored");
}
}
@@ -70,13 +70,12 @@
final String [] s = commandLine.split(" ");
if(s.length == 3) {
return new UninstallBundleCommand(s[1].trim(), s[2].trim());
- } else {
- throw new Command.ParseException("Syntax error: '" +
commandLine + "'");
}
+ throw new Command.ParseException("Syntax error: '" + commandLine +
"'");
}
return null;
}
-
+
@Override
public String toString() {
return getClass().getSimpleName() + " " + bundleSymbolicName + " " +
versionRange;
Modified:
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/Loader.java
URL:
http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/Loader.java?rev=894395&r1=894394&r2=894395&view=diff
==============================================================================
---
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/Loader.java
(original)
+++
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/Loader.java
Tue Dec 29 14:16:48 2009
@@ -76,10 +76,6 @@
* @param launcherClassName The fully qualified name of a class
implementing
* the Launcher interface. This class must have a public
* constructor taking no arguments.
- * @param slingHome The value to be used as ${slingHome}. This may be null
- * in which case the sling folder in the current working
- * directory is assumed. If this name is empty, the current
- * working directory is assumed to be used as ${slingHome}.
* @return the Launcher instance loaded from the newly created classloader
* @throws NullPointerException if launcherClassName is null
* @throws IllegalArgumentException if the launcherClassName cannot be
@@ -127,8 +123,6 @@
* <p>
* This method must be called when the notifier is called.
*
- * @param slingHome The home directory of Sling. This is used to ensure the
- * launcher jar file is not open anymore (as much as possible).
*/
public void cleanupVM() {