Agile IT! Experience

NFJS / Java World Podcast

User Group Events

May. 20 - St. Paul, Minnesota
The Busy Developer's Guide to Scala by Ted Neward
by Ted Neward
Object Technology User Group - more »
May. 20 - Portland, OR
Design Patterns in Dynamic Languages
by Neal Ford
Portland Java User's Group - more »
May. 29 - Austin, TX
A Thorough Introduction to Groovy
by Jeff Brown
Austin Java Users Group - more »
Jun. 11 - Calgary, AB
Core Groovy
by Andrew Glover
Calgary Java Users Group - more »
Jun. 11 - Dallas, Texas
Grails - Agile Web 2.0 The Easy Way
by Jeff Brown
JavaMUG - more »

Private Events

Blogs

View all Blogs >>
  • Alex Miller

    Sr. Engineer with Terracotta Inc.

    I need something to handle versioning on some local personal stuff. I just want it to run on my own box and have no plans to ever share any... more»

  • Matt Raible

    Creator of AppFuse and author of Spring Live

    Alternative Adult has only posted a couple times in 2008, but his entries have peaked my interest. more»

  • Michael Nygard

    Agile technology leader and dynamicist

    So, I got a Wii for Father's Day last year. It's been a lot of fun to play together with my kids, my wife, and even my parents and in-laws.... more»

  • Mike Levin

    Software Developer specializing in Web2.0 websites

    more»

  • Andrew Glover

    Co-author of "Continuous Integration"

    The weekly bag appears to be a monthly bag at this point, man! more»

  • Ted Neward

    Enterprise, Virtual Machine and Language Wonk

    Recently, a former student asked me, I was in a .NET web services training class that you gave probably 4 or so years ago o more»

  • Howard Lewis Ship

    Creator of Tapestry and HiveMind

    At NFJS Boston last month, I ran into Alex Kotchnev. We had a number of chats about Tapestry and spurring wide adoption. I'm still working... more»

  • Neal Ford

    Application Architect at ThoughtWorks, Inc.

    The shortness of the collective memory of the development world depresses me sometimes. Joel Spolsky has a great blog post from 2004 entitled... more»

  • Venkat Subramaniam

    Founder of Agile Developer, Inc.

    I am looking forward to speaking at the Developer Summit next week in Bangalore. more»

  • Jared Richardson

    Agile coach and co-author of Ship It

    Erlang keeps popping up. This article is about a very practical, real-world integration of Erlang with popular technologies. more»

  • Brian Pontarelli

    Brian Pontarelli - founder of Inversoft

    Got my Lenovo Thinkpad X300 last week and I’ve been using it for development for only a few days. Here are my first impressions: Pr more»

  • Scott Leberknight

    Chief Architect at Near Infinity

    Often when writing unit tests I use Eas yMock to mock dependencies of the class under test. And many times I more»

  • Erik Doernenburg

    Principal Consultant @ Thoughtworks

    Another major improvement of OCMock: it now supports more flexible constraints on the expected arguments. This is done in the Objective-C way... more»

  • Graeme Rocher

    Project Lead of the Grails Project & CTO of G2One

    As I write this JavaOne 08 is being wrapped up and I am horizontal in bed. I somehow managed to get pleurisy and pneumonia a few days before... more»

  • Vladimir Vivien

    Software Engineer / Consultant

    The last day of JavaOne 2008 was heralded by the final General Session where Sun showcased several cool projects. Here are a few you maybe... more»

  • Ryan Shriver

    Business and Technology Consulting

    more»

  • Pramod Sadalage

    Co-author of "Refactoring Databases:Evolutionary Database Development"

    We had a weird requirement on our project recently.. Find all the Rows in All the tables that do not comply with the Constraints more»

  • Kirk Knoernschild

    Software Developer & Mentor

    It’s time to move on and show the simple elegance Spring brings to OSGi development using the HelloWorldSpec sample from the more»

  • Guillaume LaForge

    Groovy Spec Lead & Project Manager

    This is with great pleasure that G2One and the Groovy development team announce the first beta more»

  • Jeff Brown

    G2One Director Of North American Operations - Groovy and Grails Developer

    We have been busy preparing for JavaOne and it is finally almost here. Yay!We hope to see y more»

  • Craig Walls

    Author of Spring in Action

    I read thi s last night, but I have seen this coming for over a year. more»

  • Jason Rudolph

    Author of Getting Started with Grails

    Muness blogged a photographic introductio more»

  • David Bock

    Principal Consultant, CodeSherpas Inc.

    Installing CentOS 5, ImageMagick, and RMagick I don‘t normally blog about obscure, specific technical topics, mainly because 99% of more»

  • Jason Harwig

    Software Engineer

    pre { font-size:80%; } Of the trinity of web technologies, CSS is by far the worst at this stage. It's a language more»

  • Pratik Patel

    Software Architect

    Shake off that St. Patrick's day hang-over by coming over to the AJUG meeting this Tuesday, March 1 more»

  • Pete Behrens

    Organizational Agility Coach

    Marti nig & Associates Methods & Tools group recentl more»

  • Nathaniel Schutta

    Author, speaker, software engineer focused on user interface design.

    Like pretty much any office with more than 3 people, we struggle with the ephemeral concept of more»

  • Joseph Nusairat

    Author of Beginning JBoss Seam & Co-Author of Beginning Groovy & Grails

    Today is the first day of JBoss World, I survived the first three presentations and waiting for the keynote to be  complete to d more»

  • Richard Monson-Haefel

    VP of Developer Relations, Curl Inc.

    more»

  • Brian Sam-Bodden

    Java author, Ruby geek and Open Source Advocate

    In this installment we are going to build the Dashboard page of the Tempo application. T more»

  • Mark Fisher

    Spring Integration Lead

    more»

  • Ron Bodkin

    Chief Software Architect, Quantcast

    I'm looking forward to speaking at The Rich Web Experience conference in San Jose next month. The event runs from September 7th through 9th.... more»

  • Mark Goodwin

    Web Application Security Specialist

    We've already looked at one of the two big problems posed by anti DNS pinning on Java applets; because there's rebinding on the applet and... more»

  • Scott Davis

    Author of "Groovy Recipes" & TDD Expert

    Every time I see a live show at the Denver Botanic more»

  • Brian Goetz

    Author of Java Concurrency in Practice

    Recently, Neal Gafter mused about whether we should consider removing more»

  • Romain Guy

    Java User Interface expert.

    more»

  • Ramnivas Laddad

    Author of AspectJ in Action, Principal at Interface21

    InfoQ.com has published my AOP myths and realities talk recorded at a No Fluff Just Stuff conference. InfoQ.com founded by Floyd Marine more»

  • Keith Donald

    Core Spring Developer, Creator of Spring Web Flow

    A neat "hidden gem" of Spring's container is the ability, from a XML-based bean definition, to automatically populate a bean property of ty... more»

  • David Geary

    Author of Graphic Java Swing and Co-author of Core JSF

    The 2006 NFJS tour kicked off t more»

  • Jason Hunter

    Author of Java Servlet Programming

    I just posted the JDOM 1.1 release for download. This release includes about 20 improvements and bug fixes. more»

  • Stuart Halloway

    CEO of Relevance

    <p>We are happy to announce that <a href='http://www.mckinneystation.co m/'>Geof Dagley</a> has joined the Relev more»


In the Spotlight - Vladimir Vivien

Software Engineer / Consultant

Vladimir Vivien is a software engineering living in Tampa, FL (US) currently working in the healthcare industry. Past and current experiences include development in Java and C#.Net for industries including publishing, finacial, and heathcare.

Vladimir's interests include JMX, OSGi, Rich-Client technologies such as XUL and OpenLaszlo, and dynamic languages including Groovy, Python, JavaScript. He thinks the future direction of the Java language is hidden in Groovy.

Contact: vmatters @ gmail dot com.























Presentations by Vladimir Vivien

Creating Manageable Systems with JMX

Starting with the Java 5 programming language, it has gotten easier to incorporate monitoring and manageability into any application running on a standard VM. Developers now have access to a wealth of runtime VM profile information exposed through Java Management Extensions (JMX), including memory consumption, garbage collection, and thread activities (with even more capabilities in the Java 6 programming language). Using JMX, developers are also able to expose runtime control and management information for their own applications.













organic thoughts


Vladimir Vivien's complete blog can be found at: http://vladimirvivien.com/blogs/ot/

Friday, May 9, 2008

The last day of JavaOne 2008 was heralded by the final General Session where Sun showcased several cool projects. Here are a few you maybe interested in. Some are useful others just plain cool:

1. VisualVM - This is a great (and seems to be indispensable) tool to do VM runtime monitoring and profiling. It runs outside of the an IDE and lets you look deep into the VM and your runninig application at runtime. The profiler is the same that is found in NetBeans and provides a hierarchical navigation and snapshot of all activities of a running application. Check it out at https://visualvm.dev.java.net/.

2. NetBeans 6.1 JavaScript Support - if you do a lot of JavaScript, then the NetBeans is for you. In the demo shown on stage, Netbeans manages to make JavaScript development as well-supported as regular Java. The IDE provides Javadoc-like support, code completion, data structure navigation, on-the-fly documentation, even code hints, etc, etc. While other IDE such as Intellij has had support for JavaScript for a while, this is the first glimpse of it on the NetBeans platform.

3. LiveScribe (http://livescribe.com) - this is not a developer tool, but rather a pen-base computing platform based on the Java Micro Edition. It records pen stroke and voice as you write. Describing it here does not do it justice, but the one demo that caught my attention was a translating demo where the presenter wrote words in one language and the pen automatically translates it into different language...

4. Sentilla, Pervasive Computing Device: Sentilla sells small computing devices meant to be used in sensor networks. Pervasive computing is the notion that everything around us will (some day) have a microchip. Companies such as sells a platform to build and deploy these devices everywhere.

5. JFugue, Music Processing Software - this open source software lets you programmatically build music players in Java. It uses a simple text base language to describe music timing, rythm, notes, sound bank, etc. With the JFugue API, you can create music in several ways including direct notation and pattern inference.

Thursday, May 8, 2008

Integrating Spring and JBoss SAR Components
Last time I wrote about JBoss, it was a discussion on how to create a JBoss service component (SAR). However, in many cases, a SAR component has to be integrated with other component-based technologies. In this article, I will discuss how to accomplish this by integrating the JBoss with the Spring component model and how to expose Spring components to receive management services from within JBoss JMX Console.

Integration
The architecture and implementation of the JBoss service component system differ vastly from the Spring Framework's component model. JBoss (version 4.x and below) implements its internal kernel, for its component container, completely on the Java Management Extension API. As such, when you build a JBoss components, you automatically inherits all the management facilities exposed by JMX. The Spring container, on the other hand, is designed to be a lightweight and portable container and has the ability to host POJO's as components. Therefore, Spring has become the container of choice for many system designers because of its simplicity and portability to be hosted in any environment.


As you can see, integrating Spring in another container requires some sort of adapter that controls how and when the Spring context is created and destroyed. As we will see later in this document, this can be easily accomplished using a few API calls.
Motivation
Why would I want to integrate Spring and JBoss you ask? Well, there is an application domain that is not suited to be implemented as web-based apps. Inevitably, at some point in your career, you will need to implement headless services that expose functionalities without a GUI. These type of services are temporally durable and operate without any human intervention. When creating these types of GUI-less services, you may decide to use the Spring container as your core operating environment for POJO components. Since Spring exposes a uniform abstraction layer for the Enterprise Java API's, it makes sense to code around Spring so that your implementation is portable to any environment that can host enterprise services (JBoss container, ServiceMix, Mule, EJB's, etc). Then, your Spring components can leverage services offered by that enterprise environment (database, timers, messaging, adapters, management, etc).

Integration Points
The portability and programmability of the Spring container makes it an attractive platform for developers to create POJO component-driven apps. For web-based apps, Spring provides ready-made adapters to easily integrate your Spring context within the servlet container. However, for non-web system, Spring does not readily provide specific hooks for integration (this is a good thing, it keeps things simple). On the other hand, the Spring API exposes a simple API that makes programming the integration, of Spring in your environment, a seamless effort.

The picture above shows how Spring integration with the JBoss Application Server can be easily achieved. You create a JBoss service component that serves as an adapter to the Spring container. As the JBoss service object receives lifecycle events from the application server, event-handling logic can be inserted in the adapter to control the creation and management of the Spring context. Once booted and running, the Spring container takes over and mounts its internal POJO components and registers them with the available MBean Server for management.

The Spring Directory Scanner
Extending on the example presented in the previous blog on JBoss components, this example demonstrates how to create a Spring-based directory scanner that gets hosted within the JBoss application container. The previous example, all of the logic of the scanner was implemented directly into the JBoss service component. While there's nothing wrong with that approach, it tightly couples your code with JBoss and make it far less portable. In this version of the scanner, the logic is encapsulated in POJO's hosted within a Spring context.

A JBoss service component serves as a Spring adapter and manages the creation and destruction of the Spring context from within the JBoss container. The spring context is booted up by the JBoss service component through life cycle event hooks from the server. Upon initialization, Spring mounts its POJO's and exposes the Directory Scanner component for runtime management and control through JMX. Using the JConsole or JBoss' Jmx-Console, these components can be managed at runtime locally or remotely.

The Code
The code itself is simple and self explanatory. The JBoss service component responds to JBoss application server's life cycle events. These events are used to manage the creation and management of the Spring context. The Directory Scanner Spring component is driven by a Timer Task object mounted in Spring. Every time the timer expires, it executes the scan() method on the Directory Scanner instance.

The JBoss Service Spring Adapter
The JBoss service component is a a plain Java class with life cycle methods named create, destroy, start, stop. It implements a management interface which exposes these methods for JMX control. The component deployer will automatically execute methods create() then start() upon instantiation of the service component.


public interface JBossSpringAdapterMBean {
void create();
void destroy();
long getErrorCount();
long getSpringComponentCount();
String[] getSpringComponents();
String getSpringConfigPath();
boolean isSpringLoaded();
boolean isStarted();
void setSpringConfigPath(String path);
void start() throws Exception;
void stop();
}



Besides the life cycle methods, there are other management methods that are added for convenience. For instance, there's a method that returns the error count or one that returns the list components loaded in the spring context.

During the deployment of the JBoss Spring adapter (implemented as JBoss service component), the create(), destroy(), and start() methods of the adapter will be invoked by the JBoss service archive deployer. This provides an opportunity to instantiate and manage the Spring context at key points during the lifetime of the adapter.

Booting Spring
The create() method is called after all the setters are injected with values from the JBoss service descriptor.

public class JBossSpringAdapter implements JBossSpringAdapterMBean {
private ClassPathXmlApplicationContext spring;

...

public void create(){
log.info("**** CYCLE: CREATE ****");
if(!created){
try{
spring = new ClassPathXmlApplicationContext(springConfigPath);
spring.registerShutdownHook();
created = true;
}catch(Exception ex){
errorCount++;
created=false;
log.error("Unable to start Spring Context", ex);
}
}
}

...

The create() method is used to instantiate the Spring context. In the code snippet, the path to the Spring context is injected during deployment from the deployment descriptor using the setSpringConfigPath() method. The registerShutdownHook() method registers Spring to listens to VM shutdown signal so the context can properly deactivate all of its registered components.

Shutting Down the Context
On the other hand, when your JBoss adapter class receives a shutdown signal (say, the server is shutting down for instance), you wan to have your Spring context gracefully go down as well. By providing a destroy() method, the JBoss deployer invoke that method when the server sends out a shutdown signal.

public void destroy() {
log.info("**** CYCLE: DESTROY ****");
if(created){
try{
stop();
if(spring.isActive()){
spring.close();
&nbsp; spring.destroy();
spring = null;
}
created = false;
}catch(Throwable ex){
log.error(" Failed to destroy component. ", ex);
}
}
}



Controlling the Spring Context
Another desirable aspect of the adapter is the ability to control the Spring context with a start / stop functionality. While it is not a necessary, it affords a runtime convenience where the Spring context can be controlled and managed from a JMX console.

...
public void start() throws Exception {
log.info("**** CYCLE: START ****");
if(!started){
try{
if(!spring.isActive()){
spring.refresh();
spring.start();
}
started = true;
log.info("**** Spring context started OK.****");
}catch(Throwable ex){
errorCount++;
started = false;
log.error("**** Failed to start Spring context:", ex);
}
}
}

...

public void stop() {
log.info("**** CYCLE: STOP ****");
if(started){
try{
spring.close();
started = false;
log.info("**** Spring context stopped OK.****");
}catch(Throwable ex){
errorCount++;
started = false;
log.error("**** Failed to stop Spring context:", ex);
}
}
}

...


The JBoss Service Component Descriptor
The last part of creating the JBoss Spring Adapter, is to create a JBoss Service Descriptor file (jboss-service.xml). Using this file, you can inject runtime values, and point to a descriptive xmbean descriptor file that is used to export your service archive component as an JMX MBean.

<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="integration.jboss.JBossSpringAdapter"
name="demo.integration:name=JBossSpringAdapter,type=Adapter"
xmbean-dd="META-INF/spring-adapter-xmbean.xml">
<attribute name="SpringConfigPath">/META-INF/spring.xml</attribute>
</mbean>
</server>

For details about creating a JBoss service component and how to format jboss-service.xml and the Xmbean descriptor file, visit the JBoss 4 User Guide.

Deploying the JBoss Spring Service Adapter
Without going into the implementation of the Spring Directory Scanner component, let's see what happens when the JBoss service archive is deployed. We expect the JBoss SAR deployer to recognize our JBoss Spring Adapter component as a valid JBoss service archive component and deploy it. Once deployed, we can validate the deployment through the log and through the JMX Console.

JBoss SAR Starting
During deployment, we see the JBossSpringAdapter service component being deployed by the application server. We can also see that the Spring context is being instantiated.



JBoss JMX Console shows the JBoss service component JMX management interface.

The JMX operations for the Spring service adapter are shown above. Notice that you can start and stop the spring container at runtime. That gives you the ability to conrol the lifescyle of your Spring container at runtime without redployment of the application . This maybe useful if you want to make a configuration change in production without redeployment of the entire application.

The Directory Scanner Spring Component
The scanner is a simple Java object which uses the standard java.io.File package to get filtered list of files in a given directory. You will notice that there are some annotations around the class. These are Spring-specific annotations used to expose the Directory Scanner class as a managed JMX MBean (this is not covered in this writeup). I also introduce an interface called Controllable for good form (not necessary).

The Controllable Interface


public interface Controllable {
public void start();
public void stop();
}



This interface shows control points that can be implemented in the Directory Scanner. This is not necessary, but added for completion.

The Directory Scanner Class
The class that implements the logic for scanning the directory is divided into three distinct sections
  • The properties (getter/setters) for the component
  • The life cycle control methods
  • The scanning method which is invoked to do a sweep of a a directory

@ManagedResource(description="Directory Scanner Component.",
objectName="demo.integration:name=DirectoryScanner,type=SpringComponent")
public class DirectoryScanner implements Controllable{

...

@ManagedAttribute(description="Comma separated list ....")
public String getExtensionList() {
return (fileFilter != null) ? fileFilter.toString() : null;
}

@ManagedAttribute
public void setExtensionList(String extensionList) {
fileFilter = new FileListFilter(extensionList);
}

@ManagedAttribute(description="The directory location to scan.")
public String getLocation() {
return (location != null) ? location.getPath() : null;
}

@ManagedAttribute
public void setLocation(String location) {
this.location = new File(location);
}

...

@ManagedOperation(description="Lifecycle to start component.")
public void start() {
started = true;
log.info("**** Directory Scanner Compoennt started OK.");
}

@ManagedOperation(description="Lifecycle to stop component.")
public void stop() {
started = false;
log.info("**** Directory Scanner Compoennt stopped OK.");
}

...

public void scan() throws RuntimeException {
if (started) {
if (location != null && location.isDirectory()) {
File[] list = location.listFiles(fileFilter);
log.info("Scanned files with extensions [ " + fileFilter.toString() + "]" +
" from [" + location.getAbsolutePath() + "]");
} else {
log.warn("Unable to scan location Make sure it's valid.");
}
}
}

}


As you can see, this is a simple class. The thing to notice is the Spring-specific annotations that decorate the class. They are used to export and describe the class as a JMX MBean server. It's beyond the scope of this write up to go into the details of how to do this in Spring. However the next section shows the Spring file that describes and wire it all together.

The Spring Configuration File
The configuration of this component is simple and straight forward.

<bean id="scanner" class="component.spring.DirectoryScanner" init-method="start" destroy-method="stop">
<property name="location" value="../../"/>
<property name="extensionList" value="*"/>
</bean>

Above, we see the DirectoryScanner being configured to scan two directory up from where the application is invoked. Also, we set the list of files to scan.


<bean id="timerFactory"
class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref bean="scheduledTimerTask" />
</list>
</property>
</bean>

<bean id="scheduledTimerTask"
class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="period" value="3000" />
<property name="timerTask" ref="timer" />
</bean>

<bean id="timer"
class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
<property name="targetObject" ref="scanner" />
<property name="targetMethod" value="scan" />
</bean>

The stuff above is boiler plate for setting up timer services from Spring. Here we are declaratively setting the timer to invoke the scan() method on the DirectoryScanner POJO wired above.

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="assembler" ref="assembler"/>
<property name="namingStrategy" ref="namingStrategy"/>
<property name="autodetect" value="true"/>
<property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/>
</bean>
<bean id="jmxAttributeSource"
class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource"/>

<!-- will create management interface using annotation metadata -->
<bean id="assembler"
class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
<property name="attributeSource" ref="jmxAttributeSource"/>
</bean>

<!-- will pick up the ObjectName from the annotation -->
<bean id="namingStrategy"
class="org.springframework.jmx.export.naming.MetadataNamingStrategy">
<property name="attributeSource" ref="jmxAttributeSource"/>
</bean>

Finally, the code snippet above sets up the POJO to be exported as an MBean into the running MBeanServer. This configuration relies on the annotation embedded in the class to derive the meta data used to describe the class inside the MBeanServer.

Download Source
You can download the application sample application to get the code source.

Observations
  • Think in Component - component-based development is incredibly easy to get into and understand. It facilitates the separation of concerns and promotes forces you into better coding practices (testing, loose coupling, re-usability, etc).
  • JBoss Service Component Evolving - Starting with version 4.x, JBoss components can now be annoted (instead of using the descriptor file) to describe its meta characteristics for JMX. Starting with version 5, JBoss will switch to OSGi as the executable unit for its components.
  • Exception Management - When deploying components into a container (such as JBoss app server), great care must be taken to handle exceptions properly. In JBoss (version 4.x), when a component throws an unhandled exception, that component is immediately disabled and shutdown. You must catch all exceptions and handle them properly. In DirectoryScanner, for instance, if the scan() method throws an exception during a scanning request, the entire component is deactivated.
  • (OSGi) Components Are Here to Stay - All major containers including JBoss AS, SpringSource App Platform, IBM WebSphere, Glassfish, and JOnAs support OSGi bundles as their coarse component model.

Refereces
  1. Source for Directory Scanner - http://vladimirvivien.com.s3.amazonaws.com/jBoss-spring-integration.zip
  2. JBoss Server Microkernel - http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch2.chapter.html
  3. Spring Documentation - http://static.springframework.org/spring/docs/2.5.x/reference/index.html
  4. Spring JMX Documentation - http://static.springframework.org/spring/docs/2.5.x/reference/jmx.html
  5. OSGi - http://en.wikipedia.org/wiki/OSGi
  6. OSGi and Spring - http://www.infoq.com/interviews/osgi-adrian-colyer







Thursday, May 8, 2008

If you doubted that OSGi can achieve mass appeal, the list of sessions at J1 proves contrary. Most major tool vendors has either implemented it or have plans to support OSGi bundles:
  • OSGi has been in IBM's arsenal for while now (Eclipse, Websphere, etc)
  • SpringSource's new Spring Application Platform uses OSGi has its
  • Glassfish Version 3 will be OSGi-bundle compatible
  • JBoss 5's kernel will load its component as OSGi
  • JSR 277, the Java Module system, slated for JDK7, can load OSGi bundles

From small embedded devices, to desktop, to the large application server, OSGi seems to be the component model that the industry is adopting. It will be interesting to see how the corporate developer integrates OSGi in their development rituals.

Wednesday, May 7, 2008

On day one of the JavaOne, the theme is clear: JavaFx (http://javafx.com/) is here to stay. The FX story is coalescing into a platform clearly targeting digital lifestyle experiences. It is clear that tremendous of resources are being devoted to bring the FX story together as technology stack with support for rich that stretches from mobile devices, desktop, to the backend.

The Tools
- Continued JavaFX support from NetBeans
- Photoshop/Illustrator plug-in's to export art work as JavaFx artifacts directly

The Features
- JDK 6 update 10 (jdk 6u10) - setting the path for the desktop features envisioned by Sun
- Applets - Sun is going back to the Applets as a way to augment browsing experiences.
- Audio/Video - under the FX unbrella Sun is offereing an HD qualility a/v codec for Java
- FX is slated to target devices such as cellphones and other mobile stacks with a consistent user experience from device to desktop.
- Project Hydrazyne: another Sun initiative to let users easily create rich content and experiences dritributed in a Sun hosted cloud.

I would like to see this effort successeed, for anything elese, just to have competition in the content technology market place. Adobe leads that sector, Microsoft is making inroad with Silverlight, now Sun wants to give Java developer a way into the rich content user exeperience.

You just have to read the blogs around the net to find doubters about this strategy laid out by Sun. However, I think if the company remains on message, provide the tools, continue to share the vision, there will be new convert. Lets see what happens!

Wednesday, April 9, 2008

After I attended the Groovy/Grails Experience in February this year, I realize that the Groovy builder pattern can be used to façade many other API's (not just swing). So, I decide to create, yet another builder, for the JMX API and here it is!

http://code.google.com/p/groovy-jmx-builder/

Features

Suppose you have a class called Greeter (on your class path) that prints out greeting to a specified person in a specified language, so the class may look like this

public class Greeter {
private String name;
private String language = "en";

// ...

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

// ...

public String greet(){
String greet = (String) (langs.containsKey(getLanguage()) ?
langs.get(getLanguage()) : langs.get("en"));
return greet + " " + getName();
}

String greet(String person){
return langs.get(language) + " " + person
}
}

You can use Groovy Jmx Builder to expose an instance of that class for management as an MBean.

def greeter = new Greeter()
JmxBuilder jmx = new JmxBuilder()
def server = jmx.export(svr){
bean(greeter){
name("greeterDemo:service=greeting")
desc("This service prints a greeting on console")
attribute(name:"name", desc:"name of person to greet", writable:true)
attribute(name:"language", desc:"the language to use", editable:true)
operation(name:"greet", desc:"Sends greeting to user")
operation(name:"greet", desc:"Send greeting to user"){
parameter(type:"java.lang.String", name:"Person", desc:"The person to send greeting to")
}
}

bean(object:greeter, name:"greeterDemo:service=greeting2")
}
You use the JmxBuilder() class to capture meta data about your class instance that will be made available at runtime for management.

In JConsole, the generated MBean may look like this



Feedbacks
I am interested in feedbacks for this project. So, download it and give it a try. I will be adding more features to it in the future.