You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:15:10 UTC
[sling-maven-launchpad-plugin] 27/49: SLING-1692 - replacing dummy
code for updated() method.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag maven-launchpad-plugin-2.0.10
in repository https://gitbox.apache.org/repos/asf/sling-maven-launchpad-plugin.git
commit c52ad9c822064d4edfcabcef56c02d2d93c5c018
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Tue Aug 24 16:22:40 2010 +0000
SLING-1692 - replacing dummy code for updated() method.
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/maven/maven-launchpad-plugin@988610 13f79535-47bb-0310-9956-ffa450edef68
---
.../AbstractLaunchpadStartingPlugin.java | 34 +++++++++++++++-------
.../apache/sling/maven/projectsupport/RunMojo.java | 9 ++++--
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingPlugin.java b/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingPlugin.java
index f94cb3f..d0346c1 100644
--- a/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingPlugin.java
+++ b/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingPlugin.java
@@ -33,9 +33,9 @@ import org.osgi.framework.BundleException;
/**
* @author justin
- *
+ *
*/
-public abstract class AbstractLaunchpadStartingPlugin extends AbstractBundleListMojo implements Notifiable {
+public abstract class AbstractLaunchpadStartingPlugin extends AbstractBundleListMojo implements Notifiable {
/** Default log level setting if no set on command line (value is "INFO"). */
private static final int DEFAULT_LOG_LEVEL = Logger.LOG_INFO;
@@ -68,7 +68,7 @@ public abstract class AbstractLaunchpadStartingPlugin extends AbstractBundleList
/**
* The definition of the package to be included to provide web support for
* JAR-packaged projects (i.e. pax-web).
- *
+ *
* @parameter
*/
private ArtifactDefinition jarWebSupport;
@@ -169,16 +169,29 @@ public abstract class AbstractLaunchpadStartingPlugin extends AbstractBundleList
sling = null;
}
- public void updated(File tmpFile) {
- // TODO - should anything happen here?
- getLog().info("File updated " + tmpFile.getAbsolutePath());
+ public void updated(File updateFile) {
+ // clear the reference to the framework
+ sling = null;
+
+ if (updateFile != null) {
+ getLog().warn("Maven Launchpad Plugin doesn't support updating the framework bundle.");
+ }
+
+ getLog().info("Restarting Framework and Sling");
+
+ try {
+ executeWithArtifacts();
+ } catch (MojoExecutionException e) {
+ getLog().error("Unable to restart Framework and Sling", e);
+ System.exit(1);
+ }
}
/**
* {@inheritDoc}
*/
@Override
- protected void executeWithArtifacts() throws MojoExecutionException, MojoFailureException {
+ protected void executeWithArtifacts() throws MojoExecutionException {
try {
final Map<String, String> props = new HashMap<String, String>();
@@ -208,8 +221,8 @@ public abstract class AbstractLaunchpadStartingPlugin extends AbstractBundleList
File tmp = null;
try {
tmp = File.createTempFile("sling", "props");
- mavenFileFilter.copyFile(propertiesFile, tmp, true, project, null, true, System
- .getProperty("file.encoding"), mavenSession);
+ mavenFileFilter.copyFile(propertiesFile, tmp, true, project, null, true,
+ System.getProperty("file.encoding"), mavenSession);
Properties loadedProps = PropertyUtils.loadPropertyFile(tmp, null);
for (Object key : loadedProps.keySet()) {
props.put((String) key, (String) loadedProps.get(key));
@@ -233,7 +246,8 @@ public abstract class AbstractLaunchpadStartingPlugin extends AbstractBundleList
}
- protected abstract Sling startSling(ResourceProvider resourceProvider, Map<String, String> props, Logger logger) throws BundleException;
+ protected abstract Sling startSling(ResourceProvider resourceProvider, Map<String, String> props, Logger logger)
+ throws BundleException;
protected void stopSling() {
if (sling != null) {
diff --git a/src/main/java/org/apache/sling/maven/projectsupport/RunMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/RunMojo.java
index 248bd78..a337bf3 100644
--- a/src/main/java/org/apache/sling/maven/projectsupport/RunMojo.java
+++ b/src/main/java/org/apache/sling/maven/projectsupport/RunMojo.java
@@ -62,11 +62,16 @@ public class RunMojo extends AbstractLaunchpadStartingPlugin {
stopSling();
}
};
+
+ private boolean registeredHook = false;
protected Sling startSling(ResourceProvider resourceProvider, final Map<String, String> props, Logger logger)
throws BundleException {
- Runtime.getRuntime().addShutdownHook(shutdown);
-
+ if (!registeredHook) {
+ Runtime.getRuntime().addShutdownHook(shutdown);
+ registeredHook = true;
+ }
+
// creating the instance launches the framework and we are done here
Sling mySling = new Sling(this, logger, resourceProvider, props) {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.