webservices contract-first and contract sharing

The webservices contract-first is, i think, a good concept. But how it actually should be executed is really complicated…

in my opinion it is writing the wsdl by hand and then generate the server and clients form it. So the contract is clear. On the otherhand it is also possible to write the server stubs (in eg. java) first, and then generate the wsdl out of it and define this as contract first. The big benefit of the second method is, that noone needs to be able to write the dm wsdl xmls… but is this really contract first?

The big other issue on webservice is the sharing of the wsdl itself… if you have a handwritten wsdl it is easy to share it… but where? But remember the generated server and its generated new wsdl does not need to be exactly the same…

at work we have a seperate service-contract maven project, which puts the wsdl on a seperate server on install. the idea then is then to get the wsdl with cxf and generate the server and clients. Good idea, nobody uses it 🙁

So a different solution should be found…

cant start vm: “Reason: Failed to lock the file.”

So i did it… i had to kill my vmplayer and after a computer reboot could not start my vm… ok this is my working vm… and atually i relay on it… and i really didnt want to reinstall it… and i really got a bit afraid, that today i just reinstall the vm, and acrually cant work…

so the error was:

Cannot open the disk ‘.vmdk’ or one of the snapshot disks it depends on.
Reason: Failed to lock the file.

So after reading the first google it, i installed an unlocker, to unlock all the files… host os is windows7, so actually i thought, this can be possible… but actually there was no lock on the files… after googling a little more i found this. So i deleted all the *.lck folders and tada: every thing is back to normal 🙂 i think 😛

gnome: switching workspaces

so finally working with linux… its a Red Hat :/ but its company policy 🙁

but at least its a linux…

due to running it in an vm, it has a major problem with switching workspaces… which i actually need! the problem is that the vm takes over the CTRL+ALT to leave the vm… but CTRL+ALT+arrow allows switching the workspace… and i really need this shortcut… so how to fix this?

simple… ask google 🙂

Mainly just change the vm ware commands… C:\Users\$YOUR_USERNAME$\AppData\Roaming\VMware add the following lines to the preferences.ini

pref.hotkey.shift = “true”
pref.hotkey.alt = “true”
pref.hotkey.control = “true”

restart the vm… and every thing is good… 🙂 ok now the leave the vm is CTRL+ALT+SHIFT, which i normaly doesnt use 🙂

source

checkstyle and pmd

first of all i think checkstyle and pmd are 2 really cool tools, which can improve java source code… but its kinda hard to fulfill them…

or lets say… an old project is really hard… mainly it should be easy, but due to svn and history reasons, an automated refactoring is crap!

but lets do just the important and simple things:

<plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-checkstyle-plugin</artifactId>
       <configuration>
              <configLocation>[remote file]</configLocation>
       </configuration>
</plugin>
<plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-pmd-plugin</artifactId>
       <version>2.5</version>
 </plugin>

run checkstyle

mvn checkstyle:check

run pmd

mvn pmd:pmd

and with hudson is really cool 🙂

svn and eclipse… and maven

ok one of the problems of eclipse with svn is that no eclipse specific file should be commited to the repository… mainly because they are developers computer specific and kinda crap on others computers… additionally not every one uses eclipse… so that the hell should he be doing with the eclipse files? so goal is to delete and ignore them… simple… but now every body needs to set his project localy correctly…

with maven it is actually a bit more confusing… which folders to add? how to add the Maven Dependencies?

Right Click the Project -> Maven -> Update Project Configuration

Done 🙂

delete files older then X days

who to find and delete files older then X days:

find . -mtime +5 -exec echo rm -rf {} \;

remove the echo to really execute.

@Autowired

after thinking a lot about DIP, it was kinda clear, that we need to refactor some stuff… ok not really the thinking part, more the discusting part… a big beans.xml file sucks… and analysing my beanx.xml showed, that one small component is used everywhere and a lot of injects only where this one class…

first, something about a concept… in my opinion there are two ways for dependency injection… the one where a config file injects classes to others and the one where the class, wishes to get an injection… secondly is @Resource, @Autowired…

and in my project, i thought the one class, which is used almost everywhere should be get by @Autowired… and actually it was an static class, where the key-value configuration out of the db is loaded… so simply refactored it…

and the main problem was: tell spring, that it should autowire!

<context:annotation-config />
<context:component-scan base-package=“[class name]” />

after adding this few lines to the beans.xml, it actually found the [class name] in time and could inject it 🙂

crap config!

powermock

PowerMock is an extension for Mockito or EasyMock, which can mock really special things… static classes, Constructors, partial mocks,…

cool thing…. http://code.google.com/p/powermock/

read from classpath

in our project we have a few templates… so the biggest question is, where to put them… there are a lot of simple answers, but consider this: 4 productive instances, 2 test and 1 dev… these platforms dont know each others… so the solution database, which they share, or localy on each machine… db is not a solution, because the main user has no access to it, and changing templates might happen at the beginning… so file system it is… and we dicided to put them in classpath… easier to roll out for the devs… so how access a file from the classpath?

String filenameOnClasspath = “/myfile.txt” // Located in a directory which is on the classpath
URL url = getClass().getResource(filename);
String fullyQualifiedFilename = url.getFile();

Source

maven create eclipse

Just enter following command:

mvn archetype:create -DgroupId=com.test -DartifactId=mytest

The project will be created… to add it to eclipse it is important to run this command:

mvn eclipse:eclipse

now it can be imported to eclipse