Wicket

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
(New page: == Step by Step == <ol> <li>Download Resin from http://caucho.com/download <li>Untar Resin into /usr/local/share/resin <li>Download Wicket from http://wicket.apache.org <li>Unzip Wicket a...)
 
(Enabling MyApplication with Resin's WebBeans)
Line 17: Line 17:
  
 
Wicket's <code>MyApplication</code> application can be activated with Resin's WebBeans injection by changing the resin-web.xml configuration slightly.  If you set the <em>applicationFactoryClassName</em> init-param to "com.caucho.wicket.ResinApplicationFactory" (and make sure resin-support.jar is in ext-webapp-lib), your <code>MyApplication</code> can use
 
Wicket's <code>MyApplication</code> application can be activated with Resin's WebBeans injection by changing the resin-web.xml configuration slightly.  If you set the <em>applicationFactoryClassName</em> init-param to "com.caucho.wicket.ResinApplicationFactory" (and make sure resin-support.jar is in ext-webapp-lib), your <code>MyApplication</code> can use
<a href="http://caucho.com/resin/doc/resin-ioc.xtp">Resin-IoC or WebBeans</a> injection or interception, avoiding any need to use JNDI at all.
+
[http://caucho.com/resin/doc/resin-ioc.xtp Resin-IoC or WebBeans] injection or interception, avoiding any need to use JNDI at all.
  
 
<code><pre>
 
<code><pre>
Line 50: Line 50:
 
   }
 
   }
 
}
 
}
</pre></code>
 
 
</web-app>
 
 
</pre></code>
 
</pre></code>

Revision as of 23:38, 27 January 2008

Step by Step

  1. Download Resin from http://caucho.com/download
  2. Untar Resin into /usr/local/share/resin
  3. Download Wicket from http://wicket.apache.org
  4. Unzip Wicket and copy the jars into resin/ext-webapp-lib
  5. Download Velocity from http://velocity.apache.org
  6. Unzip Velocity and copy the jars into resin/ext-webapp-lib
  7. Create a webapp in resin/webapps/wicket
  8. Start Resin with java -jar resin/lib/resin.jar
  9. Create the Hello, World application in resin/webapps/wicket, following http://wicket.apache.org/examples.html
  10. Browse http://localhost:8080/wicket (Resin will autocompile the classes for you)

Enabling MyApplication with Resin's WebBeans

Wicket's MyApplication application can be activated with Resin's WebBeans injection by changing the resin-web.xml configuration slightly. If you set the applicationFactoryClassName init-param to "com.caucho.wicket.ResinApplicationFactory" (and make sure resin-support.jar is in ext-webapp-lib), your MyApplication can use Resin-IoC or WebBeans injection or interception, avoiding any need to use JNDI at all.

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

    <filter filter-name="wicket"
               filter-class="org.apache.wicket.protocol.http.WicketFilter">
      <init-param 
            applicationClassName="demo.HelloWorldApplication"
            applicationFactoryClassName="com.caucho.wicket.ResinApplicationFactory"/>
    </filter>

    <filter-mapping url-pattern="/*" filter-name="wicket"/>

</web-app>

Your application can then inject any Resin service including DataSources, JMS queues, user-defined beans in the resin-web.xml, etc.

package demo;

import javax.webbeans.*;
import javax.sql.*;

public class MyApplication extends WebApplication {
  @In DataSource _database;

  public Class getHomePage()
  {
    return HelloWorld.class;
  }
}
Personal tools