Pages

Wednesday, November 21, 2012

What is the definition of a JUG Leader?

Daniel deOliveira, a friend of mine, asked me for what I thought a JUG leader definition should be:
I’m writing an academic paper about the seven dimentions of collaboration in JUGs and I needed a definition for a JUG Leader. I looked in several search engines and … nothing :-( Amazing :-0
I replied to him, and the JUG Leaders list with my definition below. One of the things he noted was that there is no definition out on the Internet that he could find. I decided to add one.

What is the definition of a JUG Leader?

A JUG leader is someone who is passionate about Java. That is the most obvious answer. However, that answer has many different levels. A JUG Leader can be a very technical individual, and some are the best developers in their JUG. This does not need to be the case.

A JUG Leader understands the power of communication, collaboration, and community. As I noted, a JUG leader does not need to be the technical expert of the group, but they need to be able to identify those members (community) and get them to share (communicate) their knowledge. The group dynamic results in a number of synergies that lead to making the group successful (collaboration).

JUG Leaders can act as facilitators. They tend to pay attention to the activities of their members. Often, when someone mentions an issue, or something that they need assistance with, a JUG Leader knows someone else in the community who may have the answer, or provide direction.

JUG Leaders introduce people. We tend to meet really interesting people, and cool projects. When a member asks about a project, or a person, we can often introduce them to the right people. They can also provide assistance to employers looking for people. They tend to know who is in their communities and their expertise.

The best JUG Leaders are people oriented. They are personable, and are the type of people you want to hang around with. They realize that technology changes, but that people are the constant. This leads them to make relationships with people. The power of relationships with people will overcome technical challenges, and personal conflicts. We already know that JUG Leaders are passionate, but the relationship part tempers our dealings with others. We understand that people will disagree, it is how we deal with disagreement that others will judge us.

A JUG Leader is the continual "newbie". They tend to be first adopters. This results in an appreciation for new members. They are always new to some technology, and publicly recognize those projects that support new people.

A JUG Leader is social. As a JUG leader, you tend to be involved with social media. A number also tend to be bloggers. This passion for communication and sharing drives them to blog, or tweet.

A JUG Leader cultivates success. The most successful JUGs have other leaders which are pulled from the membership to make the JUG successful. The JUG should not succeed, or fail on the efforts of one individual. The leader organically grows its members, and asks them to do things that they will be successful in. Move people forward by giving them opportunities to succeed.

Hard projects should only be handled the JUG Leader, or those who will not be deterred by failure. Those projects which could fail should be very public. In the event of failure, the JUG Leader can demonstrate that failure is OK, and that we move on. The leader mentions the failure in terms of themselves, and not the JUG. This is very important.

Success will breed success, and a very public success is a win that should be mentioned in terms the JUG making it possible. Communal ownership and pride in your JUG will make the leader and the JUG grow.

Those are some of my thoughts on what a JUG leader is, or at least what we should aspire to be.

Tuesday, November 20, 2012

Article: Java needs new ideas, not a vague slogan

I read the Opinion piece from the editors of SD Times issue 283 November 2012. I was taken aback that I felt that the Monday morning arm chair quarterback had taken over the SD Times. They completely missed JavaOne 2012, and failed to deliver quality journalism by missing the community aspects. Here is the letter I sent in rebuttal.
I have been attending the JavaOne conference for the last 8 years. This was a great JavaOne. It was great because there were no earth shattering announcements. The community has grown and developed. JDK8 was delayed for some legitimate technical reasons, and some less technical. A lot of work was done on OpenJDK to enhance its adoption, and usage. This was apparent to everyone, except the editorial staff. "Dull" the show was not. This year, a number of participants, and speakers talked about what a "good", or "great" show it was. In my sessions, the talks were packed, and in one case standing room in the back.
ARM was a big winner with a lot of talk about using Java embedded. Raspberry Pi got a lot of developers talking about it along with Java. 
The Java Users Group Sunday, NetBeans Day, and GlassFish Day were well attended by enthusiastic crowds. The Java Users Group Sunday was a community led event without any input from Oracle. Oracle graciously offered us the space and technical staff. I should know I was one of the many organizers. NetBeans Day was community driven as well. The big winners at JavaOne were the communities. 
Did the editorial staff notice that two user groups got Duke's Choice Awards: London Java Community, and jDuchess. Humanitarian efforts went noticed with the United Nations High Commissioner on Refugees (UNHCR) getting a Duke's Choice Award for Level I Registration. A number of open source projects also got the coveted Duke's Choice award including Agrosense. The judging was also community driven. 
The JCP is always a tough subject. It is also the easiest to score political points on by saying its broken. Try talking about the advancements in the JCP. The SE/EE Executive committees are merged. The process has worked on cleaning up a lot of the low hanging fruit, and now the big challenges are left. This is no secret. Wait, that's right... transparency has been put into place in the JCP so it really is no secret. 
I am not a fanboy of JavaFX, but Oracle has made significant investments in it. It provides a development platform that will work where Java runs. HTML5 is not the panacea that answers everything. I know that tech writers seem to make it seem that way. Thick clients are here to stay, and why not have "sexy" ones. 
"Make the future Java" may seem an odd choice of slogans, but from my perspective; the future is what I make it.

Thursday, November 15, 2012

Annoying IE9 CSS Hover and Overflow Issue

Case

I have a <table/> which is surrounded by a <div/> which has the attribute style="overflow:auto". The table has a hover attribute to highlight table rows on mouseover. Additionally, There are some checkboxes arranged in a table below it, but it could be another element. When you mouseover the table in the div, the checkboxes start moving the the bottom of the page.

Resolution

I found the following bug posted on the jQuery bug tracker: Problem with .hover() and IE9 that describes the behavior. Brian Richards, who is linked to in the bug, has a simple bug elegant fix that worked for me.In his blog post, IE9 Hover Bug Workaround, he simply added min-height:0% to the style.

I hope that the solution works for others who may encounter the problem. I also found another blog to put on my blog roll to keep an eye on. Thanks for blogging Richard.

Tuesday, November 13, 2012

JSF 2.x Tip of the Day: AJAX Composite Component with AJAX Event Listener

This example is using a JSF composite component to create an AJAX enabled <h:commandButton/> that has an <f:ajax/> component. Additionally, there is a listener that handles the AJAX events that occur.

This is a simple example which demonstrates the concepts, but could be extended to create your own type  of AJAX button like you would find in PrimeFaces, or RichFaces.

The source code for the project can be found here: cc-ajax-commandbutton.zip

The composite component is located in a directory called resources/lotuscc. The only thing interesting about the implementation is the method-signature for the listener.

ajaxCommandButton.xhtml



The index.xhtml page, and IndexBean are very straightforward.

index.xhtml



IndexBean.java


JDK7 vs. JDK 6 File Monitoring

One of the really nice advancements, or features of Java 7 is the WatchService. This feature takes advantage of the OS file event notification facilities where available, or otherwise uses a "primitive" polling mechanism. In my blog article WatchService Using ScheduledExecutorService Example, I show an example of how to use the WatchService along with an ExecutorService to do file monitoring. This is really easy to implement and use.

However, the question of how to do it on JDK 6 was posed to me for those who can't do an upgrade for business reasons. I did a quick Google search to see what was out there. Alas, some of the most popular search results were poor, or really badly implemented solutions. I did come across a nice piece of code done by Pascal Essiembre. I didn't find much more on the developer. I would give a link to his work if I were sure that what I found was him. Pascal wrote the code below which is EPL 1.0 so you are free to use it. I used it to check it out, and it works likely in the same manner as the "primitive" implementation in JDK7. Here is the code unmodified from the form I found. This is very nicely done. Good code lives on. I just wish this were more near the top of the search results.

Thanks Pascal for your code contribution to the Java community.

Sunday, November 11, 2012

Article: Oracle's Java Revival

I just finished reading an article titled Oracle's Java Revival by Andrew Binstock in InformationWeek. It was apparently renamed for print from the article in Dr. Dobbs Two Years Later: A Report Card On Oracle's Ownership of Java. It is a good article with some positive remarks on Oracle's stewardship and  some criticism.

Oracle has a very business savvy approach to IDEs. They have two IDEs which they own. JDeveloper which is the industry step-child and really is only used by Oracle developers, and NetBeans. Oracle also supports Eclipse too. This allows them to cover all the bases for Java developers. A big winner in the article is NetBeans. I agree with the remarks from Andrew on this
As for tools, Oracle has certainly stepped up investment in the open-source NetBeans IDE. Since the 7.0 release, each version has added new capabilities while maintaining the product's historical light and usable feel. The upcoming v. 7.3 looks to continue the trend.
This is true. As I write this post, NetBeans has released 7.3 Beta 2. NetBeans continues to innovate and provide tooling that developers need. I would like to see more focus on making sure that the IDE plugins can be upgraded in an easy manner. There are a number of great plugins which have been developed over the years. The upgrade path should be as simple as the Inspect and Transform Refactoring tool for migrating your code to Java 7. There are a number of plugins which I would love to see upgraded.

I found that Andrew's remarks around OSS projects disappointing and incorrect.
Oracle's ambiguous relationship with the JCP and the OSS communities remain two other weak points. Except for its work with NetBeans, the OpenJDK, and the GlassFish server projects, Oracle's open-source presence is low profile, in direct contrast to Google, which is a continuous and enthusiastic contributor to OSS.
I don't think this is an accurate assessment. NetBeans, and GlassFish are vibrant communities which are closely integrated. When a feature becomes available in GlassFish, you can expect that it will be available in NetBeans. OpenJDK is an enormous project on top of which Java itself rests. The excitement and participation have never been better. Communities like London Java Community have been working with the OpenJDK project to make it easier for community members to contribute.

Google does not work on anything that does not benefit Google. All of the F/OSS software from Google is a strategic move to get community contributions to make their products better. Is this bad? No, but I don't think they should be given a free benevolence pass either. OpenJDK benefits Oracle for sure, but in a number of cases it is pure benevolence. A vibrant Java community is good for Oracle.

GlassFish is a reference implementation of Java EE. The work here benefits Oracle for sure. Again, the work here is used by more than just Oracle. There are a number of businesses whose only dealings with Oracle are via NetBeans, GlassFish, and OpenJDK. No money to be made for Oracle. Is this more benevolent? I will let you decide that one.

Google has done a lot for Java and I will be the first to applaud their efforts.
The biggest growth in Java undoubtedly comes from Google's adoption of the language for Android. So the lawsuit that Oracle filed (and lost) against the search giant is a howitzer shell fired at one of Java's biggest users and most important evangelists. Given the personalities of the two corporations, I expect this is a stand-off that will endure for a long time. Java will have to grow despite it, rather than through it.
Nothing could be truer! The lawsuit has done nothing, but harm to the community. I am angry that Oracle pursued the legal course, and Google for forcing the issue when they did not get what they wanted in the JCP and via other communications channels. There is enough blame to spread on both companies here.

The JCP is a conundrum. There is a lot of positive work being done here with two large Java User Groups (SouJava, and London Java Community) leading the efforts from the community side. Patrick Curran, JCP staff, executive boards, and members have done a lot of work to improve the process. A lot of work remains to be done. The recent elections and confirmation that JUGs are here to stay on the JCP should be taken as good things to come.

JavaOne 2012 was one of the best events I have attended over the years. This one is in my top two from the years I have attended.  James Gosling was in attendance, and gave a presentation at the community keynote. A sea change from the previous year.
...I'm inclined to agree with James Gosling's revised opinion of Oracle's stewardship, that it's been good for Java.
This has been my observation as well. I have thanked Oracle publicly and privately for their work, and will continue to do so. I have had a  better relationship with Oracle than I have sometimes in the past with Sun. I hope that this continues going forward.

The article closed with this remark which I think is shallow. While Oracle has gotten its fair share of black eyes around things. Sun was a moving target. This was especially true near the end. Its sudden dropping of projects which it claimed to sponsor, vaporware, and conferenceware were a source of a lot of developer excitement and angst. IBM has never enjoyed a lot of love from the developer community.  It has been considered by a number of developers as the "less evil" twin of Microsoft for better, or worse. Oracle I think can get some developer love. It may take a while, but they do have a commitment to the developer community, and it is beginning to pay dividends.
While I doubt it will ever know the love that both Sun and IBM enjoyed from the developer community, if it continues to develop the language, the platform, and supporting tools well, it will be successful enough and Java and the JDK will continue to occupy a preferred place in the development firmament.

Saturday, November 10, 2012

WatchService Using ScheduledExecutorService Example

I was developing some code for the Java Certification Boot Camp project on Java.net where I wanted to demonstrate how to use the WatchService from JDK7 to monitor filesystem activity. I also wanted to demonstrate using it with an Executor.

As part of the process, I needed a graceful way to exit the program when the program completed. I thought that I would simply Google a solution, but I did not find one that met my needs.

So here is the use case I would like to have a WatchService running in its own thread and monitoring the filesystem. After a time period, I would like the service to shutdown gracefully.

I decided to use A ScheduledExecutorService which would start the WatchService using a Callable<V>, and another Runnable which was scheduled to shutdown the WatchService and the ScheduledExecutorService.

So here is how I did it.

WatchServiceImpl.java


Monday, November 05, 2012

JSF 2.x Tip of the Day: Using <ui:decorate/>, <ui:fragment/>, and <ui:include/>

We have been doing a lot of JSF work lately, and I was surprised that my team really did not have a really good grasp of mixing <ui:decorate/>, <ui:fragment/>, and <ui:include/>. These elements are very powerful and allow you to build more complex and reusable code.

The <ui:fragment/> is probably one of the most important elements in Facelets. The ability to use the rendered attribute to determine if the contained content should be displayed is one of the most important uses. Today, I see a lot of examples where you place some code in a <h:panelGroup/> element where you set the rendered attribute using an EL binding. This has the side effect of producing a <span/> element. If you add enough of them, you end up with spans inside spans inside spans... you get the idea.

The <ui:fragment/> has no side effects. You either produce (emit) the code you want, or nothing. A very clean process. The <ui:decorate/> component is one of the least most used and not very well understood. The <ui:decorate/> component is used to add additional functionality to a page. If any other template code is in the decorator page to be included, it is added to the page. In other words, it includes the other content on the page. For example, take a look at the code below for a decorated table. Note that the <table/> is included in the output. It is also outside of the <ui:decorate/> tag.

decoratedTable.xhtml


This was added to a page as you can see in the next snippet, and produced the image below.

DecoratedPage.xhtml



Finally, the <ui:include/> allows you to add content from another page into the current page. This inclusion mechanism allows you to take advantage of code that can be templated for reuse. In order to be complete, I will show the remaining code snippets from the examples above, as well as another example.

unorderedListTemplate.xhtml



listElements.xhtml



decoratedExample.xhtml



Friday, November 02, 2012

Servlet 3.0 and JSF 2.x Tip of the Day: JSF Forward to External Servlet in Different Context

I posted a previous postServlet 3.0 Tip: How Do I Get to Another Servlet Context? which demonstrates how to get to another context. This extends that discussion by showing how to forward a JSF request to the other context and have the servlet output the results. Here is the basic code to be called from the JSF page.

Here is the method.

Here is the servlet I called.

CrossAppServlet.java



Success

Note: If you were going to pass it to JSF, you would need to remove the view state since the Faces Servlet receiving the values would result in a ViewExpiredException since this view state is not in the target Faces Servlet.

JSF 2.x Tip of the Day: <ui:fragment/> and Namespaces

A junior engineer lamented that he could not get NetBeans auto-completion to work, and that his xhtml pages were all red. He wished that NetBeans could be "smarter".

I told him it was "smarter", but he needed to show a little understanding. His problem was that he was using the <ui:fragment/> without namespaces defined.

So here is how you do it to avoid a sea of red. Notice how I just simply added the namespaces as attributes right to the <ui:fragment/>. No more red, and NetBeans is happy.

Thursday, November 01, 2012

Servlet 3.0 Tip: How Do I Get to Another Servlet Context?

This was a question I got tonight. It was a little more complicated prior to Servlet 3.0, but now it is very easy. In fact I almost thought it was not worth writing a post about it. Then I asked a friend in IM if he knew how to do it. It was so much more complicated, I decided to capitulate and post my response.

So how do I navigate to another web application on the server from my current application context?

Simple...

Dynamic Servlet Registration Example

Today I wanted to load a servlet dynamically, and decided to figure out how to do it. It turns out to be really simple.
I created a ServletContextListener and annotated it. In the contextInitialized() method, I set the servlet name, its class, and a mapping and we are done.

We can then deploy the project and watch the magic. Here is the Apache Maven project: dynamic-servlet.zip

ServletContextListenerImpl.java



ExampleServlet.java