The Holy Java

Building the right thing, building it right, fast

Archive for December, 2010

Most interesting links of December

Posted by Jakub Holý on December 31, 2010

In the last month of 2010 I’ve stumbled upon surprisingly few intersting articles, partly due to having a lot to do in my job.

  • Reusable Code Is Bad (for advanced developers only!) – we know duplication is bad but “premature enabling for reuse” is equally bad – or ewen worse – because it introduces more complexity and you most likely aren’t going to need it anyway. Apply your experience and knowledge to detect when you will actually benefit from reuse and reduce overall maintenance and complexity. Read the comments too, there’re some interesting ones.

Posted in Languages, Top links of month | Tagged: , | Comments Off

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

Howto: JAX-WS service with XML Source input instead of JAXB-produced POJOs (similar to JAX-RPC with SOAPElement input)

Posted by Jakub Holý on December 29, 2010

Sometimes you may want to create a JAX-WS webservice with its input defined by a proper, structured XSD yet accessing the input as raw XML object and not as POJOs produced by JAXB, similarly as with a JAX-RPC webservice having input of the type SOAPElement. This is possible using @WebServiceProvider with

Read the rest of this entry »

Posted in j2ee, Languages | Tagged: , , , | 3 Comments »

Tip: Multiple webservice implementation classes available at the same time under WAS7

Posted by Jakub Holý on December 29, 2010

If you want to experiment with webservices by providing several alternative implementations of the same webservice (represented by the <wsdl:service> element), each having its own URL, and you’re using Websphere 7 and JAX-WS, then:

  1. For each alternative implementation, add <wsdl:port> with a unique name under the <wsdl:service> element in the WSDL file. Beware: This is essential to enable multiple implementations.
  2. For each alternative implementation, define a servlet and servlet mapping in web.xml like this:
    <servlet id="$IMPLEMENTATION_CLASS_NAME$">
  3. Create the implementations – likely as POJOs denoted with the @WebService annotation – and set the corresponding portName for each of them (@WebService(portName=”<unique port name>”, …))
  4. Deploy and use Read the rest of this entry »

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

Ivy resolve downloads but ignores some artifacts (though not modules)

Posted by Jakub Holý on December 23, 2010

I’ve had a strange issue with Apache Ivy‘s resolve task – it resolved and downloaded all my dependencies but didn’t put some of them to the classpath (via ivy:cachepath) and certainly wouldn’t copy them either (via ivy:retrieve). An indicia was that in the resolve report the number of “artifacts” was zero while the number of “modules” matched the number of the dependencies. The issue was caused by my defaultconfmapping=”*->compile” – it turned out that most modules, as interpreted by Ivy, produce their artifacts only for the configuration “master” and not for compile.

Read the rest of this entry »

Posted in Tools | Tagged: , , | Comments Off

Joshua Bloch: Performance Anxiety – on Performance Unpredictability, Its Measurement and Benchmarking

Posted by Jakub Holý on December 10, 2010

Joshua Bloch had a great talk called Performance Anxiety (30min, via Parleys; slides also available ) at Devoxx 2010, the main message as I read it was

  1. Nowadays, performance is completely non-predictable. You have to measure it and employ proper statistics to get some meaningful results.
  2. Microbenchmarking is very, very hard to do correctly. No, you misunderstand me, I mean even harder than that! :-)
  3. From the resources: Profiles and result evaluation methods may be very misleading unless used correctly.

Read the rest of this entry »

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