Re: PROPOSAL: Extensions to XMIReader and XMIWriter interfaces

Martin Matula <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.mdr.devel
Message-ID <[email protected]>
Brian Smith wrote:
> Martin Matula wrote:
> 
>> Extend XMIReader interface by adding the same read methods that it 
>> already has but with additional parameter of type HRefResolver.
> 
> 
> I think this isn't a good idea because then users won't be able to use 
> their own HRefResolver with the methods already defined. I think it 
> might be better to have a "setHRefResolver" method on XMIWriter, and if 
> it isn't called, then XMIWriter will use a default HRefResolver (e.g. 
> Lookup.getDefault().lookup(HRefResolver.class)).

Hm. The problem with this approach is that it introduces the concurency 
issues. (i.e. can modules that do not use HRefResolver be sure that the 
XMIWriter/Reader do what they are expected to?, what if someone forgets 
to unset the HRefResolver/XMIReferenceProvider?, etc.)
Maybe a solution could be a registry of HRefResolvers and 
XMIReferenceProviders.
that usualy for each XMIReferenceProvider there will be a corresponding 
HRefResolver. Unique XMIReferenceProvider/HRefResolver ID can be 
serialized into XMI during the write operation (depending on which 
XMIReferenceProvider is used) and during read, XMIReader could 
automatically lookup corresponding HRefResolver. This would solve the 
problem for XMIReader interface. However I don't know how to solve it 
for XMIWriter. And also I do not know if this approach of 
XMIReferenceProvider/HRefResolver pairs is not too limiting.
Martin

> 
> This way, we can set the default resolver at application start up time, 
> and thus isolate direct dependencies on MDR-specific methods to a 
> smaller part of our code.

Yes, I agree that for more simple applications where only one 
XMIReferenceProvider/HRefResolver is used it would be valuable to set 
the default one somehow.
Do you think the lookup is appropriate? AFAIK there is no way of 
redefining lookup entries in your application if MDR library already 
adds the default implementation of HRefResolver. Should we then remove 
all meta-inf lookup entries from the MDR libraries themselves and move 
them to the applications that use MDR? (this would solve also the issue 
that we currently have with dev builds of NB - see the e-mail I sent out 
this morning).

> Also, are there any restrictions on the format of the string returned by 
> XMIReference.getReference()?

I guess there are no restrictions besides that it should not break the 
validity of XML file, but if you generate something that does not comply 
with href convention used in MOF, very likely only your HRefResolver 
will understand it.
Martin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.