Thursday, June 13, 2013

JEE: Java EE 7 (Glassfish v4.0) is out, putting the productivity at your hands.


My participation:

I am so proud of being part of Adopt-A-JSR program and my involvement in the testing, evaluating and evangelist JEE 7 JSRs and related technologies.
Alongside FishCAT program that target the enhancement and stabilizing Glassfish version 4.0.

Java EE 7 is out:

The most interesting and productive shipped with plumbing of cutting-edge (innovative) technology support; Java Enterprise Edition 7 (JEE 7) is out for public, as promised to be released in Q2 of 2013. The JSR 342 Java Platform, Enterprise Edition 7 could be downloaded from here.

Java EE 7 release is being designed with primary focus on the following features:

  1. Higher Productivity.
  2. HTML5 Support.

Alongside JEE 7 specification release, its modular and most efficient reference implementation application server Glassfish v4.0 is out for development of JEE 7 applications, and could be downloaded from glassfish.org web site. In addition, it is the world's first Java EE 7 Application Server.

Glassfish.org web site redesigned with new clear, fresh design as well. It looks very neat.

For release notes, it could be downloaded from here.

There are also many examples to get start, which could be found in documentation section.

Java EE 7 IDE is out:

For sake of development and get your hands dirt with JEE 7 specification that should be tested on Glassfish v4.0, there is a Netbeans 7.3.1 IDE, which includes support for JEE 7 full JSRs stack. It could be also downloaded from netbeans.org. Also, bear in mind that Netbeans JEE version includes Glassfish v4.0.

Consult the following page to see more IDEs (Integrated Development Environment) that supports Java EE 7 development: IDEs and plugins.

Try, Develop and have fun

As by now you have the JEE7 specification, Glassfish v4.0 and supported IDE Netbeans v7.3.1 (everything you need comes out-of-the-box without any plugin), so what are you waiting for, click to download and develop to get the feel of new smile of the technology.

Maven Development

For maven fans to develop a Java EE7 application here is the minimal POM pom.xml file:


For Java EE 7 Full Platform

For Java EE 7 Web Profile

For other Java EE 7 JSRs coordination, please visit Java EE 7 Maven Coordinates Wiki link.

Webcasts and Developer days

Besides the finished event "Java EE 7 Launch Webcast", there is another java developer day covering Java EE 7, SE, and Embedded named "Java Developer Day - June 25 - Java SE, Java EE & Java Embedded" that will be online at Tuesday, June 25, 2013, register here.

Tutorials and examples

Visit Java EE 7 Documentation: JEE 7 Tutorial, for full tutorials and examples on how to use the specification alongside its JSRs.

All my sessions, hacks and code contribution could be downloaded from this link under Adopt-A-JSR organization under Github Java EE 7 Hacks, codes and sessions.

Monday, June 10, 2013

Java: What is object deep copy and how it can be achieved in Java ?

If you need to copy and object, you can do it in Java using clone method that is member method of Object class, which is all objects parent class in Java. but wait, clone method performs a shallow copy not a deep copy.

In deep copy the object is copied along with the objects it refers to. Deep clone copies all the levels of the object from top to the bottom recursively.

When a deep copy of the object is done new references are created.

One solution is to simply implement your own custom method (e.g., deepCopy()) that returns a deep copy of an instance of one of your classes. This may be the best solution if you need a complex mixture of deep and shallow copies for different fields, but has a few significant drawbacks:
  1. You must be able to modify the class (i.e., have the source code) or implement a subclass.
  2. If you have a third-party class for which you do not have the source and which is marked final, you are out of luck.
  3. You must be able to access all of the fields of the classes superclasses. If significant parts of the objectes state are contained in private fields of a superclass, you will not be able to access them.
  4. You must have a way to make copies of instances of all of the other kinds of objects that the object references. This is particularly problematic if the exact classes of referenced objects cannot be known until runtime.

Disadvantages:
Custom deep copy methods are tedious to implement, easy to get wrong, and difficult to maintain. The method must be revisited any time a change is made to the class or to any of its superclasses.

Solution 2:

Other common solution to the deep copy problem is to use Java Object Serialization (JOS).
The idea is simple:
Write the object to an array using JOSes ObjectOutputStream and then use ObjectInputStream to reconsistute a copy of the object.

The result will be a completely distinct object, with completely distinct referenced objects.

Advantages
JOS takes care of all of the details: superclass fields, following object graphs, and handling repeated references to the same object within the graph.

Note:
It will only work when the object being copied, as well as all of the other objects references directly or indirectly by the object, are serializable. (In other words, they must implement java.io.Serializable.) Fortunately it is often sufficient to simply declare that a given class implements java.io.Serializable and let Javaes default serialization mechanisms do their thing.

Disadvantage:
Java Object Serialization is slow, and using it to make a deep copy requires both serializing and deserializing.

Enhancing JOS performance:
There are ways to speed it up (e.g., by pre-computing serial version ids and defining custom readObject() and writeObject() methods), but this will usually be the primary bottleneck. The byte array stream implementations included in the java.io package are designed to be general enough to perform reasonable well for data of different sizes and to be safe to use in a multi-threaded environment.

These characteristics, however, slow down ByteArrayOutputStream and (to a lesser extent) ByteArrayInputStream.

More References on this:
Deep Copy
Java Clone mechanism
Another "Deep copy" solutions and techniques.

Thursday, May 16, 2013

Conf: Will speak at the JEEConf 2013 Java Conference in Ukraine, Kiev.

I will give two presentations at two-day conference JEEConf 2013 in Kiev, Ukraine, at the end of coming May 2013 from 24 to 25.
It’s going to be the largest event for Java developers (about 1000 attendees). This is my first participation in this conference, and will go there with pleasure. Below are the descriptions of my two talks.

Note: My talks will be in English.
  1. Title: The Power of Java7 NIO.2 essential stuff.

    Abstract:
    In this session hear how a leading financial services company uses Java 7 NIO.2. This session will covers all the important essential aspects involved in developing NIO.2-based applications. It provides clear instructions for getting the most out of NIO.2 and offers many case studies to spice up your Java 7 applications with the new I/O capabilities.

    Contents:

    1. The Path class operations.
    2. Get/set file metadata through the new java.nio.file.attribute API.
    3. Manage symbolic and hard links.
    4. Manipulating files and directories through the new java.nio.file.Files API.

    Time allocated: 50 min.

    Date/Time and Venue: From: 14:30 To:15:20 Kiev time, @ 24/5/2013 in STAGE B(150).

  2. Title: The Power of Java7 NIO.2 advanced concepts.

    Abstract:
    In this session hear how a leading financial services company uses Java 7 NIO.2. This session will covers all the important aspects involved in developing advanced NIO.2-based applications. It provides clear instructions for getting the most out of NIO.2 and offers many case studies to spice up your Java 7 applications with the new I/O capabilities.

    Contents:

    1. The Path class operations.
    2. Need to copy, move, or delete an entire directory? Use the FileVisitor API.
    3. Explore the Watch Service API and file changed notification.
    4. Develop blocking/non-blocking socket-based applications. Learn how to develop Java network-based applications in blocking and non-blocking styles. Both TCP and UDP are covered in brief.
    5. The Asynchronous Channel API. You can develop asynchronous network based Java applications with a suite of classes and options.

    Time allocated: 50 min.

    Date/Time and Venue: From:12:00 To:12:50 Kiev time, @ 25/5/2013 in STAGE B(150).

Before the first session (it is very short time for each session, but I will try) to intreduce the adopt-A-JSR program, and in the second one I will introduce the Adopt-OpenJDK program as well so I can spread these programs knowledge, to get more participants.

Monday, May 6, 2013

Tunis JUG Day 2013: I will give 2 talks about (JEE7 JSR 356 Wbsockets, 353 JSON-P & Java8 NIOs)

The first edition of ESPRIT JUG DAY will be held on May 18 2013 from 8h00 to 19h00 in ESPRIT.

I am so happy to get an invitation to Tunisian JUG day that will be held in Carthage city, Tunis coming 18/5/2013 from JUG organizer & Leader Bessem Hamidi .


This is first time for the This JUG to organize such an event, and as I know, there are around 3000+ attendees will attend this JUG day; it is very big day event and number of attendees as well.

I will give 2 talks and they are:
  1. Submission Title:
    Build.now(); TRUE, Real Time Applications with JEE7 (A hack session).

    Submission Abstract:

    Historically, creating web applications that need bidirectional communication between a client and a server (e.g., instant messaging & gaming applications) has required an abuse of HTTP to poll the server for updates while sending upstream notifications as distinct HTTP calls.

    HTML5 specification includes the WebSockets (WS) protocol, I will introduce the Websocket JSR 356 (Tyrus RI), & JSON Processing JSR 353 for data exchange which is part of JEE7.

    In addition, there is a brief comparison of traditional HTTP & WS, followed by covering of how WebSockets works. You will see how using WS removes the overhead of heavy HTTP request and response headers with real case study. Finally, we will review the code of the Web app build on GlassFish 4 app server.

    Time: 17h00 - 18h30

  2. Submission Title:
    Java 8 NIO.2 API features, a walkthrough (The essential & advanced Stuff).

    Submission Abstract:

    Most of applications nowadays depend intensively on asynchronous or non-blocking IO and file manipulation operations and some other requirements that the standard IO won’t be able to fulfill and that’s the case for most applications today, that’s why people decided to move to NIO, in this session, hear how a leading financial services company uses Java NIO.2. This session will covers all the essential aspects involved in developing NIO.2-based applications day by day. It provides clear instructions for getting the most out of NIO.2 and offers many case studies to spice up your Java applications with the new I/O capabilities.

    Time: 11h00 - 13h00

Date: 18 of May 2013
Where: Esprit School Conference room, Carthage city, Tunis.

Before the first session I will introduce the adopt-A-JSR program, and in the second one I will introduce the Adopt-OpenJDK program as well so I can spread these programs knowledge, to get more participants.

Moreover, the JUG leader asked me to help them, on the adopt-A-JSR & Adopt-OpenJDK programs process and how they can participate. And indeed I will provide the help with all steps, materials and information alongside the required support to make it easy to participate. As they are very active locally and the JUG has many participants (around 3000+), so the adoption programs can gain benefits from their experiences.

The Esprit team is the organizer of this JUG Day, and they are very active and they are running a big Esprit school that graduate students in the following Majors Media, Telecom, software engineering and others. Also they have 8 classes running Java in this school.

They had made a very cool intro media for the event:



Thanks Very much Bessem Hamidiand Esprit Organisers.

Wednesday, May 1, 2013

JDev:Enabling memory clearing and monitoring on JDeveloper

If you are familiar with Netbeans IDE and its tool that enable you to free up and monitor its memory usage (PermGen and Heap size).

Here we will enable it on any version of JDeveloper IDE and when you open your IDE, you should found this tool at the lower right corner as shown in the following figure:

How to configure it:

  1. Enable Memory Monitor On, in the JDevloper by setting the MainWindow.MemoryMonitorOn property to true in ide.properties as the following:-
  2. ide.properties file should be found under the following path {your jdeveloper system folder}\o.jdeveloper

  3. JDeveloper system folder; is the folder, which contains all JDeveloper configurations, server and properties of JDeveloper.

  4. Example: "C:\Users\mohamed_taman\AppData\Roaming\JDeveloper\system11.1.2.3.39.62.76.1\o.jdeveloper"

  5. Note: Don't add MainWindow.MemoryMonitorOn=true, as it is already exists with value of false, search on it and change its value to true.