RSS

Category Archives: Software Entwicklung

Maven and the magic of profiles

Maven and the magic of profiles

POI4XPages has a module called poi.assembly. This module builds the final ZIP file which can be uploaded to the OpenNTF website. One step in the assembly is that the module downloads the source code direct from github. This step takes a lot of time, so each mvn clean build takes a lot of time, because the assembly line is also executed. Fortunately Maven has a concept called profiles. Maven let you define different profiles. In the POI4XPages case, I’ve built two different profiles, which contains different set of modules:

200Each profile has its own id tag. The default_no_assembly profile is activated by default. The <activation> markup let you activate also profile by defining environment variables.

I’ve now to different run configuration in my eclipse client. To run the default profile, I use the following:

201

But if I need the assembly profile, I use the following configuration:

202

Merry christmas!

 
Leave a comment

Posted by on December 24, 2014 in Architektur, Java, Maven, OpenNTF, POI4XPages, XPages

 

Tags:

Maven and XPages Plugin – From Scratch / Part III – The Testsuite

Part I has covered the building of the parent pom.xml, Part II was about the plugin and now in Part III we talk about the test suite. It’s fair to say that this part seems not to be very interesting, but in this Part we talk also about the why.

Why do I make the org.openntf.base.jaxb.dxl plugin?

The core purpose of the jaxb.dxl plugin is to convert a DXL export of a document, or of some design elements into an object based representation. Imagine this: You have a document with 2 rich text fields, one is a traditional rich text field and the other is mime based. For some reason (like transforming the content of the rich text field to a POI document or PDF document) there is an interest in the structure of this rich text field. A simple export as DXL and conversion to this java objects which are cascaded helps a lot.

Or you have this database, and you want to scan the content of all design element for a specific @Formula….. Export the database to DXL and convert it with jaxb to java object tree. And the scan the tree and analyse.

But why not start with the implementation, that sound better than testing!

Agree. Implementing is always better than writing test for the sake of writing tests. But after reading the book “Test Driven Developement” by Kent Beck, my understanding of test has changed. Tests explains what I want to do. Read the following test:

150

This test covers my user story “Reading a dxl-document.xml and convert it to a java object structure”. To make this test work, I’ve to writte a lot of implementation stuff, so stay tuned.

The next Maven module -> org.openntf.base.jaxb.dxl.testsuite

Again with the eclipse client:

151

select as packaging type “eclipse-test-plugin”:

152And we have a new project.

And now repeat the following steps, like you have done for the plugin in Part II

  1. New file called MANIFEST.MF into the folder META-INF
  2. New file called build.properties

Open the MANIFEST.MF File and go to the MANIFEST.MF Tab and enter the following stuff:

153The directive “Fragment-Host” makes this plugin to a fragment of org.openntf.base.jaxb.dxl. This is the best behavior to separate test and implementation in a plugin.

Open the build.properties File and go to the build.properties tab. Enter the following stuff:

154Now is a good moment to do a right-click on the project go to Plugin-Tools and execute “Update Classpath”

Open the MANIFEST.MF again and add the following dependency. This is needed that we can start writing our test class.

155

Let’s write the first Test:

156

We have also imported the dxl-db-test.xml and the dxl-document-test.xml. This documents were produced by a nice simple DXL Export.

To make the test compile (STEP 2 in TDD), we have to import the XSD File for domino_9_0_1 and convert it to classes. We use for this the JAXB import

JAXB Import of the domino xsd

160

Start with menu “New” and select the JAXB Classes from Schema Wizard

161

Select the target project for the import (yes our plugin)

162

If you do not have the domino_9_0_1.xsd in a project in your workspace, you can import it from your Notes/Data directory

163

Please specify carefully the package, where the classes should be produced. Existing classes will be overwritten (note to myself, move the DXLActivator Class to an other package or a level up)164

Select finish. The import will now generate a lot of classes.

You can now resolve the import of the Document object (yes its a …jaxb.dxl.Document object)

165

Time to finish the compilation problems in the test class.

Create the ConvertorFactor in the plugin (see the package that I select? It’s outside of the dxl package, because the content of this package was generated before).

166

We build also a dummy implementation of “convert2DocumentFromStream”. 167

Only one step, and we can test (with executing our runtime configuration)

We have to include the *.xml Files in our binary build. We open for this step the MANIFEST.MF and add the 2 files

168

Lets build the project by executing org.openntf.base clean install169

Oh yes the build fails! This is total ok at this point, because our test fails, and a failing test should stop our build!

Now its time to have some fun and finalize the plugin… The next Part will cover how to build the feature and the update site

If you wanna follow the project, please watch this repository on github.com https://github.com/guedeWebGate/org.openntf.base

 
Leave a comment

Posted by on December 23, 2014 in Architektur, Java, Maven, XPages

 

Tags: ,

A word about Maven

When I try to explain what Maven is, then I’m using often the following picture:

Maven is a factory building with a brilliant factory manager

Imagine this: There is this empty factory building and you walk with your construction plan to the office of the factory manager. You enter the room and the factory manager takes your construction plan. He read it and then he runs to tool storage. In a short time he has all the tools to build your construction taken from the storage and build a production line.

According to your plan, he has also hired the Q & A people, which let first run some unit tests directly in the production line and also some integration tests. At the end of the whole production line is also an assembly line to build the kit that is ready to ship.

… at this point you say. “mvn clean install” and the factory manager builds the software.

The other day, you come back to the factory building with a new construction plan. And the factory manager “cleans” the building and setup a new production line for you. If he finds some tools not in the storage, he orders the tools directly from *Maven Central*. But with the same passion and quality as the day before the manager tries to build the software.

What Maven can do for you depends on your construction plan and the tools that are available

Back from the analogy:

  • factory building -> maven
  • factory manager -> mvn
  • construction plan -> pom.xml
  • tool storage -> maven repository
  • tools -> maven plugins

Your construction plan contains all instruction about what builder should be used, how unit testing should work, and also how the assembly should run.

And it is not some kind of magic to build your own builder. I’ve built the headless designer integration, also a builder to build complete XPages Applications. It’s only hard work, nothing more and nothing less (and also a lot of fun 🙂 )

 
Leave a comment

Posted by on December 23, 2014 in Architektur, Maven

 

Tags:

Automated build with Jenkins / Some progress

This saturday was dedicated to do some tests with automated build and Jenkins / Maven. Jenkins is a brilliant tool to let a server do some automated tasks. Maven is the tool which delivers a configuration language to describe how to build something. The goal of maven is to do the same thing always in the same way. For me as a highly creative person is doing the same thing always in the same way, a creativity killer. So I think Maven will be my friend, because he is doing all the annoying jobs for me.

But Maven needs some clear instructions to do his stuff right. And like Eclipse needs Maven also a clear environment to work. Based on some research on the SBT Project and with the help of my friend Google, I figured out that I need eclipse.tycho to build plugins, features and update sites. I had prior to saturday already done the following steps:

  1. Setup of Jenkins
  2. Setup of Maven
  3. Setup of Git (for Grabbing the Project direct form the GitHub)

I started with the parent pom.xml file. This file contains all instructions and dependencies for all my plugin. The full file can be read here.

The important thing was to define the following repository:

<repositories>
<repository>
<id>notes</id>
<layout>p2</layout>
<url>${notes-platform}</url>
</repository>
</repositories>
 

As I sad. Maven needs a clear environment to build all the plugins and the eclipse.tycho needs a repository, where all the plugins of the domino runtime are located. Unfortunately such a repository is currently not available. So I had to create a p2 update site. This is in fact the same, as you define your eclipse development environment to use a specific target platform. See the following instruction, how I did that.

As you can see in the repository definition, I’ve nut used in the <url> tag a fix url. It’s a variable, which can be sent to Maven in the command line. This has the good impact that I can use my new update site also as a file resource. To build my POI4XPages Project, I had only to checkout all the code from git, switch to the feature/CIandMavenIntegration branch and go to the root directory of the project:

mvn clean install -Dnotes-platform=file:///D:/updatesite/site.p2/
did the job…. almost 🙂

The next problem was, that Maven uses the standard JDK as Java Environment to compile. So I toke the DominoProg/jvm folder and copied it to my build server. Then I changed the Java Home to my new jvm location. In the mean time, I had also done all the pom.xml files for the plugins. And then, the great moment happens:

buildDoneWhats next….

  • I will now make some documentation, how I’ve setup this also on my Jenkins Server
  • I’ve to think, what should I do with the result of the build (assembly)
  • Test the same with Notes Application (Martin Pradny has made some good progress)
  • And learn how to test after the build 🙂 (The next annoying thing….)

 

 
1 Comment

Posted by on April 7, 2014 in IBM, OpenNTF, Software Entwicklung

 

Tags: , ,

Offense, Defence and Special-Teams – Thats all you need in XPages!

I’m since the movie “Remember the Titans” a fan of football. A game which can only be won when the teamwork is really great. Because of lack opportunities in Switzerland, I enjoy the fact that each time when IBM Connect is, it is also Superbowl time. This time a great defence won over a good offense.

Inspired by an article of Paul Withers http://www.intec.co.uk/back-end-developers-are-from-mars-front-end-developer-are-from-venus/ I try to explain a good XPages Development Team with some Football words. And football fans forgive me, I’m a swiss guy and I will never have any chance to fit the knowledge of any football fan but….

Front-End Developers / UI Developers are the Offense!

They do the brilliant stuff which makes an application shiny and intuitive. They care about the first impression. They are interested in fast response from the backend, and love to do the most of the application logic (not the business logic) in the client. They measure loading time and render time. They are great in visualisation of data and love a clear interface.

Like in football, these guys makes the points!

Back-End Developers are the Defence!

They do the hard work 🙂 because they build the API for the Front-End Developers to process the data. They care about a robust domain-object-model and a stable API. They care about the transactions to the storage and the processing of the processes. They are more interested in brilliant algorithms than any kind of UI representations.

Like in football, they are responsible that you do not lose the ground.

Interfaces, Integration and Connections – The Special-Teams

Most applications are not islands. They are integrated in business processes and depends on other system. Here comes your Special-Teams to the game. You need these guys who have a deeper understanding of the interfaces and can talk with the “guys on the other side”.

Like in football, the Special-Teams can make the difference! The last point you need to win!

In what kind of developing are you good?

PS: Next Time I write maybe about RAD and Fast-Prototyping 😉

 

Tags: , ,

If you love IBM Domino – please learn Java, NOW!

It’s now over 3 years ago that I head to take over a project, which covers a critical business case. And it was one of my most painful experience ever. It ends up that each day I worked on that project, I took pain-killer. The request was quite simple: “Please rollback a Java agent to a LotusScript Agent”. But I’ve never seen such a painful implementation of Java. It was quite horrible and against all that I’ve learned about Java.

But Java is the most important language for the future of IBM Domino. If you’re an Application Developer please learn Java. And please learn it, like you would learn something new. Trow away all your knowledge about programing, you can reintroduce it later. Here my advises how you should start:

  1. Download Eclipse
  2. Read Head First Java
  3. Do all examples from HeadFirst Java
  4. Read Design Patterns from HeadFirst
  5. Read Effective Java from Joshua Bloch

“I have not the time for that” could be your answer. The most of us do not have the time for our own education, but only 30 minute per day will pay of in a short time. And reading this books has also a positive effect on coding with Lotus Script 🙂

“How do I bring that in my Domino / Notes Projects?” – This is one of the most critical part. But in fact it’s very easy. DECIDE and DO….

…. and there is webinar this Thursday January 16 from TLCC and Teamstudio which covers XPages and Java Development. I hope you will participate: http://www.tlcc.com/admin/tlccsite.nsf/pages/xpages-webinar

And when you feel your self fit with Java, it’s time for the best-selling developer book form IBM Press called Mastering XPages.

 

 

 
5 Comments

Posted by on January 12, 2014 in Design Pattern, Domino, Java, XPages

 

Tags: , ,

Paid per line programming code? – Why I love refactoring

Earlier this month I’ve started to read a new book called “Effective Java“. Jesse Gallagher mentioned this book as a “must read”. After my positive journey with reading “Design Pattern” (The head first edition) was it no question that I definitely read the sample of “Effective Java”. And yes, after reading the sample, I bought it. (To my colleges at WebGate: Yes be afraid – I have now a new book – Ho Ho Ho).

But reading a book without bring the new knowledge into the daily work is only the half of fun. So where to start? One of the first thing that has attracted me while reading “Effective Java” was the initialization of a Singleton.

A Singleton is an object, which exist only one time in specific context like a jvm, plugin or a XPages Application. The “normal” code to initialize a singleton is the following construct:

public class DocumentProcessor {
private static DocumentProcessor m_Processor;
private DocumentProcessor() {
}

public static DocumentProcessor getInstance() {
if (m_Processor == null) {
m_Processor = new DocumentProcessor();
}
return m_Processor;
}
}

One of the disadvantage of this code is, that this code is not “safe” if you try to create an instance of DocumentProcessor with Java Reflection and modifying the constructor. The other thing that I’m not loving is the amount of code, that I always have to write. But Joshua Bloch explains a simple way with enums to have a singleton look at this code:

public enum DocumentProcessor {
INSTANCE;
}

How smart is this! And not much code. I’m not paid per line of code I write, so it’s not touching my income :). Now you can access with DocumentProcessor.INSTANCE the singleton. It’s very cool, but what, if I have already a lots of Singleton? How can I make that my code will not break the code of other clients (classes which calls my API).

Remember all client classes call the current code (before refactoring) with WordProcessor.getInstance(). I can easy change this in my classes, but external clients which calls my WordProcessor will fail, when the do not have the WordProcessor.getInstance().

The following code is a “defensive” approach which makes this safe to all the other clients:

public enum DocumentProcessor {
INSTANCE;

/**
* gets the Instance of the DocumentProcessor.
*
* @deprecated -> Use DocumentProcessor.INSTANCE instead
*
* @return Instance of the DocumentProcessor
*/
@Deprecated
public static DocumentProcessor getInstance() {
return DocumentProcessor.INSTANCE;
}

This code is not only safe, it gives the other developer also an instruction, how to adapt the new API.

Will I now go to all my code (and it’s a lot of code I wrote each year) and change this all? And what about all the other cools stuff that I will learn while reading the book?

No, that’s not my approach. But I will challenge my code, myself and later the WebGate Development Team with the knowledge. Each code that I’ve to touch will also be reviewed with my new knowledge.

Have fun

Christian

 
1 Comment

Posted by on December 21, 2013 in Design Pattern, Domino, Java, XPages