Reficio™ - Reestablish your software!

Generic ESB Monitoring Architecture Compliant with JBI

I finally managed to publish my master thesis titled “Generic ESB Monitoring Architecture Compliant with JBI”. It is quite old now, but since I have just resurrected my blog it is a perfect topic to start with. Maybe somebody will still find it interesting – it was quite successful in a few IT contests. You can download it here: LINK. Here is the abstract:

Currently, the significance of the Enterprise Application Integration (EAI) in the field of Service Oriented Architecture (SOA) is gradually increasing. The quality of the integration patterns is constantly ameliorating. Progressive integration solutions are designed, published and offered to the community by most of the prominent IT vendors. Today, Enterprise Service Bus (ESB) is one of the most meaningful solutions and top-selling products on the market of the integration services. There is, however, no agreed-upon definition of what an ESB actually is. Java Business Integration (JBI) presents an approach to standardizing the ESB pattern by specifying a concrete, well-defined and Java-centric model of ESB. The first version of the specification does not mention any kind of monitoring solution for JBI, which is the vital drawback of the concept. Increasing complexity of the SOA-oriented IT systems implies higher importance of the selective monitoring, which allows to mitigate the problem of the management of software infrastructure. The main goal of the thesis is to design and implement a system which adds a monitoring and management logic to a Java Business Integration container in such a way that the logic is fully transparent and compliant with the JBI specification and allows to gather, process and expose sophisticated information regarding the qualitative parameters and operational reliability of the JBI container. The design of the system was performed in accordance with the Experimental Driven Development (EDD) methodology. At the beginning a statement of functional and non-functional requirements was created. Afterwards, an analysis and prototype construction were performed. At the end, the prototype was meticulously examined during a set of experiments which were conducted, in order to provide best-fitting architectural solutions which are compliant with the aforementioned requirements. Finally, it was possible to design and implement functional and innovative realization of the JBI monitoring solution called GlassBus. Performance test have proofed that the average JBI performance deterioration, while being monitored, is not higher than 20 percent. Not only did the results of the work described in this thesis fully satisfy the authors, but they also amazed the academic supervisor. Progressive architectural solutions introduced in GlassBus ensure its forthcoming success.

Here’s the link to the Scribd online reader: Scribd

Hardcore Java: Quine and Backward quine

Browsing through old university folders I found interesting pieces of code that I wrote some time ago for a contest at IBM. Have you ever heard of a quine? If not, here’s the definition by Wikipedia:

In computing, a quine is a computer program which produces a copy of its own source code as its only output. (…). For amusement, programmers sometimes attempt to develop the shortest possible quine in any given programming language.

Now, when everything is clear – let’s amuse ourselves and write a shortest possibile quine in Java :)
After some experimenting, I ended up with a Java code which consisted of 135 characters (the code is wrapped for better readability):

That’s all you think? – no class, no main method? Yes, but let’s make some test in order to prove the correctness of the presented approach (note: you won’t run it in eclipse – you have to use command line) :

OK, but grouches may say that it is an old trick – and that’s actually true. You can google much stuff concerning that problem. So, let’s raise the bar and write a shortest backward quine – a program which will output its content backwardly. I haven’t found a word about it on the Internet. My version contains 191 characters:

Is your version shorter :) ? Groovy version is gonna be much briefer – I will code it and post soon…

E-point prize for the best thesis is mine :)

I am really excited to inform that the master thesis written by Marek and me was awarded for the second time! Today, our dissertation titled “Generic ESB Monitoring Architecture Compliant with JBI” has received the e-point prize for the best thesis on JEE Internet solutions. The official results are published on the e-point site (in Polish). See the screenshot attached below:

Few months earlier it had been also awarded by the Polish Information Processing Society – I blogged about it HERE. On that occasion, I would like to thank Marek for great and successful cooperation! As far as I know it was the last contest to which we submitted our dissertation so in the nearest future I will publish its content in the Internet. Stay tunned :)

Mission Impossible with Kirk Pepperdine

Last Tuesday Kirk Pepperdine gave a talk at Warszawa Java User Group. Kirk is a Real Guru in the Java world so I was truly excited to meet him. He has been working in high performance and distributed computing for nearly 20 years. What is more, in 2006 Kirk was recognized by Sun Microsystems as a Java Champion recipient for his contributions to the Java community.

“Performance Tuning with Cheap Drink and Poor Tools” was the topic of the session. At the beginning participants got a cheap food (pizza) and a cheap drink (coke) – so everybody was in high spirits :) You can expect everything when you attend a JUG meeting. Sometimes people present something you actually got acquainted with very well, sometimes you don’t know the subject, but Wikipedia, Google and Eclipse would give you the same answers without leaving your home. Some sessions are, however, sensational – and Kirk’s talk was really that case!

At first, Kirk put emphasis on the fact that there is no taxonomy regarding performance tuning. The main problem is that very often developers do not realize that the process of giving a performance boost to an application is much different than the development itself. Kirk made a joke that many companies tune their application in accordance with the following rule:

“We don’t know where we are going, but we are having a great time” .

According to the speaker, issues concerning performance should be take into consideration at every stage of the project life-cycle. Could we disagree with that? I don’t think so, but why it is neglected most of the time…?

Later, Kirk presented a sample application which encompassed the most common performance bottlenecks. The audience was supposed to tune it on the spot. It was really funny as this simple exercise showed the main problem right away! Developers are used to work with the code – we can even say that we love the code :) So, what do we actually do to solve potential performance problems? – we look into the code! According to Kirk it is the last thing that should be done. However, to cut the long story short, here are some general rules presented by Kirk:

  • When is the performance bad? – When users do complain!
  • Everything matters – tune application in exactly the same hardware/software environment as the production environment.
  • DON’T LOOK INTO THE CODE unless you really know where you wanna look.
  • Find the DC (dominating consumer): application, jvm, os, hardware.
  • If CPU kernel time is higher than 10% – application is the DC.
  • Use poor tools – such as: jps, jstack, jvisualvm – to locate the piece of code that is responsible for the degradation of performance. THEN look into the code to modify it.
  • Using a profiler is the last step
  • Don’t shoot wild – don’t do anything blindfold – making your code look beautiful won’t help!

Do you agree with that? YES, YES, YES ;)

Spring integration in jBPM 4

When I was supposed to use the fourth version of jBPM for the first time I couldn’t find a sufficient documentation concerning the integration with Spring. I have also seen that there are many questions regarding that issue on forums or discussion lists. Despite the fact that there are some entries on Andries Inzé Blog or in jBPM official documentation which actually outline that problem I felt a lack of a sample project archetype. Something that I could download, build and take the first shot right away!

After few months I found some time to make this dream come true :) as I have created a sample Spring+jBPM+Maven2 project. All details of the integration are described in my developers notebook under the entry: Spring integration in jBPM 4. The article briefly shows how to set up:

  • Maven Project Configuration [pom.xml]
  • Logging configuration [log4j.xml]
  • jBPM Configuration [jbpm.cfg.xml]
  • and Spring Configuration [applicationContext.xml]

It also outlines how to write and execute a sample test case.

That is all what you need to start playing with jPBM in your favorite IDE(A)! More on this is comming soon! Stay tunned!

JavaCamp #1 in Krakow

Last weekend I returned to Krakow to take part in the Java Camp meeting. I decided to travel by car, which was actually an unfortunate decision. 300km, 2 traffic jams, 6 hours of driving – all these facts perfectly summarize my journey :(   The meeting was organized by PJUG (Polish Java User Group). It took place at AGH University of Science and Technology which I have graduated from, thus it was really nice to return there. The agenda was interesting, especially when you consider the fact that I was one of the speakers :)

The meeting began with the session called “Developing Rich Web Applications in JBoss RichFaces” led by Marcin Nowrot. Marcin presented the overview of the newest RichFaces (3.3) components by showing a sample demo application. I have to admit that this session wasn’t really beneficial for me since it was more like a RichFaces advert. I expected an objective review which would summarize all the pros and cons of the library, so all in all, I was disappointed. I also didn’t like the fact that hardly no code was shown. What is more, Marcin’s application was similar to the Exadel Demo so everybody could do the same test at home. The last thing I would like to mention is the speech code used by Marcin. Addressing people by sir or madame is not a common behavior on JUG meetings – it built a wall between Marcin and the audience. But I would like to emphasize the fact that it is only my humble opinion – I am sure that there were many people that enjoyed the session.

Afterwards, I presented jBPM in action! The main goal of my session was to present the most important advantages of leveraging jBPM capabilities in an ordinary JEE application. I also wanted to popularize it a bit since in Poland it is rather unknown. It was confirmed by the fact that only two people raised their hands after I asked how many of them had used any of BPM frameworks before (there was about 60-80 people present). After outlining the basic concepts of BPM I went into the details of jBPM. I presented the wide variety of jBPM tools: ant installer, web console, eclipse plugin and signavio editor. Later, I showed two examples which explained how to integrate jBPM with EJB and Spring. In my opinion people were a little bit surprised that it can be done so easily. Yeah, jBPM is lightweight! Finally, I presented a sample business application implemented in… Grails. It was supposed to automate the process regarding JUG meeting’s organization. Some methods were implemented in two ways: with and without jBPM. First of all I showed the version which didn’t use jBPM – business rules and the logic of the process were hard-coded. Later I showed the version which was implemented with the usage of jBPM. Then I explained all the advantages and disadvantages of such approach. According to the feedback that I received my presentation wasn’t so bad but I don’t want to rate myself… :)

Later, we had the possibility to get acquainted with JavaFX. Andrzej Grzesik introduced the concept of RIA. It is the acronym of Rich Internet Application, but you can also find different kind of RIAs on the Internet :) The presentation was cool. Andrzej shared his experience concerning JavaFX giving an objective view of it’s current status and stability. JavaFX and RIA do not belong to my current area of interest, but it was cool to deepen my knowledge in that field.

Next, there was a long awaited pizza break! It was a great opportunity to chat with other developers and to exchange opinions concerning the sessions which were already held. Pizza was a little bit to spicy :D so we have drunk all the coke left to stay alive, but who cares – it was great!

The last session that I attended was the “Matlab Java Injection” presented by Miroslav Kopecky from Prague. It was a really good presentation! Mirek showed how to leverage Matlab’s capabilities directly in Java applications. He explained step-by-step how to set up the environment, write Matlab functions encompassed by “m” files, import them to Java application and finally use as Java classes. Mirek also presented a wide variety of examples which enabled us to deeply understand all the covered aspects. My favorite example was the JSP servlet showing a javascript plot generated by Matlab. I was really amazed by the fact that Matlab provides such sophisticated Java integration mechanisms. I have even promised myself to write a sample Java-Matlab application, if I will find enough time…

Summing up, it was really great to visit Krakow for the second time this autumn. I met new people, learned new things and gained a priceless practical experience as a speaker. What more could I ask for?

How to drop all indexes on an Oracle table

Few days ago I needed to delete all indexes on an Oracle table. After some scripting I ended up with the following one:

It drops all indexes which are not referenced by the constraints of the table. It is essential, because if the table has a constraint created using the specified index the drop statement will fail. If you want to use the script just replace the ‘my_table’ string with the appropriate table name.

COOLuary 2009 – a real belter of an unconference

I spent an additional day in Cracow to participate in the third edition of COOLuary organized by Grzegorz Duda and his Developer’s World. I was really excited to take part in it, since I have heard that the idea of unconference is gaining popularity nowadays.

The unconference consisted of four panel discussions (50 minutes each). Grails, BPM, Terracotta, JMS, proxying are only some examples of topics mentioned during the sessions. What I enjoyed most was the fact that the discussions were informal and all participants had the possibility to change the topic when the conversation headed toward an unintended direction. I also liked the idea of the conference being a purely face-to-face, developer-to-developer sharing of experience – without a trace of fuzz or evangelism!

The most interesting part, however, was the hands-together session with Mark Richards. It lasted three hours and I enjoyed every single minute of it! Mark spun a yarn about some of his most interesting JEE projects and problems related to them. First of all, we discussed all pros and cons of distributed transactions (JSR-95 and compensation frameworks). It is a topic where I am currently performing R&D, so I really absorbed every aspect of the session. Later we moved onto business locks, JMS byte messaging and Web-Services.
The three hours spent with Mark was the best time I have had during JDD and COOLuary and I would even come to Cracow if it were the only session that I could attend. It was so great that I really hope to be able to take part in No Fluff Just Stuff conferences to see Mark again… If you want to see Mark in action watch this movie on InfoQ .

Java Developer’s Day 2009 in Krakow

During last weekend I had the possibility to attend the Java Developer’s Day 2009 in Krakow (link) . It was the third time that I took part in this conference (also in 2006, 2007). It was a great event with a keynote speech performed by Mark Richards – one of my idols! Not only is Mark a great speaker, but also a well-educated and experienced computer scientist, thus it was a real pleasure to attend his sessions. Generally, I attended the following ones:

  • “Pimp up your domain model with jBPM” (Tom Baeyens and Joram Barrez)
    The session was really good, however Tom and Joram have only presented the overview of features encompassed by jBPM so it wasn’t anything that could attract me. I’ve been using jBPM for almost one year right now so I would rather be interested in sophisticated usage scenarios. However, I admire Tom and Joram for the last example which outlined how to set up the whole jBPM environment in 60 seconds – it was really a great show!
  • “The Art of Messaging” (keynote, Mark Richards)
    What a session it was! Mark presented a large part of knowledge regarding messaging and JMS in particular. I especially liked the results of the benchmarks performed in different messaging scenarios. The jokes were also great. I hope to see Mark back in Poland soon…
  • “Exception Handling in the Systems Built with JEE” (Tomasz Skutnik)
    Session was really interesting, however the speaker delivered some controversial statements regarding checked exceptions with which I could not agree. Tomasz also encouraged us to implement proprietary code for proper resource management. It is really concerning since these features are already implemented in frameworks such as Spring – so I encourage him to get acquainted with that…
  • “Asynchronous, Concurrent and Distributed Processing in Java EE…” (Waldemar Kot)
    The session was good. Earlier, I have never heard about the CommonJ Work Manager API – the “de facto” standard of manual thread management in JEE. One thing that annoyed me a little bit was fact that Waldi kept his hands in pockets almost all the time during the speech – in my opinion it was inappropriate. However, from the technical point of view the session was cool.
  • “Effective Code Review for Agile Java Developers” (Wojciech Seliga)
    Great presentation of the Atlassian and JetBrains products performed by a guy who was experienced in TDD and Agile. Code reviews and pair-programming were the focal points of this talk. It is really sad that I can’t see a way to use these methodologies in my company in the forthcoming decade…
  • “Common Anti-patterns and Ways to Avoid Them (Mark Richards)”
    Interesting session during which Mark presented some most popular anti-patterns. Excellent speech!
  • “The Architecture of Applications Based on DDD that use Seam and Flex” (Slawomir Sobotka)
    I had been checking my emails during this session, so I can say nothing about it… I was also pretty tired at that time.
  • “Resource-Oriented Architecture (ROA) and REST” (Scott Davis)
    Scott is a real Groovy&Grails enthusiast and it was noticeable from the very first seconds of his talk. Groovy examples were great – especially that one regarding REST service invocation implemented in one line. From the technical point of view this session was quite poor, as Scott presented a lot of evangelism. However, considering the fact that it was the last session, it was a great finish of the conference. I wasn’t disappointed…

To sum up. JDD09 was a great event! After the conference I had the possibility to meet my friends from studies – with whom I (after)partied in Jazz Rock! See you all next year!

Splitting and Tokenizing Strings in Java

There are at least two ways of tokenizing Strings in Java. Simple examples work like a charm, but it is very easy to encounter some weird or unintuitive behavior while experimenting with complex regexes or some corner cases. Thus, in order to gain deeper knowledge, I am gonna dive into the implementations details and present some general rules of string tokenizing in Java.

How to tokenize a String:

To pass for example SCJP a programmer has to predict the exact result of the split method invocation (including the empty matches – what causes most of the problems). I will now present general rules which could probably help in systematizing the knowledge regarding the String tokenization.

The rules are organized in such a way, that the preceding rules have a bigger priority that the following rules, so you should follow the list until one of the rules matches the situation you are actually examining:

1.) If the regex expression does not match any part of the input:

  • Matcher: returns exactly one element – namely the given String
  • Scanner: returns exactly one element – namely the given String

Example:

  • Matcher: “James Bond”.split(“MI6″, 0) == ["James Bond"]
  • Scanner: new Scanner(“James Bond”).useDelimiter(“MI6″).next() == “James Bond”;

2.) When the given String is empty:

  • Matcher: returns exactly one empty match [""]
  • Scanner: the result is empty []

Example:

  • Matcher: “”.split(“MI6″, 0) = [""]
  • Scanner: new Scanner(“”).useDelimiter(“MI6″).hasNext() == false;

3.) When the delimiter regex is empty:

  • Matcher (index == 0): Tokenized characters of the given String preceded by one empty String
  • Matcher (index < 0): Tokenized characters of the given String preceded and followed by one empty String
  • Scanner: Tokenized characters of the given String

Example:

  • Matcher (index == 0): “007″.split(“”, 0) = ["", "0", "0", "7"]
  • Matcher (index < 0): "007".split("", -1) = ["", "0", "0", "7", ""]
  • Scanner: Scanner s = new Scanner(“”).useDelimiter(“MI6″); s.next() = “0″, s.next() = “0″, s.next() = “7″, s.hasNext() = false;

The last thing I want to mention are the “empty-matches” or “zero-length” matches:

  • Matcher (index == 0): Returns: leading and inner “empty-matches” – BUT IF ALL MATCHES ARE EMPTY – the result set is empty
  • Matcher (index < 0): Returns: leading, inner and trailing "empty-matches"
  • Scanner: Returns: only inner “empty-matches”

Example:

  • Matcher (index == 0): “::”.split(“:”, 0) = []
  • Matcher (index < 0): "::".split(":", -1) = ["", "", ""]
  • Matcher (index == 0): “:1::2::”.split(“:”, 0) = ["" , "1", "", "2"]
  • Matcher (index < 0): ":1::2::".split(":", -1) = ["" , "1", "", "2", "", ""]
  • Scanner: Scanner s = new Scanner(“::”).useDelimiter(“:”); s.next() = “”, s.hasNext() = false;

Hope this helps!