Direkt zum Hauptbereich


Es werden Posts vom 2012 angezeigt.

JUnit testing services and clients with javax.xml.ws.Endpoint

Following situation: you have written some generic stub to use in your projects that creates a client for a service. Your client is smart and does some magic for connections (proxy, cache or other kind of magic). Or maybe you just have written a service for that matter. Anyway, you now want to test it. Unit testing the functionality of your methods is a must. But you still want to reach 100% coverage and need to test the service as it would run in real life.
Then you can use the javax.xml.ws.Endpoint class.
If you prefer figuring it out yourself, you can find the code (as a project for netbeans) --here--
To follow the code examples as html click  --here--

So here is how you do it:

If you've coded nothing fancy, then you probably have a class like this:

This is a generic client for opening connections to services. It gives you back a port of the type of your service where you can call your operation as a method of the port. It is very convenient if you have to do some nasty network-conne…

Stop the software / car analogy

I can understand that making analogies is a very powerful form of explaining a hard concept, but you should be aware of the demons you might be unleashing. 
I like analogies, as much as anyone. I do the Einstein-Train-Thing to convince my self that I understand relativity like the next man. But everybody is careful talking about relativity and nobody would walk outside the framing without considering it very carefully.
Software on the other hand is not so respected, and I ask you: does the next man really get it?
Everybody can relate to cars, right? So that is a good reason to use the analogy, you would think, but here is where I have to disagree:

Thinking you know about the domain, sells, production lines, marketing, resourcing, electronics, hydraulics and all the engineering that has been put into the car is the first mistake. The second mistake is assuming other people do (unless they work for BMW or something like that). 
You think you are making the software concepts simpler, ju…

Guide to hiring software developers for your dream team

You want to hire a new developer to support your team, or want to build up a new development team? New trends show how everybody is investing their money in software development. In my opinion, every company today has to do some software (or should), but there are very different ways to go about it. You could have some kind of  project managers supervising an outsourced team in Bangalore or Rio doing your software. If that works for you be happy, but you should be aware that you are not investing in software as in creating value for your company. Your software is costing you like you were leasing a machine. Lots of companies have found out the hard way, that this model does not suffices. Different to leasing a machine, you will not get the new model in 2 years just like that. In order to be competitive in today's market you need to invest in the knowledge that is reflected by your software applications and house them intern. If your company has decided to build up a …

I miss Buffy

I can't believe there are so many people out there that never watched the show. It had it all, a super cute star with kick-ass powers and cheap vampires that didn't shine and drunk real blood... Today we were talking about the show in the office, and only one (other than me) was a fan. I was surprised. A nice idea came up though:

wooden stakesilver crossholy water

male death rates and hot pants

Python and Access-Control-Allow-Origin

Ok, here is something that probably happens a lot:
You are trying to do some .js (if not you should get started), and write some code in your favorite ide, save it, load it in your favorite browser and everything is ok. You are a good developer and start making packages and loading your files when you need them: lazy. You don't want to overdo things, and manage to put stuff into a bunch of .js and .html. You load them into your browser and BAM:
Failed to load resource: Resource failed to load So now you are all WTF, right? You Google (some would Bing) it and sure enough, what you were thinking is the ugly true and by now you get angry as a bird. Why? Ok, for those that didn't know there is a thing called Same Origin Policy, that forbids you from loading stuff across different domains and bla bla bla... So what does it has to do we you? You sure enough are not trying do load across domains, your are loading a file... you may think, but no. Your file is …

ThreadLocal as an Enum - I'm not afraid to admit it!

Well, as disturbing as it might be, I am not afraid to at least admit it: I did not know about the elegance of the following construct:

public enum TLData { INSTANCE; privatefinal ThreadLocal<String> myData = new ThreadLocal<String>(); publicString getMyData() { return myData.get(); } publicvoid setMyData(finalString myData) { this.myData.set(myData); } }

Since you are using an Enum, nobody can create new members from outside, you don't have to care about privatizing any methods and you can access it as easy as:

publicclass myClass { publicvoid myMethod() { /*** setting the data */ TLData.INSTANCE.setMyData("some data"); /*** getting the data */String myData = TLData.INSTANCE.getMyData(); } }

Isn't that fancy? I had to admit I never thought of it myself. A colleague of mine had to put it under my nose.