Wednesday, November 28, 2007

Connecting jconsole to JBoss JMX server

So I was working on integrating the JBI ant tasks to the Open ESB distribution for JBoss and I was having some issues connecting to the JMX server. So, I wanted to try something simple and see if I could connect jconsole to the JMX server first. Out of the box this does not work. You will have to add some system properties to your or run.bat file for this to work. It's pretty simple really, but took me a while to find. For this to work just add the following properties to you file:

# Enable the jconsole agent remotely on port 64850

Next, start JBoss and once it is started you can start jconsole by issuing the command jconosle from a command window. You can connect in one of three ways. If you are connecting locally just select the local tab, you will see the PID and the class for JBoss and select Connect. If you are connecting to remotely select the remote tab and enter the Host/IP and the Port (the one you entered in your file).

Monday, November 12, 2007

Contributing a patch back to an Open Source project

I recently needed to contribute a patch back to an open source project I was working on, and since I wasn't familiar with using cvs from the command line I needed to research how to create a diff. I thought I would post my findings since it took me a while to find anything useful. First you will want to create a diff of the code you are contributing. For a single class you could do the following:

cvs diff -u > myClass.diff

This creates a unified diff, which I have read most open source projects prefer, or the class you modified with what is current in CVS, and output the diff to myClass.diff.

If the class is not under CVS control, you can add the class and then run the following:

cvs diff -uN > myClass.diff

If you have modifications to more than one class you can do a diff on the entire package by doing the following:

cvs diff -uN myPackage > myPackage.diff

This will recursively perform a diff on anything that is either added or under cvs control and write the output out to myPackage.diff.

You can also set how many lines of context you wish in your unified diff by doing the following:

cvs diff -u8N > myClass.diff

Friday, November 9, 2007

Happy Birthday Marines - Semper Fi

Don't forget to celebrate the best holiday of the year on Saturday November 10th, The 232 Birthday of the United States Marine Corps. If you need a little inspiration this weekend checkout General Conway's Marine Corps Birthday Message, this is just one of the several proud traditions that all Marines will be participating in this weekend. If you know a Marine, make sure and tell them Happy Birthday. Semper Fi.

Monday, November 5, 2007

soapUI - Great plug-in for IDEA

I had used soapUI before, with Netbeans, but hadn't ever even looked to see if my preferred IDE IntelliJ IDEA had a plug-in. Today I was getting ready to run some tests and needed soapUI and I didn't want to start Netbeans, so I installed the soapUI plug-in for IDEA. It's great, and very simple to use. Some of you may have used the standalone version of soapUI before, but if your like me you always have your IDE up so why not just get the plug-in. If you haven't ever used soapUI and need a really great tool to send SOAP for testing purposes, it's a great tool and I highly recommend it.

Tuesday, October 30, 2007

I've been keeping my mouth shut!!!!

Well since my beloved Wolverines started out 0-2, I've been keeping my mouth shut this football season. I think it's time I start to talk some smack again. My only fear is that once I do, my teams will fall a great defeat to a lesser opponent, but hey who cares.

So after Michigan's dismal start, they have now reeled off 7 wins in a row. Granted the Big 10 isn't so good this year, but we have been winning despites some critical injuries. Last week Big Blue pulled a win out with their starting running back and quarterback on the sidelines in street clothes. Buckeyes beware!

On another note, I never brag about my second favorite team, but this year I have to. The University of Kansas is playing some football. I don't care what everyone is saying about how weak their schedule is, that fact is they are 8-0. They have beaten Colorado, K-State, and Texas A&M on the road. Years past the we couldn't win a game on the road. You can say what you want about the Jayhawks and their weak schedule, but the fact remains that they have a damn good defense (5th in the Nation I believe), and an offense that can put points on the board against any team in the country. I'm not saying they are going to win the National Championship (For one, the BCS would never allow a team like KU to be in the title came, but that's a whole other topic for discussion), but I wouldn't be surprised if they rolled into Arrowhead Stadium on November 24th looking to win the Big 12 North and a shot at the Big 12 title.

With all the fun of college football, we sometimes forget that college basketball is right around the corner. My Jayhawks kick off the season on Thursday with an exhibition game against Pittsburg State. Rock Chalk Jayhawk.

I think it's going to be a good year for my Jayhawks, hopefully the basketball team can start out like the football team and end with a National Championship.

Ok, enough sports talk. I'll get back to blogging about tech stuff next time. I'm hoping to work through some more Groovy examples, and get some of those up here. Until next time....Rock Chalk Jayhawk...Go KU!

Wednesday, October 10, 2007

Two Minute Drill for Groovy

I know I promised more on Groovy, and I will get some more examples up here. However, one of my co-workers, Joe Kueser, just posted a great blog about Groovy. Basically Joe's Blog, "What Makes Groovy So...Groovy?", is a two minute read that provides a great summary of a lot of the features in Groovy. Be sure to check out Joe's Two Minute Drill.

Saturday, October 6, 2007

Converting Dom to Groovy Code

I've been looking into and learning a little Groovy on the side. One of the things I'm most interested in is learning how to use the MarkupBuilder provided by Groovy. Essentially this, in my opinion, is a much better way to parse and construct XML. As a developer I use XML almost daily. First I'm looking at integrating this into my unit tests. Today I stumbled on the DomToGroovy class and found this pretty cool. I was trying to figure out how to construct XML using Groovy. I knew what the XML looked liked, so using the DomToGroovy class I could get a good idea what the Groovy code would look like that I needed to write. Below is a sample of how to do this, and I recommend the GroovyConsole to test with.

import javax.xml.parsers.DocumentBuilderFactory

def xmlExample = """
<jbi:message tns=""
type="tns:rssWsdlOperationRequest" version="1.0"
<entrylist xmlns="">
<title>Entry 1</title>
<description>First Entry</description>
<publishdate>Dec 7, 1976</publishdate>
<title>Entry 2</title>
<description>Second Entry</description>
<publishdate>Dec. 7, 1976</publishdate>

def builder = DocumentBuilderFactory.newInstance().newDocumentBuilder()
def inputStream = new ByteArrayInputStream(xmlExample.bytes)
def document = builder.parse(inputStream)
def output = new StringWriter()
def converter = new DomToGroovy(new PrintWriter(output))

println output.toString()

The output essentially shows you what the Groovy code would look like to construct the XML that we provided.

jbi:message(type:'tns:rssWsdlOperationRequest', version:'1.0',
xmlns:tns:'') {
jbi:part) {
EntryList(xmlns:'') {
Entry) {
title('Entry 1')
description('First Entry')
publishDate('Dec 7, 1976')
Entry) {
title('Entry 2')
description('Second Entry')
publishDate('Dec. 7, 1976')

I think this is a pretty slick way to quickly generate a code sample so that you can quickly get started. More to come on Groovy later......

Tuesday, September 25, 2007

The "I" in JBI is for Integration

Just in case anyone was wondering....

I came across this article today which discusses integrating XMPP presence in J2EE, and as I am reading the whole time I'm thinking I could do this with JBI utilizing the XMPP Binding Component and the JMS Binding Component. Leveraging the BPEL Service Engine I could easily orchestrate everything and not have to write any code, just create a composite application and deploy it to my JBI Container (e.g. OpenESB) and I'm golden. The XMPP BC would handle receiving the presence notifications and utilizing BPEL we could pass that along to the JMS BC to be published to the topic or queue.

I get the feeling that most developers feel the need to always write code to come up with solutions to their problems, when in all actuality there might be a solution to your problem already. I have said it 100 times myself, "I'm not happy unless I'm in my IDE coding away".

So my last thought....

Before you get knee deep in code (I know it's fun), check out some of the components that are available and see how you can use JBI to integrate solutions for your problems. Remember the "I" in JBI is for Integration.

Monday, September 10, 2007

XMPP BC - More Development on the way

We are set to add some more enhancements to the XMPP BC, but first a quick recap of what we added last month:

  • Group Chat capabilities
    • Join
    • Invite
    • Kicks
    • Leave
    • Send/Receive Messages
  • Send/Receive Complex Types
Here is what we have in the works for this month:
  • More Group Chat capabilities
    • Create/Destroy Groups
    • Presence Notifications (Allows a consumer to monitor the status of members in the room)
  • Upgrading to the latest Smack API (3.0.4)
Stay tuned for more updates, you can get the latest release here.

Wednesday, September 5, 2007

Silverlight - The death of the browser

At least mine anyways. So I was reading one of the Flex evangelists blogs about Silverlight 1.0 being released, and I thought I would see what all the hoopla was about. So I went to and checked out some videos. What a mistake that was. First you will have to install Silverlight, no big deal I've had to install the Flash Player before as well. Once I get that installed and restart my browser, it took 2-3 minutes for my browser to load everything, and the whole time my processor is pegged at 100%. I waited patiently and finally was able to play a movie, and of course instead of showing the highlights immediately Microsoft had to pat themselves on the back. Finally the highlights started, and the quality was terrible. I couldn't hardly read the score because it was fuzzy, and it the actual footage looked choppy. I've seen enough, I try and go back to Google Reader and now my browser isn't responding, I had to kill the process and start a new session. Nice job Microsoft. First impressions are the most important, and my first impression of Silverlight is to go uninstall it as fast as I installed it.

Tuesday, September 4, 2007

Flex and Real Time Collaboration

I stumbled upon this interesting Video Podcast from Dereck DeMoro of Jive Software in which he discusses the benefits of switching to Flex while developing the Spark Web Client. A few key points that he mentioned was that they were developing a desktop application (Spark) that was written in Java (Swing in particular) and a Web client that was written in HTML and JavaScript. He mentions how they wanted to mimic the two applications to provide the same user experience, and how they struggled to do this. Once they switched gears and started developing with Flex they were able to have one code base that utilized for the web application and the desktop application. For the web app, you just embed the swf into an HTML file, and for the desktop application they leveraged Adobe AIR (formerly Apollo). He talked about how this greatly simplified their development efforts, as well as things like testing since they only had to test one baseline.

Another key thing he mentions is the easy transition he and his team had (They were all Java developers with no Flash or Flex experience) in transitioning to Flex. I've had to opportunity to program in Actionscipt and it is very similar to Java, in fact I would bet most Java Programmers could pick it up in no time.

Sometimes I get the feeling that Java developers don't want to try something different, they just want to stick to what they know. To me, if it's better I don't care, and in my opinion Flex is better.

The Big House wasn't so Big on Saturday

Yes, I am a die hard Michigan Wolverines fan, and yes I've been getting phone calls, emails, and text messages from friends I haven't talked to in quite some time rubbing salt in my wounds. Maybe Saturday's loss to Appalachian State was a wake up call for a very talented senior laden football team, or maybe it's a start to a very disappointing season. I guess we will have to wait and see, but as most Michigan Fans will say if we can beat Ohio State at the end of the year then who cares if we lost to that 1-AA team in September.

At least Team USA annihilated Argentina (Led by Bron and Melo, I think we definitely take the gold for coolest names), and American Sprinters dominated at the World Championships (Tyson Gay was awesome), the USA is looking good for Beijing.

Wednesday, August 29, 2007

Team USA

I've been watching USA Basketball play in the FIBA Americas Tournament, and I must admit I've been impressed. Years passed Team USA looked like what they were, a bunch of spoiled overpaid kids. Not this team. They are playing with a lot of passion, and I think will get us back to the top. Kobe Bryant has especially impressed me. He is one the most people consider a selfish ball hog, but has taken on the role of defensive stopper. I have watched several games where he has just shut down the other teams best player, kudos Kobe. Anyways, make sure to tune in, we have Argentina coming up soon.

Wednesday, August 22, 2007

Bridging the Gap - XMPP to SIP Group Chat

As noted in one of my earlier blogs, we have been enhancing the XMPP BC to be able to participate in Group Chat Sessions. During this process we thought we would also show how you can utilize JBI to be a convergent platform and bridge gaps across protocols. To do this, we thought we would show how a SIP User Agent (e.g. an xlite soft phone) could participate in an XMPP Group Chat session. Brian O'Neill's blog talks a little more about utilizing JBI as a convergent communication platform, and provides a use case here.

Enough with the fluff, on with the demo. I've uploaded the Netbeans Projects here that I will be discussing in this blog so you don’t have to create them from scratch. Below is a list of prerequisetes in order to run the demo:

- You will need to get the latest OpenESB installer

o This comes with Netbeans, Glassfish, and the JBI Components you will need to run the demo.

- Set up an Openfire XMPP Server

o You can go here for a demo on how to setup Openfire

o You will need to get an XMPP client (e.g. Spark or Pidgin)

§ You can go here to see a demo of how to setup Spark

§ You will need to create one user in Openfire with the username sipua and password sipua (This is defined in the XMPP WSLDs

- Set up a SIP User Agent/SIP Server

o We used XLite for the demo, but you should be able to utilize just about any SIP UA and SIP Server.

o Login as a user (e.g. chad)

- Edit the XMPP WSDL

o Edit all xmpp WSDLs to reflect the correct domain (the domain of your Openfire server) and the correct groupChat name (e.g. A@conference.OpenFireDomain). Both attributes can be found in the xmpp:address section of the WSDL.

- Edit the SIP WSDL

o Edit all sip WSDLs to reflect the correct proxyDomain (sip:address section of the wsdl) (the domain of your SIP server)

- Edit the BPEL Process

o Click on Assign3 and edit the String to be the groupChat name you defined in your XMPP WSDL’s earlier.

o Click on Assign1 and edit the String chad@ to be whatever user you are logged in as (e.g. mySipUserAgent@mySipServerDomain).

You should be all set now. You will need to recompile the Composite Application by right clicking (in Netbeans) on SIPAndXMPPCA module and selecting “Clean and Build”. You are now ready to deploy your application. Follow the following steps to deploy and run the test.

- Start Glassfish

o In Netbeans Click Window à Services à Servers à Right click on Sun Java Application Server à Click Start.

- Start Openfire

o With an XMPP client (e.g. Spark or Pidgin (or Both)) log in, you may have to create an account first.

- Start SIP Server and SIP User Agent

o Using a SIP UA (e.g. XLite) log in as the user you defined in the Bpel Process above (e.g. chad@

- Ensure JBI Components are installed and started

o In Netbeans navigate to Window à Services à Sun Java System Application Server 9 à JBI

§ Under Service Engines verify the following Component is installed and started

· sun-bpel-engine

§ Under Binding Components verify the following Component is installed and started

· gestalt-sip-binding

· gestalt-xmpp-binding (uninstall this component by right clicking on the component and selecting "uninstall". We need to ensure you have the latest XMPP BC, you can find it here. Download the xmppbc.jar and install it by righ clicking on Binding Components and selecting Install New Binding Component. After Installation, make sure you start the XMPP BC (Right click and select Start).

o If the components are not there, you can download them here.

- Deploy the SIPAndXMPPCA by right clicking on the project and selecting “Deploy Project”

- Once deployed, you should be able to use your Spark or Pidgin clients and join the Conference room that was created (e.g. A). You should see yourself in the room as well as the user sipua. You can now send a message to the group and your SIP UA will receive the message. Have your SIP UA respond and see the message appear in the Group Chat.

So a quick recap of what we accomplished. First, we were able to create an application that could bridge two protocols that normally couldn’t speak to each other (See screenshot below). Second, we did this without writing one line of code. Yes, you read that correct. To do this application from scratch all you have to do is configure it, and then tell BPEL how to orchestrate it. Netbeans provides a nice way to do this with their toolkit support (automatically generating WSDL’s and leveraging the design view for the BPEL process to drag and drop activities on the screen)

If you have any questions feel free to shoot us an email by using our mailing lists (SIP BC, XMPP BC), or leave a comment on my blog.

Saturday, August 18, 2007

Google Rocks

I'm all the time checking out Google Labs to see what cool thing they have come up with next. I'm a big fan of Google and some of the tools they have put out. I thought I would share some of the ones that I consider must haves, I use these on a daily basis.

- Google Reader: Fabulous tool for managing all of your favorite RSS Feeds. Manages the feeds through a very simple and easily to read web interface. Doesn't matter if you are at work or home all you have to do is log in and you can view it, unlike desktop applications like RSS Owl. Also allows you to star your favorite reads or share with others, providing a unique RSS Feed URL for others to view your shared items.

- Google Desktop: Google has mastered the art of indexing and searching, Google Desktop does this for your desktop. This tool will index your entire hard drive and emails so that you can quickly search for items you know you have, but can't seem to find.

- Blogger: I got into blogging several months ago and settled on Blogger mainly because it was a Google product and I can utilize my same Google login. I've been really happy with the ease of managing my blog, if you are thinking about blogging I would highly recommend Blogger.

- iGoogle: Customize your experience with Google. iGoogle allows you to customize your Google Home page to add things that you are interested in.

So those are the items that I use every day, here are some items that I have been playing around with that are pretty cool.

- Google Pages: Are you wanting to create a personal web page, but you don't know how to write HTML, don't want to pay for hosting or a domain name, or don't know how to use FTP? Google Pages could be for you. With your Google account you create a custom made web page and publish that page to your unique Google pages URL. You don't have to understand HTML, FTP, and you don't have to pay for a domain name or hosting services.

- Google 411: Are you tired of paying fees to use 411 and then paying extra to connect? Check out Google's 411 service, 1.800.GOOG.411. I've used it and it works great, and best of all it's Free.

So to sum it all up, Google Rocks. My wife calls me a geek every time I mention a new cool Google tool I find, but I can't help it, I guess I'm an addict. Anyways, you can find all of these tools on Google Labs. Last thing, Google is more than a search engine; make sure you are utilizing all of the tools they have available, they are Free.

Thursday, August 16, 2007

My Sports Praise

Since I ranted about some things that tick me off about sports, I thought I would share some recent examples why at the end of the day I absolutely love sports.

- My Cardinals are making a charge in the dog days of August proving that teamwork and heart can perceiver all obstacles.
- Rick Ankiel - If you do not know who he is, use Google and read his story. Fantastic, welcome back.
- High School Football - It is 100% American, the purest form of athletics (no money, tv ratings, etc.) just good competition.
- Tiger Woods - I am not that big of a golf fan, but you have to relish watching greatness.

I could go on and on, but there is no need to do that. See you on the field!!!!!!!!!!

Tuesday, August 14, 2007

New Enhancements for the XMPP Binding Component

We have some new enhancements for the XMPP Binding Component coming down the pipe this month. Already in place is the ability to join, leave, and send messages to group chats. You can join a group chat upon deployment or you can dynamically join/leave groups at runtime. Also in the works for this month are enhancing the XMPP BC to handle complex types. You can view the documentation for the WSDL Extensions here.

Wednesday, August 1, 2007

My Sports Rant

So, my favorite time of year is quickly approaching......Football Season. Lately I have been catching up on where my teams stand, and as usual someone is holding out for more money. This is my biggest problem with Pro Sports in general, causing me to be a bigger College sports fan. I get sick and tired of seeing athletes hold out for more money cause they have had a couple of good seasons. What happens if you have a bad couple of years, should the team be allowed to negotiate your contract down to what you deserve, oh no that is not how it works. I am a Chiefs fan, and as most sports fans know, Larry Johnson is holding out for more money. I can see where he is coming from in a way. He has been one of the best backs, if not the best, the last couple of years, and he does not make nearly as much as some of the other backs in the league, e.g. LT, Shaun Alexander, Edge, etc. My beef with all of this is what ever happend to honoring your contract. You are still making a lot of money, more than 90% of the people out there will make in a lifetime. Teams have to honor the contract no matter what, unless they want to cut you. At the end of the day I do not really blame the athletes, I blame the agents. Most of the time I think they ruin what is good about sports, they are not in this for the athletes, they are in it for themselves. Just this morning they were talking about Brady Quinn holding out for more money because he thought he should have been drafted higher, sorry buddy you did not so you get pick 22 money. Now go prove yourself on the field and get that money the next contract, what a novel thought .... proving yourself and earning that money.

I will get off my soap box now.......

Monday, July 30, 2007

Utilizing Installation Descriptor Extensions in JBI

JBI provides a means to add extensions to your Installation Descriptor (jbi.xml). These extensions can be used for a variety of different things, like configuration for your component. Working examples of components utilizing this feature check out the OpenESB HTTP Binding Component or ServiceMix HTTP Binding Component . Recently I needed to use this feature to add some configuration type attributes to the component we were developing. The first thing you will need to do is add the extensions to your installation descriptor. As noted in the API, the Installation Descriptor Extensions are located at the end of the <component> element of the installation descriptor, something like the following:

The rest of the jbi.xml

During bootstrap init() the InstallationContext is passed in, this object gives you access to the Installation Descriptor Extensions, via installationContext.getInstallationDescriptorExtensions (Which returns a DocumentFramgment containing all Extensions). At this time you need to store the values in an object so that you can access them during the Components init(). The best way to achieve this is to use JMX. So the first thing you will need to do is Create an Interface that defines your MBean, and then create your class that will implement that interface. Something like the following:

public interface ConfigExtensionsMBean {
public void parseConfigExtensions(DocumentFragment documentFragment);
public String getLocation();
public int getPort();
Now we need to write our concrete class that implements this interface, something like the following:

public class ConfigExtensions implements ConfigExtensionsMBean {

private int port;
private String location;

public enum Attributes {Location, Port};

public String getLocation() {
return location;

private void setLocation(String location) {
this.location = location;

public int getPort() {
return port;

private void setPort(String port) {
this.port = new Integer(port);

public void parseConfigExtensions(DocumentFragment frag) {
//Parse the DocFrag here and call the setters for the port and location.
So now we have the Interface and the Concrete class, we just have to use it now. So the first thing we need to do is in your Bootstrap classes init() method we need to get the Installations Service Description Extensions and create our MBean and register that MBean in our MBean server, this should look something like the following:

public void init(InstallationContext context) {
ConfigExtensionsMBean mBean = new ConfigExtensions();
DocumentFragment doc = context.getInstallationDescriptorExtension();

MBeanServer mBeanServer = context.getContext().getMBeanServer();
ObjectName mBeanName = context.getContext().getMBeanNames().createCustomComponentMBeanName("MyMBean");
try {
if (!mBeanServer.isRegistered(mBeanName) {
ObjectInstance oi = mBeanServer.registerMBean(mBean, mBeanName);
} catch (Exception e) {
So what we just did was read the extensions, parse them and call the setters, and registered the mBean for future use. So now our new component is ready to be initialized and needs access to that mBean. The following is how you can access them during ComponentLifeCycle.init(ComponentContext context):

public void init(ComponentContext context) {
MBeanServer mBeanServer = context.getMBeanServer();
ObjectName mBeanName = context.getMBeanNames()

try {
host = (String) mBeanServer.getAttribute(mBeanName,
port = (Integer) mBeanServer.getAttribute(mBeanName,
} catch (Exception e) {
log.warning("Exception getting mBean Attributes: " + e);
So, there you have it, an example of how to utilize the Installation Descriptor Extensions from your jbi.xml.

Tuesday, July 24, 2007

Patterns and Matchers - java.util.regex Package

Recently I got the oppurtunity to utilize the java.util.regex package, which I had never used before, and found it very simple and handy to work with. As I look to do on my blog, I will share a simple example of how to match character sequences against patterns specified by regular expressions utilizing the Java API. So, as TDD goes we will write the test first and then develop our code against our unit test. If your not familiar with unit testing, you will need to download JUnit. Ok, we will start by creating our new test class.

import junit.framework.TestCase;
import java.util.List;

public class ProcessorTest extends TestCase {
String testData =

public void testProcessor() {
Processor processor = new Processor();
List list = processor.processMessage(testData);
assertEquals("List was not correct size", 2, list.size());
assertEquals("Name did not match", "Chad", list.get(0));
assertEquals("Name did not match", "Bob", list.get(1));

This will obviously fail since we haven't created our Processor class yet, so lets go ahead and create our new Class, and then we can run our unit test to verify that our code is doing what we want it to do.

import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.List;
import java.util.ArrayList;

public class Processor {

public List processMessage(String text) {
String pattern1 = <\\w*?name>>;
String pattern2 = </\\w*?name>;
List result = new ArrayList();
Pattern p1 = Pattern.compile(pattern1);
Pattern p2 = Pattern.compile(pattern2);
Matcher m1 = p1.matcher(text);
Matcher m2 = p2.matcher(text);
while ((m1.find()) && (m2.find())) {
result.add(text.substring(m1.end(), m2.start()));
return result;

Now we can run our unit test again and our test will pass. So this is just a simple example of how to use the Matcher and Pattern class provided as part of the JDK, and how to utilize Unit Testing to test your code.

Monday, July 23, 2007

Using Grizzly to read TCP Packets

Recently I had the need to be able to listen on a port and read TCP packets that were sent from a logger (java.util.SocketHandler), and I wanted to utilize the Grizzly framework to do this. With some help from the Grizzly team I was able to accomplish this and thought I would share what I did. The first thing I had to do was write a main that could connect to a port and receive TCP packets, it looked something like the following:

public class TCPProcessor {
public static void main(String[] args) throws Exception {
int port = Integer.getInteger(args[0]);

Controller controller = new Controller();
TCPSelectorHandler tcpHandler = new TCPSelectorHandler();
final MyProtocolFilter filter = new MyProtocolFilter();

controller.setProtocolChainInstanceHandler(new DefaultProtocolChainInstanceHandler() {
public ProtocolChain poll() {
ProtocolChain protocolChain = protocolChains.poll();

if (protocolChain == null) {
protocolChain = new DefaultProtocolChain();
protocolChain.addFilter(new ReadFilter());

return protocolChain;
Now that I have my main listening, I need to write the Filter that will handle the processing of the data packet. With the ProtocolChain, the ReadFilter will read the TCP packets and pass it to the next filter in the chain, which is were I need to process my data. My filter will look something like the following:
public class MyProtocolFilter implements ProtocolFilter {
public boolean execute(Context context) {
final WorkerThread workerThread = ((WorkerThread)Thread.currentThread());
String message = "";
ByteBuffer buffer = workerThread.getByteBuffer();

if(buffer.hasRemaining()) {
byte[] data = new byte[buffer.remaining()];
int position = buffer.position();
message = new String(data);
System.out.println("New message being read, message is: " + message);
return false;

public boolean postExecute(Context context) throws IOException {
return true;

So now you could whip up a test to send some data over TCP and the Processor will read the packets and print the message out.

Thursday, July 19, 2007

Fun in the Sun!!!!

I am currently in Mexico on vacation with my wife and daughter and thought I would share some photos. This is the first vacation we have had a chance to take with our daughter, and she has had just a great time. You can tell by the picture that she has thoroughly enjoyed the tropical drinks, I think she likes eating the pineapple more than drinking the drink though.
I have to admit, she has been quite good the entire trip, we drove from Missouri (a 24 hour drive) and I was worried about her ridding in the car that long, thank goodness for portable DVD players. In the meantime, we have just had a great time relaxing in the sun and playing in the ocean. Back to the real world next week.

Thursday, July 5, 2007

New Enhancements for the RSS Binding Component

We have recently added some new enhancements to the RSS Binding Component. We now provide support for subscribing and receiving notifications from secure feeds that use Basic Authentication, and the ability to subscribe to multiple feeds at the same time during runtime. Be sure to check out the RSS WSDL Extensiblity elements for definitions on how to create the WSDL. If you have any questions feel free to contact me or use the mailing list from the project site.

Tuesday, June 12, 2007

Your One Stop Shop for JBI Components

Are you in the need for a certain JBI Component, but don't know where to download it at? Here is a great place to download the binaries for the component you need. Don't forget to check out the wiki for demo's and descriptions of the components.

Monday, June 11, 2007

XMPP to RSS Demonstration

As noted in my last blog, I have been working on some open source binding components. We recently finished the RSS Binding Component and I wanted to get one of the demonstrations we did out here as an example of how you can use JBI to tie multiple protocols together that would normally be somewhat difficult to do. So in this demonstration I use the XMPP BC to send instant messages, and take that message and publish it as an RSS Feed. You can download the Netbeans project here. Prerequistes to build this application are as follows:

OpenESB Installer
this comes with Netbeans, Glassfish with JBI Runtime, and JBI Components
Wildfire XMPP Server: for instructions on how to set up go here.
Spark XMPP IM Client: For instruction on how to set up go here.
XMPP Binding Component installed
RSS Binding Component installed
File Binding Component installed
BPEL Service Engine Installed

All of the Binding Components and the Service Engines come with the OpenESB installer. If you happen to be missing one you can find and download the component you need from here.

You will want to edit the WSDL's to fit your needs. First look at the fileWsdl.wsdl. You will notice that in the address section (file:address) you will be writting a file to you User Home/mag16AOC directory. You can edit this if you wish, and write the file where ever. Next look at the message (file:message) section of the WSDL and notice the file will be called mission100.xml. You can re-name the file if you wish.

Next look at the rssPublish wsdl, you will want to edit the feedUrl in the rss:address section to be specific to your machine (i.e. http://localhost:64801/feed/mag-16_aoc/mission_100). What this means is once you deploy this application and start sending instant messages, the messages will be published to the above link and you can view them using an RSS Reader (i.e. RSSOwl), or you can navigate to that link in a web page and view it there. Next look at the rssSubscribe wsdl. You will want to edit the rss:address section to be the same feedUrl you used above. What this does is subscribes to this feed and every time there is a new post you will get notified and the entry will be written to the file we described above.

Finally lets take a look at the xmppWsdl. You will need to edit the xmpp:address section to update the domain (i.e. localhost).

You can now clean and build the module in netbeans by right clicking on the project and selecting clean and build. With a successfull build you will want to right click on the XMPPtoRSSDemoCompApp and clean and build that. You are now almost ready to deploy these and test. You will first need to create a user for your spark client (This is assuming you have followed the instructions on how to setup Spark and Wildfire). Make sure you Wildfire server is running and start your Spark client. You will need to select "Accounts" and create a new user (i.e. bob, server is localhost). Once logged in you will want to pull up your Wildfire server Admin page and add a user. This user must be the same that is defined in the xmppWsdl (i.e. username = mag-16_aoc, passworkd mag-16_aoc), once this user is created you will want to add him as a contact in your buddy list for your Spark client. You are now ready to deploy and test.

Start the server in Netbeans ( Window --> Runtime --> Servers --> Right Click on Sun Java System Application Server 9 and select Start). Once the server is running you will see a Tab that says JBI, expand that and verify that under Binding Components you see the RSS Binding Component, XMPP Binding Component, File Binding Component, and under Service Engines verify you see BPEL SE. If those are in place you are ready to deploy your Composite Application. Right Click on the XMPPtoRSSDemoCompApp and select Deploy. Once successful you will see the buddy you added in your Spark client (mag-16_aoc) come online (i.e. turn green). You are now ready to send instant messages and have those messages published to an RSS Feed. Send a couple of messages and then navigate to the feedUrl you defined and verify the feed is being published. You can also verify your subscribe is working by navigating to the file and verifying that the file is being written to the location described in your fileWsdl.

So in short what we have done using JBI is the capability to "mash" two protocols together that could normally not happen, at least easily. This is a great example of how to take simple IM client and disseminate information to a large group of people. If you have any questions feel free to email me or use the mailing list on our project site for the RSS BC or XMPP BC

Wednesday, June 6, 2007

New RSS Binding Component on

As I have noted in some of my other blogs, I have been fortunate enough to be working on a team lately that has been developing and open sourcing some JBI components to This last month we developed a RSS Binding Component that is now available for download and use. Feel free to check it out and feel free to let us know what you think or if you have any questions. You can contact us at the following email address:

Also, feel free to check out our other Binding Components, XMPP, SIP, and UDDI, that we developed a couple of months ago. For questions about these components you can contact us at the following:

The project sites contain documentation on how to use the components as well as demonstration videos that will walk you through creating a component application. For a complete list of binding components available see the JBI Components WIKI

Friday, May 18, 2007

Java Threading - ScheduledExecutorService

Today I stummbled upon something I had not done, this may be old hat for some of you, but none the less I thought it was pretty cool and thought I would share. I was working on a class that needed to kick off a thread, so i started down the path I knew and created a class that implemented Runnable, created the run method, and it looked something like the following:

public class MyThread implements Runnable {
private Boolean running;

public MyThread(Boolean running) {
this.running = running;

public void run() {
while (running) {
try {
} catch (InterruptedException ie) {

public void process() {
//Do someting cool here

public void setRunning(Boolean running) {
this.running = running;

public class ExecuteThread {
private Boolean running = true;
private MyThread myThread;

public void activate() {
myThread = new MyThread(running);
Thread thread = new Thread(myThread);

public void deactivate() {

Using the ScheduledExecutorService provided in the java.util.concurrent package you can handle the execution of a thread and control the initial delay, delay, and the unit of time with one method call. Something like the following:

public class MyThread implements Runnable {
public MyThread() {

public void run() {

public void process() {
//Do something cool here

public class ExecuteThread {
private MyThread myThread;
private final ScheduledExecutorService scheduler =

public void activate() {
myThread = new MyThread();
(myThread, 0, 10, TimeUnit.SECONDS);

public void deactivate() {

Again, this might be old news for some of you, but I thought this was a very effective way to handle threading and it really cleaned up my code in the end.

Thursday, May 10, 2007

Creating a Binding Component Deployment Plug-In for Netbeans

Recently I have had the pleasure of working on a team developing and open sourcing to some binding components for JBI. One of the tasks we had to complete was integrating our binding components into netbeans. One of the things netbeans provides is a WSDL wizard, so when you are creating new modules the wizard lets you select the type of binding you will be using, and based off that binding will give you a base template of your wsdl with some default values of attributes you need to provide. When I first started I had no idea on how to create a plug in for netbeans. So, this will cover how to create a Binding Component Deployment Plugin. The first thing you will need to get is the
OpenESB installer for netbeans.

Once you have Netbeans installed you will want to create a new project by doing the following
  • Select File --> New Project
  • Under Categories select --> JBI Components
  • Under Projects select --> Binding Component Deployment Plugin and click next
  • Name your plugin (i.e. NewBCPlugin)
  • define your source package (i.e.
  • Define your component Name (i.e. newbc).
  • Edit your WSDL Extension
    1. Define your Namespace (i.e.
    2. Define your prefix (i.e. newbc)
  • And click Finish

Once that is finished you will have a Source Packages directory, and under there you will have two packages something like the following:

    • layer.xml
    • newbcWsdlExt.xsd

You will need to edit the layer.xml file. You will need to update the last section to be something like this.

You will also need to update the schema to fit your needs for your Binding Component. You will next need to add this wsdl.xsd to the package. Once you have added this xsd make sure you add it as an import to the newbcWsdlExt.xsd file.

That should be a good starting point for you on that package. Next we will neeed to create a new package called,and create the following files under that package:

First lets edit the This property file defines what type of extensions your wsdl will provide (i.e. transport). It should look something like the following:

NewBCTransport=NewBC Transport
NewBCMessage=NewBC Message

TEMPLATE_name_NewBCTransport=NewBC Transport

Next we are going to edit the, this class is pretty straight forward and should look like the following:


import org.netbeans.modules.xml.wsdl.ui.
import org.openide.util.NbBundle;

public class NewBCTemplateProvider
extends ExtensibilityElementTemplateProvider {

static final String templateUrl =

public InputStream getTemplateInputStream() {
return NewBCTemplateProvider.class

public String
getLocalizedMessage(String str, Object[] objects) {
return NbBundle.getMessage
(NewBCTemplateProvider.class, str, objects);

For this code to compile you will have to update your libraries by doing the following:

  • Right click on your project --> Properties
  • Select Libraries
  • Add the following libraries
    • WSDL UI (You will need to edit this library and select use Implementation Version)
    • Utilities API

Next we will look at creating the template.xml; this is the file where you add any attribute that is defined in your NewBCExt.xsd to include default vaules. Once this plugin
is installed these default values show up as properties in the WSDL Editor. Your template.xml should look something like this.

Finally you well need to add META-INF/services directory which should be located under your src directory (newbc/src/META-INF/services). This should contain a file called


and it should say the following:


Now you are at a point you can test the plugin. You will need to right click on the project and perform a clean and build. Next you will need to test, right click the project and select "Install in Target Platform". This will start a new instance of Netbeans with your plugin installed. Once it is started create a new project and under Service Oriented Archietecture select BPEL Module. Once the project is created right click on Process Files and select create new WSDL Document. Click next through the Wizard until you get to selecting the type of binding. Here you will want to select the drop down box called Binding Type and select your new plugin (If it isn't showing up in the list there is something missing).

If you would like a complete netbeans example project just like we did here, you can download the zip here