Here's some examples:

*ping-service\src\META-INF\persistence.xml:*
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd";
version="1.0">

    <persistence-unit name="transactions-optional">

<provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider>
        <properties>
            <property name="datanucleus.NontransactionalRead" value="true"/>
            <property name="datanucleus.NontransactionalWrite"
value="true"/>
            <property name="datanucleus.ConnectionURL" value="appengine"/>
        </properties>
    </persistence-unit>

</persistence>

*ping-service\war\WEB-INF\applicationContext.xml:*

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:aop="http://www.springframework.org/schema/aop";
       xmlns:tx="http://www.springframework.org/schema/tx";
       xmlns:context="http://www.springframework.org/schema/context";
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.0.xsd
">

    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            <tx:method name="*" propagation="REQUIRES_NEW" />
        </tx:attributes>
    </tx:advice>

    <aop:config>
        <aop:pointcut id="daoOperations"
            expression="execution(* dmitrygusev.ping.services.dao.*.*(..))"
/>
        <aop:advisor advice-ref="txAdvice" pointcut-ref="daoOperations" />
    </aop:config>

    <bean id="entityManagerFactory"
        class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"
        lazy-init="true">
        <property name="persistenceUnitName" value="transactions-optional"
/>
    </bean>

    <bean name="txManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>

    <context:annotation-config/>

    <bean name="jobsDAO"
class="dmitrygusev.ping.services.dao.impl.JobDAOImpl"/>
    <bean name="refDAO"
class="dmitrygusev.ping.services.dao.impl.RefDAOImpl"/>
    <bean name="accountDAO"
class="dmitrygusev.ping.services.dao.impl.AccountDAOImpl"/>
    <bean name="scheduleDAO"
class="dmitrygusev.ping.services.dao.impl.ScheduleDAOImpl"/>
    <bean name="jobResultDAO"
class="dmitrygusev.ping.services.dao.impl.JobResultDAOImpl"/>

</beans>

*ping-service\src\dmitrygusev\ping\services\dao\ScheduleDAO.java :*
package dmitrygusev.ping.services.dao;

import com.google.appengine.api.datastore.Key;

import dmitrygusev.ping.entities.Schedule;

public interface ScheduleDAO {

    public abstract void update(Schedule schedule);

    public abstract void delete(Long id);

    public abstract Schedule createSchedule(String name);

    public abstract Schedule find(Key scheduleKey);

}

*ping-service\src\dmitrygusev\ping\services\dao\impl\ScheduleDAOImpl.java :*
package dmitrygusev.ping.services.dao.impl;

import static com.google.appengine.api.datastore.KeyFactory.createKey;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.google.appengine.api.datastore.Key;

import dmitrygusev.ping.entities.Schedule;
import dmitrygusev.ping.services.dao.ScheduleDAO;

public class ScheduleDAOImpl implements ScheduleDAO {

    @PersistenceContext
    private EntityManager em;

    public Schedule createSchedule(String name) {
        Schedule schedule = new Schedule();
        schedule.setName(name);

        em.persist(schedule);

        return schedule;
    }

    @Override
    public void update(Schedule schedule) {
        em.merge(schedule);
    }

    @Override
    public void delete(Long id) {
        Schedule schedule = find(createKey(Schedule.class.getSimpleName(),
id));
        em.remove(schedule);
    }

    @Override
    public Schedule find(Key scheduleKey) {
        return em.find(Schedule.class, scheduleKey);
    }
}


*Then inject ScheduleDAO in your page class using T5's @Inject annotation
and use it.*



On Sun, Nov 8, 2009 at 17:46, Dmitry Gusev <dmitry.gu...@gmail.com> wrote:

> Tapestry 5.1 should run on GAE 1.2.6(7) as is.
>
> I used T5.1 w/ Spring/JPA on GAE and didn't get any troubles at the cloud
> except some issues on development machine:
>
>
> http://dmitrygusev.blogspot.com/2009/10/develope-java-applications-with-gae-sdk.html
>
> http://dmitrygusev.blogspot.com/2009/08/turn-java-security-manager-off-in.html
>
>
>
> On Sun, Nov 8, 2009 at 16:51, sodium <sodiu...@yahoo.com> wrote:
>
>>
>> Hi,
>>
>> I have been using Tapestry5 for few of my projects and loving it, but i am
>> thinking of integrating it in Google App Engine.
>> As for Tapestry 5.0.18, i have managed to run it without jpa support by
>> following an example of
>>
>> http://old.nabble.com/SUCCESSFULL-deploy-Tapestry5-on-google-appengine-ts23018048.html
>>
>> http://old.nabble.com/SUCCESSFULL-deploy-Tapestry5-on-google-appengine-ts23018048.html
>>
>> For Tapestry5.1, i still very confused about
>>
>> http://old.nabble.com/Tapestry-5.1-running-in-Google-App-Engine-%28GAE%29-tp24923950p24927028.html
>>
>> http://old.nabble.com/Tapestry-5.1-running-in-Google-App-Engine-%28GAE%29-tp24923950p24927028.html
>>
>> Actually my biggest concern is using jpa in GAE with Tapestry5, can anyone
>> provide some clues on how to go about integrating Tap5 with jpa for GAE ?
>> If
>> someone can provide a sample project for GAE(1.2.6) Tapestry5(hopefully
>> 5.1)
>> integration with jpa support, i will definitely bow down to u like a
>> slave.
>> Been scratching my head so hard that my hair is starting to fall...
>>
>> I tried integration Tapestry 5.0.18 with guice2 for jpa support from
>>
>> http://old.nabble.com/Integration-of-T5-with-the-domain-model-ts9953748s302.html
>>
>> http://old.nabble.com/Integration-of-T5-with-the-domain-model-ts9953748s302.html
>> but the EntityManager keep returning null. Sigh..
>>
>> Any pointers and advice is very much appreciated.
>>
>> --
>> View this message in context:
>> http://old.nabble.com/GAE-and-Tapestry5-integration-tp26253952p26253952.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>
>
> --
> Dmitry Gusev
>
> AnjLab Team
> http://anjlab.com
>



-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Reply via email to