![]() | Resin Documentationapp server |
jaxb bean configurationResin's configuration integrates JAXB-style bean configuration. With Resin, applications can use JAXB to configure its resources
directly from the resin.conf or resin-web.xml. A "JAXB Bean"
is just a Java class that follows a simple set of rules. Each configuration
parameter
The <bean> tag creates a singleton component for the Theater, which can be used by any servlet, JSP, JSF, EJB or WebBeans component by using the WebBeans injection annotations.. WEB-INF/resin-web.xml <web-app xmlns="http://caucho.com/ns/resin"> <bean name="beans/theater" class="example.Theater"> <init> <name>Balboa Theater</name> <movie> <title>Plan 9 from Outer Space</title> </movie> <movie> <title>Snakes on a Plane</title> <star>Samuel L Jackson</star> </movie> <movie> <title>The Maltese Falcon</title> <star>Humphrey Bogart</star> <star>Mary Astor</star> <star>Peter Lorre</star> <star>Sydney Greenstreet</star> </movie> </init> </bean> <servlet-mapping url-pattern="/test" servlet-class="example.TestServlet"/> </web-app> WEB-INF/classes/example/Theater.java package example; import java.util.*; import javax.xml.bind.annotation.*; @XmlRootElement public class Theater { @XmlElement(name="name") private String _name; @XmlElement(name="movie") private ArrayList<Movie> _movieList = new ArrayList<Movie>(); } WEB-INF/classes/example/Movie.java package example; import java.util.*; import javax.xml.bind.annotation.*; @XmlRootElement public class Movie { @XmlElement(name="title") private String _title; @XmlElement(name="star") private ArrayList<String> _starList = new ArrayList<String>(); } WEB-INF/classes/example/TestServlet.java package example; import javax.servlet.*; import javax.webbeans.In; public class TestServlet extends GenericServlet { @In private Theater _theater; ... }
|