• 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.
  • Follow Caucho on Twitter

    • Tell us your thoughts about using IDEs with Resin: http://forum.caucho.com/showthread.php?t=16022 2010/08/26
    • Wondering if a CDI-based alternative to grails/roo has appeared. A groovy/CDI framework would be interesting. 2010/08/24
    • By open source experience, I mean contributions 2010/08/17
  • Tags

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

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org

Posts Tagged ‘embedded’

Embedded Resin… with WebBeans!

Friday, April 11th, 2008

One of the coolest new features of Resin 3.1.5 is embedding. Basically with a few simple lines of code, you can embed Resin into any existing Java application. More than that though, you can take advantage of Resin IoC/WebBeans even within the embedded environment. Let me give you an example…

Let’s start with simple embedding:

package demo;

import com.caucho.resin.*;

public class EmbeddedResin {
  public static void main(String[] args)
    throws Exception
  {
    ResinEmbed resin = new ResinEmbed();
    HttpEmbed http = new HttpEmbed(8080);
    resin.addPort(http);

    resin.addWebApp(new WebAppEmbed("/", "ROOT"));
    resin.start();
    resin.join();
  }
}

This basically starts up a new Resin within this application listening to port 8080 and serving up a webapp whose root is at “ROOT”. The resin.start() call starts the instance while the resin.join() waits for it to finish. Depending on the application, you may want to separate those calls.

So that’s very cool, but now what if I have a bean that I want to inject somewhere. Let’s say this FooBean:

package demo;

public class FooBean {
  public String hello()
  {
    return "Hello from the world of Embedded Resin!";
  }
}

I can actually do annotation based injection into a JSP for example:

<%@ page import="javax.webbeans.*,demo.*" %>
<%! @In private FooBean _foo; %>

<%= _foo.hello() %>

All I have to do is add a call to resin.addBean() to the example above:

package demo;

import com.caucho.resin.*;

public class EmbeddedIoC {
  public static void main(String[] args)
    throws Exception
  {
    ResinEmbed resin = new ResinEmbed();
    HttpEmbed http = new HttpEmbed(8080);
    resin.addPort(http);

    resin.addBean(new BeanEmbed(new FooBean()));

    resin.addWebApp(new WebAppEmbed("/", "ROOT"));
    resin.start();
    resin.join();

  }
}

It’s pretty cool to me that you can drop a random bean into the embedded Resin, then just have it show up somewhere in a JSP. :-) I bundled this example up here. Just run “ant compile”, then “ant run” to use it.

Tags: embedded, ioc, resin, webbeans
Posted in Engineering | No Comments »

Resin 3.1.5 released!!!

Wednesday, February 27th, 2008

Woohoo! I’m pretty excited about this one. There are so many new cool features. Here’s the list:

  • Resin IoC - Fully WebBeans (JSR-299) compliant IoC container
  • Embedded Resin - Use Resin in an existing application or within a unit testing framework like JUnit.
  • Support for gobs of 3rd-party packages: Maven2, Ivy, Mule, Struts2, CXF, Wicket, and more!
  • Lots of updates to security, including an update to the authenticator configuration
  • Exposure of the Resin JMS queues as BlockingQueues
  • Watchdog updates
  • Security updates
  • Resin remoting

Wow… there are a lot of features there. I was going to write a bigger entry to cover everything, but I think now that it would be better if I split it up. Over the next few days, I’ll be writing more in depth entries about each of these features. It’ll probably take a week… :-)

Tags: embedded, ioc, jms, messaging, remoting, resin, watchdog
Posted in Announcements | No Comments »


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