I’m trying to migrate the Workspace initialisation from an Activator start()
method to a Declarative Service in
https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/178145
<https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/178145>
Although this works if the workspace location has been set with a -data flag,
it doesn’t work if the user decides to change the location later on. That’s
because the IDEApplication prompts the user for a location in the
org.eclipse.ui.ide bundle, which in turn, has a dependency on the
org.eclipse.core.resources bundle that defines the workspace.
The following happens at startup:
* Equinox publishes an org.eclipse.services.datalocation.Location of type
osgi.instance.area
https://github.com/eclipse/rt.equinox.framework/blob/1c00fefd63ceff66a96d66f578a30a5677864877/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/SystemBundleActivator.java#L178
<https://github.com/eclipse/rt.equinox.framework/blob/1c00fefd63ceff66a96d66f578a30a5677864877/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/SystemBundleActivator.java#L178>
* IDEApplication prompts the user for a dialog, and then sets the instance
location:
https://github.com/eclipse/eclipse.platform.ui/blob/b65540939ac72f0c57a7b2ed32235fcfc9471361/bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/IDEApplication.java#L313
<https://github.com/eclipse/eclipse.platform.ui/blob/b65540939ac72f0c57a7b2ed32235fcfc9471361/bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/IDEApplication.java#L313>
* This is ultimately accessible from
Workspace->LocalMetaArea->Activator.installLocation
https://github.com/eclipse/rt.equinox.bundles/blob/e4e1bb43f2b17f84b39c6361e938bd9ae7e6e086/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java#L55
<https://github.com/eclipse/rt.equinox.bundles/blob/e4e1bb43f2b17f84b39c6361e938bd9ae7e6e086/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java#L55>
The problem is that because the Location is published at startup, whether or
not it has been set, it’s not trivial to configure to DS to set up a dependency
to arrive when the value has been changed. It’s also not clear what should
happen to configurations that use ResourcesPlugin but don’t use the
IDEApplication.
The problem is that if we launch the Workspace with no dependencies, it will
default to and initially set up) the default value, unless @noDefault is
specified, in which case it will likely error out.
We could set up a dependency such that the Workspace only is launched when an
osgi.instance.area Location is published, but Equinox will do this
automatically unless the @noDefault is given.
Finally, we could publish a service/placeholder/Location in IDEApplication,
which could be used to trigger the creation of the Workspace by DS.
Ultimately I think the only way of solving it is to either set the URL of the
workspace as a service property of the location when it’s published, and when
the URL is updated then update the service properties accordingly. Thus we
could have the creation of the workspace dependent upon a service being
published:
{org.eclipse.osgi.service.datalocation.Location}={type=osgi.instance.area}
=>
{org.eclipse.osgi.service.datalocation.Location}={type=osgi.instance.area,url=/path/to/workspace}
We could then set up the DS component for the Workspace to listen to a service
filter that has the URL set as a property.
https://github.com/eclipse/rt.equinox.framework/blob/1c00fefd63ceff66a96d66f578a30a5677864877/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/datalocation/Location.java#L37
<https://github.com/eclipse/rt.equinox.framework/blob/1c00fefd63ceff66a96d66f578a30a5677864877/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/datalocation/Location.java#L37>
Thoughts?
Alex_______________________________________________
platform-dev mailing list
[email protected]
To unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/platform-dev