Archive for the 'java' Category

Published by Fabian on 11 Feb 2009

WebServices without UTF-8

currently I am working on integration some WebServices with a Mule ESB. Its working pretty nicely, but also is not as straightforward as it could be. Especially troubling is a WebService I try to consume which claims to be SOAP, receives and returns plenty of elements on toplevel (which make invoking it via CXF a pain) and: Its returning a corrupted character stream. I contacted the provider and they answered:

The data we are providing is collected from multiple sources, this makes it impossible for us to serve UTF-8 data. We have attached the WSDL for ISO-8859-1

The attached WSDL just changed the XML prolog – fail – this is only the encoding of the wsdl not the service.

Still Mule/CXF complains about invalid UTF-8. But wat bugs me is that it seems to be impossible to correct that bug. I dug 2 days into the deeps of Mule and CXF and found multiple places where I potentially could hook in, but there is an internal Mule Interceptor that reads the XML, fails at the invalid UTF-8 data and dies with throwing an Exception.

Too bad :-(

Does anybody know of a workaround for such? I thought I could use Transformer, but it seems i will not get access to the raw input stream.

Published by Fabian on 19 Dec 2008

Goodbye GuT…

… hello new office.

Today I was the last day in our old office located in the GuT – Gründer und Technologiezentrum (Center for Founders and Technology). It was a good place for codecentric to grow and I liked it there, even if it was very packed the last months. Also for some other companies this would be pretty empty, but we think creative minds need “caves and commons“. Places to rest, think and work alone, and places to gather, meet and work together.

The new office is a real gem. It is the old local court building of Solingen Ohligs. Built in the 19th century it has a long story to tell. And thanks to the huge effort a local investor put into the reconstruction of the old building it can tell its story and be a great office with a special style. Large mosaic floors, some antique furniture and a refurbished loft make an ideal housing for modern and ergonomic office furniture and equipment. It also allows to create a truly great working environment for agile software development.

Besides saying goodbye to the old office, i was there to also give a talk about Effective Java, 2nd edition from Josh Bloch. I presented some interesting and some strange ideas from the book, either hopefully having transferred some knowledge or even better encouraged my colleagues to read the book, because I think it is a must read for Java developers. So if you, dear reader, haven’t read the book yet, please read it :-)

Have a peaceful christmas time, read you back on January 2nd after codecentric has moved into the new office, with a report from my new workplace.

Published by Fabian on 06 Oct 2008

Writing a Custom Easymock Argument Matcher

Easymock is a great tool, but for me it was lacking a neat way to make sure that a recorded method call is only valid for an agument with a specific property value. Easymock has a mechanism that could be used for that:

public static <T> cmp(T value, Comparator<T> comparator, LogicalOperator operator)

However I do not find this very telling.
So I ended up writing a custom IArgumentMatcher:

private ObjectClass hasPropertyEnum(final MyPropertyEnum enumValue) {
	reportMatcher(new IArgumentMatcher() {
		@Override
		public void appendTo(StringBuffer buffer) {
			buffer.append("hasPropertyEnum("+enumValue+")");
		}
 
		@Override
		public boolean matches(Object argument) {
			if (argument instanceof ObjectClass ) {
				ObjectClass clazz = (ObjectClass ) argument;
				if (enumValue!= null) {
					return enumValue.equals(clazz.getMyProperty());
				}
			}
			return false;
		}
	});
	return null;
}

At least I find this much more telling than writing a comparator.
Now I am able to record a call like this:

expect(myServiceMock.myMethod(hasPropertyEnum(MyPropertyEnum.A_ENUM))).andReturn(null);

Or is there a nicer Easymock solution?

Published by Fabian on 31 Aug 2008

Creative Writing Stress

Seems that I am a bit loaded with doing creative writing. Besides day2day work I am preparing

  • A presentation about Optimizing Symfony Performance for the symfony camp, happening from 11th – 13th September. Luckily I got most of the slides already done and just need to polish and prepare the rest.
  • A manuscript for a book I am planning to publish next year. At the moment I am discussing it with some publishers.
  • A talk/review of Effective Java 2nd Edition, which will present the New and Noteworthy. I will hold it on our company Friday events. Later the material will also be published on our webpage.
  • Material for a regular column in a german Java magazine. My part will be Web stuff.
  • The symfony 1.2 release. Well actually no creative writing, but some planning, coordination and of course some programming as well.

But I am not complaining, I like being loaded with work. It makes relaxing a whole sunday even more interesting. But I thought it would be nice for you to know that I have less creative writing time for my blog at the moment.

Published by Fabian on 07 Aug 2008

SCJP prepares for the real life…

… at least sometimes …
Today I had my “you forgot what you learned for the SCJP” moment.

long MSEC_PER_YEAR = 365 * 24 * 60 * 60 * 1000;

Despite the fact that this is not not accurate, due to many things (leap year and seconds, possible adjustments to DST), this should match the milliseconds between to dates one year apart.

Well at least I thought so, but the computation is incorrect. I did figure this out after a while (and ended up rewriting it anyways), so I am pretty sure one of my readers can come up with a solution for this “puzzle” :-)

Published by Fabian on 29 Jul 2008

“The Early Bird Catches The Exception”

Thanks for that quote, Nick, that one was delighting my morning.

« Prev - Next »