Author: justin Date: Tue Aug 24 16:22:40 2010 New Revision: 988610 URL: http://svn.apache.org/viewvc?rev=988610&view=rev Log: SLING-1692 - replacing dummy code for updated() method.
Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingPlugin.java sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/RunMojo.java Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingPlugin.java URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingPlugin.java?rev=988610&r1=988609&r2=988610&view=diff ============================================================================== --- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingPlugin.java (original) +++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingPlugin.java Tue Aug 24 16:22:40 2010 @@ -33,9 +33,9 @@ import org.osgi.framework.BundleExceptio /** * @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 AbstractLaunchpadS /** * 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 AbstractLaunchpadS 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 AbstractLaunchpadS 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 AbstractLaunchpadS } - 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) { Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/RunMojo.java URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/RunMojo.java?rev=988610&r1=988609&r2=988610&view=diff ============================================================================== --- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/RunMojo.java (original) +++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/RunMojo.java Tue Aug 24 16:22:40 2010 @@ -62,11 +62,16 @@ public class RunMojo extends AbstractLau 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) {