Author: bdelacretaz
Date: Wed Aug 20 10:18:11 2014
New Revision: 1619066
URL: http://svn.apache.org/r1619066
Log:
exit.iftrue command added for warmup runs
Added:
sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/Exit.java
Modified:
sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartFileProcessor.java
Modified:
sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartFileProcessor.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartFileProcessor.java?rev=1619066&r1=1619065&r2=1619066&view=diff
==============================================================================
---
sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartFileProcessor.java
(original)
+++
sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartFileProcessor.java
Wed Aug 20 10:18:11 2014
@@ -32,6 +32,7 @@ import org.apache.sling.crankstart.api.C
import org.apache.sling.crankstart.api.CrankstartException;
import org.apache.sling.crankstart.core.commands.Configure;
import org.apache.sling.crankstart.core.commands.Defaults;
+import org.apache.sling.crankstart.core.commands.Exit;
import org.apache.sling.crankstart.core.commands.InstallBundle;
import org.apache.sling.crankstart.core.commands.Log;
import org.apache.sling.crankstart.core.commands.NullCommand;
@@ -65,6 +66,7 @@ public class CrankstartFileProcessor imp
builtinCommands.add(new StartFramework());
builtinCommands.add(new Configure());
builtinCommands.add(new Defaults());
+ builtinCommands.add(new Exit());
// Need a null "classpath" command as our launcher uses it
// outside of the usual command mechanism - it shouldn't cause
Added:
sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/Exit.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/Exit.java?rev=1619066&view=auto
==============================================================================
---
sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/Exit.java
(added)
+++
sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/Exit.java
Wed Aug 20 10:18:11 2014
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.sling.crankstart.core.commands;
+
+import org.apache.sling.crankstart.api.CrankstartCommand;
+import org.apache.sling.crankstart.api.CrankstartCommandLine;
+import org.apache.sling.crankstart.api.CrankstartContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** CrankstartCommand that exits if its qualifier is true.
+ * Used for warmup runs where we just want to create the
+ * initial Sling state.
+ */
+public class Exit implements CrankstartCommand {
+ public static final String I_EXIT = "exit.iftrue";
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Override
+ public boolean appliesTo(CrankstartCommandLine commandLine) {
+ return I_EXIT.equals(commandLine.getVerb());
+ }
+
+ public String getDescription() {
+ return I_EXIT + ": exit if the command qualifier is 'true'";
+ }
+
+ @Override
+ public void execute(CrankstartContext crankstartContext,
CrankstartCommandLine commandLine) throws Exception {
+ if(Boolean.valueOf(commandLine.getQualifier())) {
+ log.info("Qualifier is true, stopping the OSGi framework");
+ crankstartContext.getOsgiFramework().stop();
+ }
+ }
+}