You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joseph Hannon <ja...@gmail.com> on 2005/11/14 20:24:33 UTC

Help on getting a Cayenne DataContext using HiveMind service

Based on piece at http://wiki.apache.org/jakarta-hivemind/CayenneIntegration,
I implemented the following to attempt access to the Cayenne DataContext
(DC) from a non Tapestry class (any class). I get my Visit object from
HiveMind, so I know HiveMind is working. I am using Tapestry 4.0-beta-11,
Cayenne 1.2M7, and HiveMind 1.1-rc-1 running on Jetty 5.1.5. My app starts
up with no problems, then I get an exception on calling to get a DC. I
called for a DC from my WebApp and with a JUnit test to see if either would
work, neither did.

Will someone suggest what I can do to get this service working, or at least
make it accessible first? Will this approach work when calling from non
Tapestry classes? Do you have a good example of getting a service to work? I
can just use that instead.

Thanks,
Joseph

Caller:

Registry hivemindRegistry = RegistryBuilder.constructDefaultRegistry() ;
DataContextService dcs = (DataContextService) hivemindRegistry.getService(
DataContextService.class) ;

WebApp exception:

org.apache.hivemind.ApplicationRuntimeException: There is no service point
for interface org.code.hivemind.DataContextService.
at org.apache.hivemind.impl.RegistryInfrastructureImpl.getService(
RegistryInfrastructureImpl.java:236)
at org.apache.hivemind.impl.RegistryImpl.getService(RegistryImpl.java:84)
at org.code.utility.Utility.fetchDataContext(Utility.java:82)
...


JUnit Test exception:

org.apache.hivemind.ApplicationRuntimeException: Service point
DataContextService does not exist.
at org.apache.hivemind.impl.RegistryInfrastructureImpl.getServicePoint(
RegistryInfrastructureImpl.java:179)
at org.apache.hivemind.impl.RegistryInfrastructureImpl.getService(
RegistryInfrastructureImpl.java:205)
at org.apache.hivemind.impl.RegistryImpl.getService(RegistryImpl.java:79)
at org.code.utility.UtilityTest.testHiveMindDataContext(UtilityTest.java:80)
...

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>

<distributable/>

<filter> .... </filter>

<filter-mapping> ... </filter-mapping>

<listener>
<listener-class>org.objectstyle.cayenne.conf.WebApplicationContextProvider
</listener-class>
</listener>

<servlet> ... </servlet>

<servlet-mapping> ... </servlet-mapping>

</web-app>


hivemodule.xml:

<?xml version="1.0" encoding="utf-8"?>

<module id="org.code.hivemind" version="1.0.0">

<contribution configuration-id="tapestry.state.ApplicationObjects">
...
</contribution>

<service-point id="dataContextService" interface="
org.code.hivemind.DataContextService"/>

<implementation service-id="dataContextService">
<invoke-factory>
<construct class="org.code.hivemind.DataContextServiceImpl"/>
</invoke-factory>
</implementation>

</module>


Interface:

package org.code.hivemind;

import org.objectstyle.cayenne.access.DataContext;

public interface DataContextService
{
public DataContext getDataContext () ;

}


Implementation:

package org.code.hivemind;

import org.objectstyle.cayenne.access.DataContext;

public class DataContextServiceImpl implements DataContextService
{
public DataContext getDataContext()
{
DataContext dataContext = DataContext.getThreadDataContext() ;
if (dataContext == null)
{
dataContext = DataContext.createDataContext() ;
DataContext.bindThreadDataContext(dataContext) ;
}

return dataContext ;

}

}

Re: Help on getting a Cayenne DataContext using HiveMind service

Posted by Joseph Hannon <ja...@gmail.com>.
Will someone see if you can determine why I am not able to find the service
detailed in my post? Typos? Configuration setup? This is becoming quite
urgent.

Thanks,
Joseph

Re: Help on getting a Cayenne DataContext using HiveMind service

Posted by John Coleman <jo...@ntlworld.com>.
I am also looking to do something like this Joseph.

I imagine creating a set of implementation neutral interfaces for all the IO
and providing actual persistence implementation through a service that has a
Cayenne flavour. This service would be wired up in hivemind, and receive the
DC via another service, see below.

I found these notes so far
http://wiki.apache.org/jakarta-hivemind/CayenneIntegration in the wiki,
which gives this code:
package de.example.hivemind.impl;

import org.objectstyle.cayenne.access.DataContext;

import de.example.hivemind.DataContextService;

public class DataContextServiceImpl implements DataContextService
{
        public DataContext getDataContext()
        {
                DataContext dc = DataContext.getThreadDataContext();
                if(dc == null) {
                        dc = DataContext.createDataContext();
                        DataContext.bindThreadDataContext(dc);
                }
                return dc;
        }
}

And also this http://wiki.apache.org/jakarta-hivemind/Examples regarding
Cayenne.

John

----- Original Message ----- 
From: "Joseph Hannon" <ja...@gmail.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Monday, November 14, 2005 7:24 PM
Subject: Help on getting a Cayenne DataContext using HiveMind service


Based on piece at
http://wiki.apache.org/jakarta-hivemind/CayenneIntegration,
I implemented the following to attempt access to the Cayenne DataContext
(DC) from a non Tapestry class (any class). I get my Visit object from
HiveMind, so I know HiveMind is working. I am using Tapestry 4.0-beta-11,
Cayenne 1.2M7, and HiveMind 1.1-rc-1 running on Jetty 5.1.5. My app starts
up with no problems, then I get an exception on calling to get a DC. I
called for a DC from my WebApp and with a JUnit test to see if either would
work, neither did.

Will someone suggest what I can do to get this service working, or at least
make it accessible first? Will this approach work when calling from non
Tapestry classes? Do you have a good example of getting a service to work? I
can just use that instead.

Thanks,
Joseph




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