Class ObrURLStreamHandlerService
- java.lang.Object
-
- java.net.URLStreamHandler
-
- org.osgi.service.url.AbstractURLStreamHandlerService
-
- org.apache.felix.bundlerepository.impl.ObrURLStreamHandlerService
-
- All Implemented Interfaces:
org.osgi.service.url.URLStreamHandlerService
public class ObrURLStreamHandlerService extends org.osgi.service.url.AbstractURLStreamHandlerService
SimpleURLStreamHandler
which is able to handle obr urls. The urls must be conform the following schema: obr:/// Example: obr://org.apache.felix.javax.servlet/1240305961998 Update to the bundle is done
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ObrURLStreamHandlerService.NewestSelectionStrategy
Strategy returning the newest entry.private static class
ObrURLStreamHandlerService.ResourceSelectionStrategy
Abstract class for Resource Selection Strategies(package private) static class
ObrURLStreamHandlerService.SameSelectionStrategy
Strategy returning the current version.
-
Field Summary
Fields Modifier and Type Field Description private org.osgi.framework.BundleContext
m_bundleContext
The BundleContext to search for the bundles.private org.apache.felix.utils.log.Logger
m_logger
Logger to use.private RepositoryAdmin
m_reRepositoryAdmin
The RepositoryAdmin to query for the actual url for a bundle.private java.lang.String
m_updateStrategy
The update strategy to use.static java.lang.String
OBR_UPDATE_STRATEGY
Property defining the obr update strategyprivate static java.lang.String
SYNTAX
Syntax for the url; to be shown on exception messages.
-
Constructor Summary
Constructors Constructor Description ObrURLStreamHandlerService(org.osgi.framework.BundleContext context, RepositoryAdmin admin)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.net.URL
getRemoteObrInstallUrl(java.lang.String path)
Assume the URL is a query URL and try to find a matching resource.private java.net.URL
getRemoteUrlForBundle(org.osgi.framework.Bundle bundle)
Determines the remote url for the given bundle according to the configuredObrURLStreamHandlerService.ResourceSelectionStrategy
.private ObrURLStreamHandlerService.ResourceSelectionStrategy
getStrategy(java.lang.String strategy)
java.net.URLConnection
openConnection(java.net.URL u)
This implementation looks up the bundle with the given url set as location String within the currentBundleContext
.private boolean
validateFilter(java.lang.String filter)
-
-
-
Field Detail
-
SYNTAX
private static final java.lang.String SYNTAX
Syntax for the url; to be shown on exception messages.- See Also:
- Constant Field Values
-
OBR_UPDATE_STRATEGY
public static final java.lang.String OBR_UPDATE_STRATEGY
Property defining the obr update strategy- See Also:
- Constant Field Values
-
m_bundleContext
private final org.osgi.framework.BundleContext m_bundleContext
The BundleContext to search for the bundles.
-
m_reRepositoryAdmin
private final RepositoryAdmin m_reRepositoryAdmin
The RepositoryAdmin to query for the actual url for a bundle.
-
m_logger
private final org.apache.felix.utils.log.Logger m_logger
Logger to use.
-
m_updateStrategy
private java.lang.String m_updateStrategy
The update strategy to use. Default: newest
-
-
Constructor Detail
-
ObrURLStreamHandlerService
public ObrURLStreamHandlerService(org.osgi.framework.BundleContext context, RepositoryAdmin admin)
Constructor- Parameters:
context
- context to useadmin
- admin to use
-
-
Method Detail
-
openConnection
public java.net.URLConnection openConnection(java.net.URL u) throws java.io.IOException
This implementation looks up the bundle with the given url set as location String within the currentBundleContext
. The real url for this bundle is determined afterwards via theRepositoryAdmin
.- Specified by:
openConnection
in interfaceorg.osgi.service.url.URLStreamHandlerService
- Specified by:
openConnection
in classorg.osgi.service.url.AbstractURLStreamHandlerService
- Throws:
java.io.IOException
-
getRemoteObrInstallUrl
private java.net.URL getRemoteObrInstallUrl(java.lang.String path) throws java.io.IOException, org.osgi.framework.InvalidSyntaxException
Assume the URL is a query URL and try to find a matching resource. Note: the code from the below method comes from OPS4j Pax URL handler- Parameters:
path
- the OBR url path- Returns:
- the remote URL of the resolved bundle
- Throws:
java.io.IOException
- if an error occursorg.osgi.framework.InvalidSyntaxException
-
validateFilter
private boolean validateFilter(java.lang.String filter)
-
getRemoteUrlForBundle
private java.net.URL getRemoteUrlForBundle(org.osgi.framework.Bundle bundle) throws java.io.IOException, org.osgi.framework.InvalidSyntaxException
Determines the remote url for the given bundle according to the configuredObrURLStreamHandlerService.ResourceSelectionStrategy
.- Parameters:
bundle
- bundle- Returns:
- remote url
- Throws:
java.io.IOException
- if something went wrongorg.osgi.framework.InvalidSyntaxException
-
getStrategy
private ObrURLStreamHandlerService.ResourceSelectionStrategy getStrategy(java.lang.String strategy)
-
-