• Author

    Caucho Technology is an engineering company devoted to reliable open source and high performance Java-PHP solutions. Caucho products include Resin application server, Hessian web services and Quercus Java-PHP solutions. Caucho Technology was founded in 1998 and is based in La Jolla, California.

  • Pages

    • Archives

      • July 2008
      • June 2008
      • May 2008
      • April 2008
      • March 2008
      • February 2008
    • Categories

      • Blogroll

        • Scott Ferguson
      • Meta

        • Register
        • Log in

      BAM client and server

      July 23rd, 2008 by ferg

      After we realized BAM can be used as a queueing system replacing JMS, we looked at the BAM client and service configuration to simplify it for queueing, and at the same time fix some of the problems associated with JMS messaging.  The new BAM configuration is fairly simple.  A <bam-service> configures the service, just like Resin’s <ejb-message-bean>.  A BamClient class creates a new client.

      1. Create a SimpleBamService to handle the queued messages
      2. Configure the <bam-service>
      3. Send messages using a BamClient

      So sending a message looks like the following. “my-message” can be any serializable object, and
      “service@localhost” is the JID name of the service.

      import com.caucho.bam.BamClient;

      BamClient client = new BamClient();

      client.message("service@localhost", "my-message");

      The service itself implements com.caucho.bam.BamService.

      package example;

      import com.caucho.bam.SimpleBamService;

      public class MyService {
        public void message(String to, String from, java.io.Serializable data)
        {
          System.out.println("DATA: " + data);
        }
      }

      And the configuration looks like

      <web-app xmlns="http://caucho.com/ns/resin">

        <bam-service name="service@localhost" class="example.MyService"/>

      </web-app>

       

       

       

      Posted in Uncategorized | No Comments »

      Musedot on Quecus and Resin

      July 22nd, 2008 by emil

      I got a nice note from Frank E. Banks yesterday about his cool new music search engine, musedot. It’s running on Resin and Quercus open source. Here’s a quote from Frank about why he chose Caucho for his platform:

      Musedot (http://musedot.com) is a music search engine I created that is built with java for the core logic and uses resin/quercus for java integration and presentation logic (php). Once I determined that I would need to write a search engine from scratch, and one that needed to be robust and fast, I started doing a lot of research on the best architecture and settled on resin/quercus because I wanted to avoid the overhead of the Java web services model and doing something as complex as writing it all in C was totally out of the question. The fact that it is open source was also important. Despite having to learn two new program languages, java and php, the development process has gone smoothly (for software development) and I my choice has proven to be an excellent one.

      Thanks, Frank!

      Tags: musedot, quercus, resin
      Posted in Uncategorized | No Comments »

      Resin performance best practices

      July 17th, 2008 by emil

      I had a phone call with a customer today who expressed interest in a Resin performance/operations best practices community. Some ideas they had were for an online community (forums, mailing lists, etc.) or even face-to-face meetups. We would be happy to host these if there is interest. Please let me know either by commenting here or by emailing me at emil at caucho dot com.

      Posted in Uncategorized | 1 Comment »

      Hessian fixes

      July 12th, 2008 by emil

      I’ve been cleaning up some Hessian bugs in preparation for the next release and I ran into a couple of doozies. During the week, I dealt with an issue reported by Riccardo wherein I rediscovered that ActionScript doesn’t actually have 64-bit longs, only IEEE 64-bit doubles. This screws up 2’s compliment arithmetic if you don’t recognize it, as I had done before. :-) It’s now fixed…

      Today I worked on (de)serializing Java enums with constant-specific methods. Don’t know what those are? Neither did I. Tim Dawson was kind enough to send me a couple of examples:

      // enum with overriden method
      enum MyEnum1 {
        A {
          @Override
            public int getSomeValue() {
              return 1;
            }
        },
        B {
          @Override
            public int getSomeValue() {
              return 2;
            }
        };

        public abstract int getSomeValue();
      }

      // enum with specific method
      enum MyEnum2 {
        A{
          public void someMethod1(){}
        }, B{
          public void someMethod2(){}
        };

        public int getSomeValue() {
          return 0;
        }
      }

      Kind of an interesting use case. Here’s the rub. Try running this code with it:

      public static void main(String[] args) {
        System.out.println("Enum1 isEnum => " + MyEnum1.A.getClass().isEnum());
        System.out.println("Enum1 parent isEnum => " + MyEnum1.A.getClass().getSuperclass().isEnum());

        System.out.println("Enum2 isEnum => " + MyEnum2.A.getClass().isEnum());
        System.out.println("Enum2 parent isEnum => " + MyEnum2.A.getClass().getSuperclass().isEnum());
      }

      What do you think you get? The answer’s under the cut…
      Read the rest of this entry »

      Tags: actionscript, hessian, java enum
      Posted in Uncategorized | No Comments »

      New Hessian implementations

      July 10th, 2008 by emil

      Just a quick note: 3 new implementations of the Hessian protocol have recently come to our attention. An alternative Java implementation and 2 for Objective C. They’re now listed on http://hessian.caucho.com/. If anyone has any other implementations that are not listed on that page, please let us know!

      Tags: hessian
      Posted in Uncategorized | No Comments »

      XSS, Servlet Filters, and PHP

      July 8th, 2008 by emil

      Last night, I attended the San Francisco Java Meetup which was led by Jason Brittain on the topic of Cross Site Scripting (XSS). This is a serious security problem and Jason offered one solution: using Servlet filters to remove illegal input in user parameters. He has his own filter which will soon be available on SourceForge. He also mentioned the XSS filter from Stripes Framework. These are general solutions that may or may not be appropriate for your application, but they’re worth a look.

      A question came up toward the end of the session on how to do this for PHP. My answer was simple: use Servlet filters! Quercus is available as a Servlet, so you can just insert these or other filters in front of (or behind) it. I understand there may be some PHP solutions for this, but this opens the option using a servlet filter as well. This area is still being developed, but if a servlet filter becomes one of the better known, recognized ways of doing really good XSS attack filtering, you’ll be set using Quercus.

      Tags: quercus, xss
      Posted in Uncategorized | No Comments »

      Engineering update

      July 2nd, 2008 by emil

      This week has been (and will be) mostly an engineering week for me, but it’s an exciting one so I thought I’d let everyone know what’s going on.  First, I’m working on improving BAM to be easier to use from a developer’s point of view.  Essentially we moved to an introspected service instead of a strict interface for receiving events.  To give an example, the main BAM interface for receiving events is BamStream.  It contains methods like the following:

      public void message(String to, String from, Serializable value);

      There are similar methods for queryGet, querySet, etc. These methods are event handlers that are called on a service when a new message or query arrives for the service. The problem with this is you might have to write the following dispatch pattern:

      public void message(String to, String from, Serializable value)
      {
        if (value instanceof Foo) {
          // do something specific to Foo
        }
        else if (value instanceof Bar) {
          // do something specific to Bar
        }
      }

      This isn’t too bad, but it looks messy when you have a ton of different message types. To fix the problem, we’ve written a base class called GenericService. Now instead of writing the code above, you would extend GenericService and write the following:

      public void handleFoo(String to, String from, @Message Foo foo)
      {
        // do something specific to Foo
      }

      public void handleBar(String to, String from, @Message Bar bar)
      {
        // do something specific to Bar
      }

      This is equivalent to the code before, but now we do the dispatch for you. Under the covers, there’s some reflection magic going on, but basically all you have to do is make methods that match the right signature and use parameter annotations like @Message, @QueryGet, @Presence, etc.

      In other news, I’ve also been making sure that WordPress Mu works with Quercus. There were a couple of buglets, but those are fixed in the trunk now and it should be ready to go with Resin 3.2.0, due out in about 2-3 weeks. I put up a wiki page that describes how to do the installation. It’s a bit long right now, but hopefully we’ll soon be getting a Debian install that reduces the steps by half.

      Tags: bam, quercus, wordpress mu
      Posted in Engineering | No Comments »

      Easy development with Resin

      June 25th, 2008 by emil

      Resin is one of the easiest application servers to develop with because of a number of developer-oriented features, but not a lot of people know about them! Let me mention a few of my favorites here:

      • Automatic, in place compilation and recompilation of Java source. This feature lets you develop Java with the same ease as PHP. Just save your .java file in your webapp’s WEB-INF/classes directory (with the appropriate package path) and Resin will compile it for you. Changes are picked up as well and redeployed without restarting the whole server. Forget the hassle of building a .war for every little change, much less restarting the server.
      • Versioned webapps. Say you’ve deployed your application, but found a bug. There are a few users who still have live sessions, so you don’t want to boot them off, but at the same time, you don’t want to allow new users to start new sessions with the buggy webapp. Versioned webapps let you deploy a new version that runs in parallel with the old version. The new version gets all the new sessions, while the old version stays live until the last old session expires. It allows a nice, soft rollout of new code. To use the feature, all you have to do is name your .war files with a version number. For example, foo-1.0.war would be superceded by foo-1.1.war, automatically.
      • Live profiling. The /resin-admin application that’s provided with Resin has a number of great features for developers, one of which is the live profiler that shows how much time is spent in any given method and gives a stack trace to show how that method was reached. This should help you find the bottlenecks in your application.
      • Heap dumps. This is another feature in the /resin-admin that gives you a sorted heap dump showing which objects take up the most memory.

      There are a ton of other features, but hopefully that gives you a reason to try Resin or check out some of the features you’re missing if you’re already using Resin.

      Existing users: are there any features that you’re using that you find helpful as a developer?

      Tags: development, resin
      Posted in Evangelism | No Comments »

      BAM update

      June 10th, 2008 by emil

      The last two weeks have been pretty engineering heavy for me, thus the slow pace of updates. ;-) What I’ve been working on are several BAM-related technologies.  First, the Sudoku demo has been simplified and clarified.  I’ll be writing a tutorial based on it soon which I’m also hoping to publish in the Flash & Flex Developers’ Magazine.  Next, I’ve been working on building a PHP/BAM bridge.  This is pretty exciting and shows the real power of Quercus: you can write true event-based programs in PHP.  This is not something that is done easily or cleanly in the C implementation of PHP.  The first example of this will be an XMPP chat server.  Basically we’re moving PHP beyond the realm of simple HTTP web applications to have the full power of the Java platform.

      Tags: bam, php, quercus, xmpp
      Posted in Engineering | No Comments »

      Hessian articles in Flash & Flex Magazine

      June 6th, 2008 by emil

      I’ve got a couple of articles in the latest Flash & Flex Magazine about Hessian.  You can even download one of them!

      I’m submitting another article on using BAM with a Flash client that should hopefully be out later in the summer.

      Tags: bam, flash, flex, hessian
      Posted in Evangelism | No Comments »

      « Older Entries

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