»Spring 3« ist da. Vieles ist geblieben, manches verschwunden, manches neu. Spring 3 verspricht eine verbesserte und dynamischere Konfiguration, einen leistungsfähigen und mächtigen REST-Support und viele kleine Verbesserungen. Parallel zu dem Spring 3-Release wurden auch andere Tools und Projekte aktualisiert, auf die wir ebenfalls einen Blick werfen wollen:
Wichtige Änderungen
Java Configuration
Spring Expression Language
Spring MVC und Rest
Embedded Database
SpringSource Toolsuite
Spring Roo
Grails
Die Veranstaltung findet in Dortmund im Harenberg City Center statt und ist kostenfrei. Neben dem Vortrag gibt es auch einen kleinen Imbiss. Bitte melden Sie sich hier an.
»Spring 3« ist da. Vieles ist geblieben, manches verschwunden, manches neu. Dieser Vortrag beleuchtet die Änderungen und zeigt wie man die neuen Features einsetzen kann.
Zusätzlich werfen wir gemeinsam einen Blick auf die SpringSource Toolsuite, Spring Roo, Grails.
If you are using the famous Issue tracker JIRA by Atlassian you are able to change the workflow. Workflows are used to define the status an issue can get. Between the 2 statuses there are a transition. In JIRA you can translate the statuses (Administration | Status | Translate).
But for transitions there is not such a dialog. But there is an solution for this. You can modify the language property file. If you use an script you can do this automatically. But one step after another
1. Locate the language library
In JIRA all language files are bundled in a library. This library you find in WEB-INF/lib in your JIRA installation.For the german translation the library is named language_de_DE.jar.
2. Extract the JAR and edit the JiraWebActionSupport_de_DE.properties
The JiraWebActionSupport_de_DE.properties is in the package com/atlassian/jira/web/action. You can edit this file with a simple editor. For every transititon you must add one or two properties:
for the title
for the submit button, if you transition needs a dialog (e.g. the reopen issue has a dialog where you can leave a comment)
For instance you have a transition Test Issue. This transition doesn’t need a dialog. So you need only one property:
testissue.title=Testen
As an exteded example you have a transition named Issue tested. For this you need a dialog the user can leave a comment. In this case you need 2 properties:
After you finished the modification you can repackage the JAR.
3. Restart JIRA
This you should really do before you start with the next steps.
4. Add the needed properties to the transitions
The next step is to create a relation between JIRA and the properties. This can be done in the panel for modifying transitions (Administration | Workflows | Steps (of the workflow you want to change) |  Click on the transition | Properties of the transition). In the page loaded then you can add the needed properties.
What you need to add is a key-value pair. The key is for JIRA. With this key JIRA knows what kind of i18n text this property represents. The both relevant key are:
jira.i18n.title (for the title)
jira.i18n.submit (for the submit button)
As value you can add the properties you add to the language file (JiraWebActionSupport_de_DE.properties). After you are done you can close every dialog and activate the workflow.
As a result you see something similar to this:
Hmm…there are many steps…is there a chance to simplify this?
Yes, of course. You can create a script to do this automatically. For example I have one written in Groovy doing all steps automatically:
//Points to the language_de_DE.jardef langPack =newFile("...")//Points to the folder the modified JAR should be copied todef targetDir =newFile("...")//Points to the folder the langPack should be extracted todef tempDir =newFile(System.properties["java.io.tmpdir"]+"/language_pack")def langFile =newFile(tempDir, "com/atlassian/jira/web/action/JiraWebActionSupport_de_DE.properties")//Create the antbuild for some common tasksdef ant =new AntBuilder()if(tempDir.exists()){
ant.delete(dir:tempDir)}
ant.mkdir(dir:tempDir)
ant.unzip(src:langPack, dest:tempDir)//Using Groovy's multiline stringsdef t ="""
issuetested.title=Getested
issuetested.submit=Getested
"""//Append the existing content with our extended properties
langFile.text= langFile.text+ t
ant.zip(basedir:tempDir, destfile:newFile(targetDir, "language_de_DE.jar"))
ant.delete(dir:tempDir)//Build JIRA"cd /opt/jira".execute()"build.bat".execute()//Restart Tomcat"cd /opt/tomcat/bin".execute()"catalina.sh start".execute()
With this simple script you can do all steps automatically. One thing isn’t really nice. The properties you append to the original languagge file are saved in the script. This should be changed if there are more than a handful properties.
This article is about the managing of Domainobjects with the Spring Framework. Domainobjects are often initilized with the new keyword. This avoids the usage with Spring, because there aren’t Spring Beans. But with AOP and the @Configurable Annotation of Spring you can manage these objects too.
This article introduce you into OSGi with Spring Dynamic Modules. It starts with a typically sample of version conflicts if you use libraries with different versions. The next step is the try with pure OSGi. But this results in problems with the current sample application, because this one is Spring-powered.
Now it will evaluated with Spring Dynmaic Modules. After this we discuss problems with webapplications and different versions and service interfaces.
The PDF to this article I will offer you the next days. Stay tuned.
Both operators are implemented in Groovy to shorten the code.
The Elvis Operator shorten your if-conditions. You know the common ternary expression:
def gender = user.male ? "male": "female"
This you can shorten with the Elvis operator:
def gender = user.male ?: "female"
Only if the expression evaluates to false or null the default value (here: female) will be used.
The other operator is the Safe-Navigation Operator. If you are working with Java Beans and their getter methods you have often a chain of calls:
customer.getAddress().getCity();
This works fine until one of the getters return null. Then you get a NullPointerException. To avoid this you can surround this call with a try-catch block:
try{
customer.getAddress().getCity();
}catch (NullPointerException npe){
//what can I do here???
}
This are at least 5 lines of code for catching the NullPointerException. But what can you do with this exception? Commonly you do nothing. You can log this or redirect this exception to the next tier. In Groovy there is the Safe-Navigation Operator:
customer?.address?.city
At first in Groovy you can use the properties instead of accessing the getter methods. The ?. operator checks if the expression on the left hand is null. If true the complete expession evaluates to null.
Certainly you know that Groovy is one of the dynamic languages published in the last years. There are some languages with this approach: Ruby, JRuby, Python, PHP, JavaScript and many more.
Groovy is a little bit special if you are a Java-Developer. Groovy is built on the top of the Java-Platform. So it is easy to learn the concepts and syntax of this nice language. Aside of powerful syntax enhancements there are the dynamic approach. With the Meta Object Protocol (MOP) you are able to analyze and change every Object.
Getting all properties of an Object
Properties in Groovy are a little bit special. In difference to fields a property always have a Getter-/Setter-Method. It is very easy to get all of such properties:
With this codefragment you get a list of all properties of the Object someObject. The content of this list are groovy.lang.MetaBeanProperty. With this class you can
get and set the field
get and set the Getter and Setter separately
query for a special property
You can see in Picture 1 the Classdiagram of the MetabeanProperty class. With the help of this class you can easily analyze and change existing Groovy classes.
Picture 1: Classdiagram of groovy.lang.MetaBeanProperty
What is a MetaClass?
Every Class has some meta informations. This are informations about fields, properties and methods. Additionally it exists an invokeMethod. This method is used to call dynamically methods of Groovy Classes. The behaviour of this method is similar to the Reflection mechnism of Java (you know the package java.lang.reflect?).
Picture 2: Classstructure of groovy.lang.MetaClass
Dynamically adding method to classes
With the help of this class you are able to add new methods to an existing class. Even final (and immutable) classes could be extended:
This little fragment adds one method to the final class java.lang.String. After this code is executed you can access this from your¬† Groovy Code. Please attend that this only works if you are calling the additional methods from Groovy. You cannot call it from your Java Code, because the Compiler doesn’t know anything of this additonally method. But you can use reflection with a simple invokeMethod to use the dynamically added method.
Testdriven Development is a must-have if you want to have high quality in your project. The most difficult part you can test is the WebUI. There are many tools to support you in testing UIs. But mostly they are expensive and difficult to use. But there is a light…
Selenium is started to simplify the test of WebUI. But Selenium as standalone is not fully automated. This talk describes how to automate the test of WebUI.
This article shows how to modularize existing software in different ways. The first one use pure OSGi. With the second try the modularization will be done with Spring dm.
This article is written german. If you can read german here is the original abstract:
Geschnitten oder am Stück? – Modularisierung von Software mir Spring Dynamic-Modules
Bob D. Veloper schlägt die Hände über dem Kopf zusammen. Schon wieder ist der Build fehlgeschlagen. Und schon wieder wurden interne Klassen der Adresskomponente von der Customerkomponente verwendet. Dieser Vorfall bewegt Bob dazu dieses Thema genauer anzugehen und zu lösen.
Dieser Artikel beschreibt den Weg von Bob D. Veloper, den er nimmt, um seine Software zu OSGI-fien.
Hello, my name is Thorsten Kamann. I am Software-Architect, Projectmanager and Coach at itemis. My main focus are lightweighted architectures and designs. Especially the Spring Framework, Groovy and Maven are tools/frameworks I prefer. Moreover I am Scrum-Master and using Scrum for my projects.