Implementing an experimental feature to help with dynamic code generation.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@548377 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java
index e57965f..64ad7af 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java
@@ -20,9 +20,7 @@
import java.io.File;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.Dictionary;
-import java.util.List;
import org.apache.felix.framework.ext.FelixBundleContext;
import org.osgi.framework.*;
@@ -44,22 +42,24 @@
m_valid = false;
}
- public void addImportPackage() throws BundleException
+ public void addRequirement(String s) throws BundleException
+ {
+ // TODO: EXPERIMENTAL - Experimental implicit wire concept to try
+ // to deal with code generation.
+ m_felix.addRequirement(m_bundle, s);
+ }
+
+ public void removeRequirement() throws BundleException
{
throw new BundleException("Not implemented yet.");
}
- public void removeImportPackage() throws BundleException
+ public void addCapability() throws BundleException
{
throw new BundleException("Not implemented yet.");
}
- public void addExportPackage() throws BundleException
- {
- throw new BundleException("Not implemented yet.");
- }
-
- public void removeExportPackage() throws BundleException
+ public void removeCapability() throws BundleException
{
throw new BundleException("Not implemented yet.");
}
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index b02c547..223813c 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -1865,6 +1865,31 @@
// Implementation of BundleContext interface methods.
//
+ protected void addRequirement(BundleImpl bundle, String s) throws BundleException
+ {
+ // TODO: EXPERIMENTAL - Experimental implicit wire concept to try
+ // to deal with code generation.
+ synchronized (m_factory)
+ {
+ IRequirement[] reqs = ManifestParser.parseImportHeader(s);
+ IRequirement[] dynamics = bundle.getInfo().getCurrentModule()
+ .getDefinition().getDynamicRequirements();
+ if (dynamics == null)
+ {
+ dynamics = reqs;
+ }
+ else
+ {
+ IRequirement[] tmp = new IRequirement[dynamics.length + reqs.length];
+ System.arraycopy(dynamics, 0, tmp, 0, dynamics.length);
+ System.arraycopy(reqs, 0, tmp, dynamics.length, reqs.length);
+ dynamics = tmp;
+ }
+ ((ModuleDefinition) bundle.getInfo().getCurrentModule().getDefinition())
+ .setDynamicRequirements(dynamics);
+ }
+ }
+
/**
* Implementation for BundleContext.getProperty(). Returns
* environment property associated with the framework.
diff --git a/framework/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java b/framework/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java
index 25e187c..a3bfa78 100644
--- a/framework/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java
+++ b/framework/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java
@@ -23,8 +23,8 @@
public interface FelixBundleContext extends BundleContext
{
- public void addImportPackage() throws BundleException;
- public void removeImportPackage() throws BundleException;
- public void addExportPackage() throws BundleException;
- public void removeExportPackage() throws BundleException;
+ public void addRequirement(String s) throws BundleException;
+ public void removeRequirement() throws BundleException;
+ public void addCapability() throws BundleException;
+ public void removeCapability() throws BundleException;
}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleDefinition.java b/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleDefinition.java
index 710e411..9139325 100644
--- a/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleDefinition.java
+++ b/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleDefinition.java
@@ -54,6 +54,13 @@
return m_dynamicRequirements;
}
+ // TODO: EXPERIMENTAL - Experimental implicit wire concept to try
+ // to deal with code generation.
+ public void setDynamicRequirements(IRequirement[] reqs)
+ {
+ m_dynamicRequirements = reqs;
+ }
+
public R4Library[] getLibraries()
{
return m_libraries;