Package com.diffplug.gradle.osgi
Interface OsgiExecable
-
- All Superinterfaces:
Runnable
,Serializable
- All Known Implementing Classes:
ConventionPde.TargetPlatformSetter
,InstalledJreAdder
,OsgiExecable.ReflectionHost
,ProjectImporter
,SetupAction
public interface OsgiExecable extends Serializable, Runnable
Runs code that lives outside an OSGi container inside of it. Works just likeJavaExecable
. 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 aOsgiExecable.ReflectionHost
andOsgiExecable.ReflectionClient
pair, as such: ```java class ProjectImporter extends OsgiExecable.ReflectionHost { private static final long serialVersionUID = 6542985814638851088L; ArrayListprojects; 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. ```
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
OsgiExecable.ReflectionClient<Host extends OsgiExecable.ReflectionHost>
Client code which gets called within the OSGi runtime.static class
OsgiExecable.ReflectionHost
Defines 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 Methods Modifier and Type Method Description static <T extends OsgiExecable>
Texec(org.osgi.framework.BundleContext context, T input)
Executes the givenOsgiExecable
within an embedded OSGi runtime.
-
-
-
Method Detail
-
exec
static <T extends OsgiExecable> T exec(org.osgi.framework.BundleContext context, T input) throws Exception
Executes the givenOsgiExecable
within an embedded OSGi runtime.- Throws:
Exception
-
-