HI Senaka
Please read my comments in-lined
I understand that the mechanism Indika explains can be used to
retrieve an InputStream for a non-XML resource on the Registry which
can be manipulated inside our code. However, are there similar
utilities to extract an OMNode, for an XML-resource in the same manner?
If you are using any current available registry implementations, the
'lookup' method returns XML file as an OMElement and binary and pain
text as OMText wrapping content as DataHandler. Then, if you are using
'SynapseConfigUtils. getInputStream(resource)' , it returns a stream.
In this method 'resource' can be an OMElement, OMText or URL.
Therefore, it is no mater whether registry resource is XML or non-XML.
also is there any API which is helpful in deciding whether the stream
is non-XML or XML.
Currently no... You have to add some code. Best way may be using
'content-type'. You have to add get/set method of contentType to
'RegistryEntry'. RegistryEntry holds meta-data about registry resource.
Then, you need a method the get content type from resource.
Both SimpleUrlRegistry and ESBRegistry fetch content from resource by
treating them as URLs and making connection to the url. In URLConnection
API (Java language API), there is a method to get content type. But, you
have to care here and may need to implements a basic algorithm as WSDL,
XSD may return content type as 'plain/text' even their content XML. This
is due to WSDL's file extension is *.wsdl , not *.xml.
Within the RegistryEntry getRegistryEntry(String key) , you have to set
content type to the RegistryEntry instance.
public RegistryEntry getRegistryEntry(String key) {
RegistryEntryImpl registryEntry = new RegistryEntryImpl();
..............
registryEntry.setContentType(connection.getContentType());
..............
}
Note: Above method will not access resource content, only meta-data ,
therefore, it will not be a cost operation.
Then, you can use that API.
RegistryEntry regEnrty = registry.getRegistryEntry ("vvv");
String contentType = regEnrty. getContentType();
Then based on value of 'contentType', you can decide its content
--binary, xml, text....
For WSO2RegsirtyAdapter whose underlying registry is WSO2 registry, they
provide API to get the content type of a resource (Resource.
getMediaType). Logic will be same as above.
Will the class-mediator properties be able to dynamically read from
the Registry based on a key? Is this a TODO for the future release? If
so, perhaps we can invest some time in implementing this feature for
the class mediator properties instead of focusing on a project
specific implementation, since the APIs are generic, according to what
I understand from this discussion.
It is great if you can do require changes and submit a patch. You can
refer to the POJOCommandMediator.
Thanks,
Senaka
Thanks
Indika
_______________________________________________
Esb-java-dev mailing list
[email protected]
http://mailman.wso2.org/cgi-bin/mailman/listinfo/esb-java-dev