You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by jo...@apache.org on 2016/10/28 01:41:05 UTC
deltaspike git commit: DELTASPIKE-1205 Added an example for data that
is very similar to JPA.
Repository: deltaspike
Updated Branches:
refs/heads/master 716640903 -> e14a48623
DELTASPIKE-1205 Added an example for data that is very similar to JPA.
This closes #67
Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/e14a4862
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/e14a4862
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/e14a4862
Branch: refs/heads/master
Commit: e14a486231f6c5e4c80c06f584c3b34679548e35
Parents: 7166409
Author: John D. Ament <jo...@apache.org>
Authored: Thu Oct 27 21:40:59 2016 -0400
Committer: John D. Ament <jo...@apache.org>
Committed: Thu Oct 27 21:40:59 2016 -0400
----------------------------------------------------------------------
deltaspike/examples/data-examples/README.md | 24 +++++
deltaspike/examples/data-examples/pom.xml | 94 ++++++++++++++++
.../org/apache/deltaspike/example/Article.java | 108 +++++++++++++++++++
.../deltaspike/example/ArticleController.java | 98 +++++++++++++++++
.../deltaspike/example/ArticleRepository.java | 29 +++++
.../apache/deltaspike/example/HttpParam.java | 37 +++++++
.../apache/deltaspike/example/HttpParams.java | 37 +++++++
.../apache/deltaspike/example/LogProducer.java | 33 ++++++
.../apache/deltaspike/example/Resources.java | 62 +++++++++++
.../META-INF/apache-deltaspike.properties | 20 ++++
.../src/main/resources/META-INF/persistence.xml | 33 ++++++
.../src/main/webapp/WEB-INF/beans.xml | 23 ++++
.../src/main/webapp/WEB-INF/faces-config.xml | 41 +++++++
.../src/main/webapp/WEB-INF/web.xml | 43 ++++++++
.../data-examples/src/main/webapp/add.xhtml | 52 +++++++++
.../data-examples/src/main/webapp/index.xhtml | 39 +++++++
.../data-examples/src/main/webapp/list.xhtml | 64 +++++++++++
deltaspike/examples/pom.xml | 1 +
18 files changed, 838 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/README.md
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/README.md b/deltaspike/examples/data-examples/README.md
new file mode 100644
index 0000000..84daafc
--- /dev/null
+++ b/deltaspike/examples/data-examples/README.md
@@ -0,0 +1,24 @@
+Notice: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ .
+ http://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+Data Module for DeltaSpike
+==========================
+This example shows:
+
+1, how to use JPA in deltaspike;
+2, how to use the Data module for repositories;
+3, the function of @Transactional, how @Transactional save entity automatically.
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/pom.xml b/deltaspike/examples/data-examples/pom.xml
new file mode 100644
index 0000000..5c43ebb
--- /dev/null
+++ b/deltaspike/examples/data-examples/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.deltaspike.examples</groupId>
+ <artifactId>examples-project</artifactId>
+ <version>1.7.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>deltaspike-data-examples</artifactId>
+
+ <name>Apache DeltaSpike Data Examples</name>
+
+ <packaging>war</packaging>
+
+ <properties>
+ <deploy.skip>true</deploy.skip>
+ </properties>
+
+ <dependencies>
+ <!-- DeltaSpike modules -->
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-jsf-module-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-jsf-module-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-jpa-module-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-jpa-module-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-data-module-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-data-module-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>7.0</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ </build>
+</project>
+
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/Article.java
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/Article.java b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/Article.java
new file mode 100644
index 0000000..10505b6
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/Article.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.example;
+
+import java.io.Serializable;
+import java.util.Date;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name = "articles")
+public class Article implements Serializable
+{
+
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String title;
+ private String content;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "time_created")
+ private Date date;
+
+ // A must have!
+ public Article()
+ {
+ // this form used by Hibernate
+ }
+
+ public Article(String title, Date date)
+ {
+ // for application use, to create new articles
+ this.title = title;
+ this.date = date;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ private void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public Date getDate()
+ {
+ return date;
+ }
+
+ public void setDate(Date date)
+ {
+ this.date = date;
+ }
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
+
+ public String getContent()
+ {
+ return content;
+ }
+
+ public void setContent(String content)
+ {
+ this.content = content;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Article{" + "id=" + id + ", title=" + title + ", content=" + content + ", date=" + date + '}';
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/ArticleController.java
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/ArticleController.java b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/ArticleController.java
new file mode 100644
index 0000000..8300191
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/ArticleController.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.example;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+import java.util.logging.Logger;
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ViewScoped;
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.transaction.Transactional;
+
+@Named
+@ViewScoped
+@Transactional
+public class ArticleController implements Serializable
+{
+
+ private Article article = new Article();
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private ArticleRepository articleRepository;
+
+ @Inject
+ private FacesContext facesContext;
+
+ @HttpParam("aid")
+ @Inject
+ private String aid; // article id
+
+ public Article getArticle()
+ {
+ return article;
+ }
+
+ public void setArticle(Article article)
+ {
+ this.article = article;
+ }
+
+ public Article findArticleById(Long id)
+ {
+ article = articleRepository.findBy(id);
+ return article;
+ }
+
+
+ public String persist()
+ {
+ article.setDate(new Date());
+ articleRepository.save(this.article);
+ facesContext.addMessage(null, new FacesMessage("article:" + article.getTitle() + " persisted"));
+ return "persisted";
+ }
+
+ public String delete(Article article)
+ {
+ articleRepository.remove(article);
+ facesContext.addMessage(null, new FacesMessage("article:" + article.getTitle() + " deleted"));
+ return "deleted";
+ }
+
+ public List<Article> getAllArticles()
+ {
+ return articleRepository.findAll();
+ }
+
+ public void loadArticle()
+ {
+ if (aid != null)
+ {
+ this.article = findArticleById(Long.valueOf(aid));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/ArticleRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/ArticleRepository.java b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/ArticleRepository.java
new file mode 100644
index 0000000..4e8cb07
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/ArticleRepository.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.example;
+
+import org.apache.deltaspike.data.api.EntityRepository;
+import org.apache.deltaspike.data.api.Repository;
+
+@Repository
+public interface ArticleRepository extends EntityRepository<Article, Long>
+{
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/HttpParam.java
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/HttpParam.java b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/HttpParam.java
new file mode 100644
index 0000000..75755f4
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/HttpParam.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.example;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import javax.enterprise.util.Nonbinding;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Retention(RUNTIME)
+@Target({ METHOD, FIELD, PARAMETER, TYPE })
+public @interface HttpParam
+{
+ @Nonbinding String value();
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/HttpParams.java
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/HttpParams.java b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/HttpParams.java
new file mode 100644
index 0000000..b4edfa9
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/HttpParams.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.example;
+
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletRequest;
+
+public class HttpParams
+{
+
+ @Produces
+ @HttpParam("")
+ String getParamValue(InjectionPoint ip)
+ {
+ ServletRequest request = (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
+ return request.getParameter(ip.getAnnotated().getAnnotation(HttpParam.class).value());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/LogProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/LogProducer.java b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/LogProducer.java
new file mode 100644
index 0000000..2cacecb
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/LogProducer.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.example;
+
+import java.util.logging.Logger;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+public class LogProducer
+{
+
+ @Produces
+ Logger createLogger(final InjectionPoint ip)
+ {
+ return Logger.getLogger(ip.getMember().getDeclaringClass().getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/Resources.java
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/Resources.java b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/Resources.java
new file mode 100644
index 0000000..2d69e68
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/java/org/apache/deltaspike/example/Resources.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.example;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.faces.context.FacesContext;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+@ApplicationScoped
+public class Resources
+{
+
+ @PersistenceUnit
+ private EntityManagerFactory entityManagerFactory;
+
+ @Produces
+ @Default
+ @RequestScoped
+ public EntityManager create()
+ {
+ return this.entityManagerFactory.createEntityManager();
+ }
+
+ public void dispose(@Disposes @Default EntityManager entityManager)
+ {
+ if (entityManager.isOpen())
+ {
+ entityManager.close();
+ }
+ }
+
+ @Produces
+ @RequestScoped
+ public FacesContext produceFacesContext()
+ {
+ return FacesContext.getCurrentInstance();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/resources/META-INF/apache-deltaspike.properties
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/resources/META-INF/apache-deltaspike.properties b/deltaspike/examples/data-examples/src/main/resources/META-INF/apache-deltaspike.properties
new file mode 100644
index 0000000..e172e31
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/resources/META-INF/apache-deltaspike.properties
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy=org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStrategy
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/resources/META-INF/persistence.xml b/deltaspike/examples/data-examples/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..5b8904d
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<persistence version="2.0"
+ 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_2_0.xsd">
+ <persistence-unit name="primary" transaction-type="JTA">
+ <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
+ <class>org.apache.deltaspike.example.Article</class>
+
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="create" />
+ <property name="hibernate.show_sql" value="true" />
+ </properties>
+ </persistence-unit>
+</persistence>
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/beans.xml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/beans.xml b/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/beans.xml
new file mode 100644
index 0000000..e9f29b3
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/faces-config.xml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/faces-config.xml b/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..ca5f7c2
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,41 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one
+~ or more contributor license agreements. See the NOTICE file
+~ distributed with this work for additional information
+~ regarding copyright ownership. The ASF licenses this file
+~ to you under the Apache License, Version 2.0 (the
+~ "License"); you may not use this file except in compliance
+~ with the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing,
+~ software distributed under the License is distributed on an
+~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~ KIND, either express or implied. See the License for the
+~ specific language governing permissions and limitations
+~ under the License.
+-->
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+ <navigation-rule>
+ <from-view-id>/add.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>persisted</from-outcome>
+ <to-view-id>/list.xhtml</to-view-id>
+ <redirect />
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/list.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>deleted</from-outcome>
+ <to-view-id>/list.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+</faces-config>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/web.xml b/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..76f7ba6
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.xhtml</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list>
+ <welcome-file>index.xhtml</welcome-file>
+ </welcome-file-list>
+</web-app>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/webapp/add.xhtml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/webapp/add.xhtml b/deltaspike/examples/data-examples/src/main/webapp/add.xhtml
new file mode 100644
index 0000000..968a6ff
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/webapp/add.xhtml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+-->
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://xmlns.jcp.org/jsf/core">
+ <f:metadata>
+ <f:viewAction action="#{articleController.loadArticle}"/>
+ </f:metadata>
+
+ <h:head>
+ <title>Simple JPA page</title>
+ </h:head>
+
+ <h:body>
+ <h1>#{empty(articleController.article.id) ? 'Add New ' : 'Edit '}Article</h1>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:outputLabel value="title:" for="title"/>
+ <h:inputText id="title" value="#{articleController.article.title}" size="20"/>
+
+ <h:outputLabel value="content:" for="content"/>
+ <h:inputTextarea id="content" value="#{articleController.article.content}" cols="20" rows="5"/>
+
+ <h:commandButton value="#{empty(articleController.article.id) ? 'Add New ' : 'Edit '}Article"
+ action="#{articleController.persist}"/>
+ </h:panelGrid>
+ </h:form>
+
+ </h:body>
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/webapp/index.xhtml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/webapp/index.xhtml b/deltaspike/examples/data-examples/src/main/webapp/index.xhtml
new file mode 100644
index 0000000..0adf039
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/webapp/index.xhtml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+-->
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+ <h:head>
+ <title>Simple Data Module page</title>
+ </h:head>
+
+ <h:body>
+ <h1>Deltaspike Data module examples</h1>
+ <h:link value=">>Add new article" outcome="add.xhtml" />
+ <br />
+ <h:link value=">>article list" outcome="list.xhtml" />
+ <br />
+ </h:body>
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/data-examples/src/main/webapp/list.xhtml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/data-examples/src/main/webapp/list.xhtml b/deltaspike/examples/data-examples/src/main/webapp/list.xhtml
new file mode 100644
index 0000000..bdfd666
--- /dev/null
+++ b/deltaspike/examples/data-examples/src/main/webapp/list.xhtml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+-->
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+ <h:head>
+ <title>Simple JPA page</title>
+ </h:head>
+
+ <h:body>
+ <h1>Article List</h1>
+ <h:messages style="color:red"/>
+
+ <h:form>
+ <h:dataTable value="#{articleController.allArticles}" var="article" border="1">
+ <h:column>
+ <f:facet name="header">ID</f:facet>
+ <h:outputText value="#{article.id}"/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">title</f:facet>
+ <h:outputText value="#{article.title}"/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">date</f:facet>
+ <h:outputText value="#{article.date}"/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">operation</f:facet>
+ <h:link value="edit" outcome="add.xhtml">
+ <f:param name="aid" value="#{article.id}"/>
+ </h:link>
+ #{' '}
+ <h:commandLink value="delete" action="#{articleController.delete(article)}"/>
+ </h:column>
+ </h:dataTable>
+ </h:form>
+
+ <h:link value=">>add new article" outcome="add.xhtml"/>
+ </h:body>
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e14a4862/deltaspike/examples/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/pom.xml b/deltaspike/examples/pom.xml
index 52238b7..478c1d2 100644
--- a/deltaspike/examples/pom.xml
+++ b/deltaspike/examples/pom.xml
@@ -60,6 +60,7 @@
<module>security-requested-page-after-login-picketlink</module>
<module>scheduler-playground</module>
<module>jpa-examples</module>
+ <module>data-examples</module>
</modules>
<properties>