Category Archives: Java

Java EE best practices

jeeSome time ago Adam Bien published on his blog the recording of the presentation delivered by him on the 33rd Degree Conference 2014 in Kraków. I was on the conference and this is the presentation I most liked. The exact title of the show is Rethinking Packaging, Modularization, Interfaces with Plain Java EE 7.

Continue reading

@Fixture to enhance fixtures in JUnit tests

fixtureIn this post I’d like to briefly present extended approach to provide fixtures into JUnit tests. JUnit already provides a possibility to execute methods right before/after test method and before/after test class. This standard functionality does not fulfill more sophisticated requirements. Thanks to @Beofre/@After annotations, for each test there is always executed exactly the same method. In a case in which we’d like to have a dedicated fixture code for each method the existing approach is not so convenient. I’ve developed fixture handling addition to JUnit framework with a possibility to define different fixture for each test.

Continue reading

Employing Java 8 in service layer

java8The purpose of this post is to take a look on lambda expressions introduced in Java SE 8 and using them in service layer making code more concise and sophisticated as well. The focus is put on services implementation. The CarService is introduced here as an example. Emphasis is put on Java8 lambda expressions, java.util.function package, especially on Predicate and Function. New features is a must in Java world. The possibilities do not bring new values in programming languages in general. They are already known from other languages. However, Java is a really general purpose programming language and it always takes time to introduce new features and ensuring production-ready platform. This post is code oriented. The most significant code snippets are provided throughout the content whereas the complete sources can be found on softexploration github.

Continue reading

Testing (in)finite loops with Java 8 enabled unit tests

java8This post is an extension to the Infinite loops, halting problem and FindBugs containing slightly refactored core code and prepared unit tests using Java SE 8 capabilities. The main extension point is the class LoopUtils which provides methods allowing to verify loops finiteness. Thanks to these methods it is possible to classify methods to finite and infinite. Finiteness is determined by a flexible defined timeout. When a single method’s execution time reaches value of timeout then an execution is classified as infinite. The new code takes advantages on few Java SE 8 new possibilities. The source code is in the same repository but in a dedicated java8enabled branch [1].

Continue reading

Java EE jee-bankapp code snippets released

jeeSome time ago when I was preparing for the Java EE 5 Business Component Developer exam I wrote few lines of code for exercise. I decided to make an order with the code to create a Java EE application. I believe it can bring an education value for those people who plan to attempt the exam or just want to learn JEE. I shared the Java EE application in github jee-bankapp. It is just named jee-bankapp because it implements bank account basic operations. This is not a full-working application to operate on an account. It is rather a skeleton which takes advantages of different JEE possibilities. Best practices are not always here followed whereas most emphasis is put on various approaches to JEE implementation.

There is created a separated page dedicated to this JEE app. You can expect that this page will be updated.

Local and remote EJB performance comparison – PART II

Collecting and analyzing results

In this post are executed EJB performance tests on the technical infrastructure designed in PART I. The aim of these tests is to perform local and remote calls between EJB components and collect information about time spent on these calls. In the beginning is given a brief introduction to a business interface then is elaborated a test scenario. The last part is a result presentation and an attempt to define final conclusion.

Continue reading

Local and remote EJB performance comparison – PART I

Technical infrastructure development

It is an obvious fact that local EJB calls are more efficient than remote. The aim here is to observe the difference between these calls in terms of time and resources consumption and finally provide observation results. In this post is given an overview and an explanation of a technical infrastructure with a goal to measure both local and remote EJB calls. The infrastructure consists of Java EE application suites and two managed servers running on Oracle WebLogic application server.

Continue reading