Venkata Krishnan wrote:
I set up the targetnamespace for the names of
Intents and PolicySets in the SCADefnsProcessor after an Intent or PolicySet
has been read by a downstream processor.
Given how the policy code is currently organized that seems the simplest
option: SCADefinitionsProcessor is responsible for handling the
targetNamespace, and setting it in the qnames of the policy intents and
policySets that it adds to its lists of policy intents and policySets.
This could be much simplified though, with the following changes:
1) cosmetic but it'll help make that code more readable, change
if (extension != null) {
if ( extension instanceof Intent ) {
((Intent)extension).setName(new QName(targetNamespace,
((Intent)extension).getName().getLocalPart()));
to
if (extension instanceof Intent ) {
Intent intent = (Intent)extension;
intent.setName(new QName(targetNamespace,
intent.getName().getLocalPart()));
as the double 'if' is not necessary, and a local variable will help
avoid repeating the casts.
2) Unless I'm missing something, I don't think that you need to set the
targetNamespace of QualifiedIntent.qualifiableIntents, as it looks like
it's already read as a QName from the XML stream (and this QName does
not have to be in the current targetNamespace).
3) Finally a bigger change: it seems that you have StAXArtifactProcessor
extensions for Intent, PolicySet etc... but these elements are not
extensions, so you didn't have to go through all that, as they are part
of the SCA core namespace. So, a much simpler approach would be to just
read them in, directly from SCADefinitionsProcessor. This is similar to
CompositeProcessor for example, if we had made a separate processor for
Component, we would have had to pass a lot of context to it.
In short, it looks like you've created a maze of processor extensions
for things that didn't have to be extensions, and are now wondering how
to pass context through this maze :)
The solution is simple, just don't make them extensions :) You can
either move this code to SCADefinitionsProcessor.read() or to private
methods of SCADefinitionsProcessor to which you'll be able to pass
whatever context you need.
Hope this helps.
--
Jean-Sebastien
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]