Package com.diffplug.gradle.osgi
Interface OsgiExecable
- All Superinterfaces:
Runnable,Serializable
- All Known Implementing Classes:
ConventionPde.TargetPlatformSetter,InstalledJreAdder,OsgiExecable.ReflectionHost,ProjectImporter,SetupAction
Runs code that lives outside an OSGi
container inside of it. Works just like
projects;
public ProjectImporter(Collection projects) {
super("com.diffplug.gradle.oomph.ProjectImporterInternal");
this.projects = new ArrayList(projects);
}
}
class ProjectImporterInternal extends OsgiExecable.ReflectionClient {
ProjectImporterInternal(ProjectImporter host) {
super(host);
}
public void run() {
// add all projects to the workspace
IWorkspace workspace = ResourcesPlugin.getWorkspace();
for (File projectFile : host.projects) {
try {
Path path = new Path(projectFile.toString());
IProjectDescription description = workspace.loadProjectDescription(path);
etc.
```
JavaExecable.
Make sure the code you execute only uses
classes which are available to the OSGi
runtime you're using. If you'd like to call
some code which is only available inside the
OSGi container, use a OsgiExecable.ReflectionHost
and OsgiExecable.ReflectionClient pair, as such:
```java
class ProjectImporter extends OsgiExecable.ReflectionHost {
private static final long serialVersionUID = 6542985814638851088L;
ArrayList-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classClient code which gets called within the OSGi runtime.static classDefines data which will be passed via reflection to code within the OSGi runtime - the reflection allows us to call code for which we don't have the necessary dependencies to resolve its imports unless it is only instantiated within the OSGi container. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <T extends OsgiExecable>
Texec(org.osgi.framework.BundleContext context, T input) Executes the givenOsgiExecablewithin an embedded OSGi runtime.
-
Method Details
-
exec
static <T extends OsgiExecable> T exec(org.osgi.framework.BundleContext context, T input) throws Exception Executes the givenOsgiExecablewithin an embedded OSGi runtime.- Throws:
Exception
-