You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@tomee.apache.org by bu...@apache.org on 2012/07/05 10:53:31 UTC
svn commit: r824516 - in /websites/staging/openejb/trunk: cgi-bin/ content/
content/examples-trunk/ content/examples-trunk/cdi-query/
content/examples-trunk/cdi-query/src/
content/examples-trunk/cdi-query/src/main/
content/examples-trunk/cdi-query/src/...
Author: buildbot
Date: Thu Jul 5 08:53:30 2012
New Revision: 824516
Log:
Staging update by buildbot for openejb
Added:
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/pom.xml (with props)
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/EntityManagerProducer.java (with props)
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/User.java (with props)
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/UserDao.java (with props)
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/resources/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/resources/META-INF/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/resources/META-INF/beans.xml (with props)
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/resources/META-INF/persistence.xml (with props)
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/test/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/test/java/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/test/java/org/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/test/java/org/superbiz/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/test/java/org/superbiz/dynamic/
websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/test/java/org/superbiz/dynamic/CdiQueryTest.java (with props)
Modified:
websites/staging/openejb/trunk/cgi-bin/ (props changed)
websites/staging/openejb/trunk/content/ (props changed)
websites/staging/openejb/trunk/content/examples-trunk/pom.xml
Propchange: websites/staging/openejb/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Jul 5 08:53:30 2012
@@ -1 +1 @@
-1357036
+1357498
Propchange: websites/staging/openejb/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Jul 5 08:53:30 2012
@@ -1 +1 @@
-1357036
+1357498
Added: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/pom.xml
==============================================================================
Binary file - no diff available.
Propchange: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/pom.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/pom.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/EntityManagerProducer.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/EntityManagerProducer.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/EntityManagerProducer.java Thu Jul 5 08:53:30 2012
@@ -0,0 +1,30 @@
+/*
+ * 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.superbiz.dynamic;
+
+
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+@Stateless
+public class EntityManagerProducer {
+ @PersistenceContext
+ @Produces
+ private EntityManager em;
+}
Propchange: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/EntityManagerProducer.java
------------------------------------------------------------------------------
svn:executable = *
Added: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/User.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/User.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/User.java Thu Jul 5 08:53:30 2012
@@ -0,0 +1,54 @@
+/*
+ * 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.superbiz.dynamic;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class User {
+ @Id
+ @GeneratedValue
+ private long id;
+ private String name;
+ private int age;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+}
Propchange: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/User.java
------------------------------------------------------------------------------
svn:executable = *
Added: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/UserDao.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/UserDao.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/UserDao.java Thu Jul 5 08:53:30 2012
@@ -0,0 +1,24 @@
+/**
+ * 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.superbiz.dynamic;
+
+import com.ctp.cdi.query.Dao;
+import com.ctp.cdi.query.EntityDao;
+
+@Dao
+public interface UserDao extends EntityDao<User, Long> {
+}
Propchange: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/java/org/superbiz/dynamic/UserDao.java
------------------------------------------------------------------------------
svn:executable = *
Added: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/resources/META-INF/beans.xml
==============================================================================
Binary file - no diff available.
Propchange: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/resources/META-INF/beans.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/resources/META-INF/beans.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/resources/META-INF/persistence.xml
==============================================================================
Binary file - no diff available.
Propchange: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/main/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/test/java/org/superbiz/dynamic/CdiQueryTest.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/test/java/org/superbiz/dynamic/CdiQueryTest.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/test/java/org/superbiz/dynamic/CdiQueryTest.java Thu Jul 5 08:53:30 2012
@@ -0,0 +1,103 @@
+/*
+ * 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.superbiz.dynamic;
+
+import java.util.Collection;
+import java.util.Properties;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.NamingException;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * the UserDao can be injected but doesn't manage transaction so we create
+ * a TxProvider bean which provides the tx context.
+ *
+ * In this sample it simply delegates but in real life it often aggregates multiple calls.
+ */
+public class CdiQueryTest {
+ private static EJBContainer container;
+ private static boolean initialized = false;
+
+ @Inject
+ private TxProvider dao;
+
+ @Test
+ public void findAll() {
+ Collection<User> users = dao.findAll();
+ assertEquals(10, users.size());
+ }
+
+ @BeforeClass
+ public static void start() throws Exception {
+ final Properties p = new Properties();
+
+ p.setProperty("jdbc/CdiQueryTest", "new://Resource?type=DataSource");
+ p.setProperty("jdbc/CdiQueryTest.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.setProperty("jdbc/CdiQueryTest.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.setProperty("jdbc/CdiQueryTest.UserName", "sa");
+ p.setProperty("jdbc/CdiQueryTest.Password", "");
+
+ container = EJBContainer.createEJBContainer(p);
+ }
+
+ @Before
+ public void injectAndInit() throws NamingException {
+ container.getContext().bind("inject", this);
+ if (!initialized) {
+ for (int i = 0; i < 10; i++) {
+ final User u = new User();
+ u.setAge(i % 4);
+ if (i % 3 == 0) {
+ u.setName("foo");
+ } else {
+ u.setName("bar-" + i);
+ }
+ dao.save(u);
+ }
+ initialized = true;
+ }
+ }
+
+ @AfterClass
+ public static void close() {
+ container.close();
+ }
+
+ @Singleton
+ @Lock(LockType.READ)
+ public static class TxProvider { // just here to provide the transactional context
+ @Inject
+ private UserDao dao;
+
+ public Collection<User> findAll() {
+ return dao.findAll();
+ }
+
+ public void save(final User u) {
+ dao.save(u);
+ }
+ }
+}
Propchange: websites/staging/openejb/trunk/content/examples-trunk/cdi-query/src/test/java/org/superbiz/dynamic/CdiQueryTest.java
------------------------------------------------------------------------------
svn:executable = *
Modified: websites/staging/openejb/trunk/content/examples-trunk/pom.xml
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/pom.xml (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/pom.xml Thu Jul 5 08:53:30 2012
@@ -17,7 +17,7 @@
limitations under the License.
-->
<!--test 2-->
-<!-- $Rev: 1354371 $ $Date: 2012-06-27 08:47:32 +0000 (Wed, 27 Jun 2012) $ -->
+<!-- $Rev: 1357498 $ $Date: 2012-07-05 08:53:09 +0000 (Thu, 05 Jul 2012) $ -->
<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">
<parent>
@@ -46,6 +46,7 @@
<module>cdi-application-scope</module>
<module>cdi-produces-disposes</module>
<module>cdi-produces-field</module>
+ <module>cdi-query</module>
<module>component-interfaces</module>
<module>custom-injection</module>
<module>datasource-ciphered-password</module>