romix.chhttps://romixch.wordpress.com
My personal experiences with Java, Android and Linux.
Thu, 04 Oct 2018 21:08:04 +0000 en
hourly
1 http://wordpress.com/https://s0.wp.com/i/buttonw-com.pngromix.chhttps://romixch.wordpress.com
Correct Usage of Java 8 Optionalhttps://romixch.wordpress.com/2015/03/14/correct-usage-of-java-8-optional/
https://romixch.wordpress.com/2015/03/14/correct-usage-of-java-8-optional/#respondSat, 14 Mar 2015 21:33:16 +0000http://romixch.wordpress.com/?p=189Optional is a new type of Java 8. I saw it before with scala and was quite impressed. You know Tony Hoare’s “billion-dollar mistake”: the null reference. How many NullPointerExceptions have you yet? The type Optional wants to fix that. With Optional you won’t get any NullPointerExceptions anymore. But it is important to use Optional the right way. So don’t disappoint Hoare and take the chance to fix the billion-dollar mistake.

Return values

If you have a method with a result which sometimes may be empty, don’t return null. Even if you add a comment to your method. They will not always read it.

Avoid nested null checks

Sometimes you have several optional values in a row. Only if all optionals return a value, you want to return an http 200. Http 404 should be returned if somewhere in the chain there is no value. Again there is a complicated way:

I think it is much better than the nested if statements. If you use all Optionals the right way, your code stays readable and you can fix some of the “billion-dollar mistake”.

]]>https://romixch.wordpress.com/2015/03/14/correct-usage-of-java-8-optional/feed/0romanschallerWhy I don’t like IBM RTC as Source Control Managementhttps://romixch.wordpress.com/2015/03/10/why-i-dont-like-ibm-rtc-as-source-control-management/
https://romixch.wordpress.com/2015/03/10/why-i-dont-like-ibm-rtc-as-source-control-management/#commentsTue, 10 Mar 2015 17:29:42 +0000http://romixch.wordpress.com/?p=168In a previous post I already mentioned why the architecture of IBM RTC will never scale like git. As a developer you use an SCM and probably a project management tool on a daily basis. Even small annoying things make you feel bad and are time consuming. In this post I list some reasons why a move away from RTC to git will save real money for your organisation and make your work easier.

Maven integration

IBM RTC is not prepared to work with hierarchical structured projects. Maven is a widely used build and dependency management tool. In some cases it is important to have a hierarchical structure of your projects. Especially if you work with parent and child projects. Unfortunately RTC hinders you to check out parent and child projects in the same workspace. You can make it run but have to do some workarounds. There is also a good blog post about it by Mike MacDonagh (Working with Maven multi-module projects in RTC Jazz SCM with m2). He talks about RTC v3.x but it is basically the same as with v5.x.

There are no reasons why you couldn’t do it with git. git does not know anything about a project. It is not it’s business. RTC seams to manage things that it shouldn’t.

IDE integration

All current IDEs have git support in their basic versions. I don’t know of any Java-IDE which comes with IBM RTC integration out of the box. This means you have to install it manually. In case of Eclipse it means to download about 500 MB(!) of plugins. With every new version of Eclipse you have to wait for the new IBM plugin before you can use the new features. You got the same situation with Visual Studio, IntelliJ and NetBeans.

Comparing file versions between branches / streams

With git you can easily compare file versions from different releases in different branches. The history view shows all very clearly (image on the right side).

In IBM RTC you can’t do that. It is a recommendation from IBM to create a new stream for every release. At first sight it might look pretty but if you really work with it you see the disadvantages:

It is complicated to merge streams.

There is really no way to compare your file from one stream with another stream until you load both streams.

It is even impossible to see if the file changed in another branch.

Merging

Some people say the merging process of git was better than the one with IBM RTC. Maybe I will post a direct and detailed comparison between those two tools later.

Complicated commits / delivery

This is a quick comparison between the git way and the RTC way.

The git way

Either you use the console:

git pull
git commit -m 'your comment'
git push origin master

Or you use the awesome Git Staging view from Eclipse:

To commit and push there are only three steps:

Drag and drop the Files to your staging area

Add a comment

Click the Button “Commit and Push”

The RTC way

IBM RTC didn’t manage to create such a smooth view. Every action needs lots of server calls because you don’t have a local repository. They added a lot of asynchronous calls which lets your view update randomly. You sometimes wait for ages depending on how big your component, stream, change set or history is.

You need to do make at least five steps. It includes context menus, keyboard strokes and tree navigation:

check-in your changes (3 clicks)

Open the outgoing folder under your stream and find your newly created change set.

Either click on it once and press “F2” or wait a second and perform another click.

type your comment

Deliver (another 2 clicks)

Sometimes you have to answer some complicated questions about not checked-in changes.

Then some asynchronous tasks start running and mostly after a second or two everything is delivered.

Working offline

As you have no local repository every interaction with RTC requires a server call. It is not designed to work offline. Git always had that use case in mind.

Git ecosystem

Git is very popular, widely used and extendable with hooks and triggers. Therefore many open source projects emerged around it. Just a brief list:

github.com: “Social coding”. The most popular git repository. I social web ui with issue tracking and many other integrations.

gitblit: Github like open source server ready to host on your local infrastructure.

You need really good reasons to make a decision against this tools and for a proprietary SCM.

Licenses and hardware resources

IBM RTC is expensive and resource consuming. I am probably not allowed to tell you the price you have to pay. But believe me it is expensive. To keep RTC running you need:

RTC-Server on a heavy weight Websphere

An expensive database like DB/2 (or MSSQL or Oracle although not recommended)

Git needs:

A filesystem for your repositories

You will install another tool like those mentioned above if you need issue tracking or project management. They will mostly run with an apache2 or apache tomcat and a MySQL database server.

Other issues or feedback?

Let me know if you got further pros or cons of RTC or git. I will update this post as I stumble upon more points.

]]>https://romixch.wordpress.com/2015/03/10/why-i-dont-like-ibm-rtc-as-source-control-management/feed/9romanschallergit_branch_compareEgit-3.1-StagingViewrtc-commit2rtc-commit3rtc-commit4rtc-commit5How to add custom headers to Apache Camel Restlethttps://romixch.wordpress.com/2014/12/04/add-custom-header-to-apache-camel-restlet/
https://romixch.wordpress.com/2014/12/04/add-custom-header-to-apache-camel-restlet/#commentsThu, 04 Dec 2014 22:19:45 +0000http://romixch.wordpress.com/?p=141We use Apache Camel to glue services together. Camel Restlet can help you to translate a bean call into a REST call and vice versa. As we started using it we came to a need to add custom headers to a REST call. We thought it must be an easy job but it ended up digging deep into the Restlet source code to find a solution.

But first: Thanks to Lukas Eberli for his digging. He finally found the solution!

To be honest we didn’t read the documentation first. We just had a look at the API. I’m sure you work the same way. But what you get if you inspect the Camel interface ProducerTemplate is a massive amount of methods (more than 80!). OK, let’s just concentrate on the 10 (!) overloads of sendBodyAndHeaders – or should I use requestBodyAndHeaders? This two have both a parameter headers of the type Map. But don’t think you could just put your own headers into this map. That won’t work. Your headers will just disappear somewhere deep in Restlets code. The only possibility to put your own headers into the http request is this:

Unfortunately we could not find any documentation pointing to this. Only digging into the code of Restlet reveals this features. I am also disappointed of the giant interface ProducerTemplate. The lack of types puts you into type casting everything. I thought apache guys would do better than this. There is obviously a lot to improve…

]]>https://romixch.wordpress.com/2014/12/04/add-custom-header-to-apache-camel-restlet/feed/1romanschaller@font-face not working with Internet Explorer and HTTP-Header Pragma=no-cachehttps://romixch.wordpress.com/2014/10/03/font-face-not-working-with-internet-explorer-and-http-header-pragmano-cache/
https://romixch.wordpress.com/2014/10/03/font-face-not-working-with-internet-explorer-and-http-header-pragmano-cache/#commentsFri, 03 Oct 2014 21:28:17 +0000http://romixch.wordpress.com/?p=116We recently spent a whole day trying to fix an Internet Explorer related bug. If you got the same problem you can find our solution here.

Our phenomenon

We included a special font with the css property @font-face. That worked quite well for all browsers. Until we used SSL for HTTP encryption. IE could not load the fonts anymore. By examining the HTTPS traffic with Fiddler we finally found out that the HTTP header “pragma=no-cache” did the difference. So if you want to user @font-face and deliver your site with HTTPS you must never ever set the HTTP header “pragma=no-cache”. As soon as we got rid of this HTTP header, IE behaved the way it did before.

Edit 2014-10-04:

There are others who report that the headers “Vary” or “Cache-Control=no-cache” confused IE.

How we fixed the problem

In our case we use following stack:

Wildfly 8.1 as application server

Undertow 1.1 as web server

BASIC authentication

Unfortunately Undertow 1.1 introduced the feature to disable caching for secured resources (commit). Since then all resources are delivered with pragma=no-cache which are secured with BASIC authentication. So since we updated to Undertow 1.1 IE did not work properly anymore. The only way to fix it was not to secure the fonts. We could not find any way to overrule the new default behaviour of Undertow 1.1.

Still upset about IE

We are still upset about the behaviour of the Internet Explorer! Why on earth do they always manage to screw things up like that? If you watch the communication between IE and your server you see following:

IE requests the font from the server.

As soon as the server starts delivering the resource, IE closes the connection. Probably because it suddenly detects that it should get the resource from cache.

This behaviour apparently destroys the cache content. So IE can’t access the font.

IE tries to retrieve the next declared font but with the same wrong pattern.

Edit 2015-04-21:

Sorry for the bad news. They didn’t fix it. They just changed status to “Won’t fix” and “Closed”. Although there are other people reporting the same issue.

]]>https://romixch.wordpress.com/2014/10/03/font-face-not-working-with-internet-explorer-and-http-header-pragmano-cache/feed/2romanschallerWhy IBM RTC will never scale like GIThttps://romixch.wordpress.com/2014/06/01/why-ibm-rtc-will-never-scale-like-git/
https://romixch.wordpress.com/2014/06/01/why-ibm-rtc-will-never-scale-like-git/#commentsSun, 01 Jun 2014 06:33:38 +0000http://romixch.wordpress.com/?p=2On my personal and open source projects I work for years with GIT. Some months ago my employer switched from CVS to IBM RTC (Rational Team Concert). We immediately got performance issues. I explain here why I think that RTC will never be as fast as GIT and why you should not use IBM RTC.

Scaling strategies

In order to scale a service you can do two things: Scale up and scale out. Scaling up means putting more memory and CPU to your single machine and hope that it gets faster. Scaling out means using more machines and distribute work and load. Scaling up is easier to achieve, as it has less impact to the architecture of a piece of software than scaling out. Especially for a software like RTC which is designed as a single process service.

While RTC stores all the data in one single database, it can only scale up. GIT is designed to work entirely without an online server. Every client has enough data to do most of the tasks locally. Putting it this way GIT is able to massively scale out.

Why RTC is lame

Lets have a look at the most common tasks people do with an SCM. This will illustrate how much the RTC Server is stressed with superfluous requests.

Most executed tasks

Viewing file history (1)

Comparing versions (2)

Committing local changes (3)

Less executed tasks

Pulling the changes from others (4)

Merging (5)

Publishing my changes to others (6)

Comparing RTC and GIT

With RTC all those tasks need a running and connected Server. So you can not even see the commit history of a file without RTC online. In GIT you only need a remote repository if you want to get the changes from others or publish your owns. And this is reasonable. There is no need for communication for all other tasks. Because everything else is static and can be distributed.

I am really confused why IBM chose such a design. It implies lots of requests to the server. They have to deal with massive parallelisation problems. At the end they will never catch up to a performance of git or mercurial. Also think about the impact of server maintenance or outages. With RTC it hurts to reboot the server. Developers don’t like it if you take away their SCM.

If you choose RTC as your SCM you should be aware of this facts. If you only have about 50 developers you will not run into performance issues. For 200 or more developers you probably won’t like it.

Way out

Many developers are looking for a way to migrate from RTC to GIT. Now there is a project on GitHub which can do this for you. It is still under construction but help is appreciated:

Credits

]]>https://romixch.wordpress.com/2014/06/01/why-ibm-rtc-will-never-scale-like-git/feed/1RTCvsGITromanschallerScaleUpScaleOutInstall Citrix ICA-Client on Ubuntu 13.10https://romixch.wordpress.com/2014/05/17/install-citrix-ica-client-on-ubuntu-13-10/
https://romixch.wordpress.com/2014/05/17/install-citrix-ica-client-on-ubuntu-13-10/#respondSat, 17 May 2014 12:12:07 +0000http://romixch.wordpress.com/?p=81I use Citrix to remote login to my windows computer at work. That works quite well once I installed the ICA-Client. But unfortunately the debian packages from Citrix are broken and some certificates are missing. I had to do following steps to fix it.

]]>https://romixch.wordpress.com/2014/05/17/install-citrix-ica-client-on-ubuntu-13-10/feed/0romanschallerCreate custom launchers for my eclipse installationshttps://romixch.wordpress.com/2014/05/10/create-custom-launchers-for-my-eclipse-installations/
https://romixch.wordpress.com/2014/05/10/create-custom-launchers-for-my-eclipse-installations/#respondSat, 10 May 2014 17:14:25 +0000http://romixch.wordpress.com/?p=28Launchers in linux are *.desktop files which describe an startable desktop application. Desktop environments like KDE, Gnome or Xfce use those files to create their start menus. Also my favorite application starter Kupfer uses the same information source. Most of the applications are installed using apt-get from a distribution like Ubuntu. They always install their own launchers for all users on that machine. But if you install for example eclipse distributions in your home directory, you have to create the .desktop files on your own. To get the best result I do it like this:

To add a launcher for Play eclipse IDE I created the file ~/.local/share/applications/Eclipse_Play.desktop with following content:

]]>https://romixch.wordpress.com/2014/05/10/create-custom-launchers-for-my-eclipse-installations/feed/0romanschallerPlayInKupferPlayInLauncherCreate PhoneGap app and run it on your smartphonehttps://romixch.wordpress.com/2014/05/10/create-phonegap-app-and-run-it-on-your-smartphone/
https://romixch.wordpress.com/2014/05/10/create-phonegap-app-and-run-it-on-your-smartphone/#respondSat, 10 May 2014 14:37:49 +0000http://romixch.wordpress.com/?p=6There are a couple of things you have to do to start developing a PhoneGap app on your Linux machine. The PhoneGap documentation at http://phonegap.com/install/ looks very easy. But it does not tell you how to install the prerequisites nor does it tell how to install the platform SDK for Androd or how to run the app on your device. So I thought I write down all the things I did.

Install NodeJS

The package nodejs contains the webserver itself.nodejs-legacy only adds a link to your /usr/local.
Package npm is the package manager for NodeJS. We will need it to install PhoneGap.

Install PhoneGap

Now you can run the first step from PhoneGap’s install guide:

$ sudo npm install -g phonegap

Create your app

Typing following lines will create your first app.

$ phonegap create my-app
$ cd my-app

As you can see your are now in your app folder. If you follow the PhoneGap documentation you would now just run "$ phonegap run android". But this will leverage your frustration as you just get nasty error messages. What do you miss? You still need to install a platform SDK (for example Android), configure it and tell your app how to use this SDK. Just follow this tutorial.

Install Android SDK

I installed the SDK without ADT. The ADT (Android Development Tools) contains the SDK and a full Eclipse IDE. But we don’t need the IDE as we want to use PhoneGap and don’t create native apps for each platform. It is a bit tricky to just catch the SDK. Open this site: http://developer.android.com/sdk/index.html#ExistingIDE. Click the link “Download for other platforms” at the bottom of the page. Under “SDK Tools Only” you can see something like android-sdk_r22.6.2-linux.tgz. That is what you need. Download it and unpack it in a useful folder. For example beside your app.

You’re not done yet. You have only an SDK without any APIs of any Android version. To download them you can start the Android SDK Manager:

$ cd <android-sdk-folder>
$ ./tools/android

This will start the manager. Here you can download and install the real APIs in each version. See what I installed:

As new android APIs will appear you can always return to this manager and update your SDK.

Configure platforms

You can now move to your app directory and tell PhoneGap to build for Androd:

$ phonegap platform add android

Build your app

You’re now almost finished with configuring your machine. Almost… Just one more thing. For PhoneGap to find your SDK you need to modify your path variable:

Hint: Put this two lines to your .bashrc so you don’t have to type it all the time.

Now we are ready to build the app:

$ phonegap build android

If you’re lucky you get lots of output with this lines at the end:

BUILD SUCCESSFUL
Total time: 5 seconds

At platforms/android/ant-build you will find an .apk file which you can install on your device.

Run the app on your device

But at the end you would like to test the app quickly on your physical device. You can do this using PhoneGap and the Android adb (Android Debug Bridge). On linux the only thing you need is to create a udev file: