RIA Integration: Bits and Pieces. Part 1.

There are many ways to have various software components to communicate in Java EE enterprise architecture. The same is applicable for integrating rich Internet Applications written in Adobe Flex and Java EE systems. Let “s consider the following scenario:

An application A is being developed using Flex-BlazeDS-Java, and it needs to integrate with a third-party Java-based Web application B, where the users must register, otherwise they can “t continue using the application A.

Of course, to implement this scenario you can engage some of the business process management software packages that will allow you to describe and configure the workflow with minimum or no coding. But the less moving parts are used in the architecture the better. Here “s the pretty simple way to implement our scenario.

Step 1. When the user presses the button on Flex view, the code is being executed inside the virtual machine ndash; Flash Player, which in turn is sitting inside HTML wrapper. So the first goal is to make a call from inside the Flash Player to the outside world. Using the ActionScript class ExternalInterface you can map the internal function, say registerUserAS() to the wrapper “s JavaScript function registerUserJS(). You have to write both of these functions yourself.

Step 2. The JavaScript function registerUserJS() opens the URL of the application B in a separate Web browser window, where the user registers as required by the application B.

Step 3. In the application A, develop and deploy Java servlet, say RegistrationCompleteServlet that can be called by the application B when the user successfully completed the registration. During this call, the application B will pass to the servlet a Data Transfer Object RegistrationInfoDTO, with all required registration details.

Step 4. The RegistrationCompleteServlet and BlazeDS are collocated in the same Java Servlet container(e..g. GlassFish, Tomcat, et al). The RegistrationCompleteServlet initiates a push of the RegistrationInfoDTO to the BlazeDS destination RegistrationDest with the routing to the proper client. How to push the data to the client over the AMF protocol is described in our book Enterprise Development with Flex.

Step 5. Almost forgot to mention that during the startup, our Flex application has created a Consumer subscribed to the messages from the destination RegistrationDest. As soon as the RegistrationInfoDTO is published to this destination, Flex client will receive it and let the user into the next view with a nice greeting, “Thank you, Yakov for registering. Your credit card information has been validated rdquo;.

That “s ” all there is to it. I “ve included “Part 1 rdquo; in the title of this blog, because hoping that this will become a series of writeups on integrating Flex and Java EE.

Hacking or design patterns?

Earlier this year, I made a statement defending hacking in an interview for Oracle. Yesterday, I found a thread on theserverside.com where java developers were sharing their view on the subject. In this blog I “ll take the same two quotes there ignited some arguments and will try to explain my point of view.

1. “Recently, I ‘ve been running a seminar for a small group of Java developers. Several times they ‘ve asked me, ‘Is this code an example of MVC pattern? ‘ I got the impression that implementing MVC had become an end in itself. Using Design Patterns is not a dogma. Just write the code that makes sense. Not everything that makes sense has a named design pattern. ”

2. “Abusing design patterns is not always the fault of Java developers. I find the approach used in the enterprise software shops similar to medicine in the US. In my opinion, lots of doctors here practice ‘protective medicine. ‘ They are trying to protect themselves from malpractice law suits. Enterprise managers and tech leads also try to minimize the risk introduced by lower-skilled developers who are part of every team. Yes, abiding to object-oriented principles definitely helps in making code readable, but this does not always translate into better performing applications. If hacked-up code produces great results, apply it without worrying whether another developer will have problems understanding it. ”

I work for Farata Systems, a consulting company that makes a living by developing rich Internet applications utilizing Adobe Flex and AIR and Java EE. We are a small company (about 30 people). We do consulting as well as develop our own software (both commercial and open source). The number 30 is important here. Many years ago, a respectful person taught me that until the company is under 30 people it “s efficient because there is no need to hire middlemen managers. The founders of the company can run the projects themselves, and there is no ballast.

After several years of running the company with two other geeks, I couldn “t agree more. We can afford to cherry pick developers, which large company can “t. I “ll tell you more ndash; we can afford having people who don “t have to stick to design patterns just to ensure that Joe Smith who became a programmer after attending 6 months of vocational school will understand the code. We can afford to build teams not with code monkeys who were shoved into our throats “because XYZ is our offshore partner and we have to keep them busy rdquo;. We are also working with offshore developers, but only with those who can do the job and can read/write the code regardless if it belongs to M, V, or C tiers.

Design patterns were not created equal. It “s OK to bash Singletons. They are easy to be blamed for being a replacement for global variables. But MVC is still considered to be good. Unfortunately, it “s not about three tiers any longer. Java architects enjoy creating layers. They “ll be happy to explain anyone how these extra layers will make your application very configurable and flexible. Layers are best friends of consulting firms who have sharpened their skills in creating beautiful powerpoints with nice round-square rectangles filled with color gradients. Thick arrows going from left to right shows how “with our consulting company you “ll move from here to there in just a couple of years rdquo;. The arrows must leave no doubts in the minds of hiring managers that “these guys can do it rdquo;.

And most importantly, these multi-tiered diagrams will explain the hiring manager of a large corporation that it “s OK that Satish is weak on the front end and Boris never worked with the back end hellip;if you know what I mean. This multi-tiered design can turn both Satish and Boris into code monkeys who will do nothing but inserting their business logic into easy to understand location and the framework will do the rest. Design patterns promote the lowest-denominator-skills software development.

You may be surprised, but even such a sacred cow as dependency injections is not a must. Believe it or not, pretty much any application can be created without DI. I “m not kidding. No XML configuration files to process. Popularity of dependency injection in the middle tier is based on the necessity of integration techniques to allow upgrades and replacement of large pieces of technology with their new implementations. To be fair, I need to praise Java EE 6 for smart and light implementation of DI that doesn “t make you drown in XML.

Applying DI in the front-end applications on top of the frameworks with well designed event model is an overkill on the desktops and suicidal on smart phones and tablets that need to be optimized for memory and speed. We see bigger consultancies still doing it because it is a proven and easy to sell solution. Unfortunately, starting a new Flex project with an analysis of which MVC framework to choose seems to become a habit in enterprises.

My interview statement that writing the code that works is the ultimate goal is applicable only in teams that can afford to employ skilled professionals. If for whatever reason you can “t, go with the flow and rely on injections that somehow will put the collection of Orders into your Customer object.

Finally, to make this blog even more thought provoking, I “ll touch upon yet another sensitive subject. Who do you need to write code for ndash; humans or computers? On one hand, the code must be readable, cause the same piece of code is being read a lot more often than being written/modified. On the other, the code must be efficient. For example, in financial trading applications adhering to design patterns is a low priority item. Speed is the king there.

Recently, I showed one chapter of my new Java tutorial to a very experienced Java developer. He was surprised that I included an example of BitSet there. This is what he said ndash; word for word, “Perhaps your experience is different than mine, but I don ‘t think I ‘ve ever seen this class used in practice. It really feels a bit old-fashioned, and C-like. In 2010 I ‘m not sure anyone writing code in Java really worries about this level of saving bits. Maybe it still relevant in some embedded systems, but do those systems actually run Java? rdquo;

Ten years ago I was working on developing an equity trading system for a Wall Street company. It was a J2EE application with a heavy use of messaging. A trading order had to be sent to a queue, and this was an object with about 50 fields with yes/no values. Using BitSet for sending a set of flags (bits that are set to 1 or 0) instead of text or numbers is the most economical way to do this. Did I care that a programmer who “d be reading my code a year from now won “t immediately understand that just a couple of bytes carried had tons of information about the order? I did not. This piece of code was not readable, but efficient.

IMO, in the ideal world of inhabited by skilled software engineers, the code has to be written for computers. But we don “t live in the perfect world. So I don “t insist.

How many women does it take to cook borsch?

Apache Software Foundation left the JCP Executive Committee. This step caused turmoil in the Java community. Java developers started take sides. How do you take sides these days? You twit, you blog, you facebook. Some die hard folks sent emails. Why won “t I take a side too? But first, I “ll make a bold assumption. Ninety five percent of Java developers don “t even know what the JCP is. Don “t believe me? Start asking the following question while interviewing job applicants, “What “s the difference between JCP, JSP, JSR, and JSF? rdquo; Then post interesting answers as comments to this blog. It “ll be fun.

Prior to the release, each version of Java SE, ME, or EE is a described in a set of specifications. For example, two weeks ago, JSR 336 has been passed ndash; it contained the description of the Java SE 7 content. Preparing of this document (let “s name it Borsch) if took four years after the release of Java SE 6. Similarly, Java EE is defined in e specifications for various technologies such as Servlets, JavaServer Pages (JSP), Enterprise Java Beans (EJB), Java Messaging Service (JMS) et al.

Each of these specifications has been defined by an open organization called Java Community Process (JCP). If a person or a group of people decides to propose a specification for some future technology, they would create so called Java Specification Request (JSR) and form a group of experts working on this specification. JSRs are numbered. For example, the specification for Servlets 3.0 was described in JSR 315. Let me pretend that I don “t know how painful the process of accepting the final release of JSR 315 was.

If you decide to get familiar with any specific JSR, visit this Web site . Currently, Java EE includes 45 JSRs, Java SE has 44, and Java ME (Micro Edition covers small devices) consists of 85. In other words, Java EE is (was?) based on standards.

Early in the morning, ten women have gathered in the kitchen of a poor but very friendly and outgoing lady called Sunny to cook Borsch. Each one brought her own recipe. Hours passed by but they still couldn “t agree on the set of ingredients to put in the pot. Finally, the burner was turned on, but another arguments began, “What “s the right level of the lid closure? rdquo;

Interestingly enough, the ladies didn “t care that much about the Borsch any longer. They really enjoyed The Process (a.k.a. Java Community Process). When Sunny “s husband came home, he saw ten happy ladies and no dinner on the table. No biggies. There was a pack of shrimps in the freezer, and 15 minutes later everyone enjoyed the dinner.

Am I loosing track here? Oh, yeah! Apache has left the JCP. Does it mean that these people won “t answer the phone when Oracle engineers will ask their opinion about some of the upcoming features of Java? Sure they will. Engineers always talk to engineers even though it “s sad that Oracle lawyers try to seriously censor what can be said. Are they unique in that? Hell no! Last week, one of the Java community leaders sent an email to the certain mailing list announcing that this was his last post about one Java-related subject because he was hired by Google hellip;

Does it mean that Oracle wants to hurt Java while having all their middleware written in this great language? Of course not. Oracle has talented engineers, and they will find a way to listen to the community feedback regarding the future of Java with or without JCP. Will they cook Borsch even slower than the JCP did? I doubt it.

Attending Adobe and RIM Playbook seminar

I spent a day today attending Adobe and RIM (producer of all-over-the-place Blackberry) seminar about developing software for the upcoming Playbook tablet. If you haven “t heard about the Playbook yet, it “s a 7 rdquo; dual-core 1Ghz machine with 1Gb of RAM, two video cameras, and multi-tasking.

I was there for a very practical reason trying to evaluate this hardware to be a platform for the mobile version of our software product ndash; Licensing and Contracting for insurance agents. The desktop version of this product is a pretty advanced Adobe AIR application that automates processing of lots of PDF forms, engages OCR technologies, uses Web Services, et al.

While we are already working on creation of the Android of this product and have concrete plans for iPads, it would be simply wrong to ignore the company that have already sold 115 millions of Blackberries and is about to release a tablet that will compliment their hugely popular smart phone.

Adobe and RIM work very closely on this device. All applications that come with Playbook are written in Adobe AIR. Flash Builder Burrito IDE streamlines creation of the mobile application s in general and for the Playbook tablet in particular. Of course, the entire platform has a room to grow, but I have no doubts that next year AIR will feel at home on the Playbook “s OS called QNX.

The tablet looks likes a smaller version of iPad. The screen resolution is 1024×600. The 600 seems a bit low for the enterprise applications though. The video rendering is really fast. Flash Player 10.1 is supported.

Based on the needs of our insurance application, we “ll have to wait and see, because today “s Playbook doesn “t support working with PDF, which is crucial for us. Next year this device will support Blackberry Java Development Environment.

Overall, it “s a nice device. Currently there are no fees for joining Blackberry Application World, where early adopters can get all required software for the creation of applications for Playbook.Adobe evangelists have already created a handful of applications demoing features of this new device.

I have one more concern related to development under MAC OS (based on my observations, 50% of developers who work with Adobe software are carrying MacBooks). The requirement to have a full version of VMWare Fusion will make development for Playbook not overly productive unless you have 8Gb or RAM.

The Spring of 2011 will be a very exiting time for those who already understand that tablets are the new trend. Variety of new devices are going to be released soon, and don “t forget about Apple engineers, who I “m sure, are working hard on a dual CPU successor of the iPad.

Next year, we “ll definitely release a new version of our application – an insurance agent will be selling you term life carrying a small tablet talking to a cloud in occasionally connected environment. The trucks full of paper forms will become history. We “ll just need to decide, which tablet will become our pilot.

Today Oracles JVM has no chance on the client

Unfortunately, I had to demonstrate how to install JDK SE 6 under Windows. I needed it for the book. After spending an hour trying, I decided to take a break and recorded a screencast showing how a process that had to be a one-click deal was responding to my attempts to install Oracle ‘s software.

I agree, I ‘m a little spoiled by the ease of installing Adobe ‘s Flash Player and AIR. I was ready to do some dances and answer 10 questions while installing Java. But things got worse. I ‘ve deleted the previous install of Java SE 6U22 and now it keeps telling me that I already have it, and so far I ‘m not sure how to get out of this situation.

Sun Microsystems had ignored Java on the client for fifteen years. The brave announcements that JavaFX will be THE solution for the client didn ‘t have any substance and three years of “let ‘s pretend we develop a RIA tool ” lead nowhere. And I ‘m not even talking about the technical merits of JavaFX. Who cares what the program can do if it can ‘t be delivered to the client? The clients needs a runtime – at a minimum – JRE. On top of that, it ‘ll need another little something (so far we don ‘t know what) – JavaFX 1.3 is undergoing dramatic changes, and it ‘s not clear how JavaFX 2.0 applications are supposed to be delivered to the consumer. Not to the corporate users whose desktops can be re-imaged by sysadmins with pre-installed JRE, but for a driver from Alabama who happened to run into a Web site that happened to be written in Java or JavaFX? No way.

I know that 100% of Oracle middleware is written in Java. I know that Oracle promises to pay attention to Java on the client. This is not going to work unless some really really serious attention will be paid to achieving SEAMLESS INSTALL OF JRE ON THE CLIENT ‘S computers. And keep in mind that most of the users are still on Windows. Learn from Adobe who know how to install VMs by making just one or two clicks. Yes, I ‘m talking about Flash Player.

Now you can enjoy the 4-minute screencast titled “You already have Java installed. Do you want to reinstall it? ” Meanwhile, I ‘ll may immerse into the exciting world of Windows registry cleaners and Cleanup utilities. No, I ‘d better restore the one month old backup of the Windows VM.

Social networks as anti-depressants

Most of the innovations in software come from the USA. The best software products are created in the US. The most popular social networks were invented in the US. Harvard’s most popular course is “How to be Happy”.

So what?

Everyone has some form of depression. More and more people spend more and more time in FaceBook, Twitter and the like. More and more people are looking for a virtual safety net. Small portion of the users of these networks are there either for business reasons or looking for sex partners. The vast majority of the users of these networks who are older than 22 years old are suffering serious form of depression without realizing this.

Billy Joel sang “It’s better than drinking alone …”

Social networks are hugely popular in the US. This hurt Prozac sales. If Twitter and FaceBook were not invented, American citizens would be buying more anti-depressants.

God bless America!

A New Kind of Java Tutorial is Almost Ready

During the last six months I had a pet project for Wiley Publishing. I “ve been writing a new Java tutorial, which teach Java programming in a little bit different style than traditional books. The title of the book is “Java Programming 24-Hour Trainer “. I can almost hear the voices, “Yeah, yeah, yeah hellip;Yet another promise to teach me Java in no time. How about teaching me Java in 24 minutes? ”

This is not to state that you can learn the software covered in this book within 24 hours of studying. This is about having a trainer that “s with you 24 hours a day. This book is a set of short chapters with minimum amount of theory but with an instructional DVD, with screencasts recorded by yours truly. There is a screencast for each lesson except the last one.

This relatively small 500-page book consists of 38 lessons and covers both Core Java and Java EE 6. Each lesson is from 10 to 15 pages long so you won “t even have time to fall asleep. Each screencast is from 10 to 15 minute long so you won “t have time to get bored. At the end of this lesson is an assignment to complete. In this book I use Eclipse IDE and GlassFish v3 is the application server that I like.

Just look at these thirty eight lesson titles and give me a good reason why you shouldn “t be pre-ordering this book. Know Java already? Doesn “t really matter. I thought I knew it too before I started writing this book. Now I know it better. It “ll help the newbie “s to learn and seasoned Java programmers to refresh their knowledge, especially when it “s time to make a career move. These are the lesson titles:

1 Introducing Java

2 Eclipse IDE

3 Object-Oriented Programming

4 Class Methods

5 Back to Java Basics

6 Packages, Interfaces and Encapsulation

7 Programming with Abstract Classes and Interfaces

8 Introducing the Graphic User Interface

9 Event Handling in UI

10 Introduction to Java Applets

11 Developing a Tic-Tac-Toe Applet

12 Developing a Ping-Pong Game

13 Error Handling

14 Introduction to Collections

15 Introduction to Generics

16 Working with Streams

17 Java Serialization

18 Network Programming

19 Sending E-mails with Java

20 Introduction to Multithreading

21 Digging Deeper into Concurrent Execution

22 Working with Databases Using JDBC

23 Swing with JTable

24 Annotations and Reflection

25 Remove Method Invocation

26 Java EE 6 Overview

27 Programming with Servlets

28 JavaServer Pages

29 Developing Web Applications with JSF

30 Introducing JMS and MOM

31 Introducing JNDI

32 Introduction to Enterprise JavaBeans

33 Introduction to Java Persistence API

34 Working with RESTful Web Services

35 Introduction to Spring MVC Framework

36 Introduction to Hibernate Framework

37 Bringing JavaFX to the mix

38 Java Technical Interviews

This book will hit the bookstores in February and you can pre-order it on Amazon at this address. I hope you “ll enjoy reading this book as much as I enjoyed writing it.

Submitted &”Java for Blondes&” workshop proposal

I ‘ve submitted the following hands-on workshop proposal to the Flash And The City conference:

“Java for Blondes

In Java community, Flashers are considered second league. While Java developers build highly-available scalable multi-threaded systems for Wall Street, Flashers are fooling around with animations, effects and bending pixels. This is a four-hour hands on workshop. The first part will be spent explaining basics of Java development. In the second part, attendees will develop Flex/BlazeDS/Java/DBMS application, which is their to keep. There is a limited number of seats for brunettes too. ”

Not sure if this kind of a proposal will make it to this event, but I ‘m planning to run this workshop (or its stretched version) a couple of times next year.

Blondes, unite!

Flex Camp Wall Street next week

A good mix of practitioners and Adobe Evangelists will be presenting on various topics related to using Adobe Flex in the real-world projects. Farata Systems will be represented by Victor Rasputnis and myself. Hope to see you there.

Victor will show you how to generate complete CRUD Adobe Flex/BlazeDS applications based on Hibernate framework on the Java server side. Clear DataBuilder Eclipse plugin will assist us in annotating Java interface without the need to do manual coding and configuration. You will see remote lazy loading of the collections, server-less transactions controlled from the client and, integration with Adobe Fiber – a model-driven development environment of Adobe LCDS… but with BlazeDS.

I ‘ll talk about making networking of Wall Street applications reliable with BlazeDS. Loosing a trade order is not an option. But using free and open source BlazeDS for Flex/Java communications doesn “t guarantee 100% of all your clients ” orders will reach the destinations. This talk is an overview of networking problems of Flex-BlazeDS enterprise applications with the demo of the error-emulating protocol, which concludes with introducing of reliable AMF channels.

Visit the Web page of Flex Camp Wall Street for more details.

Ill be teaching public Java class in December in NYC

I ‘ll be teaching a hands-on Java/Java EE class in December in New York City. If you know any other programming language, this may become your chance to jump into the enterprise Java development. It won ‘t be easy to get from zero to hero in just five days, but it ‘s doable with the right motivation. During the first three days you ‘ll be learning the Java language as it ‘s used for programming for the client side (Java SE), and the last two days are for developing on the server side with the latest Java EE 6 technologies.

If interested, register here. While you “ll be enjoying my class, your spouse will enjoy Christmas shopping in New York City.This offer may be especially appealing for wives and girlfriends of Russian oligarchs – send him to school and have fun in the City of the World! If the price of this class seems to low for him, I can provide an alternative registration page with an extra zero at the end.

If you want me to teach this class privately on-site in your organization, send me an email at yfain at faratasystems.com.