blob: 0aaf49433d77905f2a9e4bca395ca4060f243886 [file] [log] [blame]
Title: Remote Object Persistence CWS Deployment
<H2><A name="RemoteObjectPersistenceCWSDeployment-CWSDeploymentwithHessian"></A>CWS Deployment with Hessian</H2>
<P><A href="http://www.caucho.com/hessian/" class="external-link" rel="nofollow">Hessian-based</A> Cayenne Web Service is a regular Java web application that contains Cayenne mapping file and persistent objects. What makes it a web service is a HessianServlet mapped via web.xml that handles requests from Cayenne Client Tier applications.</P>
<DIV class="panelMacro"><TABLE class="tipMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="http://cayenne.apache.org/docs/1.2/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD>Client tier Java classes have to be present on the server together with server DataObjects. So you'll end up with two sets of objects mapped to the same set of entities. Hopefully we will get rid of this inconvenience in the future releases.</TD></TR></TABLE></DIV>
<H3><A name="RemoteObjectPersistenceCWSDeployment-AtypicalCWSapplication.warfile%3A"></A>A typical CWS application .war file:</H3>
<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
<PRE>myapp/
WEB-INF/
web.xml
lib/
cayenne.jar
hessian.jar
my-db-driver.jar
someother.jar
classes/
cayenne.xml
DataMap.map.xml
DataNode.driver.xml
com/mycompany/PersistentObject1.class
com/mycompany/auto/_PersistentObject1.class
com/mycompany/client/PersistentObject1.class
com/mycompany/client/auto/_PersistentObject1.class
</PRE>
</DIV></DIV>
<H3><A name="RemoteObjectPersistenceCWSDeployment-ConfiguringDeploymentParametersinweb.xml"></A>Configuring Deployment Parameters in web.xml</H3>
<P>Cayenne service configuration is done via <TT>web.xml</TT>:</P>
<UL>
<LI><EM>(optional)</EM> Configuring session timout other than the default (timeout value is in <B>minutes</B>):
<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
<PRE>&lt;session-config&gt;
&lt;session-timeout&gt;10&lt;/session-timeout&gt;
&lt;/session-config&gt;</PRE>
</DIV></DIV></LI>
</UL>
<UL>
<LI>Declaring a HessianServlet
<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
<PRE>&lt;servlet&gt;
&lt;servlet-name&gt;cayenne&lt;/servlet-name&gt;
&lt;servlet-class&gt;org.objectstyle.cayenne.remote.hessian.service.HessianServlet&lt;/servlet-class&gt;
&lt;!-- optional - XMPPBridge setup for peer-to-peer notifications --&gt;
&lt;!--
&lt;init-param&gt;
&lt;param-name&gt;cayenne.RemoteService.EventBridge.factory&lt;/param-name&gt;
&lt;param-value&gt;org.objectstyle.cayenne.event.XMPPBridgeFactory&lt;/param-value&gt;
&lt;/init-param&gt;
&lt;init-param&gt;
&lt;param-name&gt;cayenne.XMPPBridge.xmppHost&lt;/param-name&gt;
&lt;param-value&gt;localhost&lt;/param-value&gt;
&lt;/init-param&gt;
&lt;init-param&gt;
&lt;param-name&gt;cayenne.XMPPBridge.xmppPort&lt;/param-name&gt;
&lt;param-value&gt;5222&lt;/param-value&gt;
&lt;/init-param&gt;
&lt;init-param&gt;
&lt;param-name&gt;cayenne.XMPPBridge.xmppChatService&lt;/param-name&gt;
&lt;param-value&gt;conference&lt;/param-value&gt;
&lt;/init-param&gt;
--&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
&lt;servlet-name&gt;cayenne&lt;/servlet-name&gt;
&lt;url-pattern&gt;/cayenne&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;</PRE>
</DIV></DIV></LI>
</UL>
<UL>
<LI><EM>(Optional)</EM> Configuring HTTP basic authentication:
<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
<PRE>&lt;security-constraint&gt;
&lt;web-resource-collection&gt;
&lt;web-resource-name&gt;Cayenne Web Service&lt;/web-resource-name&gt;
&lt;url-pattern&gt;/cayenne&lt;/url-pattern&gt;
&lt;/web-resource-collection&gt;
&lt;auth-constraint&gt;
&lt;role-name&gt;remote-app&lt;/role-name&gt;
&lt;/auth-constraint&gt;
&lt;/security-constraint&gt;
&lt;login-config&gt;
&lt;auth-method&gt;BASIC&lt;/auth-method&gt;
&lt;realm-name&gt;CWS Realm&lt;/realm-name&gt;
&lt;/login-config&gt;
&lt;security-role&gt;
&lt;description&gt;All CWS client applications&lt;/description&gt;
&lt;role-name&gt;remote-app&lt;/role-name&gt;
&lt;/security-role&gt;</PRE>
</DIV></DIV></LI>
</UL>