Permalink
Browse files

[PAXRUNNER-388] - Refactor PlatformImpl to pick up versions from pom

  • Loading branch information...
1 parent 4b32a7a commit 865624d5bf84b0aad5e0ea9d4a0faa15c25685b1 @dpishchukhin dpishchukhin committed Apr 5, 2011
View
48 pax-runner-platform/src/main/java/org/ops4j/pax/runner/platform/internal/PlatformImpl.java
@@ -143,14 +143,6 @@ public void start( final List<SystemFileReference> systemFiles,
final List<LocalSystemFile> localSystemFiles = downloadSystemFiles(
workDir, systemFiles, overwriteBundles || overwriteSystemBundles, downloadFeeback
);
- if ( configuration.keepOriginalUrls() )
- {
- localSystemFiles.addAll(
- downloadSystemFiles(
- workDir, getUrlHandlers(), overwriteBundles || overwriteSystemBundles, downloadFeeback
- )
- );
- }
// download the rest of the bundles
final List<BundleReference> bundlesToInstall = new ArrayList<BundleReference>();
LOGGER.debug( "Download platform bundles" );
@@ -226,46 +218,6 @@ public void start( final List<SystemFileReference> systemFiles,
);
}
- private List<SystemFileReference> getUrlHandlers()
- throws PlatformException
- {
- final List<SystemFileReference> urlHandlers = new ArrayList<SystemFileReference>();
- try
- {
- urlHandlers.add(
- new SystemFileReferenceBean(
- "Pax URL assembly: protocol", new URL( "mvn:org.ops4j.pax.url/pax-url-assembly/1.3.2-RC1" )
- )
- );
- urlHandlers.add(
- new SystemFileReferenceBean(
- "Pax URL cache: protocol", new URL( "mvn:org.ops4j.pax.url/pax-url-cache/1.3.2-RC1" )
- )
- );
- urlHandlers.add(
- new SystemFileReferenceBean(
- "Pax URL mvn: protocol", new URL( "mvn:org.ops4j.pax.url/pax-url-mvn/1.3.2-RC1" ) )
- );
- urlHandlers.add(
- new SystemFileReferenceBean(
- "Pax URL link: protocol", new URL( "mvn:org.ops4j.pax.url/pax-url-link/1.3.2-RC1" ) )
- );
- urlHandlers.add(
- new SystemFileReferenceBean(
- "Pax URL war: protocol", new URL( "mvn:org.ops4j.pax.url/pax-url-war/1.3.2-RC1" ) )
- );
- urlHandlers.add(
- new SystemFileReferenceBean(
- "Pax URL wrap: protocol", new URL( "mvn:org.ops4j.pax.url/pax-url-wrap/1.3.2-RC1" ) )
- );
- }
- catch ( MalformedURLException e )
- {
- throw new PlatformException( "Cannot download url handlers", e );
- }
- return urlHandlers;
- }
-
/**
* Builds the classpath java startup option out of specified system files (prepended/appended), framework jar and
* classpath option.
View
4 pax-runner/src/main/java/org/ops4j/pax/runner/CommandLine.java
@@ -97,6 +97,10 @@
*/
static final String OPTION_PROFILES_GROUPID = "profilesGroupId";
/**
+ * Keep Original URLs option.
+ */
+ static final String OPTION_KEEP_ORIGINAL_URLS = "keepOriginalUrls";
+ /**
* Disable Logos option.
*/
static final String OPTION_NOLOGO = "nologo";
View
73 pax-runner/src/main/java/org/ops4j/pax/runner/Run.java
@@ -19,52 +19,29 @@
*/
package org.ops4j.pax.runner;
-import java.io.File;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.LogLevel;
import org.apache.felix.framework.Logger;
import org.apache.felix.framework.ServiceRegistry;
import org.apache.felix.framework.util.EventDispatcher;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
import org.ops4j.io.FileUtils;
import org.ops4j.lang.NullArgumentException;
-import static org.ops4j.pax.runner.CommandLine.*;
import org.ops4j.pax.runner.commons.Info;
import org.ops4j.pax.runner.osgi.RunnerBundle;
import org.ops4j.pax.runner.osgi.RunnerBundleContext;
import org.ops4j.pax.runner.osgi.RunnerStartLevel;
-import org.ops4j.pax.runner.platform.BundleReference;
-import org.ops4j.pax.runner.platform.BundleReferenceBean;
-import org.ops4j.pax.runner.platform.InProcessJavaRunner;
-import org.ops4j.pax.runner.platform.InitDScriptRunner;
-import org.ops4j.pax.runner.platform.JavaRunner;
-import org.ops4j.pax.runner.platform.Platform;
-import org.ops4j.pax.runner.platform.PlatformException;
-import org.ops4j.pax.runner.platform.ScriptJavaRunner;
-import org.ops4j.pax.runner.platform.SystemFileReference;
-import org.ops4j.pax.runner.platform.SystemFileReferenceBean;
-import org.ops4j.pax.runner.platform.ZipJavaRunner;
-import org.ops4j.pax.scanner.MalformedSpecificationException;
-import org.ops4j.pax.scanner.ProvisionService;
-import org.ops4j.pax.scanner.ScannedBundle;
-import org.ops4j.pax.scanner.ScannerException;
-import org.ops4j.pax.scanner.UnsupportedSchemaException;
+import org.ops4j.pax.runner.platform.*;
+import org.ops4j.pax.scanner.*;
+import org.osgi.framework.*;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
+
+import static org.ops4j.pax.runner.CommandLine.*;
/**
* Main runner class. Does all the work.
@@ -99,6 +76,10 @@
* Working directory configuration property name.
*/
private static final String WORKING_DIRECTORY = "workingDirectory";
+ /**
+ * Handler URLs to support keepOriginalUrls option configuration property name.
+ */
+ private static final String KEEP_ORIGINAL_HANDLER_URLS = "keep.original.handler.urls";
/**
* Creates a new runner.
@@ -709,6 +690,30 @@ private void startPlatform( final Platform platform, final Context context, fina
systemFiles.add( new SystemFileReferenceBean( url, new URL( url ), false ) );
}
}
+ String keepOriginalUrls = context.getOptionResolver().get(CommandLine.OPTION_KEEP_ORIGINAL_URLS);
+ if ( Boolean.valueOf(keepOriginalUrls) )
+ {
+ Configuration configuration = context.getConfiguration();
+ String handlerUrls = configuration.getProperty(KEEP_ORIGINAL_HANDLER_URLS);
+ if ( handlerUrls != null )
+ {
+ String[] urlKeys = handlerUrls.split(",");
+ if ( urlKeys != null )
+ {
+ for ( String key : urlKeys)
+ {
+ NullArgumentException.validateNotEmpty(key, "Handler URL entry");
+ String handlerUrl = configuration.getProperty(key);
+ LOGGER.debug( "Handler URL [" + handlerUrl + "]" );
+ if( handlerUrl == null || handlerUrl.trim().length() == 0 )
+ {
+ throw new ConfigurationException( "Handler URL [" + key + "] is not supported" );
+ }
+ systemFiles.add( new SystemFileReferenceBean(key, new URL( handlerUrl ) ) );
+ }
+ }
+ }
+ }
}
catch( MalformedURLException e )
View
25 pax-runner/src/main/resources/META-INF/runner.properties
@@ -30,6 +30,31 @@ handler.war=org.ops4j.pax.url.war.internal.Activator
# wrap protocol handler
handler.wrap=org.ops4j.pax.url.wrap.internal.Activator
+
+# --------------------------------------------------------------------------------------------------------------------
+# Known handler artifact URLS
+# --------------------------------------------------------------------------------------------------------------------
+# assembly protocol handler URL
+handler.assembly.url=mvn:org.ops4j.pax.url/pax-url-assembly/${dependency.url.version}
+# cache protocol handler URL
+handler.cache.url=mvn:org.ops4j.pax.url/pax-url-cache/${dependency.url.version}
+# classpath protocol handler URL
+handler.classpath.url=mvn:org.ops4j.pax.url/pax-url-mvn/${dependency.url.version}
+# dir protocol handler URL
+handler.dir.url=mvn:org.ops4j.pax.url/pax-url-dir/${dependency.url.version}
+# mvn protocol handler URL
+handler.mvn.url=mvn:org.ops4j.pax.url/pax-url-mvn/${dependency.url.version}
+# link protocol handler URL
+handler.link.url=mvn:org.ops4j.pax.url/pax-url-link/${dependency.url.version}
+# obr protocol handler URL
+handler.obr.url=mvn:org.ops4j.pax.url/pax-url-obr/${dependency.url.version}
+# war protocol handler URL
+handler.war.url=mvn:org.ops4j.pax.url/pax-url-war/${dependency.url.version}
+# wrap protocol handler URL
+handler.wrap.url=mvn:org.ops4j.pax.url/pax-url-wrap/${dependency.url.version}
+# list of handler urls to support keepOriginalUrl oprion
+keep.original.handler.urls=handler.assembly.url,handler.cache.url,handler.dir.url,handler.mvn.url,handler.link.url,handler.obr.url,handler.war.url,handler.wrap.url
+
# --------------------------------------------------------------------------------------------------------------------
# Known scanners
# --------------------------------------------------------------------------------------------------------------------
View
2 pom.xml
@@ -30,7 +30,7 @@
<release-paxrunner-altGitURL>scm:git:ssh://git@github.com/ops4j/org.ops4j.pax.runner.git</release-paxrunner-altGitURL>
<dependency.base.version>1.2.3</dependency.base.version>
<dependency.swissbox.version>1.3.1</dependency.swissbox.version>
- <dependency.url.version>1.3.2-RC1</dependency.url.version>
+ <dependency.url.version>1.3.2-RC2</dependency.url.version>
<dependency.scanner.version>1.1.0</dependency.scanner.version>
</properties>

0 comments on commit 865624d

Please sign in to comment.