How to add properties to repository workspace
![](http://jazz.net/_images/myphoto/3a5c3fea3b96ab3c7dd6c3724d0c6dde.jpg)
We need to store additional properties for a repository workspace. What would be the best way to go about doing that? I created a new type subclassing SimpleItem with a reference to IWorkspace, but I don't think its lifecycle will be governed by IWorkspace (I want the container object and properties to be deleted when an IWorkspace is for example). Is there a way that I can have these properties and whatever container object (if required) to be governed by the IWorkspace lifecycle?
5 answers
![](http://jazz.net/_images/myphoto/3a5c3fea3b96ab3c7dd6c3724d0c6dde.jpg)
On Fri, 11 Jul 2008 16:07:58 +0000, kmunir wrote:
No. You can create a scheduled task (that runs every night let's say)
which will look for your items pointing at workspaces that are no longer
there and delete them.
- Dmitry
We need to store additional properties for a repository workspace. What
would be the best way to go about doing that? I created a new type
subclassing SimpleItem with a reference to IWorkspace, but I don't think
its lifecycle will be governed by IWorkspace (I want the container
object and properties to be deleted when an IWorkspace is for example).
Is there a way that I can have these properties and whatever container
object (if required) to be governed by the IWorkspace lifecycle?
No. You can create a scheduled task (that runs every night let's say)
which will look for your items pointing at workspaces that are no longer
there and delete them.
- Dmitry
![](http://jazz.net/_images/myphoto/3a5c3fea3b96ab3c7dd6c3724d0c6dde.jpg)
Can you please provide an example of a
scheduled task and how one would go about defining one?
Sure, take a look at
com.ibm.team.repository.service.internal.ItemCleanupTask for an example.
You will need to use the com.ibm.team.repository.service.asynchronousTask
extension point.
Just
curious...is there any event notification mechanism that could be used
as an alternative (i.e. using event handlers)?
There are ChangeEvents published when a workspace is deleted. There is no
callback however, so you will still need to have a regularly scheduled
task that runs and looks for those events.
It is hard to say if that will be more efficient than verifying all the
workspaces. There aren't that many workspaces, but there are a lot of
change events.
- Dmitry
![](http://jazz.net/_images/myphoto/3a5c3fea3b96ab3c7dd6c3724d0c6dde.jpg)
On Fri, 11 Jul 2008 16:07:58 +0000, kmunir wrote:
We need to store additional properties for a repository workspace. What
would be the best way to go about doing that? I created a new type
subclassing SimpleItem with a reference to IWorkspace, but I don't think
its lifecycle will be governed by IWorkspace (I want the container
object and properties to be deleted when an IWorkspace is for example).
Is there a way that I can have these properties and whatever container
object (if required) to be governed by the IWorkspace lifecycle?
No. You can create a scheduled task (that runs every night let's say)
which will look for your items pointing at workspaces that are no longer
there and delete them.
- Dmitry
Dmitry, thanks for your response. Can you please provide an example of a scheduled task and how one would go about defining one? Just curious...is there any event notification mechanism that could be used as an alternative (i.e. using event handlers)?
![](http://jazz.net/_images/myphoto/3a5c3fea3b96ab3c7dd6c3724d0c6dde.jpg)
The class com.ibm.team.repository.service.internal.ItemCleanupTask is a scheduled task, so you could look at that for the basic structure.
Scheduled tasks are contributed through extension points like most other things in Jazz, so you just need to subclass the AbstractAutoScheduledTask class and then contribute to your plugin.xml
Scheduled tasks are contributed through extension points like most other things in Jazz, so you just need to subclass the AbstractAutoScheduledTask class and then contribute to your plugin.xml