-
v1.5.0
@Deprecated
There are many examples how to create simple Wicket applications for Google application engine without Spring, JPA support. I would like to share how to create fully working application with JPA, Spring, Spring Transactions and Apache Wicket.
Once again, i guess you already know how to create simple Wicket application fot Google app engine. If not, you may read this article first.
- Apache wicket 1.4-rc4
- sl4j
- Spring 3.0.0.M3
- commons-logging
- antlr 3.0.1
- asm 2.2.3
- cglib nodep 2.1.3
- aopalliance 1.0
If you are using maven style, you might use this snippet to get maven dependencies of 3th party libraries. They are provided at the end this article :)
These dependencies do not include Google app engine dependencies, because these should be installed by yourself.
In order to use spring, you must register spring listener in web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:META-INF/application-context.xml,
classpath*:META-INF/infrastructure-context.xml,
classpath*:META-INF/entitymanager.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
The file persistence.xml exists to define the various persistence-units that are to be available for persistence using JPA. Each persistence-unit defines a set of classes and their mapping characteristics when persisting them. So you must define datanucleus provider:
<persistence-unit name="xaloon">
<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>
Usually we use org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean as a bean for entity manager factory, but i could not make it working, so there is another bean provided by spring: org.springframework.orm.jpa.LocalEntityManagerFactoryBean
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean" lazy-init="true">
<property name="persistenceUnitName" value="xaloon" />
</bean>
<bean name="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven />
WebMarkupContainer container = new WebMarkupContainer("container");
container.setOutputMarkupId(true);
add (container);
DataView<Customer> view = new DataView<Customer>("view", new CustomerProvider(), 5) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(Item<Customer> arg0) {
updateItem (arg0, arg0.getModelObject());
}
};
container.add (view);
container.add (new AjaxPagingNavigator("navigator", view));Final application might be found here
Source code might be found here
Well, seems that i have to wait for at least 6 months in order to use google application engine fully.
1. I tried to use order by id in search criteria. Development environment was fine, but production - nope. Did follow this thread, but no result.
Also there is another issue related to automatic index generation. There is a bug in current app engine SDK
2. "select from" needs whole package and entity name used in search query.
<properties>
<spring.version>3.0.0.M2</spring.version>
<wicket.version>1.4-rc4</wicket.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.transaction</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.web.servlet</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm-commons</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2</version>
</dependency>
<!-- WICKET -->
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket</artifactId>
<version>${wicket.version}</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-auth-roles</artifactId>
<version>${wicket.version}</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-spring</artifactId>
<version>${wicket.version}</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-extensions</artifactId>
<version>${wicket.version}</version>
</dependency>
<!-- WICKET STUFF -->
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>annotation</artifactId>
<version>1.4-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.3</version>
</dependency>
</dependencies>
xaloon.org provides apache wicket based components for web and business solutions.
Learn more »