The Holy Java

Building the right thing, building it right, fast

Posts Tagged ‘EMF’

EMF tips: Accessing model meta data, serializing into element/attribute

Posted by Jakub Holý on January 11, 2011

Two tips for the Eclipse Modeling Framework (EMF) 2.2.1:

  1. Accessing model’s meta model – accessing EClass/attribute by name – so that you can set an attribute when you only know its name and haven’t its EAttribute
  2. How to force EMF to serialize an object as an XML element instead of an XML attribute

Read the rest of this entry »

Posted in eclipse, Languages | Tagged: , | Comments Off

Creating dynamic EMF model from XSDs and loading its instances from XML as SDOs

Posted by Jakub Holý on January 3, 2011

This post describes how to read a dynamic EMF model from a set of XML schema files (XSDs) and how to use that model to transform XMLs to SDO DataObjects or EMF EObjects, all this in a stand-alone environment. Read the rest of this entry »

Posted in Languages | Tagged: , , , , , , | Comments Off

EMF: Reading a model from XML – how to correctly declare its namespace – variants

Posted by Jakub Holý on January 3, 2011

When you use the Eclipse Modeling Framework (EMF) to read a model instance from an XML file, such as a webservice call message payload, it’s essential for EMF to be able to match the root XML element with the model’s “ePackage” that should be used for (re)constructing the model instance from the XML and this is done by matching the root element’s and the ePackage’s namespaces (as in XSD). So it’s very important to have proper configuration of EMF and proper content of the XML. Since there ale multiple variations of both, there are more ways to get it wrong than right. To learn what I’ve discovered regarding the valid combinations suitable at different situations, read on. Read the rest of this entry »

Posted in Languages | Tagged: , , , | 5 Comments »

Creating JAX-WS webservice using Service Data Objects (SDO) instead of JAXB-bound POJOs

Posted by Jakub Holý on December 29, 2010

If you need to invoke a logic using Service Data Objects (SDOs) from a JAX-WS webservice under Websphere 7 without the SCA Feature Pack, it is possible to do it similarly to the old approach of generating a JAX-RPC webservice from a WSDL with an SDO facade (actually building on it).

The steps are:

  1. Use RAD to generate a JAX-RPC webservice from a WSDL with an SDO facade.
  2. Implement a JAX-WS webservice accessing directly its input as XML data (i.e. implement is as a WebServiceProvider for message payload)
    • Use Transformer and StreamSource/Result to convert from/to String containing XML
  3. Copy the SDO-related classes from the JAX-RPC webservice to the JAX-WS one, exclude just the JAX-RPC webservice interface and implementation
  4. Adjust the generated EMFSOAPElementUtil – change (de)serialize methods to expect/produce a String instead of SOAPElement
  5. Put it all together in the WS implementation class created in #2
  6. Finishing touches – add conversion of org.eclipse.emf.ecore.xml.type.internal.XMLCalendar to javax.xml.datatype.XMLGregorianCalendar

Read the rest of this entry »

Posted in j2ee, Languages, WebSphere | Tagged: , , , , | Comments Off