Java Articles

WebSphere Liberty Profile Webinar – Wednesday, May 28, 2PM Eastern

Although WebSphere Application Server is one of the most robust Java Enterprise Application Servers for deployment of mission critical applications, it is not always that easy to use in development. Often we see clients who deploy to WebSphere in production using Tomcat or some other server to test in development because it is "easier". The complaint is that the full WebSphere Application Server takes too long to start or redeploy applications and is not intuitive to configure for developers. To address these issues, IBM has created the WebSphere "Liberty Profile" server. This is a lightweight server, certified for Java EE 6, that starts much faster and is easier to configure.

 

In this webinar we will look at the features of the WebSphere Liberty Profile server, how it compares to the "full" WebSphere Application Server, and how you can use it to simplify the development and testing of Java EE applications. We will even show that with version 8.5.5 of the WebSphere Liberty Profile there are some intriguing new features that would even let you run the server as part of a cluster and use it for some production deployment scenarios. We will also highlight the use of FREE Eclipse development tools that are available since the cost of development tools for WebSphere Application Server has also been historically an issue.

 

Register for the webinar here

No Comments

Time for Spring …. 4!

On the first day of Spring 2014 (even though some of you may feel winter will never end) I think it is a good time to talk about what is going on with the Spring Java Framework.

Over the past year there have been some big things going on with Spring, probably the chief among them the move in April 2013 to place Spring under the control of the new company GoPivotal.  This spin-off from VMware, along with an investment from GE, is meant to support a new breed of applications where cloud and big data are a given not some afterthought on a platform not built for it.  With the ever-expanding broad ecosystem of Spring-related projects, in addition to the immense popularity of the core Spring Framework, Spring seems a natural fit as an application framework to support this.  Probably the most immediate change for those already using the Spring Framework day to day though was that there was a new web site to get Spring documentation, downloads, resources, etc:

http://spring.io/

Fast forward to the end of 2013 and we had the release of the Spring 4 Framework in December.  The release of Spring 4 fits nicely with the desire to support more modern applications as support for many new technologies has been added.  Among those are included support for Java EE 6 & 7, Java SE 8 (which was just released) and more recent versions of many optional third party libraries.  Spring 4 is also a new foundation for the expanding list of Spring-related projects, the following just a few key ones to mention now:

  • Spring Boot – Jumpstart on rapid development of Spring applications
  • Spring Data – An umbrella project with a number of useful utilities for popular data access technologies like MongoDB, Hadoop, and JPA
  • Spring XD – Unified system for big data ingestion, analytics, batch processing and export
  • Spring Security – Application security framework
  • Spring Mobile & Spring for Android – Support for developing mobile applications
  • Spring Integration – Implementation of well-known enterprise integration patterns
  • Spring Batch – Comprehensive batch application framework
  • and several more

As you start to look at the Spring 4 Framework and what it can do for you, we at Web Age Solutions would like to assist you in that discovery.  Below are some links to a webinar we will be giving next week on the changes in the Spring 4 release and a link to the new training category we have posted with Spring 4 training classes.

WEBINAR – What’s new in Spring 4, Thursday March 27th 1:30-2:30 PM Eastern

TRAINING CLASSES – Spring 4 Framework Training Classes

Here’s to hoping that your wait for using Spring 4 will not be as long as the wait for Spring 2014 has seemed!

,

No Comments

Building a Bi-Directional Event Bus with the Google Guava

The Google Guava is an open-source project released under Apache License 2.0 (a very permissive one) that bundles several core Java libraries used by Google software engineers in their projects.  The Guava library is packed with powerful utilities and efficient helper classes that aim at making the lives of Java programmers easier and their work more productive.

Generally, Guava offers a more facile way to interact with some of the existing Java language constructs as well as fills in a number of gaps that exist in the language.

For example, shown below is a piece of code that you need to write in order to create a dynamic proxy for some interface Foo using the regular Java constructs:

Foo foo = (Foo) Proxy.newProxyInstance(
Foo.class.getClassLoader(), new Class<?>[] {Foo.class}, handler);

While for some it may be perfectly fine to write code like this and they do write code this way as they believe that “Where there’s muck there’s brass”, others would argue that there is a great deal of unnecessary noise in the above code where after all the pain of getting your ducks in a row in the newProxyInstance() method, you are still forced to do downcasting to Foo.

In the Hakuna Matata world of Guava, the ugly-looking legacy Java Proxy construct (circa Java 1.3) gets hidden under the generified user-friendly API:

Foo fu = Reflection.newProxy(Foo.class, handler);

This Guava construct also enforces type-safety at design-time making casting superfluous as the type of the Lvalue (fu) is inferred from the first parameter passed to the newProxy()method (Foo.class).

That’s what SpringSource has always been so good at: shielding developers from the internal complexity of various systems with their user-friendly API.  They treat developers as valuable clients of their APIs.

Read the rest of this entry »

No Comments

Testing Cordova Hybrid Apps in Worklight

Recently I worked on a project that introduced me to IBM® Worklight® mobile application platform. Among other things, I was pleasantly surprised at the price tag of the Developer Edition of this product: it is free. The Developer Edition comes with an Eclipse-based IDE called the Worklight Studio which offers support for authoring the client-side of your mobile web, hybrid and native apps as well as developing server-side components called adapters.

The Worklight Studio comes with a web application called the Mobile Browser Simulator that can help you with developing and testing your hybrid applications created using Apache Cordova framework. The Mobile Browser Simulator offers you a suite of visual controls for simulating a variety of native bridge APIs to such native device capabilities as accelerometer, camera, compass, file system, device info, contacts database, etc., without the need to run your apps directly on mobile devices or their emulators (which would require setting up specific run-time environments, such as ADT Eclipse plug-in for Android, Xcode for iPhone, etc.)

Here is a screen-shot of the Mobile Browser Simulator that shows Cordova APIs’ visual controls/widgets on the left with the expanded Battery widget that helps simulate different battery levels and the battery plugged-in event (fired when the battery is plugged in for charging and stays in this state until un-plugged).
Worklight 6.0 Mobile Browser Simulator Screen

So, if you are interested in this approach to testing Cordova hybrid apps, below are a few simple steps to follow that will help you get up and running in no time.

Note: For this blog posting, I used Worklight ver. 6.0 which comes with Cordova framework ver. 2.6.
Read the rest of this entry »

1 Comment

Java EE 8 and beyond

Every new release of the Java EE platform makes it incrementally better by adding new features or simplifying its interfaces which was also the main theme of the latest Java EE ver. 7 release (Oracle press release can be found here).

Let’s review some of the aspects of the new release and touch on the subject of the platform’s potential growth vectors.

 Reduce the boilerplate code.   Is the mission finally accomplished?

One of the repeated topics in each and every Java EE release since version 5 has been “reducing the boilerplate code”.  And it looks like that with the help of meta programming facilities offered by annotations and Contexts and Dependency Injection (CDI) capability introduced in JEE6, this goal has been practically achieved. The latest beneficiary of this exercise is JMS that in EE7 underwent a major overhaul.  The incidental complexity of JEE programming has been reduced to the point beyond which it would require something conceptually similar to emoticons to make it even simpler.  As the old adage goes: “Make things as simple as possible, but not simpler.” So there is probably not too much to expect (or demand) in this department in future releases …

Caching

Java in-memory caching API (JCache) did not make it to the final release of Java EE7 and is likely to be included in the JEE8 release.  Not a big deal for those Java developers who know that they can always plug in ready-to-use in-memory cache solutions for Java objects such as the open-source Ehcache product (which is a version of the JCache specification as implemented by Terracotta).

More support for web technologies

JEE7 now offers support for a wider range of web technologies, such as HTML5, WebSockets, and JSON all of which will consolidate its position as a feature rich modern web server platform.  This is a big thing, no doubt.

Currently, JEE already has the servlets, JSPs, JSFs, and facelets with the overall trend toward increased sophistication of Web tier programming which is directly correlated with its growing complexity.

To reduce complexity of Web tier development and potentially draw additional interest in the platform, a move in the opposite direction – toward simplified Web programming models in JEE – may be a viable alternative.  Scripting support from web-aware components like Groovlets or the like may fit the bill.  Another area to explore could be simplified access to business logic via an AJAX-based bridge between JavaScript (or any other browser scripting language that may become popular in future, like Dart and Java modules.  Currently, there are quite a few Java Web Remoting frameworks such as DWR,  Apache Tuscany project (to some extent), and Google Web Toolkit, that can be used as a starting point for the analysis of such systems.

Embracing techniques and ideas from open source projects

Java EE has started to more willingly embrace proven techniques and ideas conceived and developed outside of the realm of Java EE specs.  Under this trend, JEE can effectively (and efficiently) leverage the know-how used in developing systems that are already enjoying a wide adoption in the Java community.  An example of this would be the Contexts and Dependency Injection (CDI) capability built on top of the ideas and concepts underlying the popular Spring and Guice dependency injection systems as well as the Seam context management framework.

Now, without much ado, JEE7 fast-tracked the Batch Processing spec based on the Spring Batch framework (batch jobs are tasks that can be executed without user interaction, such as ETL scripts, etc.).

Support for NoSQL Databases

NoSQL databases are on the curve of gradual adoption in the Enterprise world and this is one of the areas where JEE can take a big piece of the action.

One of the models to emulate is SpringSource’s Spring Data umbrella project that offers Spring-powered data connectors to NoSQL databases, map-reduce frameworks, and cloud-based data stores.

EIS vendors, who wish to expose functionality of their products to the JEE platform in a “standard JEE” way, are always welcome to create JCA-compliant resource adapters for their products thus lending credibility (in the eyes of some conservative executives) to their NoSQL solutions.

This activity needs to go along with an effort to standardize a “NoSQL language” (if one is ever accepted by the very diverse NoSQL database community).  Unstructured Query Language (UnQL) project is a step in this direction.
Read the rest of this entry »

No Comments

Create Better Web Applications With Java EE 6 Training

At Web Age Solutions, we have the challenging task of not only keeping up with technology specifications but whether clients are actually using those technologies.  We have started to see much more interest in Java EE 6 training on various platforms so this is obviously taking hold.

Java EE 6 had the unenviable distinction of being released pretty much right as companies were trying to dig out of the 2008-2009 economic downturn.  So even though it did take 1-2 years for all of the major server platforms to release versions that supported it, many clients were taking a “wait and see” approach to upgrading.  Since companies first have to upgrade to the most recent platform before they can even think about using the new technology that is available it has taken until now to really start seeing that take hold.  Even JBoss clients, which usually take a more “figure it out on our own” approach, are doing training to make sure they can fully take advantage of the latest JBoss version, including the very different administration model (which we cover in our WA2060 JBoss Administration and Clustering course).

One of the primary barriers to taking advantage of what the new platform can do is simply knowing what is available.  Quite often projects take an approach of “we do it this way because we’ve always done it this way” and don’t look for ways to improve and simplify their applications by leveraging new approaches to programming.  With Java EE 6 (and soon Java EE 7) continuing to expand the possibilities that are out there this is becoming more of an issue.  We are a long way from the days when only Servlets/JSP were “standard” and you needed a thick “patterns” book just to create your own web framework.

To further support those that might be looking for Java EE 6 training, I’ve updated all of our course maps for Java EE 6 training on the major platforms.  These course maps show a different path depending on if you are familiar with the big changes introduced in Java EE 5 since several clients often skip versions of a server and in particular we are seeing migration paths like WebSphere 6.1 –> WebSphere 8.x.  These course maps also mention some of the Spring 3 training classes we offer since clients sometimes do training in that area as well.

Java EE 6 Course Map for WebSphere 8.5

Java EE 6 Course Map for WebSphere 8.0

Java EE 6 Course Map for WebLogic 12c

Java EE 6 Course Map for JBoss

Looking to the future, the Java EE 7 specifications are finalized and servers are being updated right now to fully support them.  JBoss is as well and will probably be released early next year (they say this year but JBoss is always missing release deadlines).  The tricky thing is that the open source project is being renamed to “Wildfly” and the “JBoss” name will be reserved for only the supported version.  There is already a version mismatch between the two and now having two different names I think is going to cause more confusion but we will see.

As servers release support for Java EE 7 I think the goal is to try and release classes as early as possible.  This will depend somewhat of course on which servers release support first.  We are going to be working internally to develop ways where we can develop hands-on labs that are more modular and can be more easily reused in different courses so we can start developing those early and support more clients that are “early adopters” and want to upgrade quickly.  Java EE 7 contains a lot of updates as well so we are looking forward to introducing that to clients as they start moving to servers that support it!

Now we get to sit back and enjoy watching the “race” of which server supports Java EE 7 first.  Any bets?

No Comments

Accessing EJBs from Java SE Using WebSphere’s Embeddable EJB Container

Introduction

In this blog, we’ll explore how to employ the Embeddable EJB Container inside a Java SE application using WebSphere Application Server 8.x.

Embeddable EJB Container

One of the new features introduced in EJB 3.1 (part of Java EE 6) is the Embeddable EJB Container. The main two use cases for the Embeddable EJB Container are:

  1. Unit testing your EJBs without requiring a Java EE application server
  2. Embedding EJBs inside a Java SE application, which allows you to take advantage of their benefits (e.g., security and transactions)

The primary advantages of using the Embeddable EJB Container are:

  • You don’t need to install the application server if all you need to do is unit test or employ your EJBs within a Java SE-based application. You just need access to the vendor’s Embeddable EJB Container JAR file.
  • The Embeddable EJB Container starts almost instantaneously, unlike the server-based EJB container (which can take a minute or more to start up), since the Embeddable EJB Container initializes only EJB-related components.
  • The Embeddable EJB Container has a much smaller memory footprint than the equivalent server-based EJB container.

Read the rest of this entry »

No Comments

How about a FREE set of WebSphere and Spring Eclipse Development Tools?

Lately I’ve been working quite a bit on expanding the classes available in our Spring 3.0 category.  One of the things that has always set our Spring training apart is that we offer options to develop Spring applications for WebSphere (in addition to other classes that use JBoss or Tomcat).  Spring has been a very popular framework and WebSphere a very popular server so it has always been a popular choice for our clients.

In the past, the downside has always been that WebSphere development required Rational Application Developer (RAD).  Doing Spring development in RAD was never a great fit since you couldn’t use the Spring Eclipse plug-ins that were available from SpringSource.  You also had some choices from MyEclipse for WebSphere and Spring tools but those weren’t free.  Now recently, IBM released FREE Eclipse tools so you can control and deploy to a WebSphere server directly from Eclipse, something that used to require RAD.  I’ve blogged about that before but that was without Spring tools.

So while developing our Spring 3.0 classes for WebSphere I wanted to take a fresh look at what would be the best environment for this.  The contenders would be:

  1. RAD without installing Spring tools
  2. MyEclipse Bling (WebSphere “Blue” tools and Spring)
  3. RAD with Spring tools added
  4. Eclipse with WebSphere and Spring tools installed

Read the rest to see the “Winner” and how to set it up!

Read the rest of this entry »

No Comments

WebSphere 9 Coming Soon?

UPDATE:  As it turns out my guess that there would be an “intermediate” release was correct.  WebSphere 8.5.5 was released recently which mostly has updates for the Liberty profile being a certified implementation of the Java EE 6 Web profile.  The Redbooks updates was obviously for this 8.5.5 version.  The other points are still true though and I would be surprised if there is not an announcement of WebSphere 9.0 at or before the Impact 2014 conference next spring.

ORIGINAL POST: I know for those of you out there using WebSphere, the initial reaction to the title of this blog post is probably “But we haven’t even finished migrating to WebSphere 8.0/8.5!”  I myself didn’t think a new WebSphere version could be waiting in the wings but there have been a few interesting data points to consider:

- Java EE 7 should be final by end of May this year (http://java.net/projects/javaee-spec/pages/Home).

- Many Java EE 7 JSRs are already in final review (http://jcp.org/en/jsr/stage?listBy=proposed).

- IBM Developerworks has betas of 9.0 versions of development tools (https://www.ibm.com/developerworks/mydeveloperworks/blogs/wasdev/entry/download?lang=en)

- IBM Redbooks had a residency open to update several core WebSphere Redbooks to “the latest release of WebSphere Application Server”.  This was only open to IBM employees since people who work on the Redbook would obviously get a “sneak peek” at the next WebSphere.

Although thinking about when WebSphere 9 might be released is interesting, I think there is another possibility, that there will be some “intermediate” release that includes updates mainly to the Liberty profile, the lightweight server that IBM is trying to tailor to developers.  Perhaps there will be something like an 8.5.5 release mainly to pick up updates to the Liberty profile.

Read the rest of this entry »

2 Comments

Getting ‘Closure’

I have been a Java developer since 1995, before that I worked in C++. So my language background is primarily statically-typed and object oriented. In the last several years, I’ve been involved in a number of projects that use JavaScript. I’ve come to recognize that JavaScript is a very powerful language in its own right — but it is dramatically different from the languages that I am used to. One of the features of JavaScript that was a mystery to me is closure.

Closure has no direct equivalent in my native language Java so it took a great deal of reading and experimentation for me to come to grips with this concept. The simplest description I can give is this.

In a closure a variable declared in an outer function is visible to an inner function even if the inner function’s lifecycle is longer than that of the outer function.

Here is an example using the Apache Cordova (PhoneGap) API. The phone Cordova API allows you to package HTML5/CSS/JavaScript applications natively for a number of mobile platforms. It also provides a JavaScript API to wrap many of the native device features like the accelerometer. This example shows a closure.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
function startWatch() {

  var previousReading = { x: null, y: null, z: null };

  navigator.accelerometer.watchAcceleration(

    function (acceleration) {
      // use previousReading value here
    },
    onError,
    { frequency: 500 }
 );

}

In this example the startWatch() function declares a variable previousReading and sets its x, y and z members to null. The three values will be used to represent acceleration in meters per second squared. The function then calls navigator.accelerometer.watchAcceleration(), passing in an anonymous callback for success. The anonymous callback defined on line 7 in the source code will be called at a rate of once every 500ms and it will compare the current acceleration with previousReading then update previousReading with the current acceleration.

The code is relatively straightforward except for one important detail previousReading was declared in the scope of the outer function startWatch. But the anonymous inner function (on line 7) will be called repeatedly even after the outer function is out of scope! What happens here is that the inner function keeps a reference to any values in the outer scope that it will need when it is invoked.

For those of you who are Java programmers, don’t think you are immune from this discussion. Closures are on the proposed feature list for JDK 8.

1 Comment