San Francisco 1/2 Marathon - 2010 Results
I ran San Francisco 1/2 marathon over the weekend and improved my timing from last year by 3 minutes. I guess dance at a pre-wedding ceremony and 4 hours of sleep the night before slowed me down otherwise could've pushed harder. Anyway the results are still encouraging and the bar is higher for the next time!

This makes me among top 1.2 % runners overall, top 2.5% for "Men", and top 2.3% in "M 30-39" category. Here is the overall leader board:

I'm about 20 minutes behind the winner (5:47 pace) and so need to push really hard to close the gap there. Who knows I may win one day, but for now the plan is to close the gap as much as possible. Seems really difficult, but not impossible!
And I almost made it to the women's leader board ;-)
Michael Wardian, a popular American marathoner and ultramarathoner came second in the full marathon. It was a pleasure to see him cruising back on the Golden Gate birdge.
Here are the mile splits:

One thing clearly evident from the splits is that any amount of hill training is less. This is all the more evident by looking at speed / elevation chart:

Click on the image to replay the race.
And finally here is race route:
Here is the cumulative result of all the marathons so far:
Marathon / Half Marathon Total Time Pace San Francisco 1/2 Marathon 2010 1:35:42 7:18 San Jose Rock-n-Roll 2009 1:30:59 6:57 San Francicsco 1/2 Marathon 2009 1:38:21 7:31 Kaiser Permanente San Francicsco 1/2 2009 1:41:30 7:45 Silicon Valley 1/2 2008 1:45:42 8:04 San Francisco 1/2 2008 1:52:44 8:25 San Francisco Full 2007 4:04:33 9:20 Silicon Valley Full 2006 4:06:57 9:25 San Francisco 1/2 2005 1:48:50 8:18
Technorati: running marathon results runsfm sanfrancisco
QA#4: Java EE 6: Developers focus on business logic, Much lower TCO - by Johan Vos
Jigsaw puzzle, modular, standard, integrated specifications, simple, annotation-driven, standards compliance, vendor independence, and light-weight deployment are some of the benefits highlighted by the Java EE 6 community.
In the Java EE 6 Feedback from Community series you can learn about how Java EE 6 is currently being used in production, development and deployment environments used within the community, and even feature requests for Java EE 7.
This entry comes from Johan Vos who started to work with Java in 1995. He worked on the Java Linux port with the Blackdown team. He has been doing Java consulting and development for a number of customers in completely different areas. Over the years, he has been active in a number of Java-based community projects, e.g. OSGi, the Glassfish project and JFXtras.org. With LodgON, the company he co-founded, he is mainly working on Java solutions for social networking software. Since he can't make a choice between embedded development and enterprise development, his main focus is on end-to-end Java, combining the strengths of back-end systems and embedded devices. His favorite technologies are currently Java EE / Glassfish at the backend and JavaFX at the frond-end.
Here is a short summary of Java EE 6 from him:
Developers can concentrate on business logic, Java EE 6 is providing a standard for the infrastructure
Read on for other fun stuff ...
1. How are you using Java EE 6 today ? What limits your adoption ?
I'm using Java EE 6 in most of the Enterprise projects I'm doing. This is not a requirement, but it turns out that when talking to people about what they really want, the Java EE 6 platform provides lots of the components that are needed to create an end-to-end solution.
Java EE 6 has evolved since the announcement of J2EE. It became more usable, and easier to develop and configure. In the past, a large number of non-standard libraries and frameworks have been developed since J2EE was too complex for most simple problems. The Java EE expert group clearly has learned from these evolutions, and the current Java EE 6 spec provides the functionality that is available in those frameworks, but as a standard. This is a huge benefit.
2. What Java EE 6 technologies are you using and why ?
I often use JPA. In earlier versions of the Java Enterprise standard, it was very hard to use the persistence layer in order to connect to a database. It was often easier to write your own connection pooling system, and perform SQL queries. But with JPA 2.0, it became much easier to manage the persistence.
I'm using (stateless) Session Beans as well, including the new Singleton Bean, combined with the @Startup annotation. The latter makes it much easier to perform tasks that need to be done only once.
I'm also using JAX-RS and Jersey frequently. In particular, I use Jersey for the communication with clients based on XML. The Transaction API is also something that I often use, either explicitly or implicitly.
3. What is your development and deployment environment ?
I'm mainly using NetBeans 6.9 on Linux. I download the full version of NetBeans, since I need both Java EE as well as JavaFX. NetBeans 6.9 comes pre-installed with Glassfish 3.0.1, so there is no need to download a whole application server to start Java EE 6 development.
4. What previous versions of Java EE / J2EE have you used ? How has the migration to Java EE 6 benefited ?
I've been working with Java EE since version J2EE 1.2. I have always avoided to migrate projects from older to newer versions, but I always start new projects on the latest released version. Early version of J2EE required more implementation-specific XML configuration (remember the sun-cmp-mappings.xml), and once you've done this you don't want to change this. Once projects are in deployment, you cannot easily change the runtime procedures.
Operations are often carried out by a different group than the development team. New versions of the J2EE/Java EE standard require changes in development but also in operations.
One of the benefits of Java EE 6, however, is that it also simplify the packaging and deployment procedures. Using annotations in JAX-RS and Servlets, for example, eliminates the need of XML-based configuration files. And often these configuration files make the handover from development to production deployment difficult. Clearly, the TCO for an average Enterprise project can be much lower when using Java EE6.
5. Describe the benefits of Java EE 6 to you in 120 characters.
Developers can concentrate on business logic, JavaEE6 is providing a standard for the infrastructure.
6. Advice for anybody who is looking at Java EE 6 for their next project ?
Use what you need. Nothing less, and nothing more. Although much easier than 10 years ago, Java Enterprise development can be complex. There are 2 situations you have to avoid:
- Sometimes, developers don't know about the infrastructure already provided by the Java EE platform, and they are duplicating functionality in their own code. If you look at the JPA and the JTA for example, that provides functionality that is needed in most projects.
- In a number of other cases, I see developers using features that are available in the appserver, but that are not needed in their application. The Java EE 6 spec is a composition of a number of specifications, and you don't have to use all the sub-specs.
7. What new features you'd like to see in Java EE 7 ?
Java EE 6 brought simplicity in complex enterprise applications, and made a significant move towards web-based projects. Indeed, the Java EE 6 specification is rather focused on the Web. While there are many usecases and real-world scenarios that have the Web as the most important client, I think there should be more attention for other clients, i.e. PDA, mobile phone, TV, JavaCard. Easy integration capabilities between those low-resource devices and high-end backend system will drive the adoption of Java EE.
From another point of view, more integration with the environment would be useful. For example, in a number of cases I would like to execute a specific EJB-call once CPU load is below 50%, or once disk usage is too high. I understand this is rather difficult to standardize in a non-platform dependent way.
Thanks you Johan for taking time to prepare the answers!
Are you using, consulting, training, authoring books, etc in Java EE 6 ? Drop a comment on this blog and I'll line you up for the Q&A session :-)
The Java EE 6 hub is your key resource to learn all about the technology.
And you can always try all Java EE 6 features in GlassFish. Here is an extensive of Java EE 6 & GlassFish demos is available.
Technorati: javaee6 community feedback johanvos glassfish v3
FISL 2010 Trip Report
I presented on the Java EE 6 Toolshow to an audience of approx 200. This slides-free session showed how NetBeans 6.9 provides comprehensive tooling around Java EE 6 and GlassFish 3. The session showed:
- Simplicity and ease-of-use for creating Java EE 6 web applications
- Boost productivity using Deploy-on-Save and Session-preservation across multiple redeployments
- JSP, Servlets 3.0, EJB 3.1 in Java EE 6 web apps
- Database access using Java Persistence API 2.0
- Using Facelets with Java Server Faces 2.0
- Contexts & Dependency Injection 1.0 with JSF 2
- RESTful Web services using JAX-RS
The screencast #30 made the session delivery quite a breeze and you can watch the entire session by watching the multi-part screencasts.
Meeting Bruno Souza and Fabiane Nardon was a good highlight of the trip. They are both fairly well known in the Brazilian community and we shared stories from last year's presence of Sun Microsystems at FISL. Check out their latest adventure at toolscloud.com where they provide open source tools-based development environment in the cloud.
Personally, I stayed for only couple of days because I had to come back to run a race (more on that in next blog) and attend a wedding over the weekend. A short trip but always good to spend face-to-face time with the local community.
Check out some pictures from the trip:
And the complete album at:
Technorati: conf fisl brazil oracle glassfish javaee6 netbeans
Screencast #30: Java EE 6 & GlassFish 3 using NetBeans 6.9 - 5 screencasts
This 5-part screencast shows how NetBeans 6.9 provides comprehensive tooling for Java EE 6 & GlassFish 3. The video tutorial starts with building a simple Java EE 6 application and evolves to add features from several new technologies such as Java Persistence API 2, Java Server Faces 2, Contexts & Dependency Injection, and Java API for RESTful Web services from the platform. Specifically, the different parts show:
- How to create a simple Java EE 6 application using JSP, Servlets 3, and EJB 3.1
- Reading values from a database table using Java Persistence API 2 POJO entities
- Create a template-based website using Facelets with Java Server Faces 2
- Use Contexts & Dependency Injection with JSF 2
- Publish a RESTful Web service using JAX-RS
Enjoy!
Note, this is a playlist of all the videos so click on little arrows (shown as "<" or ">") to view the different videos.
Please give us feedback on GlassFish Forums.
Technorati: screencast javaee6 glassfish tutorial netbeans
Java Road Trip 2010 - New Orleans Stop
I talked about Java EE 6 & GlassFish 3 at the New Orleans yesterday. The day started with an overcast sky, caught up with heat wave around the country (around 91 degrees), showed a reflection of super humidity (about 80%), and then ended with a thunder, lightning, and a heavy downpour while I was boarding the flight to back home.
The venue of the event was University of New Orleans but the taxi driver had no clue, even after talking to multiple folks, on how to reach there. But finally we reached after calling up his taxi company, asking at a Shell station, entering a different university, and talking to a cop. I can only we did not loose any attendees because of the location.
There were about 30 attendees spread across 3 parallel running sessions. I talked about simplicity, light-weight, extensible, and power of Java EE 6. There were no slides and only demos - after all, code is king! The key points shown were:
- Servlets 3.0 make "web.xml" optional and instead use annotations to specify that information
- Enterprise JavaBeans (EJB) can be bundled in a WAR file.
- Java Server Faces 2 uses Facelets as the templating language. This allows templates to be created and applied across different .XHTML pages easily. The different scopes allow the bean to be used appropriately.
- Creation of Java Persistence API (JPA) entity classes from a database table.
- Creation of RESTful resources - can be done as a simple root resource or generate from a database table or an entity.
All of these features were demonstrated using NetBeans although all of them can be easily achieved using Eclipse as well. A consolidated list of Java EE 6 & GlassFish 3 Demos will help you feel some of the features mentioned above.
Here are some other relevant links for the Road Trip:
Many more cities (Austin, Houston, Denver, Salt Lake City, Seattle, and Portland) are planned before the trip makes it final stop at the San Francisco Bay Area. So make sure to catch up on a local or near by city and talk to speakers from Oracle.Â
On a personal note, the hotel was in the French Quarter neighborhood so there was lot to see around. Being in the downtown, I had to restrict myself with indoor running only. The flight out of New Orleans got delayed because of thunder, lightning, and heavy downpour and so I missed my connection but caught the tail-end of a birthday party I was supposed to attend back home.
Anyway check out some pictures from the New Orleans stop:
Check out the complete album:
Technorati: conf neworleans javaroadtrip glassfish v3 javaee6 netbeans oracle
QA#2: Java EE 6: Integrated specifications, simple and annotation driven, next level of industry standard - by Markus Eisele
This entry comes from Markus Eisele - a senior technology consultant working for msg systems ag in Germany. The msg systems ag is one of the top 10 IT consulting and systems integration companies in Germany. Markus works as a software architect, developer and consultant. He also writes for German IT magazines. Markus joined msg in 2000 and has been a member of the
Center of Competence IT-Architecture since then. After being a Technical Director with BEA Systems, he has been a proud member of the Oracle ACE Directors program since 2008 (for Fusion Middleware and SOA). He works daily with customers and projects dealing with Enterprise Java and other new technologies, on a variety of platforms using different vendors. You can catch him on @myfear or read his blog.
Here is a short summary of Java EE 6 from him:
Higher integrated specifications, simple and annotation driven, single-classloader WARs, next level of industry standard
Read on for other fun stuff ...
1. How are you using Java EE 6 today ? What limits your adoption ?
Enterprise Java has been my business since more than 9 years now. The first J2EE server I was using was the former BEA WebLogic 5.1. It supported Java 2 Platform, Enterprise Edition Specification, v. 1.2 (containing EJB 1.1, JDBC 2.0, JSP 1.1, Servlet 2.2). To be honest, it wasn't big fun looking back into these days. There was lots of configuration and weird coding. And don't even think about full-blown IDE support. It was very basic and lots of coding had to be done without any assistance.
Compared to that Java EE 6 seems to be this feels as if it is light years ahead. So many things happened to the standard in the past and it is still very exiting to see the ongoing changes. Even though I am not a member of any related expert group, I am closely monitoring the public discussions and outcomes. What I can evaluate more is the adoption in the enterprise with our customers. They are more like fast followers than early adopters. And that's basically the setup I am looking at Java EE 6 today. More from an educational or research point of view. The goal is to be ready when first customers jump in. We have to answer questions for them, like:
- What can we do to migrate existing applications?
- What is the most standards compliant way of using this technology?
- What application servers should we use?
- What do the new specifications save in terms of time and/or money?
- How stable are new product versions?
If first projects start using new standards, we will be there to support them and already have answers at hand. At the moment we do not start over with Java EE 6 in projects. First projects are expected with the first commercial server versions from Oracle or IBM (WebLogic respectively WebSphere). Some of our customers are using GlassFish and they are sticking to the latest GlassFish 2.x versions while waiting for the clustering support coming in GlassFish 3.1. In the meantime we try to enable the developers with workshops and informative sessions about new features and updated specs.
2. What Java EE 6 technologies are you using and why ?
I am still working my way through the new features at the moment. Of both: GlassFish 3.x and Java EE 6. I started with the new CDI (JSR-299 + JSR-330) capabilities and looked at the improvements for implementing business logic with EJB 3.1 and JPA 2.0. The JSF 2.0 features gave a face to many of my prototypes.
The biggest improvements at the moment are the no-interface beans and the JPA 2.0 enhancements. In combination with the single-classloader model of WAR-deployment this is very handy for even the smallest applications. A situation we were forced to use Spring or other frameworks in the past. The ongoing annotation support is another feature-set I love to see. The reduced configuration effort with xml files seems handy but could bear risks for bigger applications using different frameworks and libraries. A big part of our daily work is cluster related. Therefore I am experimenting with the first 3.1 milestones at the moment.
3. What is your development and deployment environment ?
This is highly dependent on our customers. There is no single, company wide directive on what to use. The majority is using Eclipse. I personally prefer the latest Oracle Version (OEPE) but also have different plain Eclipse versions in use. Experimenting with GlassFish 3 I often use NetBeans 6.9 for demonstrations because of the very good GlassFish and Java EE 6 integration. I tend to be very close to productive environments in development. Therefore I am rarely using other databases than Oracle or DB2. I personally love to use MySQL for PoCs or demos.
In general we use lots of other environments based upon customer needs. Maven is the favorite build tool of choice at the moment. Longer running projects however still stick to ANT.
4. What previous versions of Java EE / J2EE have you used ? How has the migration to Java EE 6 benefited ?
I used J2EE since 1.2. Simple, technical migration from one product version to another was not too challenging at all in the past. Problems arose from switching vendors (Oracle/IBM) or updating specifications with major functional changes (CMP/JPA). Most challenging are customers staying with older product versions (and their bugs and needed workarounds). The pollution with workarounds and fixes never did any good in projects. Thankfully the times of custom frameworks to hide complexity seems to be up since Java EE 5. This was probably the most expensive part in many J2EE/Java EE 5 migrations in the past.
Seeing the advantages in OSGi based servers customers will hopefully be able to adopt new standards more easier in the future. Most valuable will be the new Web Profile. Most applications simply use the included specifications and could run on lighter environments. With the new CDI specifications we could remove some third party solutions and put it in the standard way. The so far missing JAX-RS closes a big gap left open by Java EE 5.
5. Describe the benefits of Java EE 6 to you in 120 characters.
Higher integrated specifications, simple and annotation driven, single-classloader WARs. Next level of industry standard.
6. Advice for anybody who is looking at Java EE 6 for their next project ?
If you are asking for available servers and the question, which specification is right for me today, I already tried to answering this in my blogpost http://blog.eisele.net/2010/05/java-ee-5-or-6-which-to-choose-today.html.
The programming approach itself is a advancement of existing Java EE 5 projects. Everything is pointing into the direction of POJOs and more Java SE like programming. Container services should be injected respectively annotated in a last step; if needed. Programming is getting more closer to solving business problems and not to the fulfillment of specification or container requirements.
7. What new features you'd like to see in Java EE 7 ?
I think the specifications are more or less feature complete. Of course I can think of a lot of improvements and I believe it's important to stay up to date and integrate new approaches.
If you look at JSF and the RI for example, I am still missing a lot of more complex components. I always find myself implementing one or two own in my projects. If you work for more restrictive enterprises, you are not always able to use the component suite of choice. If possible I still prefer to work with either RichFaces or PrimeFaces. Further on the cooperation between JSR 299 and JSR 330 should be clearer in general. The interaction between all JSRs should be taken to a next level. Clear but abstract guidelines
have to be specified, who is working with whom and how. If you look at the @ManagedBean annotation for example, you have three different ways of defining beans that are managed (JSR-314, JSR-316, JSR-299). That's not exactly what I would call intuitive ;)
Generally I would love to see the Managed Beans specification becoming the heart of enterprise java. Containers should belong to the past. Services should be available to POJOs and injected (and of course started) as needed. This could speed up the whole environment a lot and frees developers from having to implement interfaces. But the most important improvements would be administrative. Java EE 7 should put those pruning ideas forward and realy try to drop some old stuff. And finally it is time to
solve all those never-ending licensing discussions about the TCKs!
Are you using, consulting, training, authoring books, etc in Java EE 6 ? Drop a comment on this blog and I'll line you up for the Q&A session :-)
The Java EE 6 hub is your key resource to learn all about the technology.
And you can always try all Java EE 6 features in GlassFish.
Technorati: javaee6 community feedback markuseisele glassfish v3
Java EE 6 & GlassFish 3 Demos
The is a consolidated list of all the Java EE 6 blog entries published on this blog so far:
- TOTD #139: Asynchronous Request Processing using Servlets 3.0 and Java EE 6
- TOTD #137: Asynchronous EJB, a light-weight JMS solution - Feature-rich Java EE 6
- TOTD #136: Default Error Page using Servlets 3.0 - Improved productivity using Java EE 6
- TOTD #135: JSF2 Composite Components using NetBeans IDE - lightweight Java EE 6
- TOTD #133: JPA2 (JPQL & Criteria), JavaDB, and embedded GlassFish - perfect recipe for testing
- TOTD #132: Servlets 3.0 in Embedded GlassFish Reloaded - lightweight Java EE 6
- TOTD #128: EJBContainer.createEJBContainer: Embedded EJB using GlassFish v3
- TOTD #123: f:ajax, Bean Validation for JSF, CDI for JSF and JPA 2.0 Criteria API - all in one Java EE 6 sample application
- TOTD #120: Deployment Descriptor-free Java EE 6 application using JSF 2.0 + EJB 3.1 + Servlets 3.0
- TOTD #112: Exposing Oracle database tables as RESTful entities using JAX-RS, GlassFish, and NetBeans
- TOTD #109: How to convert a JSF managed bean to JSR 299 bean (Web Beans) ?
- TOTD #108: Java EE 6 web application (JSF 2.0 + JPA 2.0 + EJB 3.1) using Oracle, NetBeans, and GlassFish
- TOTD #102: Java EE 6 (Servlet 3.0 and EJB 3.1) wizards in Eclipse
- TOTD #101: Applying Servlet 3.0/Java EE 6 “web-fragment.xml” to Lift – Deploy on GlassFish v3
- TOTD #99: Creating a Java EE 6 application using MySQL, JPA 2.0 and Servlet 3.0 with GlassFish Tools Bundle for Eclipse
- TOTD #98: Create a Metro JAX-WS Web service using GlassFish Tools Bundle for Eclipse
- TOTD #95: EJB 3.1 + Java Server Faces 2.0 + JPA 2.0 web application - Getting Started with Java EE 6 using NetBeans 6.8 M1 & GlassFish v3
- TOTD #94: A simple Java Server Faces 2.0 + JPA 2.0 application - Getting Started with Java EE 6 using NetBeans 6.8 M1 & GlassFish v3
- TOTD #93: Getting Started with Java EE 6 using NetBeans 6.8 M1 & GlassFish v3 - A simple Servlet 3.0 + JPA 2.0 app
- TOTD #91: Applying Java EE 6 "web-fragment.xml" to Apache Wicket - Deploy on GlassFish v3
- TOTD #82: Getting Started with Servlet 3.0 and EJB 3.1 in Java EE 6 using NetBeans 6.7
Feel free to use any of them in your presentations or webinars or anywhere else.
What other Java EE 6 demos would you like to see ?
Technorati: javaee6 glassfish v3 demos netbeans eclipse
QA#3: Java EE 6: Jigsaw puzzle, Modular, standard, less xml, easy, easy - by Antonio Goncalves
This blog entry is third (previous ones) in the Java EE 6 feedback from the community series. You can learn about how Java EE 6 is currently being used in production, development and deployment environments used within the community, and even feature requests for Java EE 7.
This entry comes from Antonio Goncalves - a senior software architect specialized in Java / Java EE working as a consultant. He started working with Java in 1998 and quickly with J2EE in 1999. He published a first book (in French) about Java EE 5 in 2007 and became a JCP Expert Member of various JSRs in 2008 (Java EE 6, JPA 2.0 and EJB 3.1). He is a member of the OSSGTP (Open Source Solution Get Together Paris), co-leader of the Paris JUG and has been awarded Java Champion. Follow him on Twitter (http://twitter.com/agoncal) and read his blog (http://agoncal.wordpress.com/).
Here is a short summary of Java EE 6 from him:
Jigsaw puzzle, Modular, standard, less xml, easy, easy, have I said easy?
Read on for other fun stuff ...
1. How are you using Java EE 6 today? What limits your adoption ?
The first use case of using with Java EE 6 is to develop anything I need to develop, any prototype.
- Need to write a quick task processing a database? Java EE 6.
- Need to develop a quick admin site with a few pages interacting with an LDAP directory? Java EE 6.
- Need to expose a RESTful web service? Java EE 6.
The platform became so integrated, as well as being so modular, and so simple to use, that any simple use case is a perfect excuse to use Java EE 6 (take a transactional EJB 3.1, a few JPA 2.0 entities, package everything in a war, no interfaces, no XML, and you are done).
The second use case is to use some bits of Java EE 6 as a jigsaw puzzle at my customers. The beauty of EE 6 is that most specifications can be used separately. At the moment I'm using Bean Validation and JPA 2.0 under Tomcat, no need to use the full platform not to deploy it to a full compliant application server.
In my case, Spring is limiting a wider adoption of Java EE 6. Only very recently Spring Web Flow has started to support bits of JSF 2.0. The day it fully supports it, I will be able to add a few extra specs in my applications.
Another technological limitation is the limited number of containers that implement Servlet 3.0 and EJB 3.1. Today, only GlassFish and Resin implement the Web Profile (and the full profile for GlassFish). But JSF 2.0 can run on Servlet 2.5 (i.e Tomcat 6.x).
2. What Java EE 6 technologies are you using and why ?
In fact, if the question was "What Java EE 6 technologies are you NOT using and why?" I would have answered Servlet 3.0 and EJB 3.1 because they need containers (even if EJB 3.1 has an embeddable container that goes with it) and as I said, there is still a lack of containers implementing them. The rest of Java EE 6 can be used on a per-specification basis. At my customers I use any piece of Java EE 6 that I can. Bean Validation 1.0 and JPA 2.0 are so easy and well integrated that I use them as much as I can. The integration between Bean Validation and JSF 2.0 is also very handy. JAX-RS is a fantastic RESTful web services API that you can use with Servlet 2.5 containers such as Tomcat 6.x. I'm not even talking about JMS, JAX-WS and JTA that I use on a day to day basis.
3. What is your development and deployment environment?
I am an IntelliJ Idea addict. I gave up trying to figure out how Eclipse tries to work and which plugins to install (sorry, it’s not called plugins now but OSGI bundles, the ones you start and stop at runtime… what a joke). Once in a while I use NetBeans, but the Java EE 6 support with Intellij is really amazing. And then, I really have two different kinds of usages: GlassFish, H2 and MySQL and at my customers it's more Tomact, WebLogic, Websphere (unfortunately) and Oracle. Even if I have lots of complaints about Maven, I use it everywhere so I can be IDE-agnostic when I need to build my projects.
4. What previous versions of Java EE / J2EE have you used ? How has the migration to Java EE 6 benefited ?
Being a former BEA employee from 1999 and 2001, I can say that I've used all versions of the Java EE platform (from J2EE 1.2). The early versions being a very painful experience. I did a lot of Entity Beans CMP and it was a real nightmare. I remember the very first EJBs when the deployment descriptor was serialized and then it became XML files. Migrating from Entity CMPs to JPA was not easy as you had to go to your customer and say "sorry, we lied to you, Entity Beans CMP are not great and guess what? you need to throw your code to the bin and start with a fresh JPA 1.0 domain model". Like everybody I moved to Struts, Hibernate and Spring. But I quickly realized that I wasn’t an XML fan and found Spring was becoming too complex and messy for my needs. Since Java EE 5 development on server side has been simplified with convention over configuration with containers doing most of the work. Migration and portability has improved, I often work with customers who develop Java EE 5 application on one application server and deploy it in another. Java EE 6 goes even further in terms of portability.
5. Describe the benefits of Java EE 6 to you in 120 characters.
Jigsaw puzzle, Modular, standard, less xml, easy, easy, have I said easy?
6. Advice for anybody who is looking at Java EE 6 for their next project ?
Well, first of all you should buy my book ;o) (http://apress.com/book/view/1430219548) Java EE 6 is modular; don't see it as a blob. Take the bits and pieces that you need. Start with JPA 2.0 and Bean Validation, that's easy. If you can, add JSF 2.0 that will simplify configuration, resources management and component development. Take JAX-RS if you do RESTful applications. For injection, and many more, use Weld (the CDI implementation) that runs also on Tomcat. If you do Spring 3.x, think of using @Inject (unfortunately Spring doesn't implement CDI). If you then can use GlassFish or Resin, these are the two implementations ready to execute your EJBs 3.1 (JBoss 6 is on the way). Because Java EE 6 is so simple, don't over engineer your code: interfaces are not always needed; DAOs are not always needed either... KISS and refactor your code later if you really need it.
The final word is, add Java EE 6 specification to your project in an incremental way. When you can get rid of a proprietary framework and change it to a standard one, do so. You will avoid "vendor locking" (or "open source framework locking", as open source is different from open standard). And use design patterns when you really need them.
7. What new features you'd like to see in Java EE 7 ?
What I really miss in Java EE 6 is something similar to Spring Web Flow or Seam Page Flow. I hope that in Java EE 7 a new specification will come and standardize flow management (for JSF, of course, but something more general letting you manage different sorts of flows).
Batch processing is also something missing. Spring Batch is very good and defines well known principals such as jobs, steps and so one. With EJB 3.1 there is a new Timer Service (inspired from cron and as rich as Quartz). It's time to get a Batch processing specification that can be easily scheduled.
Security is also a difficult point. JAAS is too low level. Even if there are some improvements in the Servlet 3.0 API, there is still room to tight the platform together in terms of security.
Packaging could also be changed in Java EE 7. We talk a lot about OSGi these days. As a developer I found it too difficult, I would like the EE 7 platform to simplify the creation of bundles (OSGi or something different but compatible). I’m also hoping that Java SE 7 will become more modular. Modularity in Java SE 7 + OSGi packaging in EE 7 would be a great combination.
And I remember talking to Adam Bien about it, JMS hasn't changed for more than a decade, it should benefit from the novelties of the platform and get simpler.
In a word, I would like Java EE 7 to get richer (more specs), simpler (less code to write) and more integrated (security is one example).
Are you using, consulting, training, authoring books, etc in Java EE 6 ? Drop a comment on this blog and I'll line you up for the Q&A session :-)
The Java EE 6 hub is your key resource to learn all about the technology.
And you can always try all Java EE 6 features in GlassFish.
Technorati: javaee6 community feedback antoniogoncalves glassfish v3
TOTD #142: GlassFish 3.1 - SSH Provisioning and Start/Stop instance/cluster on local/remote machines
GlassFish 3.1 Milestone 2 enables SSH provisioning that allows you to create, start, stop, and delete a cluster spanning multiple instances on local and remote machines from the Domain Administration Server (DAS). This Tip Of The Day (TOTD) builds upon TOTD #141 and explains how you can create such a cluster on Amazon EC2 with Ubuntu 10.04. Carla also blogged about a similar scenario here.
The cluster topology created is shown below:

The key points shown in the topology are:
- It consists of DAS and a remote machine "fruits" (shown in green color)
- There is one cluster "food" spanning these two machines (shown in yellow color)
- DAS has "broccoli" and "spinach" instances (shown in red color)
- "fruits" has "apple", "banana", and "orange" instances (shown in red color)
Amazon EC2 assigned the public IP address of "ec2-184-72-12-163.us-west-1.compute.amazonaws.com" to DAS and "ec2-184-72-17-228.us-west-1.compute.amazonaws.com" to the remote machine. These IP addresses are used in the command invocations below.
Lets get started!
-
Configure SSH between DAS and the remote machine - More details about SSH key setup here.
-
Copy the keypair generated in TOTD #141 (ec2-keypair.pem) to DAS as:
~/.ec2 >scp -i /Users/arungupta/.ec2/ec2-keypair.pem /Users/arungupta/.ec2/ec2-keypair.pem \\ ubuntu@ec2-184-72-12-163.us-west-1.compute.amazonaws.com ec2-keypair.pem 100% 1751 1.7KB/s 00:00
Notice, the public IP address of DAS is specified here. This key will be used to copy the private keys generated in next step to the remote machine. -
Generate a private/public key pair on DAS as:
ubuntu@ip-10-160-47-196:~$ ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/home/ubuntu/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/ubuntu/.ssh/id_dsa. Your public key has been saved in /home/ubuntu/.ssh/id_dsa.pub. The key fingerprint is: 0a:b8:cd:8c:a0:7f:3d:00:9e:ec:ac:06:a1:f1:2f:cb ubuntu@ip-10-160-47-196 The key's randomart image is: +--[ DSA 1024]----+ | | | | | | |o .. | |o*.o. S | |+.=*.. . | |ooo.+o. | | ++ o o | |o.E+ . | +-----------------+
-
Copy the generated public to ".ssh" directory of the remote machine as:
ubuntu@ip-10-160-142-175:~/.ssh$ scp -i ec2-keypair.pem id_dsa.pub \\ ubuntu@ec2-184-72-17-228.us-west-1.compute.amazonaws.com:.ssh/authorized_keys2
-
Make sure the ssh connection works between DAS and remote machine without specifying any key or passphrase as shown below:
ssh ubuntu@ec2-184-72-17-228.us-west-1.compute.amazonaws.com
-
Copy the keypair generated in TOTD #141 (ec2-keypair.pem) to DAS as:
-
Install "sun-java6-jdk" and "unzip" package and GlassFish on DAS and remote machine as explained in TOTD #141. In short:
ssh -i /Users/arungupta/.ssh/ec2-keypair.pem ubuntu@ec2-XX-XX-XX-XX.us-west-1.compute.amazonaws.com sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" sudo apt-get update sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk sudo update-java-alternatives -s java-6-sun sudo apt-get install unzip wget http://dlc.sun.com.edgesuite.net/glassfish/3.1/promoted/glassfish-3.1-b06.zip unzip glassfish-3.1-b06.zip
-
Start GlassFish on DAS and remote machine as:
export ENABLE_REPLICATION=true export PATH=~/glassfishv3/bin:$PATH asadmin start-domain --verbose &
-
Create the cluster and instances by issuing the following commands on the DAS
-
Create the cluster as:
ubuntu@ip-10-160-142-175:~$ asadmin create-cluster food [#|2010-06-25T22:11:27.604+0000|INFO|glassfish3.1|org.hibernate.validator.util.Version| _ThreadID=23;_ThreadName=http-thread-pool-4848(2);|Hibernate Validator bean-validator-3.0-JBoss-4.0.2_03|#] [#|2010-06-25T22:11:27.638+0000|INFO|glassfish3.1|org.hibernate.validator.engine. resolver.DefaultTraversableResolver|_ThreadID=23;_ThreadName=http-thread-pool-4848(2);| Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#] Command create-cluster executed successfully.
-
Create a node on the remote machine as:
ubuntu@ip-10-160-142-175:~3$ asadmin create-node-ssh --nodehost \\ ec2-184-72-17-228.us-west-1.compute.amazonaws.com --nodehome /home/ubuntu/glassfishv3 fruits Command create-node-ssh executed successfully.
-
List all the nodes as:
ubuntu@ip-10-160-142-175:~$ asadmin list-nodes localhost fruits Command list-nodes executed successfully.
-
Create two instances ("broccoli" and "spinach") on DAS as:
ubuntu@ip-10-160-142-175:~$ asadmin create-instance --cluster=food \\ --systemproperties AJP_INSTANCE_NAME=broccoli:AJP_INSTANCE_PORT=19090 broccoli [#|2010-06-25T23:22:02.891+0000|INFO|glassfish3.1|javax.enterprise.system.tools.admin .com.sun.enterprise.v3.admin.cluster|_ThreadID=103;_ThreadName=http-thread-pool-4848(2);| Creating instance broccoli on localhost|#] [#|2010-06-25T23:22:03.750+0000|INFO|glassfish3.1|null|_ThreadID=30;_ThreadName=stdout;| Using DAS host localhost and port 4848 from existing das.properties for nodeagent ip-10-160-142-175. To use a different DAS, create a new nodeagent by specifying a new --nodeagent name with the correct values for --host and --port.|#] [#|2010-06-25T23:22:03.785+0000|INFO|glassfish3.1|null|_ThreadID=30;_ThreadName=stdout;| Command _create-instance-filesystem executed successfully.|#] Command create-instance executed successfully. ubuntu@ip-10-160-142-175:~$ asadmin create-instance --cluster=food \\ --systemproperties AJP_INSTANCE_NAME=spinach:AJP_INSTANCE_PORT=19091 spinach [#|2010-06-25T23:22:24.813+0000|INFO|glassfish3.1|javax.enterprise.system.tools.admin. com.sun.enterprise.v3.admin.cluster|_ThreadID=106;_ThreadName=http-thread-pool-4848(5);| Creating instance spinach on localhost|#] [#|2010-06-25T23:22:25.636+0000|INFO|glassfish3.1|null|_ThreadID=32;_ThreadName=stdout;| Using DAS host localhost and port 4848 from existing das.properties for nodeagent ip-10-160-142-175. To use a different DAS, create a new nodeagent by specifying a new --nodeagent name with the correct values for --host and --port.|#] [#|2010-06-25T23:22:25.672+0000|INFO|glassfish3.1|null|_ThreadID=32;_ThreadName=stdout;| Command _create-instance-filesystem executed successfully.|#] Command create-instance executed successfully.
The AJP_INSTANCE_NAME and AJP_INSTANCE_PORT properties will be used by mod_jk in a subsequent blog.
-
Create three instances ("apple", "banana", and "orange") on the remote machine as:
ubuntu@ip-10-160-142-175:~$ asadmin create-instance --cluster=food --node=fruits \\ --systemproperties AJP_INSTANCE_NAME=apple:AJP_INSTANCE_PORT=19090 apple [#|2010-06-25T23:23:33.208+0000|INFO|glassfish3.1|javax.enterprise.system.tools.admin. com.sun.enterprise.v3.admin.cluster|_ThreadID=104;_ThreadName=http-thread-pool-4848(3);| Creating instance apple on fruits|#] [#|2010-06-25T23:23:35.682+0000|INFO|glassfish3.1|javax.enterprise.system.tools.admin. com.sun.enterprise.v3.admin.cluster|_ThreadID=104;_ThreadName=http-thread-pool-4848(3);| Command _create-instance-filesystem executed successfully. |#] Command create-instance executed successfully. ubuntu@ip-10-160-142-175:~$ asadmin create-instance --cluster=food --node=fruits \\ --systemproperties AJP_INSTANCE_NAME=banana:AJP_INSTANCE_PORT=19091 banana [#|2010-06-25T23:23:59.697+0000|INFO|glassfish3.1|javax.enterprise.system.tools.admin. com.sun.enterprise.v3.admin.cluster|_ThreadID=102;_ThreadName=http-thread-pool-4848(1);| Creating instance banana on fruits|#] [#|2010-06-25T23:24:01.500+0000|INFO|glassfish3.1|javax.enterprise.system.tools.admin. com.sun.enterprise.v3.admin.cluster|_ThreadID=102;_ThreadName=http-thread-pool-4848(1);| Using DAS host ip-10-160-142-175.us-west-1.compute.internal and port 4848 from existing das.properties for nodeagent ip-10-160-142-20. To use a different DAS, create a new nodeagent by specifying a new --nodeagent name with the correct values for --host and --port. Command _create-instance-filesystem executed successfully. |#] Command create-instance executed successfully. ubuntu@ip-10-160-142-175:~$ asadmin create-instance --cluster=food --node=fruits \\ --systemproperties AJP_INSTANCE_NAME=orange:AJP_INSTANCE_PORT=19092 orange [#|2010-06-25T23:24:13.286+0000|INFO|glassfish3.1|javax.enterprise.system.tools.admin. com.sun.enterprise.v3.admin.cluster|_ThreadID=105;_ThreadName=http-thread-pool-4848(4);| Creating instance orange on fruits|#] [#|2010-06-25T23:24:15.089+0000|INFO|glassfish3.1|javax.enterprise.system.tools.admin. com.sun.enterprise.v3.admin.cluster|_ThreadID=105;_ThreadName=http-thread-pool-4848(4);| Using DAS host ip-10-160-142-175.us-west-1.compute.internal and port 4848 from existing das.properties for nodeagent ip-10-160-142-20. To use a different DAS, create a new nodeagent by specifying a new --nodeagent name with the correct values for --host and --port. Command _create-instance-filesystem executed successfully. |#] Command create-instance executed successfully.
-
Create the cluster as:
-
Start the cluster
-
List all instances as:
ubuntu@ip-10-160-142-175:~3$ asadmin list-instances broccoli not running spinach not running apple not running banana not running orange not running Command list-instances executed successfully.
-
Start the cluster as:
ubuntu@ip-10-160-142-175:~$ asadmin start-cluster food . . . Command start-cluster executed successfully.
-
List all the instances again as:
ubuntu@ip-10-160-142-175:~$ asadmin list-instances . . . broccoli running spinach running apple running banana running orange running
The HTTP ports of each instance can be grepped from DAS's "domain.xml". Here are the ports for each created instance: broccoli 28080 spinach 28081 apple 28080 banana 28081 orange 28082
On Amazon, you may have to poke holes in the firewall as:
ec2-authorize default -p 28080 ec2-authorize default -p 28081 ec2-authorize default -p 28082
And now "http://ec2-184-72-12-163.us-west-1.compute.amazonaws.com:28080/" ("broccoli" instance on DAS) will show the default index page. Similarly other host and port combinations will show this page as well.
-
List all instances as:
This blog showed how to create a GlassFish 3.1 cluster spanning multiple instances on Amazon EC2 with Ubuntu 10.04.
Subsequent blogs will show:
- How to deploy an app to this cluster and some variations ?
- How to front-end this cluster with mod_jk for load-balancing ?
Technorati: totd glassfish clustering ssh instance amazon ec2 ubuntu
TOTD #141: Running GlassFish 3.1 on Ubuntu 10.04 AMI on Amazon EC2
GlassFish 3.1 Milestone 2 was released this week, download the zip file.
TOTD #138 provide simple instructions to get you started with Milestone 1 and you can follow similar steps to get started with Milestone 2 as well. A more detailed blog on the new functionality (SSH Provisioning and Dynamic App Deployment) is coming as well.
In order to test the newly added clustering capabilities of GlassFish 3.1, I decided to run Milestone 2 build on a Ubuntu 10.04 instance on Amazon EC2. My host operating system is Mac OS X and even though the steps are defined at multiple locations (mentioned below) but complete set of steps were missing. This Tip Of The Day (TOTD) shows how get started with running a GlassFish 3.1 build on Ubuntu 10.04 instance on Amazon EC2.
This TOTD consulted the following blogs:
- Starting Amzon EC2 with Mac OS X
- EC2 Starters Guide on Ubuntu
- Ubuntu 10.04 LTS Daily Build - Amazon Published EC2 AMIs
- Ubuntu Linux Install Sun JDK and JRE
- How to install Sun Java on Ubuntu 10.04 LTS
Twitterverse was very helpful and Divyen helped smoothen the rough edges!
Lets get started!
- In your home directory, create a new ".ec2" directory.
-
Generate SSH Key & X.509 certificates
-
Generate X.509 certificates key
- Go to your AWS account and click on "Security Credentials".
- In "Access Credentials" section, click on "X.509 Certificates" and click on "Create a new Certificate". Make sure to download the private key file and X.509 certificate in ".ec2" directory as "cert-xxxxxx.pem" and "pk-xxxxxxx.pem".
-
SSH key - Public AMIs can be accessed using an ssh key. Give the following command in ".ec2" directory:
ec2-add-keypair ec2-keypair > ec2-keypair.pem
This will generate the SSH key in the file "ec2-keypair.pem".
-
Generate X.509 certificates key
-
EC2 API Tools
- Download Amazon EC2 API Tools from here and unzip them in ".ec2" directory.
- Move "lib" and "bin" directory from the extracted directory to ".ec2" directory.
-
Create ".ec2.profile" file in ".ec2" directory and add the contents:
export EC2_HOME=~/.ec2 export PATH=$PATH:$EC2_HOME/bin export EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem` export EC2_CERT=`ls $EC2_HOME/cert-*.pem` export EC2_URL=https://ec2.us-west-1.amazonaws.com
The last line sets the default zone to US-West-1. The AMI id used later is from this region. Source this file by giving the following command in ".ec2" directory:
source ".ec2.profile"
-
On your firewall, authorize port 22 for SSH and 8080 for HTTP access for GlassFish on your firewall as:
ec2-authorize default -p 22 ec2-authorize default -p 8080
-
Run the instance as:
ec2-run-instances ami-c597c680 -k ec2-keypair
-
Obtain the public IP address of Ubuntu instance as:
ec2-describe-instances RESERVATION r-XXXXXXXX XXXXXXXXXXXX default INSTANCE i-XXXXXXXX ami-c597c680 ec2-XX-XX-XX-XX.us-west-1.compute.amazonaws.com ip-XX-XX-XX-XX.us-west-1.compute.internal running ec2-keypair 0 m1.small 2010-06-24T16:23:44+0000 us-west-1a aki-XXXXXXXX monitoring-disabled XX-XX-XX-XX XX-XX-XX-XX
The address "ec2-XX-XX-XX-XX.us-west-1.compute.amazonws.com" is the public IP address and will be used for ssh next. -
SSH to the ready Ubuntu instance as:
ssh -i ec2-keypair.pem ubuntu@ec2-XX-XX-XX-XX.us-west-1.compute.amazonaws.com
-
Install JDK 6 on Ubuntu
-
Add the Ubuntu partner repository as:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
-
Update the list of packages as:
sudo apt-get update
-
Install JDK 6 as:
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
-
Make sure the recently added JDK is at the top of JVM search order by giving the command:
sudo update-java-alternatives -s java-6-sun
This command adds "/usr/lib/jvm/java-6-sun" to the top of "/etc/jvm" file.
-
Add the Ubuntu partner repository as:
-
Install "unzip" package as:
sudo apt-get install unzip
-
Download & start GlassFish 3.1
-
Download GlassFish 3.1 Milestone 2 as:
wget http://dlc.sun.com.edgesuite.net/glassfish/3.1/promoted/glassfish-3.1-b06.zip
-
Unzip the downloaded zip file as:
unzip glassfish-3.1-b06.zip
-
Start GlassFish as:
./glassfishv3/glassfish/bin/asadmin start-domain --verbose
- And now your default web page is accessible at "http://ec2-XX-XX-XX-XX.us-west-1.compute.amazonws.com:8080".
-
Download GlassFish 3.1 Milestone 2 as:
-
Finally terminate the instance as:
ec2-terminate-instances i-XXXXXXXX
How are you using GlassFish in the cloud ?
Technorati: totd glassfish ubuntu amazon ec2 cloud osxtips
ClustrMaps Archive - Jun 21, 2010
The clustrmaps on this blog are scheduled to be archived sometime around today. And so here is a snapshot of visitors to this blog from Jun 21, 2009 to Jun 22, 2010:

The clustrmap reports a total of 267,931 visits from all over the world. The 2009 archive was certainly much richer but I've been tweeting more often since then!
And here is the same map with smaller clusters:

Technorati: blogs bsc milestogo clustrmaps
Uber Conf 2010 - Day 4 Report - OSGi/Java EE in GlassFish and Getting Started with Clojure
Uber Conf Day 4 (Day 3, 2, and 1) started with yet another 10 miler with fellow attendees in 1 hr 18 mins and 7:49 pace. It was slightly slower than the day before - guess physical exhaustion was setting in ;-) Here are the mile splits:

Thanks to Andy for showing how to turn on the Auto-Lap feature in Garmin 305 ... really handy!
I gave a talk on how GlassFish provides a great execution environment for deploying OSGi, Java EE, and hybrid applications easily. The slides are given below:
OSGi & Java EE in GlassFish - Best of both worldsThe remainder of the day was spent in Clojure track by Stuart Halloway. Next are some basic notes for getting started with Clojure:
Why Clojure ?
- Power (hosted on jvm)
- Robustness (functional)
- Concurrency (identity, state, time)
- Abstraction (OO done right)
- Focus (lisp)
Together, these features add up to simplicity. Simplicity means
- absence of incidental complexity
- sufficient to meet your design constraints
Simplicity does not mean
- Familiarity has nothing to do with simplicity
- its not superficial, goes to the bone (e.g. only simpler syntax is just a sugar wrapper, look for the supported idioms)
- does not mean easy, its very hard to be simple
Lot of code in Clojure is not about "set" something, its about invoke a function on it.
How to get started ?
Download the latest stable release or cutting edge build. The Clojure REPL (Read-Evaluate-Print Loop) is the easiest way to run a Clojure program as shown below:
~/tools/clojure/clojure-1.1.0 >java -cp clojure.jar clojure.main Clojure 1.1.0 user=> (print "Hello World") Hello Worldnil user=> ^D
OR
~/tools/clojure/jun7 >java -cp clojure.jar clojure.main Clojure 1.2.0-master-SNAPSHOT user=> (print "Hello World") Hello Worldnil user=> ^D
Notice, the first fragment shows how to run REPL using the latest stable release and the second fragment shows the same using the cutting edge build. "Ctrl+D" exits the REPL shell. Stuart mentioned that the Clojure community stays on the cutting edge build most of the times.
Alternatively, you can also clone "labrepl" from "http://github.com/relevance/labrepl" which is an environment for exploring the Clojure language. It also provides complete instructions for getting started with NetBeans/Enclojure, Eclipse/Counterclockwise, Maven, Max/Linux command line, Windows command line, IDEA/La Clojure, and Emacs.
Configuring Clojure in NetBeans using the Enclojure plugin with NetBeans 6.9 gives the following error:

but works easily with NetBeans 6.8. The IDE seem to support REPL, Java/Clojure integration, syntax highlighting, brace/paren/bracket matching, code navigation, debugger and lots of interesting features.
Here is a typical REPL getting started session with NetBeans and Enclojure:

Here are some equivalent syntax with Java:
Semantic Java Clojure new new Widget("foo") (Widget. "foo") Access static members Math.PI Math/PI Access instance members rnd.nextInt() (.nextInt rnd) Chaining access person.getAddress().getZipCode() (.. person getAddress getZipCode)- "defn" is a symbol so no new syntax for adding a method.
- ^ introduces metadata for the next symbol, "greet" in this case. You can put metadata anywhere.
- "clojure.core" is the core of Clojure's implementation
- "javadoc" knows the default JDK javadocs, can make a local copy and/or extend it
- "show" is Java reflection
- "dir", "show", "source" are promoted from community version to the bleeding edge build.
- Source is not always exposed
- [1 2 3] Call the function 1 with arguments 2 & 3.
- '(1 2 3) don't evaluate it and print as is, just tick it.
- Idiomatically Clojure requires less parentheses than Java
-
Every single function in Clojure is Runnable and Callable
-
Java interop is simple, wrapper-free (raw), performant, complete
Compojure is a small, open source Web framework for Clojure based upon Ring (similar to Python's WSGI and Ruby's Rack). Otherwise Clojure apps are deployed as a JAR file.
A subsequent blog will show how to deploy a simple Clojure JAR file and a simple web app using Compojure on GlassFish.
And finally, here are my top-10 reasons (in no particular order) that I'd like to attend UberConf next year:
- Long 90 minute sessions
- Lots of hands-on workshops
- Fun Run as part of the formal agenda
- Beautiful location (Westin Westminster) with lots of running trails
- Great food (breakfast + lunch + dinner)
- Small attendance so intimate discussions with speakers
- Great set of speakers
- Rarely see session hopping
- Pure technology, no product pitching
- Swags are nice - bracelet-style USB stick with all the presos, 2 different tee-shirts, fancy folder and some additional goodies for speakers
See ya next year, hopefully!
Check out the complete set of pictures at:
Technorati: conf uberconf denver clojure compojure glassfish netbeans javaee osgi
Ăśber Conf Day 1 Trip Report
Jay Zimmerman kick started the 200th No Fluff Just Stuff event and Day 1 of Ăśber Conf earlier today. This event is focused on alpha-geeks, with more access to speakers, more hands-on workshops, longer hours, and attendees from 45 different states.
Cliff Click gave a great keynote talking about Challenges and Directions in Java Virtual Machines. Here are some key points from his talk:
- Hardware, Operating Systems, and JVM are ready for concurrent processing; Tools, Languages, IDEs, etc are not.
- Background compilation, Concurrent GC, Introspection and continuous profiling are some opportunities for multi-core (2-4) machines.
- Application level parallelism - JDK libraries are really useful, thread pools, pipelines of pools. No support for self-tuning and auto-sizing pipeline of thread pools.
- Data parallelism is recommended for 4-32 core CPUs - Big data, small code, small code with lots of repetition, realm of scientific computing (weather, simulation, nuclear reactor, etc)
- For 64-100 chips - Clustering on a chip, multiple applications communicating via pipes, GC fixed mallocs, parallelism at all levels (queues, caches, DB access, processor, ...)
- Java concurrency is not right most times because of the lack of knowledge, not because of language features
- Software Transactional Memory (STM) is replace existing locak with transaction boundaries, Step towards declarative program #1 issue while debugging other concurrent programs - "they can't name the shared variable"
- Other performance pitfalls - Debugging, performance, Performance Anomalies
- Suggestions for concurrent programming - Scala, Clojure, X10, JVSTM + Data modeling
The conference started on a positive note on a personal self with complimentary upgrade to first class in the flight and yet another complimentary upgrade to high-floor room in the hotel. I forgot my Garmin 305 USB connector but found another runner who has it, so nice!
Tomorrow morning starts with a 5K run and then Java EE 6 / GlassFish 3 talk at 10:30am in Westminster 1. The interesting part is that this is the first conference, at least I'm aware of, with a 5K run as part of the formal agenda. The hotel certainly has a lots of running trails near by and I did a 4 miler in the mile-high city. Looking forward to longer distance running on Wednesday and Thursday. The piano and magician during the evening reception added a good fun to the entire mix.
Now get ready to be physically and mentally exhausted!
Here are some pictures captured from today:
And here is the evolving photo album so far:
Technorati: conf uberconf denver glassfish javaee
Ăśber Conf Day 2 Trip Report
Day 2 of Ăśber Conf (Day 1) started with about 30 runners heading out for a fun run. Some of us went farther than that and certainly felt the impact of running additional distance in this "mile high city". Here is a picture of some runners:

Here are some more pictures from the run:
Complete details about the run are below:
Many thanks to Ben Ellingson for arranging this!
The runners are meeting again outside the lobby at 7am. And if you are interested in a 10K+ run then I'll see you in the lobby at 6am.
I gave a talk on Java EE 6 & GlassFish 3 and the slides are now available:
Java EE 6 & GlassFish 3I attended a few sessions today and here are my notes from them.
- Transforming to Groovy - Venkat demonstrated Groovy's agility by taking converting a Java code to Groovy and highlighting the idioms on the way. He explained multi methods, delegation, improved reuse using Closures, Execute Around method, simplified List management, conciseness, multi-line string, file read, working with XML and other similar features of the language.
- The Art of (Java) Benchmarking - Cliff Click talked about several micro and macro benchmarks and classified them in BUSTED and PLAUSIBLE categories with appropriate reasoning. There were clear recommendations such as warmup loops, planning for variation in results, multiple runs and reporting average and standard deviation, and many others to make sure the generated results are valid.
- Hadoop Workshop I - The workshop required to run a VMWare image so I could not perform any of the hands-on stuff. But Matthew MucCullough gave a very good explanation of MapReduce, Hadoop, and other internals.
- Building RESTful ROA Architecture at Orbitz - Alex Antonov talked about how Orbitz evolved from a Jini/Java-based SOA to a ROA architecture. He listed the standard request methods (GET, PUT, POST, DELETE), standard response codes (200, 202, 404, ...), clear resource representation, and simplicity of HTTP on "Why REST". A significant part of the talk was about Protocol Buffers - a language/platform neutral and extensible mechanism for serializing structured data.
The post-dinner panel discussion with @paulk_asert, @pragkirk, @iansrobinson , @johannarothman, @benrady, and @stuarthalloway was interesting as well.
Here are some of the Q&A from the session:
Q: What language would you recommend for beginning computer science ?
Stuart: Scheme
Kirk: Text-based environment does not excite them, try visual environment.
Paul: Most of the languages can give as many good habits as bad habits so no specific answer.
Ian: No specific language - something main stream like Java and C# and then move around.
Johanna: May be Scheme
Ben: Pure science (Lisp, C) or software engineering (Java, C#)
Q: What is the key to building resilience ?
Johanna: Broaden the specialties, expand the horizon
Ben: People who solve problems, use architect/development/testing/etc skills to solve the problems
Kirk: Always look for something that moves you away from your comfort zone
Stuart: Learning little bit about functional programming, start learning and you'll be there
Q. What strategies do you guys use to stay current ?
Stuart: Gadgets, follow the ambience using holes in the day (dropping kids, traffic lights, etc). Thinking during running and mechanical typing afterwards.
Ian: Highlight keywords, thinking during morning/evenings
Paul: Networking, look for smart people within your organization
Kirk: May be chained to desk 4 hrs but work hours is 10 hrs because of different gadgets
Ben: Follow the people that you know, RSS reader
Johanna: Don't keep up, pick & choose
Q. On your best project, what was the ratio of star/steady guys ?
Ben: 10:1 in a startup, the company folded
Stuart: 2:0 or 3:0 for the dream team, 5 too big
Johanna: 85 development team - all star, respect for each other, contentious discussions.
Kirk: 75 developers, 7 individuals core group drove the project. Fundamental force that made them succeed was team cohesion (been together for 2 years)
Paul: Have people in the team who can work
Ian: Diverse teams are good
There was discussion around craftsmanship and apprenticeship. Stuart talked about how "craftsmen swap" in like-minded shops can help the growth. There was also discussion around Resume-Driven-Development (RDD). Kirk and others point was that resume basically gets you to the interview, you still need to know the skill to get the job.
And just for fun, here is the panoramic view from my hotel room this morning:
![]()
It was simply breathtaking!
And here is the evolving photo album:
Technorati: conf uberconf glassfish javaee6 denver
Uber Conf 2010 - Day 3 Report
Day 3 of Uber Conf 2010 (Day 2 and 1), again, started with a great run with fellow attendees - 10 miles in 1:15:22 with an average pace of 7:28 minutes/mile. Here is the speed-vs-elevation chart:

And complete details about the run are available below:
After a mentally and physically exhausting day, lets see how many runners show up for the run tomorrow morning. I'll try to be outside the lobby by around 6:30 am-ish.
Attended a 3 hour Scala for Java Programmers Workshop by Venkat and extensive notes + code samples on that are available here.
The next interesting talk I attended was on Emergent Design by Neal Ford and here are the key points:
- Emergent Design is about finding idiomatic patterns (technical and domain) in your code that already exists
- Architecture is stuff that's hard to change later - e.g. Language, Web framework. You write code on top of that framework and is the Design element which can be easily changed.
- What is software design ? More details on developerdotstar.com/mag/articles/reeves_design.html
- There are known unknowns and there are unknown unknowns - just like software.
- Things that obscure emergent design: nature of complexity (essential and accidental),technical debt,rampant genericness
- Emergent design enablers - TDD, Refactoring to remove technical debt, harvesting/cultivating idiomatic patterns
- Use testing as a design tool, design will emerge from tests, will have better abstractions and less complexity
- Reduce your Technical Debt by writing simpler code
I attended part of the Hudson Workshop and caught some part of Pragmatic Architecture Workshop.
Ted mentioned in his talk about three categories of knowledge:
- Things you know
- Things you know you don't know
- Things you don't know what you don't know
The goal is to move maximum amount of things from Category #3 to #2 and then from #2 to #1.
Attended another talk on How to Approach Refactoring by Venkat and here are the key points captured:
- "Refactoring: genuine desire to improve the quality of your code and design in it" and it keeps you agile
- Write a little code, make it better, write a little code, make it better, ... - evolutionary or emergent design leading to agile
- Hardest part in refactoring & unit testing: slow down and take small steps
- Commenting the code during refactoring is like leaving a dead rat on the table, that's what SCM is for
- We fear to fail, the more we fail in small steps the more we succeed in bigger steps - go refactor your code and make it agile
- Simplicity, Clarity, Brevity, Humanity - best principles to design and refactor code
- Integrate more often and its less time consuming; Integrate less often and its more time consuming
-
Principles
- Check in before you start refactoring
- Rely on automated tests
- Reduce, not add, code when refactoring
- Follow the KISS (Keep It Simple Stupid)
- Keep it DRY
- Make code self documented, let the test be the documentation
- Write readable code
- Check in frequently, take small steps
- Keep code at one level of abstraction
The evening concluded with a nice party and a wonderful magic show by Michael Carducci. Enjoy a short video of Jay "trying" to perform a magic trick:
Here are some pictures captured from earlier today:
And then the evolving album:
Technorati: conf uberconf denver refactoring design software architecture
QA#1 - Java EE 6: Standards compliance, Vendor independence, Light-weight deployment - by Adam Bien
The first one comes from consultant and author Adam Bien (blog.adam-bien.com) who is an Expert Group member for the Java EE 6, EJB 3.1, and JPA 2.0 JSRs. He has worked with Java technology since JDK 1.0 and Servlets/EJB 1.0 in several large-scale projects and is now an architect and developer in Java SE/EE/FX projects. He has edited several books about Java (FX) and J2EE / Java EE and is the author of Real World J2EE Patterns (http://press.adam-bien.com). Adam is a Java Champion and JavaOne 2009 Rock Star.
Here is a short summary of Java EE 6 from him:
Standards compliance, vendor independence, milliseconds and kilobyte deployment
Read on for other fun stuff ...
1. How are you using Java EE 6 today ? What limits your adoption ?
For server-side development Java EE 6 is the simplest thing you can get today. Because I’m lazy - Java EE 6 is the obvious choice. You can get everything you need with a single download. It works really well. Recently I let 20 students in a workshop install IDE, application server + database ...in 15 minutes. After that we started hacking. The machines were really heterogenous (Windows, Mac, Linux)- and it worked.
I’m using Java SE and EE since their inception. I didn’t used EJB 1.0 (it was before J2EE), but started with 1.1. In several projects I had to use J2EE but omitted successfully the XML-hell with XDoclet.
This was fixed with Java EE 5 - since then (>4years) there are no more workarounds necessary and you can fully concentrate on the business logic. Java EE 6 became even better.
The adoption of Java EE is far better, than expected (by me). It turns out, that in economic slow down management is really interested in standards again. This is the only explanation I have. Java EE 6 seems to take off. I had to limit the number of registrations in last workshops to 20 and repeat a workshop at a JAX-conference (one of the biggest European conferences). The organizer ask me, whether I would like to repeat a workshop, because they were already 75 registrations. The workshop was repeated - ...with about 160-180 attendees.
J2EE was said to be too complex for simple applications. The opposite is true in Java EE 6. It turns out to be any leaner, simpler and more maintainable comparing it with the alternatives. All attempts of wheel re-invention I saw so far resulted in far more complex and harder to understand code.
2. What Java EE 6 technologies are you using and why ?
I’m really enjoying the single-classloader model of WAR-deployment. In all new Java EE 6 projects we got rid off “modular” EARs and EJB-JARs and deployed everything into a WAR. It doesn’t seem to be hype-compatible, but it works very well. Especially if you don't have any additional versioning or modularization requirements. The lack of dynamic reloading and module-hot-replacement in product is given for the majority of all enterprise projects. In real world the deployment units become even coarser.
I start the implementation of the business logic with EJB 3.1 and JPA 2.0. In case remoting is necessary - I use REST (JAR-RS) with JSON for the vast majority of all cases. CDI (JSR-299 + JSR-330) is even more powerful, but I don’t use the extended dependency injection capabilities (produces, alternatives, custom annotations, stereotypes, events) from the beginning, rather than applying them selectively to solve particular problems. CDI allows you to realize a factory, observer or strategy patterns without any overhead. In fact a plain Java SE solution would be even more bloated.
For the web part - I start with JSF 2.0. Also the adoption of JSF 2.0 is unique. There are many books, tutorials, frameworks and libraries available already. I attended a JSF conference this year with several hundred attendees.
Frameworks like Wicket or GWT are very interesting. I always start, however, with the evaluation of JSF 2. Is is already available on every Java EE 6 server - so why don’t use it.Â
I would choose the alternative web frameworks, in case there is an evidence that the solution would be leaner, cheaper or easier to maintain. In the majority of all recent cases - JSF 2.0 was just good enough. Before JSF 2.0 I often used Wicket.
3. What is your development and deployment environment ?
I’m using mainly NetBeans 6.9 “Java Edition” with Glassfish v3 and Java DB / Derby (in early iterations). After the setup and stabilization phase I always use the production databases. These are mainly Oracle, sometimes DB 2 or MySQL.
In smaller teams I prefer the NetBeans build-system (Ant). In bigger teams and projects Maven. NetBeans supports both flavors really well, but Ant incremental deployment is orders of magnitudes faster than maven. You can redeploy an EJB/CDI or JPA entity with Ant in millisecods, with Maven it will take seconds. This is a huge productivity gain.
I also have an IntelliJ 9.0.2 Ultimate license and use this IDE as well. It excels NetBeans in some areas like e.g. JPA QL autocompletion. These features, however, are part of the commercial distribution and so hard to introduce into teams. In most cases I fallback to NetBeans.
4. What previous versions of Java EE / J2EE have you used ? How has the migration to Java EE 6 benefited ?
I used J2EE since 1999. The migrations were never fun. Except the migrations from J2EE into Java EE 5. Because Java EE 5/6 have still to support the old J2EE components, you can deploy your old application into a new server and start to delete code. The benefits are obvious: you can delete > 60% of the code without any impact on the functionality. With the code you can also get rid off strange patterns, extensive layering and other strange “legacy” practices. This leads to reduction of the maintenance costs.
5. Describe the benefits of Java EE 6 to you in 120 characters.
Standards compliance, vendor independence, milliseconds and kilobyte deployment.
6. Advice for anybody who is looking at Java EE 6 for their next project ?
Reduce to the max. Concentrate on the business logic and not the technology. Write plain Java SE domain objects first (Unit-Tests of course before that :-)), introduce EJB 3.1 / CDI facades later. Don’t even try to use everything what is offered by Java EE 6. But before you start to implement you own solution, look at Java SE 6 first, then Java EE 6. You will be surprised how much functionality is already there.
7. What new features you'd like to see in Java EE 7 ?
Further simplification and unification of the APIs would be great. The synergies of JSF 2, EJB and CDI could be a lot more leveraged. A more natural use of java.util.concurrent in Java EE would be also interesting (e.g. injection of Executors). For all of my cases @Asynchronous worked perfectly, but Executors seem somehow to fascinate developers :-)
JPA 2.0 could be also extended with some useful features like support of resource injection (EntityManager is the most important) into JPA-entities. Its a controversial topic - but really important for projects. Also better support for stateful environments would be nice.
I would also expect a standardized JAX-RS client. Something like jersey, but with javax.ws.rs. prefix :-)
I’m really surprised, that actually no-one really complains over the really old JMS programming model (1997). This spec could be drastically simplified. A plain injection of a simplified queue or topic would be sufficient for > 80% of all cases.
Are you using, consulting, training, authoring books, etc in Java EE 6 ? Drop a comment on this blog and I'll line you up for the Q&A session :-)
The Java EE 6 hub is your key resource to learn all about the technology.
And you can always try all Java EE 6 features in GlassFish.
Technorati: javaee6 community feedback adambien glassfish v3
Uber Conf 2010 - Notes from Scala for Java Programmers Workshop
I spent the first half of Day 3 of Uber Conf 2010 (Day 2 and 1) in Scala for Java Programmers workshop by Venkat, took extensive notes, and noted/tried pretty much all the code samples.
<warning>
This is a code intensive and slightly long entry.
</warning>
A more complete entry covering other events of Day 3 will come later today.
Lets go down the rabbit hole!
- Why Scala ? - Scala is highly concise, expressive, nice support for XML processing, pattern matching, inherent support for authoring concurrent code - lot of good things to write efficient code.
- Scala means SCAlable LAnguage - comes from the fact that you can write either a small script or a complete application using Scala.
- An application developed on single core and deployed on multi-core can easily misbehave, primarily because of the concurrency model in Java. Scala makes it much easier to write concurrent applications (more on this below).
- Writing correct synchronized code in Java requires divine power. Multi-threaded programming in Java is like working with mother-in-law, basically waiting for you to fail.
- Scala complies with Java semantics without you worrying about it. "-savedcompile" saves the generated class files as JAR in the local directory.
Here is the first sample code that calculates the factorial of a number:
def fact(number: Int) = {
var total = 1
for (i <- 1 to number) {
total = total * i
}
total
}
println(fact(5))
Key points about this code (differences from Java):
- Each class is "public" by default
- No "main" method
- "return" keyword is not required
- The index "i" is assigned a type using inference, integer in this case
- "var" defines a variable
This was done as a user exercise and so I wrote my first Scala code today ... yeee-haw!
- Recursion is very expressive but expensive because of multiple stacks. Scala makes it run iterative and so less expensive
- Scala supports tail recursion to a fairly decent extent, only one level of stack and so less expensive.
Here is a re-write of the above function using simple iterative recursion:
def total(number:Int) : Int = {
if (number == 1)
return 1
number * total (number - 1)
}
println(total(5))
And now this method converted to use tail recursion
def total(number: Int) : Int = {
def totalWithAccumulator(accumulator: Int, number: Int) : Int = {
if (number == 1)
accumulator
else
totalWithAccumulator(accumulator * number, number - 1)
}
totalWithAccumulator(1, number)
}
println(total(5))
Here is a function that calculates the total of elements in a list:
def total(list: List[int]) = {
var total = 0
for (e <- list)
total = total + e
total
}
val list = List(1,2,4,5,6,3)
println(total(list))
This is using iterative approach - keep modifying the variable over & again and tells the next step. In functional, variables are constant and never changed. And here is a new method using the functional capabilities:
// imperative
def total(list: List[int]) = {
var total = 0
for (e <- list)
total = total + e
total
}
// functional
def total2(list: List[int]) = {
list.foldLeft(0) {
(carryOver, e) => carryOver + e
}
}
val list = List(1,2,4,5,6,3)
println(total(list))
println(total2(list))
In Scala
a.+(b);
is equivalent to
a + b
".", parentheses, and ";" are optional.
When the method name ends with the colon, Scala will transpose them. The following code snippet shows this and some other features of the language:
val list = List(1,2,4,5,6,3)
// Imperative
var total1 = 0
for (e <- list)
total1 = total1 + e
println("Total is " + total1)
// Functional
val total2 = list.foldLeft(0) { (carryOver, e) => carryOver + e }
println("Total is " + total2)
// Transposition using colon
// /: is a different name for foldLeft
var total3 = (0 /: list) { (carryOver, e) => carryOver + e }
println("Total is " + total3)
// No name required if the parameters are used only once
var total4 = (0 /: list) { _ + _ }
println("Total is " + total4)
// Pipe the method
def add(op1: Int, op2: Int) = { op1 + op2 }
val total5 = (0 /: list) { add }
println("Total is " + total5)
- No primitive types in Scala, everything is an object
Code samples of closures in Scala ...
def totalSelectedNumbers(list:List[Int], selector: Int => boolean) = {
var total = 0
for (e <- list)
if (selector(e)) total = total + e
total
}
val list = List(1,2,4,5,6,3)
println(totalSelectedNumbers(list, { e => true }))
println(totalSelectedNumbers(list, { e => e % 2 == 0 }))
println(totalSelectedNumbers(list, { e => e > 4 }))
println(totalSelectedNumbers(list, { _ > 4 }))
Notice how "println" becomes more concise over subsequent lines. And a further cleaner, and concise, version can be written by allowing multiple lists to be passed to the function as shown below:
// Multiple lists to the function
def totalSelectedNumbers(list:List[Int]) (selector: Int => boolean) = {
var total = 0
for (e <- list)
if (selector(e)) total = total + e
total
}
val list = List(1,2,4,5,6,3)
println(totalSelectedNumbers(list) { _ > 4 })
Here is another exercise to write a function that doubles the number in the list:
val list = List(1,2,4,5,6,3)
println(list.map { _ * 2 })
And another exercise to find the maximum number of a list
val list = List(1,2,4,5,6,3,2,7)
val max = (list(0) /: list) { (max, e) =>
            if (e > max) e else max
         }
println (max)
And then a simplified method definition ...
println((list(0) /: list) { Math.max })- In Scala: "val" creates a pointer that cannot change, "var" creates a pointer that can change but the objects are immutable.
- In Scala, everything is public unless you say otherwise.
- Code within the class runs within the primary constructor. In Scala, there is only one constructor, every other is called as auxiliary constructor and they always go through the primary constructor. Only primary constructor can call super (only path to the base class)
Here is a simple class definition:
class Car(val year: int, var miles: Int) {
// invokes with primary constructor
println("hello there")
// year has a getter, miles has a getter/setter
def drive(dist: Int) = {
miles += dist
}
// private method only to this instance
private[this] def tuneup {}
}
val car = new Car(2010, 0)
println(car.year)
println(car.miles)
car drive 10
println(car.miles)
- Scala is a purely OO language, new methods can be defined easily on any object
Here is a sample code that demonstrates adding a new method:
import java.util._ // static import
class IntUtil(number: Int) {
def days = this
def ago = {
var cal = Calendar.getInstance()
cal.add(Calendar.DAY_OF_MONTH, -number)
cal.getTime()
}
}
val num = 2
val obj = new IntUtil(num)
println(obj.days.ago)
- Scala has no primitive types, everything is an object.
- New methods can be easily added using "implicit conversion"
Here is a code sample that shows how to perform "implicit conversion" and add a new method to a "val"
import java.util._ // static import
class IntUtil(number: Int) {
def days = this
def ago = {
var cal = Calendar.getInstance()
cal.add(Calendar.DAY_OF_MONTH, -number)
cal.getTime()
}
}
val num = 2
val obj = new IntUtil(num)
println(obj.days.ago)
// implicit conversion - only one conversion can be applied per object (or class??)
implicit def pleaseConvertInt2WonderfulIntUtil(number: Int) = new IntUtil(number)
println(2.days.ago)
- To create Singleton, use the word "object" such as:
class Car {
}
object Car {
// place all the static methods here
}
- This singleton object is also called the "companion" object and it must exist in the same file as the original object.
- Companion object is used to create the factory pattern.
- Adding "private" to the class definition makes the constructor private.
- "apply" is a special method: "blah.apply(something)" is equivalent to "blah(something)"
- "apply" has a cousin "update" and takes 2 parameters
Here is a code that demonstrates some of the above mentioned features:
import scala.collection.mutable._
class Pen private (val color: String) {
println(color + " pen being created")
}
// companion object - singleton
object Pen {
val pens : Map[String, Pen] = Map()
def createPen(color: String) = {
if (!pens.contains(color))
pens(color) = new Pen(color)
// == pens.update(color, new Pen(color)
pens.get(color)
}
}
val bluePen = Pen.createPen("blue")
val bluePen2 = Pen.createPen("blue")
val redPen = Pen.createPen("red")
Running this code shows that "blue" pen is created only once and cached during second attempt. Notice, how the Pen is created using "createPen" factory method. This code can be changed to use "apply" as:
import scala.collection.mutable._
class Pen private (val color: String) {
println(color + " pen being created")
}
// companion object - singleton
object Pen {
val pens : Map[String, Pen] = Map()
def apply(color: String) = {
if (!pens.contains(color))
pens(color) = new Pen(color)
pens.get(color)
}
}
val bluePen = Pen("blue")
val bluePen2 = Pen("blue")
val redPen = Pen("red")
Notice how default constructors instead of the factory pattern are now used.
Here is a piece of code that has two classes with similar functionality:
class Human(val name: String) {
def listen = println("I am " + name + " your friend")
}
class Animal(val name: String)
class Dog(override val name: String) extends Animal(name) {
def listen = println("I am " + name + " your friend")
}
val peter = new Human("Peter")
peter.listen
val rover = new Dog("Rover")
rover.listen
This violates the DRY principle. Scala Traits allows to encapsulate the code as shown below:
trait Friend {
val name: String
def listen = println("I am " + name + " your friend")
}
class Human(val name: String) extends Friend
class Animal(val name: String)
class Dog(override val name: String) extends Animal(name) with Friend
val peter = new Human("Peter")
peter.listen
val rover = new Dog("Rover")
rover.listen
// include trait at an object level
class Cat(override val name: String) extends Animal(name)
val molly = new Cat("Molly") with Friend
molly.listen
- XML processing is a first class citizen in Scala
val xml = therethere
println(xml)
// XPath query
println(xml \\ "@greet")
println(xml \\ "where")
val stock = Map("APPL" -> 250, "GOOG" -> 300)
def createStock() = {
stock.map { entry => }
}
// Scala code within XML
val xml = { createStock() }
println(xml)
Here is the last exercise from the workshop: Use Yahoo Weather API to find the temperature of Denver, CO:
import scala.xml._
import scala.io._
import java.net._
val theURL = "http://weather.yahooapis.com/forecastrss?w=2391279&u=f"
val xmlString = Source.fromURL(new URL(theURL)).mkString
//println(xmlString) // for debugging
val xml = XML.loadString(xmlString)
val city = xml \\ "location" \\ "@city"
val state = xml \\ "location" \\ "@region"
val temperature = xml \\ "condition" \\ "@temp"
println("Temperature in " + city + ", " + state + " is " + temperature)
- Actors enable concurrency in Scala, "receive" is used to receive the response from each Actor
- Don't use "receive" outside, use receive within
- OK to share Java code within Scala only if its mutable
- Scala has "tuples", are immutables, and really good candidate for concurrency
Here is a sample code refactoring the above code in a method, called 50 times in a loop, printed once using traditional method invocation and once using Actors. The total time taken for the two set of executions is then printed.
import scala.xml._
import scala.io._
import java.net._
import scala.actors._
import Actor._
def getTemperature(woeid: Int) = {
val theURL = "http://weather.yahooapis.com/forecastrss?w=" + woeid + "&u=f"
val xmlString = Source.fromURL(new URL(theURL)).mkString
val xml = XML.loadString(xmlString)
val city = xml \\ "location" \\ "@city"
val state = xml \\ "location" \\ "@region"
val temperature = xml \\ "condition" \\ "@temp"
(city, state, temperature) // tuples are immutable
// good candidates for concurrency
}
val start = System.nanoTime
for (woeid <- 2391250 to 2391299) {
println(getTemperature(woeid))
}
val end = System.nanoTime
println("Time taken (without Actor): " + (end - start)/100000000.0)
// Now dispatching to multiple actors
val start2 = System.nanoTime
val caller = self // self is a pointer to my actor
for (woeid <- 2391250 to 2391299) {
actor { caller ! getTemperature(woeid) } // Dispatch 50 actors
}
for (woeid <- 2391250 to 2391299) {
receive {
case msg => println(msg)
}
}
val end2 = System.nanoTime
println("Time taken (with Actor): " + (end2 - start2)/100000000.0)
A sample result from running this script showed the results:
Time taken (without Actor): 171.62816 Time taken (with Actor): 29.05179
As you can see the difference is quite evident - approx 6x better performance when using Actors.
Overall, super excited after writing so much Scala code and learned something new.
Thank you Venkat for yet another great workshop!
Technorati: conf uberconf scala java workshop
Jazoon 2010 Day 3 - Java EE 6 on Cloud, HTML 5 with JSF 2 and another run on Ăśetliberg
The Day 3 of Jazoon (Day 1 & 2) started with a great presentation on Gaia satellite and Data Processing by William O'Mullane. Gaia is a European Space Agency space mission that will be launched in Summer of 2012 to compile a catalog of approximately 1 billion stars. Most of their software is Java-based and have been fairly happy with the decision taken 10 years ago. They are very happy with the performance of Java and in certain cases its even 10x faster than C.
I gave a talk on "Running Java EE 6 applications in the Cloud". The talk explained flexibility, light-weight, extensibility, and ease-of-use of Java EE 6. It demonstrated a simple sample development and rapid deployment feature using NetBeans IDE. And then quickly jumped into how this application can be deployed on Amazon EC2, RightScale, Elastra, and Joyent infrastructure. I learned about the Simple Cloud API (Storage only) and Apache libcloud from Doug Tidwell's talk yesterday and so will try them as well.
I gave a tee-shirt from the Bay Area JUG Roundup to Rainer Grau - moderator of the conference and he was kind enough to change it for rest of the day. See his picture below.
The slides from my talk are available below:
Running your Java EE 6 applications in the cloudMore detailed steps to deploy your Java EE 6 application on each cloud management / provider mentioned above will be available in a later blog. Instant feedback via twitter is always much appreciated as shown in the case below:

The Spring 3.0 Themes and Trends talk was quite a dejavu because it was mostly a rehash of what is available in the Java EE 6 today. And I could not understand why would anybody use Spring (instead of Java EE) to use the goodness of the JSF and JPA technologies ?
Roger's talk on "Exploring HTML 5 with JSF 2" was very interesting and had a packed room, small but packed. He showed lots of HTML 5 samples and how Java Server Faces 2 can be used to include new tags like audio / video in a JSF composite component, Web Sockets and even Web Workers with JSF 2. His slides are available at:
Exploring HTML 5 with JSF 2Roger & I will work on publishing detailed steps on these demos in the coming days.
Spring Roo was a good one but it seems like that its basically trying to bring Ruby-on-Rails concepts like Dynamic Functions and Scaffold with some usual tooling tricks and heavy code generation to the Java programming language. One more framework, one more convention, one more programming style ... not sure if it fills any gap!
Dan & Aslak presented on Real Java EE Testing with Arquillian and this was mostly a demo-driven talk showing how different Java EE technologies can be easily tested using ShrinkWrap and Arquillian. And the cool thing is that they support deployment to GlassFish Embedded as well.
Here are some pictures from earlier today:
And the day concluded with yet another great run up Ăśetliberg, just a simple out & back but 1404 ft elevation gain in 4.59 miles. The elevation map is shown below:

More details about the run are given below:
Here are some pictures captured during the run:
It is just beautiful - definitely worth going at least once!
Last but not the least, Roger & I had a great dinner at au gratin - a great restaurant + adjoining bar on the first floor on Bahnhofplatz. They've got great food variety at a great location, reasonably priced (as per the Swiss standards ;-), and an American Football aficionado server by the name David. If you meet him, say our hello to him :-)
And here is the complete photo album:
This was my first Jazoon conference in the beautiful country of Switzerland and I thoroughly enjoyed it. I had some useful conversations and made some good contacts. I'd love to come back here again next year as well!
Next step Ăśber Conf ...
Technorati: conf jazoon zurich javaee glassfish cloud amazon rightscale elastra joyent html5 jsf2 spring
TOTD #140: Moving GlassFish Installation - Referenced file does not exist "osgi-main.jar"
This is a quick Tip Of The Day (TOTD) to show how to get GlassFish running again if the directory is moved to a new location after it has been started once. Note, of course, you are not moving the directory while the server is running. Its only after the server has been started once at least and stopped.
If you move your GlassFish installation to a different directory then you may see errors like:
ERROR: Error creating archive. (java.io.IOException: Referenced file does not exist: /Users/arungupta/tools/glassfish/v3/glassfishv3/glassfish/modules/osgi-main.jar)
java.io.IOException: Referenced file does not exist: /Users/arungupta/tools/glassfish/v3/glassfishv3/glassfish/modules/osgi-main.jar
at org.apache.felix.framework.cache.BundleArchive.createRevisionFromLocation(BundleArchive.java:994)
at org.apache.felix.framework.cache.BundleArchive.revise(BundleArchive.java:631)
at org.apache.felix.framework.cache.BundleArchive.(BundleArchive.java:206)
at org.apache.felix.framework.cache.BundleCache.getArchives(BundleCache.java:149)
at org.apache.felix.framework.Felix.init(Felix.java:558)
at org.apache.felix.main.Main.main(Main.java:292)
. . .
org.osgi.framework.BundleException: Bundle symbolic name and version are not unique: com.sun.grizzly.grizzly-config:1.9.18.k
at org.apache.felix.framework.BundleImpl.createModule(BundleImpl.java:1145)
at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:79)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2372)
. . .
May 30, 2010 4:27:05 PM Main install
WARNING: Failed to install file:/Users/arungupta/tools/glassfish/v3/glassfishv3-2/glassfish/modules/grizzly-config.jar
org.osgi.framework.BundleException: Bundle symbolic name and version are not unique: com.sun.grizzly.grizzly-config:1.9.18.k
at org.apache.felix.framework.BundleImpl.createModule(BundleImpl.java:1145)
at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:79)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2372)
. . .
Fortunately the fix is simple, just remove your "domains/domain1/osgi-cache" directory. The cache will be rebuilt during the next run of GlassFish.
Technorati: totd glassfish v3 osgi cache error
Ăśetliberg - Great uphill run at Jazoon 2010 Day 2
Three of us (2 ex-Ironman and me) ran to the top of Ăśetliberg (a mountain on the Swiss plateau) on the Day 2 of Jazoon - a great uphill run. There were showers + lockers right at the trailhead so that was extremely convenient. The first 3 miles were rolling hills with a constant elevation gain and then it shot up 500 ft within next 1/4 mile. After another 2.5 miles of rolling hills we reached the hill top. The total run was little over 8 miles with an elevation gain of 1755 feet in about 5.8 miles and a maximum elevation of 2830 ft - an excellent workout overall! Needless to say, the other 2 runners were pretty solid, being ex-Ironman, but this will help me prepare better for the upcoming San Francisco 1/2 Marathon.
Here is the elevation map of the run:

There was drizzling all the way up & down and lots of fog on the hill top so we could not enjoy the otherwise spectacular panoramic view of the entire Zurich city and Lake of Zurich. But may be I'll run there tomorrow again and this time with a camera :-)
And more details can be found below:
For those interested in the view only, the summit is also accessible by the train.
Thanks to Dan Allen for connecting me with Bela Ban for this run! This is how I celebrated the National Running Day. Are you planning to run anything nice ?
Other than running, I attended some good talks earlier in the day Unleash your processors, HTML 5 WebSockets, and Keeping Your Options Open - Even If the Cloud is Not. The keynote by Ken Schwaber (scrum.org fame) on "Total Cost of Ownership" gave some good points about "When are you done ?", "My / Your / Our kind of done" and other benefits of Scrum/Agile. But then soon turned into a marketing pitch about a new course starting in Switzerland.
And now finally, my talk tomorrow morning on "Running your Java EE 6 applications in the Cloud".
Here is the evolving album so far:Technorati: conf jazoon zurich uetliberg uphill running
