<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.28.3">
</HEAD>
<BODY>
Hello,<BR>
<BR>
I've done some prototyping with Geotoolkit in order to eventually develop a CSW client application.<BR>
First, my goal is to generate ISO 19115 XML data from Java objects that I would populate.<BR>
My initial, basic, tests went fine, no problem.<BR>
<BR>
Then I tried to follow the advice explained on &lt;<A HREF="http://www.geotoolkit.org/modules/metadata/faq.html">http://www.geotoolkit.org/modules/metadata/faq.html</A>&gt;, to use a proxy, instead of implementing completely all the interfaces.<BR>
Here's some snippet of code that fails : <BR>
<BR>
<PRE>
[...]
import org.opengis.metadata.Metadata;
import org.geotoolkit.metadata.iso.DefaultMetadata;

InvocationHandler handler = new InvocationHandler() {
&nbsp;&nbsp;&nbsp; @Override
&nbsp;&nbsp;&nbsp; public Object invoke(Object arg0, Method arg1, Object[] arg2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throws Throwable {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UML uml = arg1.getAnnotation(UML.class);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (uml != null) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String name = uml.identifier();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(name);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;
&nbsp;&nbsp;&nbsp; }
};

DefaultMetadata d = new DefaultMetadata();

Metadata data =
&nbsp;&nbsp;&nbsp; (Metadata) Proxy.newProxyInstance(d.getClass().getClassLoader(),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new Class[] { Metadata.class },
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; handler);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

MarshallerPool pool = new MarshallerPool(MarshallerPool.defaultClassesToBeBound());
Marshaller marshaller = pool.acquireMarshaller();
marshaller.marshal(data, System.out);
pool.release(marshaller);
</PRE>
<BR>
<PRE>
Exception in thread &quot;main&quot; javax.xml.bind.JAXBException: class $Proxy0 nor any of its super class is known to this context.
        at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:554)
        at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:470)
        at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:314)
        at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:243)
        at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95)
        at org.geotoolkit.xml.PooledMarshaller.marshal(PooledMarshaller.java:120)
        at Test.test1(Test.java:667)
        at Test.main(Test.java:615)
</PRE>
<BR>
I suppose that's due to the fact that I'm using the Metadata interface instead of the DefaultMetadata class. But, as I'm no JAVA or JAXB expert, I don't really know where I'm wrong :-)<BR>
That's not a blocking issue for me but I was wondering if you could provide more information on how to use this proxy method.<BR>
<BR>
<BR>
Then, I have another &quot;issue&quot; with the marshaller, or at least, a question : how can I return some DataIdentification items from Metadata::getIdentificationInfo() ?<BR>
Let's say that the implementation looks something like:<BR>
<BR>
<PRE>
@Override
public synchronized Collection&lt;Identification&gt; getIdentificationInfo() {
&nbsp;&nbsp;&nbsp; Collection&lt;Identification&gt; identificationInfo
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = new ArrayList&lt;Identification&gt;();
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; DataIdentification identification = new DataIdentification() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @Override
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public InternationalString getAbstract() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NameFactory factory = FactoryFinder.getNameFactory(null);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Map&lt;Locale, String&gt; names = new HashMap&lt;Locale, String&gt;();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; names.put(Locale.ENGLISH, &quot;Description&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return factory.createInternationalString(names);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @Override
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public InternationalString getEnvironmentDescription() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NameFactory factory = FactoryFinder.getNameFactory(null);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Map&lt;Locale, String&gt; names = new HashMap&lt;Locale, String&gt;();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; names.put(Locale.ENGLISH, &quot;Environment&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return factory.createInternationalString(names);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [...]
&nbsp;&nbsp;&nbsp; };

&nbsp;&nbsp;&nbsp; identificationInfo.add(identification);
&nbsp;&nbsp;&nbsp; return identificationInfo;
}

</PRE>
It compiles and runs fine... except that the marshaller doesn't output any DataIdentification-specific information, e.g. &quot;environment description&quot;. Whereas the &quot;abstract information&quot;, from the the parent Identification interface, is correctly present in the XML. Again, I suppose that must surely require some Java &quot;trick&quot; that I don't know :-)<BR>
<BR>
Thanks for your help!<BR>
<BR>
-- <BR>
Damiano ALBANI
</BODY>
</HTML>