Skip to content

Commit

Permalink
[PAXRUNNER-388] - Refactor PlatformImpl to pick up versions from pom
Browse files Browse the repository at this point in the history
  • Loading branch information
dpishchukhin committed Apr 5, 2011
1 parent 4b32a7a commit 865624d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 83 deletions.
Expand Up @@ -143,14 +143,6 @@ public void start( final List<SystemFileReference> systemFiles,
final List<LocalSystemFile> localSystemFiles = downloadSystemFiles( final List<LocalSystemFile> localSystemFiles = downloadSystemFiles(
workDir, systemFiles, overwriteBundles || overwriteSystemBundles, downloadFeeback workDir, systemFiles, overwriteBundles || overwriteSystemBundles, downloadFeeback
); );
if ( configuration.keepOriginalUrls() )
{
localSystemFiles.addAll(
downloadSystemFiles(
workDir, getUrlHandlers(), overwriteBundles || overwriteSystemBundles, downloadFeeback
)
);
}
// download the rest of the bundles // download the rest of the bundles
final List<BundleReference> bundlesToInstall = new ArrayList<BundleReference>(); final List<BundleReference> bundlesToInstall = new ArrayList<BundleReference>();
LOGGER.debug( "Download platform bundles" ); LOGGER.debug( "Download platform bundles" );
Expand Down Expand Up @@ -226,46 +218,6 @@ workDir, getUrlHandlers(), overwriteBundles || overwriteSystemBundles, downloadF
); );
} }


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 * Builds the classpath java startup option out of specified system files (prepended/appended), framework jar and
* classpath option. * classpath option.
Expand Down
Expand Up @@ -96,6 +96,10 @@ public interface CommandLine
* Profiles group id. * Profiles group id.
*/ */
static final String OPTION_PROFILES_GROUPID = "profilesGroupId"; static final String OPTION_PROFILES_GROUPID = "profilesGroupId";
/**
* Keep Original URLs option.
*/
static final String OPTION_KEEP_ORIGINAL_URLS = "keepOriginalUrls";
/** /**
* Disable Logos option. * Disable Logos option.
*/ */
Expand Down
73 changes: 39 additions & 34 deletions pax-runner/src/main/java/org/ops4j/pax/runner/Run.java
Expand Up @@ -19,52 +19,29 @@
*/ */
package org.ops4j.pax.runner; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.LogLevel; import org.apache.commons.logging.LogLevel;
import org.apache.felix.framework.Logger; import org.apache.felix.framework.Logger;
import org.apache.felix.framework.ServiceRegistry; import org.apache.felix.framework.ServiceRegistry;
import org.apache.felix.framework.util.EventDispatcher; 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.io.FileUtils;
import org.ops4j.lang.NullArgumentException; import org.ops4j.lang.NullArgumentException;
import static org.ops4j.pax.runner.CommandLine.*;
import org.ops4j.pax.runner.commons.Info; import org.ops4j.pax.runner.commons.Info;
import org.ops4j.pax.runner.osgi.RunnerBundle; import org.ops4j.pax.runner.osgi.RunnerBundle;
import org.ops4j.pax.runner.osgi.RunnerBundleContext; import org.ops4j.pax.runner.osgi.RunnerBundleContext;
import org.ops4j.pax.runner.osgi.RunnerStartLevel; import org.ops4j.pax.runner.osgi.RunnerStartLevel;
import org.ops4j.pax.runner.platform.BundleReference; import org.ops4j.pax.runner.platform.*;
import org.ops4j.pax.runner.platform.BundleReferenceBean; import org.ops4j.pax.scanner.*;
import org.ops4j.pax.runner.platform.InProcessJavaRunner; import org.osgi.framework.*;
import org.ops4j.pax.runner.platform.InitDScriptRunner;
import org.ops4j.pax.runner.platform.JavaRunner; import java.io.File;
import org.ops4j.pax.runner.platform.Platform; import java.io.InputStream;
import org.ops4j.pax.runner.platform.PlatformException; import java.net.MalformedURLException;
import org.ops4j.pax.runner.platform.ScriptJavaRunner; import java.net.URL;
import org.ops4j.pax.runner.platform.SystemFileReference; import java.util.*;
import org.ops4j.pax.runner.platform.SystemFileReferenceBean;
import org.ops4j.pax.runner.platform.ZipJavaRunner; import static org.ops4j.pax.runner.CommandLine.*;
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;


/** /**
* Main runner class. Does all the work. * Main runner class. Does all the work.
Expand Down Expand Up @@ -99,6 +76,10 @@ public class Run
* Working directory configuration property name. * Working directory configuration property name.
*/ */
private static final String WORKING_DIRECTORY = "workingDirectory"; 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. * Creates a new runner.
Expand Down Expand Up @@ -709,6 +690,30 @@ List<SystemFileReference> determineSystemFiles( final Context context )
systemFiles.add( new SystemFileReferenceBean( url, new URL( url ), false ) ); 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 ) catch( MalformedURLException e )
Expand Down
25 changes: 25 additions & 0 deletions pax-runner/src/main/resources/META-INF/runner.properties
Expand Up @@ -30,6 +30,31 @@ handler.war=org.ops4j.pax.url.war.internal.Activator
# wrap protocol handler # wrap protocol handler
handler.wrap=org.ops4j.pax.url.wrap.internal.Activator 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 # Known scanners
# -------------------------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -30,7 +30,7 @@
<release-paxrunner-altGitURL>scm:git:ssh://git@github.com/ops4j/org.ops4j.pax.runner.git</release-paxrunner-altGitURL> <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.base.version>1.2.3</dependency.base.version>
<dependency.swissbox.version>1.3.1</dependency.swissbox.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> <dependency.scanner.version>1.1.0</dependency.scanner.version>
</properties> </properties>


Expand Down

0 comments on commit 865624d

Please sign in to comment.