From: Bruno Sinou Date: Thu, 4 Nov 2010 16:17:16 +0000 (+0000) Subject: workaround to be able to use castor in the UI without use conflicts issues X-Git-Tag: argeo-slc-2.1.7~1131 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;ds=sidebyside;h=f4f1f44a0d2eb1692e866af2a0f4ab5b8787ae1c;p=gpl%2Fargeo-slc.git workaround to be able to use castor in the UI without use conflicts issues git-svn-id: https://svn.argeo.org/slc/trunk@3846 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/eclipse/plugins/org.argeo.slc.client.oxm/META-INF/MANIFEST.MF b/eclipse/plugins/org.argeo.slc.client.oxm/META-INF/MANIFEST.MF new file mode 100644 index 000000000..df483c676 --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.oxm/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Version: 1.0.0.qualifier +Bundle-Name: Test Bundle to solve use case issues +Bundle-SymbolicName: org.argeo.slc.client.oxm +Export-Package: org.argeo.slc.client.oxm +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: org.eclipse.ui +Import-Package: org.argeo.slc, + org.springframework.core, + org.springframework.oxm, + org.springframework.xml.transform + diff --git a/eclipse/plugins/org.argeo.slc.client.oxm/META-INF/spring/osgi.xml b/eclipse/plugins/org.argeo.slc.client.oxm/META-INF/spring/osgi.xml new file mode 100644 index 000000000..cac01bb38 --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.oxm/META-INF/spring/osgi.xml @@ -0,0 +1,22 @@ + + + + + This bundle is a dummy one to try to solve issues on + the OSGI dep management + + + + + + + + + + + \ No newline at end of file diff --git a/eclipse/plugins/org.argeo.slc.client.oxm/META-INF/spring/oxm.xml b/eclipse/plugins/org.argeo.slc.client.oxm/META-INF/spring/oxm.xml new file mode 100644 index 000000000..b1bc1f9bf --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.oxm/META-INF/spring/oxm.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/eclipse/plugins/org.argeo.slc.client.oxm/build.properties b/eclipse/plugins/org.argeo.slc.client.oxm/build.properties new file mode 100644 index 000000000..5fc538bc8 --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.oxm/build.properties @@ -0,0 +1,4 @@ +source.. = src/main/java/ +output.. = target/classes/ +bin.includes = META-INF/,\ + . diff --git a/eclipse/plugins/org.argeo.slc.client.oxm/src/main/java/org/argeo/slc/client/oxm/OxmBean.java b/eclipse/plugins/org.argeo.slc.client.oxm/src/main/java/org/argeo/slc/client/oxm/OxmBean.java new file mode 100644 index 000000000..5ea94d2b8 --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.oxm/src/main/java/org/argeo/slc/client/oxm/OxmBean.java @@ -0,0 +1,48 @@ +package org.argeo.slc.client.oxm; + +import org.argeo.slc.SlcException; +import org.springframework.oxm.Marshaller; +import org.springframework.oxm.Unmarshaller; +import org.springframework.xml.transform.StringResult; +import org.springframework.xml.transform.StringSource; + +public class OxmBean implements OxmInterface { + + private Marshaller marshaller; + private Unmarshaller unmarshaller; + + public void init() { + } + + public Object unmarshal(String result) { + Object res; + if (result == null) + throw new SlcException("Cannot unmarshall empty string "); + try { + res = unmarshaller.unmarshal(new StringSource(result)); + } catch (Exception e) { + throw new SlcException("Could not unmarshall " + result, e); + } + return res; + } + + public String marshal(Object graph) { + StringResult result = new StringResult(); + try { + marshaller.marshal(graph, result); + } catch (Exception e) { + throw new SlcException("Cannot Marshal object " + graph.toString() + + " - " + e); + } + return result.toString(); + } + + // IoC + public void setMarshaller(Marshaller marshaller) { + this.marshaller = marshaller; + } + + public void setUnmarshaller(Unmarshaller unmarshaller) { + this.unmarshaller = unmarshaller; + } +} diff --git a/eclipse/plugins/org.argeo.slc.client.oxm/src/main/java/org/argeo/slc/client/oxm/OxmInterface.java b/eclipse/plugins/org.argeo.slc.client.oxm/src/main/java/org/argeo/slc/client/oxm/OxmInterface.java new file mode 100644 index 000000000..dd430106c --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.oxm/src/main/java/org/argeo/slc/client/oxm/OxmInterface.java @@ -0,0 +1,9 @@ +package org.argeo.slc.client.oxm; + +public interface OxmInterface { + + public String marshal(Object graph); + + public Object unmarshal(String result); + +}