Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[wtp-dev] Per-resource singletons

We have a significant number of design scenarios in JSF tools where we have what I call "per-resource singletons". That is, objects for which we want exactly zero or one instances for an associated IResource (usually a file or project). I have already pinged the platform to see if something existed and while I heard agreement from Walter Harley that at least one other team has this need, there doesn't appear to be anything. Before I start implementing for JSF (that we will try to push downward toward the platform if possible), I was wondering if anyone in WTP had anything like this. While there are lots of interesting things we can do here, the main features are:

1) A singleton factory that allows lazy (initalized) association of singleton objects with different IResources and optionally serialize the instance information on a project or workspace basis (probably using the scope context concept used by preferences) . In the past we have used Session and Persistent properties to store these, but they have the draw back that they are lifecycle dependent. For example, if a project is closed or a file is a deleted, you can no longer retrieve them (a CoreException is thrown).

2) A resource lifecycle manager that allows either the singleton or an associated advisor object to register for common lifecycle events on the resource. For example, firing events to the singleton or advisor when the related resource is closed, renamed or deleted. Default behaviour would be provided to do disposal and cleanup of known resources (most important for us is to release held ArtifactEdit's).

3) Bridging behavior to the OSGI singleton framework (I have been told this exists but have not yet found it) so that these singletons can also react properly to bundle load and unload events.


--Cam


Back to the top