Refactor some parameter handling. (FELIX-2950)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1153237 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
index 72503cd..60be255 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
@@ -1174,17 +1174,11 @@
// Create the bundle revision instance.
BundleRevisionImpl revision = new BundleRevisionImpl(
- getFramework().getLogger(),
- getFramework().getConfig(),
- getFramework().getResolver(),
this,
Long.toString(getBundleId())
+ "." + m_archive.getCurrentRevisionNumber().toString(),
headerMap,
- m_archive.getCurrentRevision().getContent(),
- getFramework().getBundleStreamHandler(),
- getFramework().getBootPackages(),
- getFramework().getBootPackageWildcards());
+ m_archive.getCurrentRevision().getContent());
// Verify that the bundle symbolic name + version is unique.
if (revision.getManifestVersion().equals("2"))
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
index db5cb12..cc45988 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
@@ -48,11 +48,8 @@
public final static int EAGER_ACTIVATION = 0;
public final static int LAZY_ACTIVATION = 1;
- private final Logger m_logger;
- private final Map m_configMap;
private final String m_id;
private final Map m_headerMap;
- private final URLStreamHandler m_streamHandler;
private final String m_manifestVersion;
private final boolean m_isExtension;
@@ -76,10 +73,6 @@
// Bundle wiring when resolved.
private volatile BundleWiringImpl m_wiring = null;
- // Boot delegation packages.
- private final String[] m_bootPkgs;
- private final boolean[] m_bootPkgWildcards;
-
/**
* This constructor is used by the extension manager, since it needs
* a constructor that does not throw an exception.
@@ -90,19 +83,12 @@
* @param bootPkgWildcards
* @throws org.osgi.framework.BundleException
*/
- public BundleRevisionImpl(
- Logger logger, Map configMap, Bundle bundle, String id,
- String[] bootPkgs, boolean[] bootPkgWildcards)
+ public BundleRevisionImpl(Bundle bundle, String id)
{
- m_logger = logger;
- m_configMap = configMap;
m_bundle = bundle;
m_id = id;
m_headerMap = null;
m_content = null;
- m_streamHandler = null;
- m_bootPkgs = bootPkgs;
- m_bootPkgWildcards = bootPkgWildcards;
m_manifestVersion = null;
m_symbolicName = null;
m_isExtension = false;
@@ -116,23 +102,19 @@
}
BundleRevisionImpl(
- Logger logger, Map configMap, StatefulResolver resolver,
- Bundle bundle, String id, Map headerMap, Content content,
- URLStreamHandler streamHandler, String[] bootPkgs,
- boolean[] bootPkgWildcards)
+ Bundle bundle, String id, Map headerMap, Content content)
throws BundleException
{
- m_logger = logger;
- m_configMap = configMap;
m_bundle = bundle;
m_id = id;
m_headerMap = headerMap;
m_content = content;
- m_streamHandler = streamHandler;
- m_bootPkgs = bootPkgs;
- m_bootPkgWildcards = bootPkgWildcards;
- ManifestParser mp = new ManifestParser(m_logger, m_configMap, this, m_headerMap);
+ ManifestParser mp = new ManifestParser(
+ ((BundleImpl) bundle).getFramework().getLogger(),
+ ((BundleImpl) bundle).getFramework().getConfig(),
+ this,
+ m_headerMap);
// Record some of the parsed metadata. Note, if this is an extension
// bundle it's exports are removed, since they will be added to the
@@ -192,27 +174,6 @@
return included && !excluded;
}
- URLStreamHandler getURLStreamHandler()
- {
- return m_streamHandler;
- }
-
- // TODO: OSGi R4.3 - Figure out how to handle this. Here we provide access
- // needed for BundleWiringImpl, but for implicit boot delegation property
- // we store it in BundleWiringImpl.
- String[] getBootDelegationPackages()
- {
- return m_bootPkgs;
- }
-
- // TODO: OSGi R4.3 - Figure out how to handle this. Here we provide access
- // needed for BundleWiringImpl, but for implicit boot delegation property
- // we store it in BundleWiringImpl.
- boolean[] getBootDelegationPackageWildcards()
- {
- return m_bootPkgWildcards;
- }
-
//
// BundleRevision methods.
//
@@ -382,7 +343,7 @@
}
catch (Exception ex)
{
- m_logger.log(
+ ((BundleImpl) m_bundle).getFramework().getLogger().log(
m_bundle, Logger.LOG_ERROR, "Unable to get module class path.", ex);
}
}
@@ -479,7 +440,8 @@
{
// TODO: FRAMEWORK - Per the spec, this should fire a FrameworkEvent.INFO event;
// need to create an "Eventer" class like "Logger" perhaps.
- m_logger.log(getBundle(), Logger.LOG_INFO,
+ ((BundleImpl) m_bundle).getFramework().getLogger().log(
+ getBundle(), Logger.LOG_INFO,
"Class path entry not found: "
+ classPathStrings.get(i));
}
@@ -658,11 +620,13 @@
{
return m_secureAction.createURL(null,
FelixConstants.BUNDLE_URL_PROTOCOL + "://" +
- m_id + ":" + port + path, m_streamHandler);
+ m_id + ":" + port + path,
+ ((BundleImpl) getBundle()).getFramework().getBundleStreamHandler());
}
catch (MalformedURLException ex)
{
- m_logger.log(m_bundle,
+ ((BundleImpl) m_bundle).getFramework().getLogger().log(
+ m_bundle,
Logger.LOG_ERROR,
"Unable to create resource URL.",
ex);
@@ -678,7 +642,8 @@
}
catch (Exception ex)
{
- m_logger.log(Logger.LOG_ERROR, "Error releasing revision: " + ex.getMessage(), ex);
+ ((BundleImpl) m_bundle).getFramework().getLogger().log(
+ Logger.LOG_ERROR, "Error releasing revision: " + ex.getMessage(), ex);
}
m_content.close();
m_content = null;
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
index 4b3fed1..2faedc5 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
@@ -985,7 +985,8 @@
{
return BundleRevisionImpl.getSecureAction().createURL(null,
FelixConstants.BUNDLE_URL_PROTOCOL + "://" +
- m_revision.getId() + ":" + port + path, m_revision.getURLStreamHandler());
+ m_revision.getId() + ":" + port + path,
+ ((BundleImpl) getBundle()).getFramework().getBundleStreamHandler());
}
catch (MalformedURLException ex)
{
@@ -1205,19 +1206,25 @@
// not take a stand on this issue.
if (pkgName.length() > 0)
{
- for (int i = 0; !result && (i < m_revision.getBootDelegationPackages().length); i++)
+ for (int i = 0;
+ !result
+ && (i < ((BundleImpl) getBundle())
+ .getFramework().getBootPackages().length);
+ i++)
{
// Check if the boot package is wildcarded.
// A wildcarded boot package will be in the form "foo.",
// so a matching subpackage will start with "foo.", e.g.,
// "foo.bar".
- if (m_revision.getBootDelegationPackageWildcards()[i]
- && pkgName.startsWith(m_revision.getBootDelegationPackages()[i]))
+ if (((BundleImpl) getBundle()).getFramework().getBootPackageWildcards()[i]
+ && pkgName.startsWith(
+ ((BundleImpl) getBundle()).getFramework().getBootPackages()[i]))
{
return true;
}
// If not wildcarded, then check for an exact match.
- else if (m_revision.getBootDelegationPackages()[i].equals(pkgName))
+ else if (((BundleImpl) getBundle())
+ .getFramework().getBootPackages()[i].equals(pkgName))
{
return true;
}
diff --git a/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java b/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
index 98e1933..408561e 100644
--- a/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
+++ b/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
@@ -663,8 +663,7 @@
ExtensionManagerRevision(Felix felix)
{
- super(m_logger, m_configMap, felix, "0",
- felix.getBootPackages(), felix.getBootPackageWildcards());
+ super(felix, "0");
m_version = new Version((String)
m_configMap.get(FelixConstants.FELIX_VERSION_PROPERTY));
}