main website home
  • About this blog

    This blog features updates, opinions, and technical notes from Caucho engineers about Caucho products, the enterprise Java industry, and PHP. Caucho Technology is the creator of the Resin Application Server and the Quercus PHP in Java engine. A leader in Java performance since 1998, Caucho is a Sun JavaEE licensee with over 9000 customers worldwide.
  • Tags

    ajaxworld bam candi cdi cloud cluster comet configuration deploy devoxx eclipse ejb embedded flash flex google app engine hessian hmtp ioc java ee 6 javaone javazone jms messaging newsletter nyjug osgi php pomegranate quercus resin resin 4.0 REST servlet sfjug silicon valley code camp spring testing training tssjs watchdog webbeans web profile websockets wordpress
  • Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
« Resin 4.0 Cloud Computing Whitepaper
Load balanced database connection pools »

BAM! Flash! (and Hessian)

After a hiatus during a paper/presentation/training season, I’ve finally gone back and cleaned up the Flash/Flex versions of Hessian and BAM. The Hessian side is now updated to be compatible with the latest Hessian 2 changes. As Scott mentioned, the BAM API and protocol has undergone some changes since the last revision, so I’ve rewritten the Flash implementation of that as well. It was a surprisingly large amount of work, but I think everything is now up-to-date as well as a bit more stable.

For those that are interested, here’s a quick hello world with the new BAM API with a Flash client and a Java backend…

The Flash client just sends a basic query. This is a bit long not because of the BAM bits, but just because of the UI stuff. Pay attention to what the HmtpClient is doing…

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                creationComplete="onCreationComplete()">

  <mx:Script>
    <![CDATA[
      import bam.*;
      import bam.hmtp.*;

      private const TEST_VALUE:String = "test query value 1234";
      private var _client:HmtpClient;

      public function onCreationComplete():void
      {
        _client = new HmtpClient("/hmtp");
        _client.connect("foo@localhost", "password",
                        onLoginResult, onLoginError);
      }

      public function onLoginResult(jid:String):void
      {
        jidLabel.text = "jid: " + jid;
      }

      public function onLoginError(error:ActorErrorMessage):void
      {
        jidLabel.text = "login error: " + error;
      }

      public function testQueryGet():void
      {
        _client.queryGet("basic-test@localhost", TEST_VALUE, onResult, onError);
      }

      public function onResult(id:Number, to:String, from:String,
                               value:Object):void
      {
        if (value == "result[" + TEST_VALUE + "]")
          resultLabel.text = "test passed";
        else
          resultLabel.text = "test failed: received value '" + value + "'";
      }

      public function onError(id:Number, to:String, from:String,
                               value:Object, error:ActorErrorMessage):void
      {
        resultLabel.text = "test failed: received error '" + error + "'";
      }
    ]]>
  </mx:Script>

  <mx:Panel title="Bam Basic Test">
    <mx:VBox>
      <mx:Label id="jidLabel" text="logging in..."/>
      <mx:Button label="click to send query get" click="testQueryGet()"/>
      <mx:Label id="resultLabel"/>
    </mx:VBox>
    <mx:HRule/>
  </mx:Panel>
</mx:Application>

The Java service that receives and processes the query is pretty simple as well:

GeSHi Error: GeSHi could not find the language java5 (using path /var/resin/hosts/blog.caucho.com/webapps/ROOT//wp-content/plugins/codesnippet/lib/geshi/) (code 2)

Finally, to configure the service in a webapp, your resin-web.xml will look like this:

<web-app xmlns="http://caucho.com/ns/resin">
  <sec:AdminAuthenticator xmlns:sec="urn:java:com.caucho.security"
                          password-digest="none">
    <user name="foo@localhost" password="password"/>
  </sec:AdminAuthenticator>

  <bam-service name="basic-test@localhost" class="qa.BasicTestService"/>

  <servlet-mapping url-pattern="/hmtp"
                   servlet-class="com.caucho.remote.HmtpServlet"/>
</web-app>

We specify the password that clients will use, configure the BasicTestService, and deploy the HmtpServlet to handle the protocol requests.

If you’re familiar with the previous BAM incarnation, this shouldn’t look too different, but I’ll also try to get some decent examples up soon for those of you who are new to BAM. I’ll be releasing a snapshot soon with the final release coinciding with Resin 4.0

Tags: bam, flash, flex, hessian

This entry was posted on Thursday, March 12th, 2009 at 12:58 pm and is filed under Engineering. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Responses to “BAM! Flash! (and Hessian)”

  1. serj Says:
    October 19th, 2009 at 7:51 am

    hello

    I wonder if I can get some help related to hessian-comet.
    I want to test example from http://hessian.caucho.com/comet/#Comet%20Servlet, but I get this error in flex “Could not resolve to a component implementation”. I use external lib (hessian-flex-4.0.0.swc), from http://hessian.caucho.com. Maybe is not the right swc file?

    thanks for any ideea
    serj

  2. Emil Says:
    October 19th, 2009 at 10:45 am

    serj,

    I’m sorry, that example is out of date. We’ve changed our streaming/comet model from that example to use BAM instead. Unfortunately since BAM is also in transition, we don’t have an up-to-date example for that either. We’ll be focusing a lot more on streaming to the browser in the next few months though, during which time, we should also bring all of the flash-related work to a much more stable point.

    Thanks for you patience,
    Emil

  3. fatbatman Says:
    November 13th, 2009 at 6:46 am

    Hi,

    Is there a Java client for BAM, ideally with an example of how to use it?

    thanks

    James

  4. Emil Says:
    November 13th, 2009 at 4:41 pm

    Hi James,

    BAM is actually primarily Java (in fact the Hessian/Flash client needs updating), but most uses have been internal so far. The API is visible in the com.caucho.bam package of Resin, but at the moment it’s still quite subject to change. I think the plan is to solidify and publicize BAM more in the first half of 2010 to make it a solid way to do bi-directional web work.

    Thanks,
    Emil

Leave a Reply

You must be logged in to post a comment.


Caucho Technology is proudly powered by WordPress and Quercus®
Entries (RSS) and Comments (RSS).

  • HOME |
  • CONTACT US |
  • DOCUMENTATION |
  • BLOG |
  • WIKI 4 |
  • WIKI 3 |
  • Resin: Java Application Server
Copyright (c) 1998-2012 Caucho Technology, Inc. All rights reserved.
caucho® , resin® and quercus® are registered trademarks of Caucho Technology, Inc.
resin® is a cloud optimized, java® application server that supports the java ee webprofile ®