Need cleanup of the attachments api
starksm64 Feb 23, 2007 11:10 AMAs I have more metadata being stored off, its clear that the DeploymentUnit api is not sufficient/confusing. There are non-managed, non-serializable attachments showing up in the only used attachments contents. The current attachments api breakdown is:
DeploymentUnit
.addAttachment
.getTransientManagedObjects().addAttachment
.getAttachment
.getTransientManagedObjects().getAttachment
DeploymentContext
.getPredeterminedManagedObjects().addAttachment/getAttachment
.getTransientManagedObjects().addAttachment/getAttachment
.getTransientAttachments().addAttachment/getAttachment
Right now when one does a DeploymentUnit.addAttachment this is going into the DeploymentContext.getTransientAttachments() contents. When one does a DeploymentUnit.getAttachment the DeploymentContext attachments are checked for a match in the order: getPredeterminedManagedObjects(), getTransientManagedObjects(), and getTransientAttachments().
The notion of the various attachments as I understand it and discussed elsewhere is:
getPredeterminedManagedObjects() - attachment overrides for use by things like the profileservice.
getTransientManagedObjects() - attachment overrides for use by things like the runtime aspects.
getTransientAttachments() - the general runtime attachments bucket for use by deployers, aspects.
The TransientManagedObjects is currently unused, and everything is going into TransientAttachments. This is not a sufficient separation of what is managed metadata that should be persisted vs metadata that is used for inter deployer/aspect communication.
I suggest the following change to cleanup the usage and allow for true transient/non-managed attachments:
1. Remove the Attachments interface from DeploymentUnit.
2. Mirror the Attachments api in DeploymentUnit with an enum that indicates what bucket is being accessed. The non-enum version of getAttachment follows the existing order of accessing the PredeterminedManagedObjects, TransientManagedObjects and TransientAttachments. The non-enum version of addAttachment would populate the TransientManagedObjects contents.
3. To populate a non-managed attachment, one would have to use the call that takes the enum targetting the TransientAttachments list.
4. Drop the getTransientManagedObjects access from DeploymentUnit.