Doing Two Models at the Same Time

•December 20, 2008 • 3 Comments

We used to throw the best parties in our Coolidge Corner[1] bachelor pad.  The recipe was simple: we’d blast an eVite to the city of Boston, pick up a keg of Good Decision[2], break out the Beirut[3] table, and ask the local police to turn a blind eye.

In the midst of one of our more smashing affairs, conversation turned to concurrent polygamy and if any of us were fortunate enough to have practiced the art firsthand.

Josh had.  Of course, Josh had.

And he offered us this advice: “You don’t go looking for it.  It’s given to you, so don’t ask questions and just take advantage of the opportunity.”

Don’t you know it, opportunity knocked upon my roommate Jon’s door not three hours later.  With a couple of part-time models.  Two models at the same time.

While the next morning’s brunchtime report was entertaining enough, my inner geek preferred to explore how some of the same themes might be applied to component architecture.

Models:
* Are not necessarily mutually exclusive
* Should be encouraged to focus on their own domains
* May share in some concerns, each from a different angle
* Combined are worth more than the sum of their parts

Shoot forward a few years, when an enabling technology caught up with my musings in the form of JBoss Microcontainer[4].

My first impression of MC was that it was “another DI Container”.  And at its core, sure, it provides the kind of POJO autowiring that we’ve come to expect from this class of framework.  Over the past year, however, I’ve come to appreciate MC for its extensibility, a truly differenciating characteristic from other offerings.

DI is all very nice, but I’m accustomed to having some greater utilities available to create my runtime environment.  A quick glance at the MC feature list boasts Virtual Deployment Framework (VDF), a filesystem abstraction (VFS) and aspectized classloading facilities.  Armed with these, I was set to kick the tires in hopes of discovering some deficiencies in the design and thus gaining bragging rights over Ales[5].

Mission: Provide @EJB injection into MC Beans

In short, I want MC Beans to be able to inject references to EJB3 proxies.  This will be our integration point for interacting with EJB from MC-based Services.

MC applies a metadata-collecting vistor to beans that are installed, and this is passed along to an AnnotationPlugin[6] whose responsibility is to apply the requisite info to the visitor.  By implementing an AnnotationPlugin to handle javax.ejb.EJB, we’ve got our hook[7].  This process is eased by abstract support from FieldAnnotationPlugin, and the main goal here is to supply a ValueMetaData describing the injection value.:

/**
* Create @EJB value meta data.
*
* @param annotation
* @return @EJB metadata
*/
@Override
protected ValueMetaData createValueMetaData(FieldInfo propInfo, EJB annotation)
{
// Get properties from the annotation
String beanName = annotation.beanName();
String beanInterface = annotation.beanInterface().getName();
String mappedName = annotation.mappedName();
// Supply beanInterface from reflection if not explicitly-defined
if (beanInterface == null || beanInterface.equals(Object.class.getName()))
{
String reflectType = propInfo.getType().getName();
beanInterface = reflectType;
}
// Create a reference
EjbReference reference = new EjbReference(beanName, beanInterface, mappedName);
log.debug("Found @EJB reference " + reference);
// Return a new ValueMetaData w/ the reference
return new AbstractEjbReferenceValueMetadata(this.getResolver(), reference, this.getNamingContext());
}

The “EjbReference” above is a value object used by the EJB3 Reference Resolver, responsible for finding the JNDI Name to which a reference is bound.

The return value is AbstractEjbReferenceValueMetadata[8], an implementation of ValueMetaData able to:

1) Declare a dependency upon the JNDI target value.  This ensures our MC Bean will not deploy until the referenced EJB has
2) Obtain the EJB Proxy from JNDI so that it may be injected

Simple enough.

From here, the only thing left to do is let MC know that it should consider our new AnnotationPlugin upon installation of new beans.  For this task I’ll create a simple POJO[9] which, installed, will alter MC’s behaviour.  The key here is in the lifecycle “@Start”:
@Start
public void start() throws Exception
{
// Install the BeanAnnotationAdapter w/ callback to add annotation plugins on install
BeanAnnotationAdapter beanAnnotationAdapter = BeanAnnotationAdapterFactory.getInstance()
.getBeanAnnotationAdapter();
String beanAnnotationAdapterBindName = MC_NAMESPACE_EJB3 + "BeanAnnotationAdapter";
BeanMetaDataBuilder bmdb = BeanMetaDataBuilder.createBuilder(beanAnnotationAdapterBindName, beanAnnotationAdapter
.getClass().getName());
bmdb.addMethodInstallCallback("addAnnotationPlugin");
bmdb.addMethodUninstallCallback("removeAnnotationPlugin");
try
{
this.getKernel().getController().install(bmdb.getBeanMetaData(), beanAnnotationAdapter);
}
catch (Throwable e)
{
throw new RuntimeException("Could not install " + beanAnnotationAdapter, e);
}
}

Here we get at the BeanAnnotationAdapter and install it into the KernelController along with some callbacks to automatically add AnnotationPlugins when they, in turn, are installed.  From here on out, all we need is to throw EjbReferenceAnnotationPlugin into MC.

I’ve tracked this feature[10], along with passing integration tests in the EJB3 TestSuite[11].

Unfortunately, I’m left with nothing to hold aver Ales’ head as MC provided me, as a framework developer, with all the tools needed to extend the provided groundwork.  In fact, I’m even at a deficit because I needed to consult the Microcontainer Users’ Forum[12] for some suggestions.

I’d like some input from application developers – in what situations would you like to call an EJB from a POJO?  Managed objects within Microcontainer act as singletons within the confines of the system, so there should be plenty of occasions to call upon a pooled/cached distributed component.  This is the goal we address by providing integration between component models.

Because nothing catches on without a proper title, I’ll name our approach right now: Concurrent Polyforma.

So now we’ve put JBoss MC to a real-world test, proving that it can wrap your favorite model.  As an additional exercise, I also did this quite literally:

Caylin Loves MC

Caylin Loves MC

This is how we’ll help you bridge two models.  You just can’t Eiffel Tower[13] them.

S,
ALR

[1] http://en.wikipedia.org/wiki/Coolidge_Corner
[2] http://www.beeripedia.com/index.php/Samuel_Adams
[3] http://en.wikipedia.org/wiki/Beer_Pong
[4] http://www.jboss.org/jbossmc/
[5] http://www.jboss.org/community/people/alesj
[6] http://anonsvn.jboss.org/repos/jbossas/projects/microcontainer/trunk/kernel/src/main/java/org/jboss/kernel/plugins/annotations/AnnotationPlugin.java
[7] http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/mc-int/src/main/java/org/jboss/ejb3/mcint/metadata/plugins/EjbReferenceAnnotationPlugin.java
[8] http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/mc-int/src/main/java/org/jboss/ejb3/mcint/metadata/plugins/AbstractEjbReferenceValueMetadata.java
[9] http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/mc-int/src/main/java/org/jboss/ejb3/mcint/annotationadaptor/AddAnnotationPluginOnBeanAnnotationAdaptorCallbackService.java
[10] https://jira.jboss.org/jira/browse/EJBTHREE-1624
[11] http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/
[12] http://www.jboss.com/index.html?module=bb&op=viewforum&f=228
[13] http://www.urbandictionary.com/define.php?term=eiffel%20tower&defid=1242963

It’s not 2002

•December 4, 2008 • 9 Comments

2002 was the year of Bad Ideas.

An overly-anxious United States Congress granted “immediate emergency powers”[1] to the President, resulting in war[2].  WorldCom and United Airlines both went Chapter 11.  Journalist Daniel Pearl was executed by terrorists in Pakistan.[3]  Two yahoos sniped at civilians in Washington, DC.[4]  And Britney cheated on Justin.[GASP]

Amid the muck Rod Johnson quietly released “Expert One-on-One J2EE Design and Development”[5], and it was chock-full of Good Ideas.  Among them:

* The contract between the bean provider and the container was too verbose
* The remoting model imposed bulky access
* Aspect-oriented programming should be used to apply orthogonal concerns
* Entity Beans sucked
* Testing business logic contained in EJBs was difficult
* EJB inhibited good OO design due to its API restrictions

I can see why the Spring movement was seen as such a breath of fresh air to developers sick of coding Local, Remote, Local Home, Remote Home, and Implementation classes for what might be a trivial service.  The community owes a debt of gratitude to the assertions presented by Rod & co.

To underscore how correct many of these anti-EJB claims were, the Expert Group behind JSR-220[6] independently came to many similar conclusions, and after 3 years of work released the EJB 3.0 Specification in May of 2006.

Bringing simpliciation to the standard was not applauded by the Spring-a-lings.  “[They believe] the same thing Wednesday that [they believe] on Monday, no matter what happened Tuesday.”[7]

Which is fine.  Really, conflicting views within the industry should be embraced as its the consumer who will benefit in the long run from a variety of options.

But today I read something disturbing, taken straight from the Product Page of the SpringSource tc Server[8]:

“The Spring container has replaced the EJB container in a majority of enterprise Java applications and is now the de facto standard for enterprise Java.”

Oh, fuck you with a rake.

I’ll break this down into two components:

1) Spring has replaced EJB in the majority of JEE outfits
2) Spring is the standard (in practice, not law) for Enterprise Java

This evokes memory of some poorly-conceived graphs and analysis posted by Rick Hightower[9] and later covered by InfoQ[10] in 2006, where job postings and brain-dead search terms drew the picture that EJB as a platform was flaccid in comparison with Spring’s reign.  Ignoring for the moment that we’re extrapolating fact from subjective assumptions, it’s only proper that I present some current numbers using relatively impartial queries:

search_trends

Here we’ve got Google search terms.  Note the top three.

job_trends

Looks like “J2EE” is still a very popular job posting, despite being a deprecated grammar.  “EJB 3″ doesn’t even show on the map if charted.

What I’d really love to see are some third-party analysts’ metrics.  Or maybe the Spring Flingers can back these claims up with hard data. Until then, I’m relegated to hold the position that EJB is maintaining its dominance[11].  Not to mention that even today JEE hasn’t yet shaken the bad blood accumulated in the days of the EJB 2.x spec, when DI and AOP were the new hot toys.

Or maybe I’m being unkind.  After all, if the community was aware that every single bullet in the Spring mission statement[12] was addressed by a specification and backed by a series of compliant implementations, they’d have no business left.  What’s the value-add to a company that is proud to do little more than aggregate other proven technologies?

Again, Springers mostly have it right.  Simplicity is great.  But it doesn’t have to come at the expense of EJB anymore; we’ve adapted, you should too.  If Pluto can stop being a planet, surely you guys can stop being dicks.

S,
ALR

[1] Star Wars Episode II: Attack of the Clones
[2] http://en.wikipedia.org/wiki/Iraq_Resolution
[3] http://en.wikipedia.org/wiki/Daniel_Pearl
[4] http://en.wikipedia.org/wiki/Beltway_sniper_attacks
[5] http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764543857.html
[6] http://jcp.org/en/jsr/detail?id=220
[7] Stephen Colbert in reference to George W. Bush, 29 April 2006, http://en.wikipedia.org/wiki/Stephen_Colbert_at_the_2006_White_House_Correspondents%27_Association_Dinner
[8] http://www.springsource.com/products/suite/tcserver
[9] http://jroller.com/RickHigh/entry/stack_of_choice_jsf_hibernate
[10] http://www.infoq.com/news/2006/11/job-trends-ejb3-spring
[11] http://bill.burkecentral.com/2008/02/13/ejb-maintains-its-dominance/
[12] http://www.springframework.org/

Back to Your Regularly-Scheduled Program

•September 24, 2008 • 1 Comment

Avid readers will note that I’ve been silent for some time here.  It’s a new philosophy I’ve adopted: “Put Up or Shut Up“.

Anyone monitoring JBoss EJB3 source control activity over the past couple months has noticed around-the-clock commits from our team.  4AM on a Sunday.  Midnight on a Thursday.  Hell, I’ve even been known to do some work during business hours when things are really cranking.

All of this has been dedicated to one goal: JEE5 Compliance of the JBoss Flagship project, Application Server 5.  And just last week, we pushed out binaries capable of making some 27412 Integration Tests maintained by Sun turn green.

Sacha and Dimitris have already spoken to the ongoing status and importance of this milestone, so I won’t reiterate their points.

But I’m not celebrating yet.

Compliance is a prerequisite.  It cedes vendor lock-in, promotes uniformity among programmers the world over, and sets a contract for what application developers may expect from their runtime.

And I think we’ve reached a point where you should be able to take that all for granted.  Now we go back to the regularly-scheduled, which in JBoss’ case is innovation and love for the community.

The best place to start is under the hood.

Get Out of the Application Server

We invested heavily in this one.  Simply put, we moved the EJB3 implementation out of the Application Server source tree, created APIs/SPIs where coupling was required (separating contract from implementation) and set proper dependencies.  This gives EJB3 a life of its own and unbinds it from the AS release cycle.  While there’s still some work to be done in this regard, the end goal is twofold:

1) Release EJB3-only updates to AS with regular frequency
2) Don’t require AS to run EJB3

Componentize

@see http://en.wikipedia.org/wiki/Software_componentry

The idea here is to separate the logical moving parts into isolation; this way we don’t:

1) Mix concerns
2) Allow bugs in one area to pollute another

…while we do:

1) Enjoy small, easily-maintainable projects
2) Promote Unit Testing (in the true spirit of “Unit”, not to be confused with “Integration” or “Acceptance”)

Unit Test

We’ve always tested, by means of an integration testsuite that takes ~90 minutes to complete.

But componentization has given us the opportunity to create small, focused, and quick Unit Tests.  Currently we’re at 207 of ‘em, which run in about 5 minutes locally or 8.5 minutes from a freshly checked-out CI server.

Baby, that shit’s textbook.  Better curves than a pinup girl.

All told, we’re beginning to see the concrete benefits of these investments, which translate into accelerated, reliable development.

JEE Compliance is like marriage – not a conclusion, but a beginning.  I just hope compliance doesn’t mean you stop having sex.

S,
ALR

Plug it in, Plug it in.

•March 3, 2008 • 10 Comments

My childhood home really had it all.

Nice deck overlooking Callahan State Park, bicycle-friendy cul-de-sac, open living room with French windows, eat-in kitchen, and suburban zip code.

For years, it even had a hugeass Oak tree that seasonally fired acorns at your skull if you dared retrieve the mail.

So my parents never moved, and that’s why I’m friends with the same fuckers I knew back in preschool. I guess the house just worked for my folks.

And it must have worked for my neighborhood’s developers too, because don’t you know – they put three-hundred just like it next door.

[STAMP] 7 Rolling Drive [STAMP] 9 Rolling Drive [STAMP] 11 Rolling Drive …

Clearly, the economies of scale provided by a reproducible build plan were obvious to those guys.

My least favorite responsibility as Application Developer is the composition and maintenance of build files. Every once in awhile I’ll read a book that cites different roles within an organization – DBA, Backend Programmer, Frontend Programmer, GUI Designer, Assembler, Deployer, SysAdmin – and wonder why I’m doing all of them for one paycheck. I always wished there was some sucker down the hall with a business card that read “Assembly Engineer” to whom I could shove off all copy/compile/JAR tasks before going about my day.

Guess I’ve never been lucky enough to have that resource.

Here’s the problem: As simple as JBossAS is to get set up, once you start developing your application it’s likely that your server configuration will begin to sway from the default. It’s no longer an “unpack and run” situation, and this introduces a dangerous element; the environment used for local development might look very different from that used in primetime. Unless these changes are kept in check, it’s really easy to introduce bugs. Your application is not what you craft alone, but the sum total of all code churning at runtime. Everything needs to play nicely.

Easily fixed; with the introduction of an automated process, we can install and configure our server at the click of a button. This will keep our various environments in sync, with explicit differences we knowingly introduce.

I used to accomplish these goals using a series of Ant scripts, but anyone with experience in this arena knows how hellish making extensible Ant files can be. And forget cross-project portability. So this time around I’ll piggyback on Maven’s conventions.

Though close, CodeHaus’s jboss-maven-plugin didn’t quite hit the nail on the head for me. Architecturally, I needed some backing common libraries (unbound to the Maven Plugin API) such that I could mashup many of the components together for the new JBoss EJB3 Mavenized TestSuite. Not to mention that the SVN links are either outdated or the project is gonzo (Anyone? Bueller?), and I needed to add features.

Therefore, now under construction is the JBossAS Control Maven Plugin. This Blog entry is a Request for Comments.

Current Roadmap of Supported Goals Targeted for 1.0.0.GA:

install

Check for an installation at $JBOSS_HOME, and if not there, download and unpack a fresh version. May run in forced mode to always wipe the existing installation. Before I release this feature I’ll have to check with the appropriate channels about the legality of grabbing binaries from SourceForge, if there are some consent agreements or other useless red tape that have to be addressed.

create-config

From a specified base, create a new configuration. Customize by adding/overwriting/deleting as appropriate. This starts us off from a well-known default, applies the delta that makes our custom configuration, and exits. An added benefit is that we know our custom changes implicitly. KISS.

deploy

Grab the specified deployable unit(s) and deploy ‘em.

undeploy

Control-Z the deployment of specified artifacts.

start

Start a JBossAS configuration with appropriate JVM/Server arguments.

stop

What goes up, must come down.

Anything else I should be including? Or specific implementation requests for these features?

In the short term, I’ll update this entry with Anonymous SVN Access[1] and links to other instructions when they become available.

I think that should do it for this project’s scope. Also in the works right now is a functional sample project illustrating the proper configuration of these goals within the Maven Lifecycle. With one command you can get a fresh copy of the server, configure it, start it up, deploy your application, run integration tests, and bring the whole thing down before generating reports.

Good for continuous build. Good for ensuring your local development environments are sync’d up with the stuff you’re putting in Stage/Production.

[STAMP] My Application 1 [STAMP] My Application 2 [STAMP] MyApplication 3

Well-planned integration testing addresses the differences in your server environments.

[STAMP] My Application 4 …

Reproducible build plan at every level is an absolute necessity.

Until you come home drunk one night, and can’t find your house because they all look the damn same.

S,
ALR

Reference:
Continuous Integration, Martin Fowler, 2006

Edits:
[1] http://anonsvn.jboss.org/repos/maven/plugins/jboss/trunk/

Why Buy the Cow When You Can Get the Milk for Free?

•February 24, 2008 • 3 Comments

Single life is damn fun.

You’re a swingin’ bachelor(ette), your nights are nothing but body shots and hoping that “put your number in my phone” leads to “put your thingy in my hoohoo.” But most importantly, it’s a time to know yourself – your true wants and needs. Immediate fulfillment of desire is the name of the game, and because there’s no true investment in any particular individual, you’re free to explore the next hot piece that walks in the door.

Inevitably, however, restlessness will set in. There are only so many dark. loud places serving alcohol and only so many prospects who enjoy “going out, having fun, being with friends, or just hanging around”. Somewhere inbetween the morning walks of triumph/shame and evenings of lonely discontent, the whole scene becomes a cyclic deja vu starring a predictable roll of typecast players.

And at these times, you’ll be a lucky stiff to find that one of your flames has some lasting firepower. There’s a little something more there, and as sexy as the relationship began, the real attraction lies within underlying compatibility.

Now it’s prudent to unmount your head from its swivel and focus on a longer-term plan.

A successful software startup is likely to encounter a similar experience. At the helm is A Novel Idea, and the requirements gathering process should ideally yield a well-defined business plan. Once the investors, lawyers, and analysts have exhausted the ink in their fountain-tips, it’s time for some deliverables. And the pressure is on.

Specifically, it’s on the development team to set some realistic goals, often managing expectations up the chain to bring management to reality. And discussions begin to center on the core technologies, languages, and frameworks to be used for implementation. Shopping!

I believe there are 4 categories from which to choose:

  • Proprietary 3rd Party
  • Proprietary In-House
  • Web Two-oh-eey Open Source
  • Professional Open Source

Only one of these is going to offer the benefits of the other three.

Proprietary 3rd Party

Good: These guys are backed up by blue-chip assets with proven history in various markets. They’re a household name; Jim Kramer flies about yipping their P/E ratios, and you feel secure putting your backbone in the hands of seasoned veterans backed by an established support system.

Bad: You have no idea what’s going on under the hood, and no way of fixing it on your own. This is the high-end European automobile of software; any misbehaving components must be plugged into a specialized computer for analysis, and you’re getting straight played on the maintenance costs. You’re also so far from the cutting edge that you’ve grown a beard.

Proprietary In-House

Good: You know the ins-and-outs of every single byte running your application.

Bad: You must explain to the Board of Directors that they hired an individual who should be thankful to be equipped with the skills requisite for respiration. It’s impossible to do everything on your own; modern-day mathematicians take advantage of Newton’s research, they don’t redefine Physics.

Web Two-oh-eey Open Source

Good: Ease-of-use, rapid turnaround, shallow learning curve, only 4 keystrokes to a database-driven application. This category is the quickest to adopt and integrate with the latest buzzwords, generate excitement in the industry, and add an impressive “Wow” factor to developers and end-users alike.

Bad: What we have in heart here is lacking in maturity. To list: instability, ever-changing APIs, poor scalability, and ignorance of issues requiring attention for high load. Everything you’d expect from a subculture championed by 20-somethings (I’m aware of and comfortable with this hypocrisy).

Professional Open Source

I’m most familiar with JBoss, and since I’m clearly pushing an agenda (born from honest observation), will speak to our offerings.

We make available a hybrid solution stemming from approach duality. At the core of this notion is “Project vs. Product”.

Our project line is the model historically associated with JBossAS when it first launched. Motion on this front is relatively rapid for such a low-level technology, and we’re continuously releasing, componentizing, and adding featuresets as they become available via community demand or developer innovation. This is the migration path ideal for younger applications – get started easily, for free, and experiment with the wide variety of components to evaluate how they fit your needs. If you’ve got a requirement we haven’t yet supported, this is the place to collaborate, implement on your own, and get upstream for the rest of the world. To boot, there’s an active informal support system in the form of forums, IRC, and mail lists to help you stay on track.

The product concept is newer. While JBoss has long provided pay-for support and training, in this case you’re actually buying software. At first glance, this seems contrary our mission to deliver free bits and charge only for our efforts dedicated to your business specifically, but in actuality, this is a necessary and important evolution in our model.

Every commit to the codebase comes with inherent risk of introducing regression, breaking previously-intact code. So in order to provide the highest level of reliability, after a project has reached a level of stability verified by our QA teams it is branched off into its own lifecycle and granted “product” status. At first, this very closely resembles the project counterpart, but as time and development continue, the two diverge. The product receives only security, high-priority, and customer-identified patches, maintaining and enhancing the integrity of the official release. To boot, the platform is now in form where we can pledge to support each release for seven years. You’re not paying for the bits, you’re paying for our support – but we’re ensuring that you stay within code we can guarantee will remain backwards-compatible. When you upgrade, you change nothing in your application, and it still works. That’s powerful.

My focus is to the community; it’s where my interest lies. I’m assured that by providing quality software free of most restrictions (LGPL) no marketing or sales folks will need to convince you that JBoss is a generally wise partner.

So please, go out and fool around. Make and learn from some mistakes, sample the wide variety of options out there. Then come give us a real visit.

Because we’ve got the T-and-A to pique your interest, and as time goes on you’ll come to cherish that we’ll be there for you. When you do make that realization, we’ll be ready with an enthusiastic “Yes!” when you finally pop the question.

S,
ALR

Take a Cue From Queues

•February 22, 2008 • 6 Comments

New York City has an inexcusable population density, and its inhabitants are some of the most self-important existentialists on Earth.

We’ve all got something to do, it’s urgent, we need it accomplished now, and heaven help your sorry butt if you keep us waiting.

So the Service Industry has gotten pretty damn good at getting us our Iced Quad Nonfat Caramel Macchiatos, with Whip!, in due time.

There are some impressive retail strategies for dealing with the masses. I’ve seen:

  • One queue feeding into many sales registers
  • One queue per register
  • One queue, with many associates performing specialized units of work; processing a transaction in phases

Selection of one over the others is generally dependent on the business rules governing the transaction. But there is a common denominator here: The Queue.

Traditionally called “lines” in the United States, the queue represents a holding pattern of service requests until resources become available. This guarantees an even thoroughput.

But hey, I’ve got a new idea! Waiting blows…so I’m going to remove the queue from this equation. Let’s see what happens.

  • I arrive at the bank, noticing one teller who is dealing with a customer.
  • I approach the counter and give the busy banker my deposit slip and checks.
  • The teller alternates between the work she was doing prior to my arrival and the new task I’ve just given her, switching repeatedly.
  • The existing customer gives me a dirty look; her work is now being performed at 1/2 speed.
  • A new couple walks in, giving the teller 2 requests for a withdrawl.
  • Work on Customer 1 is still not done, and is now being performed at 1/4 speed.
  • Murder Scene

Maybe I need to rethink this. So its back to the lab, where I send all computational problems to Carlo de Wolf for analysis.

“The issue,” he explains, “is one of Resource Starvation.”

And the EJB3 lead of JBoss kindly continues to draw up reproducible test cases.

Let’s assume a stressing function, where we calculate Pi to 10000 digits 100 times. The idea here is just to get the CPU crunching to simulate some heavy processing.

We’ll invoke this once using traditional IoC/Dependency Injection, and again using EJB3 mechanics. Then we’ll compare the metrics.

//  Make an IoC Container Instance
IocContainer ioc = new IocContainer();
// Install the Calculator class, bound to a key
ioc.install("calculator", CalculatorBean.class);
// Lookup an instance
Calculator calculator = ioc.lookup("calculator", Calculator.class);
// Run the Stressor and print metrics
StressCreator.createStress(calculator);

Neat. Pretty simple. We programatically register a class, grab an instance, and use that instance to churn out our results:

Total Time: 28.21 Seconds
Not Executing: 0.235 Seconds
Invocation Time: 27.814 Seconds

Allright. Because we don’t have a queue here, we spend very little time outside of actual invocation of the test, and the majority of time is spent processing Pi 100 times.

Let’s do another run, using the same Stressor, but using EJB.

// Make an EJB Container
EjbContainer ejbC = new EjbContainer();
// Deploy the EJB
ejbC.deploy(CalculatorBean.class);
// Lookup an EJB Instance
Calculator calculator = (Calculator) new InitialContext().lookup("CalculatorBean/remote");
// Run the Stressor and print metrics
StressCreator.createStress(calculator);

Wonder what we’ll get this time.

From The Caller’s View:
Took 27.691 Seconds
Not Executing: 0.035 Seconds
Invocation Time: 27.541 Seconds

Collected From Inside the EJB Container:
Average Time Waiting on Queue: 13.37449 Seconds
Average Invocation Time: 1.3689 Seconds

From the point of view of a unified caller requesting 100 intensive service calls…looks pretty similar to IoC.

But there’s more here. We’ve now got a hook into the EJB Container, and can clearly see…average execution time of each of the 100 calls is about 1/100 the amount of time spent waiting on an available processor. WHY?

Because with EJB, you get instance pooling for free. When all available instances are taken from the pool, new invocations must queue up. And when you block incoming requests from slowing down your whole system, each individual request can be handled in a reasonable fashion.

The obvious question might be: What’s the damn difference? Both methods take nearly the same amount of time!

Sure. As fantastic as the EJB specification is, it can’t invent CPU cycles on the fly. What it CAN do is provide for incremental return. So the first requests in make it out without having to wait on everyone else in line to complete.

So I can easily draw the following conclusions, assuming 100 concurrent requests:

  • At WORST, the last service request in EJB will return at the same time as the full IoC return.
  • At BEST, EJB will begin to return requests in under 2 seconds, and these clients may be on their way.
  • You will not have any N number of Threads spreading your processor too thin.
  • If you’re allowing an Enterprise System to spawn a Thread for each request, you should work for McDonald’s.

On second thought, I revoke my last point. Even pre-teens working the McDonald’s drive-through make each car wait its turn.

S,
ALR

What’s Up With Chief Brown?

•February 21, 2008 • Leave a Comment

So Encyclopedia Brown was born into the game; his father is Chief of Police in Idaville, Florida.

But every time Pops gets a tough file, his best bet is to go home and explain to his prepubescent son The Case of The Missing Lollipop, which junior infallibly cracks before dessert.

Geez, Dad, you suck. How did you even get your job?

S,
ALR

Wanna Do My Homework?

•January 15, 2008 • 4 Comments

For my respect, you may be either unintelligent or unkind, but not both.

In fact, there’s an undeniable allure to the brazen arrogance of the unapologetic elite. I think that’s why NBC’s House is still on the air.

But over the past couple years, I’ve been a difficult co-worker to suffer. Unfortunately for me, life isn’t a TV show and I’m not Hugh Laurie. Being an ass doesn’t make you correct.

Life at JBoss has been therefore humbling. Which is good, because my ego was writing checks my body couldn’t cash. And since this is a Meritocracy, every developer I’ve met is The Shit. Which can make the act of contribution a little intimidating.

So as part of this reformation of character, I’m appointing myself to the role of “Community Outreach Ambassador”. Wanna be a part of something distributed the world over? Wanna give back to the software that powers your business? And most importantly, wanna do my homework?

This all ties into the proactive stance I’m taking to remain true to my application-based roots. My job as a server developer is to handle application concerns in a generic, standardized manner. But hell, if I stop developing apps I’m going to pretty quickly lose touch with my ability to identify the major pain points. That’s what’s in it for me.

And why should you donate your valuable time without pay? Great question with better answers:

  • You want a bug fixed before we’re able to schedule it in
  • You want to discuss a new feature or idea, and get it upstream and supported
  • You want to better understand the black box upon which your application is built
  • You want to compile your own binaries between official releases

It gets better. By focusing inward towards the community, the software itself becomes a byproduct of demand. This leads you, the developer, to choose JBoss AS as your JEE implementation. Your management in turn purchases support, and now you’ve got a supported platform loaded with features proven relevant in the field. To boot, you’re equipped with the tools necessary to debug problems on your own. How easy is your job now?

I therefore offer an initial push to anyone with more than a fleeting desire to take part in EJB3 Development. If you swim, you swim.

All told, the JBoss ecosystem will benefit from an influx of external contributors, and everyone reaps the rewards.

Especially me, who will be delegating my work to you, while on paid holiday.

S,
ALR

Plumbing Sucks

•January 7, 2008 • 8 Comments

Water in my apartment comes in one of exactly two temperatures; prolonged exposure to either requires medical attention. See, it’s an old building and the ancient plumbing isn’t great at the even distribution of flow to each unit. So I simply cannot shower; I must run a bath and manually regulate the heat levels coming out the faucet.

My landlords tell me there’s not much that can be done – stripping out the internals is just not cost-effective. It’s better for them to let me suffer. Were I a shrewd businessman, I’d understand.

But I’m a programmer, and I have a heart.

There’s perfectly good hot water down there. Mother January in NYC gives us unlimited cold water. And ain’t nothing wrong with my tap. It’s the transport. The damn plumbing. Once you install plumbing, you’re married to it. And divorce is expensive.

Incredible how much of the same is true in Web Application Development. Most Enterprise Applications take advantage of at least one Service-Oriented Architecture exposing its API in platform- or language-agnostic mechanisms. The “M” of MVC. This is Good.

Also Good is the wide variety of templating options available to handle the “V” of MVC. JSP/JSTL, Facelets, Velocity, XSL…all are pretty swappable.

The “C” word, as we always knew, is Bad.

Oh, Controller, responsible for parsing a request, determining an appropriate action based on its content, delegating to the correct processor, and passing the result onto the view. Historically it was identified that this common concern should be addressed in a generic fashion, and every programmer began his own proprietary solution to the problem. Soon after, Struts, and in the years following, The Framework Wars.

The AJAX Movement has not made this any easier, as often the “MVC within an MVC” pattern is applied; one each for the client- and server-side.

When I look over some of the greatest architectural decisions I’ve made in the past few years, the common thread has been my heavy use of the “delete” button. Removing entire layers of code. No more transfer/value objects. No more Business Delegates.

Now I want to get rid of the Web Tier in many cases. I love you Tomcat, but we’re doing you a disservice through abuse and overuse.

It’s time to expose our EJBs directly to our frontend teams. Asynchronous JS calls can so easily hook into business logic, and there’d be no more custom Servlet code inbetween. RPC for JS.

Not that this is unchartered territory, but all solutions I’ve encountered involve a webapp (Framework) to be deployed inside a Servlet Container, and I want to avoid the extra dependencies, glue code/configs, and unnecessary traffic over those channels.

I want JavaScript that reads:

EjbRequest request = new EjbRequest("com.alrubinger.BusinessInterfaceName","methodName","arg1","arg2","argX");
request.setResponseHandler = myResponseHandlerFunction;
request.send();

The beauty of this is that aside from the required import of a JavaScript library, theres no imposition on the application inbetween.

And behind the scenes, beyond the worry of either the frontend or application developer:

  • Request is sent (as JSON, XML, etc)
  • Received by separate, slim, non-blocking server as JCA Resource Adaptor.
  • JS > Java Object Mapping
  • Sent to “onMessage” of MDB
  • Dispatched to specified EJB, JNDI lookups transparent
  • Invocation
  • Result sent to Response Queue
  • Unwrapping, Java Object > JS Mapping
  • Write the response

I think back to all the occassions I’ve been asked to expose some method to my UI guys, and its horrifying the amount of time I’d spent (and errors introduced) simply getting well-tested data from points A to B. Stopping actual development to build a pipe. It makes me feel dirty.

So now I need a bath.

S,
ALR

Heavy is a Perception

•January 5, 2008 • 2 Comments

While putzing around the apartment tonight I stumbled across my girlfriend watching the premiere of a new Lifetime Original Series, “How To Look Good Naked“. My initial excitement quickly throttled back to reality when I discovered that my visions of skin on parade were replaced with the insufferable Carson Kressley doing some version of “Queer Eye for the Insecure Girl”. I could blame false advertising, but it’s my own fault for expecting greatness from Lifetime while simultaneously possessing a Y chromosome.

But the intent of the show mirrored some discussions I’ve been having with Michael Neale, Aussie on the JBoss Rules team. Changing your perception is a lot of the game.

Now, I’ll never, ever argue that marketing or a pretty face will make up for a crap product, but lately I’ve been ramped up over the public view that JEE, and JBoss AS in particular, are “Heavy”. And in context, this is somehow bad.

So it’s time to dispel some of that by embracing the reality of what “Heavy” means.

In the case of JBoss AS, it means:

  • Resource Pooling (Threads, Objects, Database Connections, etc)
  • Transaction Management
  • Conversational Context (Application Sessions)
  • Pass-by-Reference Semantics (Avoiding Serialization cost and Network Latency)
  • Security
  • Process Scheduling
  • …etc, etc.

…by default.

Default.

Love it. And love even further that the above is implemented to open specification (JPA, JCA, EJB, JTA), minimizing your vendor lock-in.

I21 advocates will proclaim Spring as more relevant than the Second Coming because it DOESN’T have any of that.

…by default.

Default.

See, the beauty of Spring is that it’s merely an environment into which other modules may be plugged. Light as a feather in space. Starts up before you hit “enter”, scales to the moon and back. And is extensible by adding implementations of whichever components you need.

Dirty little secret about JBoss AS: It also does nothing on its own.

The JBoss Microkernel has, for years, simply been a deployment mechanism. And today, I started it in 3 seconds in minimal configuration. If I want to add features, I drop ‘em into a folder.

Sounds Springy to me.

For a long time, I’ve hated everything:

  • Dynamically-typed
  • Ending in “uby” or “roovy”
  • Agile

…because they just don’t address Enterprise Concerns, and trade the long- for the short-term, good practice for easy-to-learn.

But that era’s got to come to an end. Development, and open-source in particular, is about choice. And we’ve got lots of great stuff in the JEE space to offer to languages and methodologies of all walks. It’s time to reach out and integrate.

So here’s my concession: EJB is powerful, but I’m going to recognize that not everyone has the desire to invest the time to learn its complex underpinnings, even if the 3.0 Specification made the semantics dead simple.

Maybe frontend JavaScript developers want to call Service code directly, eliminating the need for a Web Tier in many cases. We can do that. Maybe JRuby kids want to leverage Rails for its strong points, and shuffle off the distributed business logic to EJBs. We can make that easier, too.

So Heavy can be really, really good.

Except when you were hoping for lite porn, and instead got some chick crying in front of a three-way mirror.

S,
ALR