You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by Apache Wiki <wi...@apache.org> on 2005/10/23 13:25:36 UTC

[Jakarta-hivemind Wiki] Update of "Examples" by ChristianMittendorf

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-hivemind Wiki" for change notification.

The following page has been changed by ChristianMittendorf:
http://wiki.apache.org/jakarta-hivemind/Examples

------------------------------------------------------------------------------
  
  Maybe someone with more knowledge with Cayenne could help you out with this. We use Hibernate and have another service which sits on top. This is how our code was pre-HiveMind (I am looking at persisting configuration before we go full steam on using HiveMind in this part of the application.) We are using Hibernate and OSCache, so there are 3 properties/xml files that form parts of the configuration before you factor in application specifics.
  
+ ChristianMittendorf: I've done some testing on HiveMind integration of Cayenne. My solution requires your webapp to use servlet specification 2.4 or newer (see [http://www.objectstyle.org/cayenne/userguide/deploy/webapplicationcontextprovider.html WebApplicationContextProvider]).
+ 
+ Put a listener entry to your web.xml:
+ 
+ {{{
+ <?xml version="1.0" encoding="UTF-8"?>
+ <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+     version="2.4">
+ 	
+ 	<display-name>...</display-name>
+ 	[...]
+ 	<listener>
+ 	   <listener-class>org.objectstyle.cayenne.conf.WebApplicationContextProvider</listener-class>
+ 	</listener>
+ 	[...]
+ </web-app> 
+ }}}
+ 
+ Add the service to your hivemind.xml:
+ 
+ {{{
+ 	<service-point id="dbContextService" interface="de.cmittendorf.texample.hivemind.DataContextService">
+ 	</service-point>
+ 	
+ 	<implementation service-id="dbContextService">
+ 	 	<invoke-factory>
+ 			<construct class="de.cmittendorf.texample.hivemind.impl.DataContextServiceImpl" />
+ 		</invoke-factory>
+ 	</implementation>
+ }}}
+ 
+ Create the Interface
+ 
+ {{{
+ package de.cmittendorf.texample.hivemind;
+ 
+ import org.objectstyle.cayenne.access.DataContext;
+ 
+ public interface DataContextService
+ {
+ 	public DataContext getDataContext();
+ }
+ }}}
+ 
+ and the Implementation
+ 
+ {{{
+ package de.cmittendorf.texample.hivemind.impl;
+ 
+ import org.objectstyle.cayenne.access.DataContext;
+ 
+ import de.cmittendorf.texample.hivemind.DataContextService;
+ 
+ public class DataContextServiceImpl implements DataContextService
+ {	
+ 	public DataContext getDataContext()
+ 	{
+ 		return DataContext.getThreadDataContext();
+ 	}
+ }
+ }}}
+ 

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org