You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2015/09/25 12:42:52 UTC
[17/33] tomee git commit: Align SNAPSHOT versions & reformat examples
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/mbean-auto-registration/src/main/java/org/superbiz/mbean/GuessHowManyMBean.java
----------------------------------------------------------------------
diff --git a/examples/mbean-auto-registration/src/main/java/org/superbiz/mbean/GuessHowManyMBean.java b/examples/mbean-auto-registration/src/main/java/org/superbiz/mbean/GuessHowManyMBean.java
index 5dadbe2..00c2eb3 100755
--- a/examples/mbean-auto-registration/src/main/java/org/superbiz/mbean/GuessHowManyMBean.java
+++ b/examples/mbean-auto-registration/src/main/java/org/superbiz/mbean/GuessHowManyMBean.java
@@ -1,48 +1,48 @@
-/**
- * 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.mbean;
-
-import javax.management.Description;
-import javax.management.MBean;
-import javax.management.ManagedAttribute;
-import javax.management.ManagedOperation;
-
-@MBean
-@Description("play with me to guess a number")
-public class GuessHowManyMBean {
-
- private int value = 0;
-
- @ManagedAttribute
- @Description("you are cheating!")
- public int getValue() {
- return value;
- }
-
- @ManagedAttribute
- public void setValue(int value) {
- this.value = value;
- }
-
- @ManagedOperation
- public String tryValue(int userValue) {
- if (userValue == value) {
- return "winner";
- }
- return "not the correct value, please have another try";
- }
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.mbean;
+
+import javax.management.Description;
+import javax.management.MBean;
+import javax.management.ManagedAttribute;
+import javax.management.ManagedOperation;
+
+@MBean
+@Description("play with me to guess a number")
+public class GuessHowManyMBean {
+
+ private int value = 0;
+
+ @ManagedAttribute
+ @Description("you are cheating!")
+ public int getValue() {
+ return value;
+ }
+
+ @ManagedAttribute
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ @ManagedOperation
+ public String tryValue(int userValue) {
+ if (userValue == value) {
+ return "winner";
+ }
+ return "not the correct value, please have another try";
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/mbean-auto-registration/src/test/java/org/superbiz/mbean/GuessHowManyMBeanTest.java
----------------------------------------------------------------------
diff --git a/examples/mbean-auto-registration/src/test/java/org/superbiz/mbean/GuessHowManyMBeanTest.java b/examples/mbean-auto-registration/src/test/java/org/superbiz/mbean/GuessHowManyMBeanTest.java
index 1ef3031..b74daf0 100755
--- a/examples/mbean-auto-registration/src/test/java/org/superbiz/mbean/GuessHowManyMBeanTest.java
+++ b/examples/mbean-auto-registration/src/test/java/org/superbiz/mbean/GuessHowManyMBeanTest.java
@@ -1,51 +1,51 @@
-/**
- * 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.mbean;
-
-import org.apache.openejb.monitoring.LocalMBeanServer;
-import org.junit.Test;
-
-import javax.ejb.embeddable.EJBContainer;
-import javax.management.Attribute;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import java.lang.management.ManagementFactory;
-import java.util.Properties;
-
-import static org.junit.Assert.assertEquals;
-
-public class GuessHowManyMBeanTest {
-
- private static final String OBJECT_NAME = "openejb.user.mbeans:group=org.superbiz.mbean,application=mbean-auto-registration,name=GuessHowManyMBean";
-
- @Test
- public void play() throws Exception {
- Properties properties = new Properties();
- properties.setProperty(LocalMBeanServer.OPENEJB_JMX_ACTIVE, Boolean.TRUE.toString());
- EJBContainer container = EJBContainer.createEJBContainer(properties);
-
- MBeanServer server = ManagementFactory.getPlatformMBeanServer();
- ObjectName objectName = new ObjectName(OBJECT_NAME);
- assertEquals(0, server.getAttribute(objectName, "value"));
- server.setAttribute(objectName, new Attribute("value", 3));
- assertEquals(3, server.getAttribute(objectName, "value"));
- assertEquals("winner", server.invoke(objectName, "tryValue", new Object[]{3}, null));
- assertEquals("not the correct value, please have another try", server.invoke(objectName, "tryValue", new Object[]{2}, null));
-
- container.close();
- }
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.mbean;
+
+import org.apache.openejb.monitoring.LocalMBeanServer;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+
+public class GuessHowManyMBeanTest {
+
+ private static final String OBJECT_NAME = "openejb.user.mbeans:group=org.superbiz.mbean,application=mbean-auto-registration,name=GuessHowManyMBean";
+
+ @Test
+ public void play() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(LocalMBeanServer.OPENEJB_JMX_ACTIVE, Boolean.TRUE.toString());
+ EJBContainer container = EJBContainer.createEJBContainer(properties);
+
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ ObjectName objectName = new ObjectName(OBJECT_NAME);
+ assertEquals(0, server.getAttribute(objectName, "value"));
+ server.setAttribute(objectName, new Attribute("value", 3));
+ assertEquals(3, server.getAttribute(objectName, "value"));
+ assertEquals("winner", server.invoke(objectName, "tryValue", new Object[]{3}, null));
+ assertEquals("not the correct value, please have another try", server.invoke(objectName, "tryValue", new Object[]{2}, null));
+
+ container.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun-rest/pom.xml
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/pom.xml b/examples/moviefun-rest/pom.xml
index 055700f..d19e433 100644
--- a/examples/moviefun-rest/pom.xml
+++ b/examples/moviefun-rest/pom.xml
@@ -18,7 +18,7 @@
<groupId>org.superbiz</groupId>
<artifactId>moviefun-rest</artifactId>
<packaging>war</packaging>
- <version>1.1-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<name>OpenEJB :: Web Examples :: Moviefun Rest</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/Movie.java
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/Movie.java b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/Movie.java
index 4a8032b..bbeec38 100644
--- a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/Movie.java
+++ b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/Movie.java
@@ -1,102 +1,102 @@
-/**
- * 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.moviefun;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@Entity
-@XmlRootElement(name = "movie")
-public class Movie {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private long id;
-
- private String director;
- private String title;
- private int year;
- private String genre;
- private int rating;
-
- public Movie() {
- }
-
- public Movie(String title, String director, String genre, int rating, int year) {
- this.director = director;
- this.title = title;
- this.year = year;
- this.genre = genre;
- this.rating = rating;
- }
-
- public Movie(String director, String title, int year) {
- this.director = director;
- this.title = title;
- this.year = year;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getDirector() {
- return director;
- }
-
- public void setDirector(String director) {
- this.director = director;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public int getYear() {
- return year;
- }
-
- public void setYear(int year) {
- this.year = year;
- }
-
- public String getGenre() {
- return genre;
- }
-
- public void setGenre(String genre) {
- this.genre = genre;
- }
-
- public int getRating() {
- return rating;
- }
-
- public void setRating(int rating) {
- this.rating = rating;
- }
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@XmlRootElement(name = "movie")
+public class Movie {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+ private String genre;
+ private int rating;
+
+ public Movie() {
+ }
+
+ public Movie(String title, String director, String genre, int rating, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ this.genre = genre;
+ this.rating = rating;
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getGenre() {
+ return genre;
+ }
+
+ public void setGenre(String genre) {
+ this.genre = genre;
+ }
+
+ public int getRating() {
+ return rating;
+ }
+
+ public void setRating(int rating) {
+ this.rating = rating;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/MoviesBean.java
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/MoviesBean.java b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/MoviesBean.java
index 6f90e82..ff94d67 100644
--- a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/MoviesBean.java
+++ b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/MoviesBean.java
@@ -1,91 +1,91 @@
-/**
- * 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.moviefun;
-
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-import javax.persistence.metamodel.EntityType;
-import java.util.List;
-
-@Stateless
-public class MoviesBean {
-
- @PersistenceContext(unitName = "movie-unit")
- private EntityManager entityManager;
-
- public Movie find(Long id) {
- return entityManager.find(Movie.class, id);
- }
-
- public void addMovie(Movie movie) {
- entityManager.persist(movie);
- }
-
- public void editMovie(Movie movie) {
- entityManager.merge(movie);
- }
-
- public void deleteMovie(long id) {
- Movie movie = entityManager.find(Movie.class, id);
- entityManager.remove(movie);
- }
-
- public List<Movie> getMovies(Integer firstResult, Integer maxResults, String field, String searchTerm) {
- CriteriaBuilder qb = entityManager.getCriteriaBuilder();
- CriteriaQuery<Movie> cq = qb.createQuery(Movie.class);
- Root<Movie> root = cq.from(Movie.class);
- EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
- if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
- Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
- Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
- cq.where(condition);
- }
- TypedQuery<Movie> q = entityManager.createQuery(cq);
- if (maxResults != null) {
- q.setMaxResults(maxResults);
- }
- if (firstResult != null) {
- q.setFirstResult(firstResult);
- }
- return q.getResultList();
- }
-
- public int count(String field, String searchTerm) {
- CriteriaBuilder qb = entityManager.getCriteriaBuilder();
- CriteriaQuery<Long> cq = qb.createQuery(Long.class);
- Root<Movie> root = cq.from(Movie.class);
- EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
- cq.select(qb.count(root));
- if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
- Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
- Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
- cq.where(condition);
- }
- return entityManager.createQuery(cq).getSingleResult().intValue();
- }
-
- public void clean() {
- entityManager.createQuery("delete from Movie").executeUpdate();
- }
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import javax.persistence.metamodel.EntityType;
+import java.util.List;
+
+@Stateless
+public class MoviesBean {
+
+ @PersistenceContext(unitName = "movie-unit")
+ private EntityManager entityManager;
+
+ public Movie find(Long id) {
+ return entityManager.find(Movie.class, id);
+ }
+
+ public void addMovie(Movie movie) {
+ entityManager.persist(movie);
+ }
+
+ public void editMovie(Movie movie) {
+ entityManager.merge(movie);
+ }
+
+ public void deleteMovie(long id) {
+ Movie movie = entityManager.find(Movie.class, id);
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies(Integer firstResult, Integer maxResults, String field, String searchTerm) {
+ CriteriaBuilder qb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Movie> cq = qb.createQuery(Movie.class);
+ Root<Movie> root = cq.from(Movie.class);
+ EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
+ if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
+ Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
+ Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
+ cq.where(condition);
+ }
+ TypedQuery<Movie> q = entityManager.createQuery(cq);
+ if (maxResults != null) {
+ q.setMaxResults(maxResults);
+ }
+ if (firstResult != null) {
+ q.setFirstResult(firstResult);
+ }
+ return q.getResultList();
+ }
+
+ public int count(String field, String searchTerm) {
+ CriteriaBuilder qb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Long> cq = qb.createQuery(Long.class);
+ Root<Movie> root = cq.from(Movie.class);
+ EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
+ cq.select(qb.count(root));
+ if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
+ Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
+ Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
+ cq.where(condition);
+ }
+ return entityManager.createQuery(cq).getSingleResult().intValue();
+ }
+
+ public void clean() {
+ entityManager.createQuery("delete from Movie").executeUpdate();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
index 303dd6e..7466bb4 100644
--- a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
+++ b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
@@ -1,33 +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.superbiz.moviefun.rest;
-
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.core.Application;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-@ApplicationPath("/rest")
-public class ApplicationConfig extends Application {
-
- @Override
- @SuppressWarnings("unchecked")
- public Set<Class<?>> getClasses() {
- return new HashSet<Class<?>>(Arrays.asList(LoadRest.class, MoviesRest.class));
- }
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun.rest;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+@ApplicationPath("/rest")
+public class ApplicationConfig extends Application {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Set<Class<?>> getClasses() {
+ return new HashSet<Class<?>>(Arrays.asList(LoadRest.class, MoviesRest.class));
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/LoadRest.java b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
index 021027b..a2b23d8 100644
--- a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
+++ b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
@@ -1,42 +1,42 @@
-/**
- * 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.moviefun.rest;
-
-import org.superbiz.moviefun.Movie;
-import org.superbiz.moviefun.MoviesBean;
-
-import javax.ejb.EJB;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-
-@Path("load")
-public class LoadRest {
- @EJB
- private MoviesBean moviesBean;
-
- @POST
- public void load() {
- moviesBean.addMovie(new Movie("Wedding Crashers", "David Dobkin", "Comedy", 7, 2005));
- moviesBean.addMovie(new Movie("Starsky & Hutch", "Todd Phillips", "Action", 6, 2004));
- moviesBean.addMovie(new Movie("Shanghai Knights", "David Dobkin", "Action", 6, 2003));
- moviesBean.addMovie(new Movie("I-Spy", "Betty Thomas", "Adventure", 5, 2002));
- moviesBean.addMovie(new Movie("The Royal Tenenbaums", "Wes Anderson", "Comedy", 8, 2001));
- moviesBean.addMovie(new Movie("Zoolander", "Ben Stiller", "Comedy", 6, 2001));
- moviesBean.addMovie(new Movie("Shanghai Noon", "Tom Dey", "Comedy", 7, 2000));
- }
-
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun.rest;
+
+import org.superbiz.moviefun.Movie;
+import org.superbiz.moviefun.MoviesBean;
+
+import javax.ejb.EJB;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+@Path("load")
+public class LoadRest {
+ @EJB
+ private MoviesBean moviesBean;
+
+ @POST
+ public void load() {
+ moviesBean.addMovie(new Movie("Wedding Crashers", "David Dobkin", "Comedy", 7, 2005));
+ moviesBean.addMovie(new Movie("Starsky & Hutch", "Todd Phillips", "Action", 6, 2004));
+ moviesBean.addMovie(new Movie("Shanghai Knights", "David Dobkin", "Action", 6, 2003));
+ moviesBean.addMovie(new Movie("I-Spy", "Betty Thomas", "Adventure", 5, 2002));
+ moviesBean.addMovie(new Movie("The Royal Tenenbaums", "Wes Anderson", "Comedy", 8, 2001));
+ moviesBean.addMovie(new Movie("Zoolander", "Ben Stiller", "Comedy", 6, 2001));
+ moviesBean.addMovie(new Movie("Shanghai Noon", "Tom Dey", "Comedy", 7, 2000));
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
index 74a8450..946513c 100644
--- a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
+++ b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
@@ -1,80 +1,80 @@
-/**
- * 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.moviefun.rest;
-
-import org.superbiz.moviefun.Movie;
-import org.superbiz.moviefun.MoviesBean;
-
-import javax.ejb.EJB;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import java.util.List;
-
-@Path("movies")
-@Produces({"application/json"})
-public class MoviesRest {
-
- @EJB
- private MoviesBean service;
-
- @GET
- @Path("{id}")
- public Movie find(@PathParam("id") Long id) {
- return service.find(id);
- }
-
- @GET
- public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("max") Integer max,
- @QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
- return service.getMovies(first, max, field, searchTerm);
- }
-
- @POST
- @Consumes("application/json")
- public Movie addMovie(Movie movie) {
- service.addMovie(movie);
- return movie;
- }
-
- @PUT
- @Path("{id}")
- @Consumes("application/json")
- public Movie editMovie(Movie movie) {
- service.editMovie(movie);
- return movie;
- }
-
- @DELETE
- @Path("{id}")
- public void deleteMovie(@PathParam("id") long id) {
- service.deleteMovie(id);
- }
-
- @GET
- @Path("count")
- public int count(@QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
- return service.count(field, searchTerm);
- }
-
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun.rest;
+
+import org.superbiz.moviefun.Movie;
+import org.superbiz.moviefun.MoviesBean;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("movies")
+@Produces({"application/json"})
+public class MoviesRest {
+
+ @EJB
+ private MoviesBean service;
+
+ @GET
+ @Path("{id}")
+ public Movie find(@PathParam("id") Long id) {
+ return service.find(id);
+ }
+
+ @GET
+ public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("max") Integer max,
+ @QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
+ return service.getMovies(first, max, field, searchTerm);
+ }
+
+ @POST
+ @Consumes("application/json")
+ public Movie addMovie(Movie movie) {
+ service.addMovie(movie);
+ return movie;
+ }
+
+ @PUT
+ @Path("{id}")
+ @Consumes("application/json")
+ public Movie editMovie(Movie movie) {
+ service.editMovie(movie);
+ return movie;
+ }
+
+ @DELETE
+ @Path("{id}")
+ public void deleteMovie(@PathParam("id") long id) {
+ service.deleteMovie(id);
+ }
+
+ @GET
+ @Path("count")
+ public int count(@QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
+ return service.count(field, searchTerm);
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java b/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java
index 89fe1e1..93f6b75 100644
--- a/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java
+++ b/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java
@@ -1,77 +1,77 @@
-/**
- * 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.moviefun;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.ejb.EJB;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-@RunWith(Arquillian.class)
-public class MoviesEJBTest {
-
- @Deployment
- public static WebArchive createDeployment() {
- return ShrinkWrap.create(WebArchive.class, "test.war")
- .addClasses(Movie.class, MoviesBean.class, MoviesEJBTest.class)
- .addAsResource(new ClassLoaderAsset("META-INF/ejb-jar.xml"), "META-INF/ejb-jar.xml")
- .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");
- }
-
- @EJB
- private MoviesBean movies;
-
- @Before
- @After
- public void clean() {
- movies.clean();
- }
-
- @Test
- public void shouldBeAbleToAddAMovie() throws Exception {
- assertNotNull("Verify that the ejb was injected", movies);
-
- final Movie movie = new Movie();
- movie.setDirector("Michael Bay");
- movie.setGenre("Action");
- movie.setRating(9);
- movie.setTitle("Bad Boys");
- movie.setYear(1995);
- movies.addMovie(movie);
-
- assertEquals(1, movies.count("title", "a"));
- final List<Movie> moviesFound = movies.getMovies(0, 100, "title", "Bad Boys");
- assertEquals(1, moviesFound.size());
- assertEquals("Michael Bay", moviesFound.get(0).getDirector());
- assertEquals("Action", moviesFound.get(0).getGenre());
- assertEquals(9, moviesFound.get(0).getRating());
- assertEquals("Bad Boys", moviesFound.get(0).getTitle());
- assertEquals(1995, moviesFound.get(0).getYear());
- }
-
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.EJB;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class MoviesEJBTest {
+
+ @Deployment
+ public static WebArchive createDeployment() {
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(Movie.class, MoviesBean.class, MoviesEJBTest.class)
+ .addAsResource(new ClassLoaderAsset("META-INF/ejb-jar.xml"), "META-INF/ejb-jar.xml")
+ .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");
+ }
+
+ @EJB
+ private MoviesBean movies;
+
+ @Before
+ @After
+ public void clean() {
+ movies.clean();
+ }
+
+ @Test
+ public void shouldBeAbleToAddAMovie() throws Exception {
+ assertNotNull("Verify that the ejb was injected", movies);
+
+ final Movie movie = new Movie();
+ movie.setDirector("Michael Bay");
+ movie.setGenre("Action");
+ movie.setRating(9);
+ movie.setTitle("Bad Boys");
+ movie.setYear(1995);
+ movies.addMovie(movie);
+
+ assertEquals(1, movies.count("title", "a"));
+ final List<Movie> moviesFound = movies.getMovies(0, 100, "title", "Bad Boys");
+ assertEquals(1, moviesFound.size());
+ assertEquals("Michael Bay", moviesFound.get(0).getDirector());
+ assertEquals("Action", moviesFound.get(0).getGenre());
+ assertEquals(9, moviesFound.get(0).getRating());
+ assertEquals("Bad Boys", moviesFound.get(0).getTitle());
+ assertEquals(1995, moviesFound.get(0).getYear());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java b/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java
index b4c8c4e..7abccb6 100644
--- a/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java
+++ b/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java
@@ -1,75 +1,75 @@
-/**
- * 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.moviefun;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import javax.ejb.embeddable.EJBContainer;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-public class MoviesEmbeddedEJBTest {
-
- private static EJBContainer ejbContainer;
-
- @BeforeClass
- public static void setUp() throws Exception {
- ejbContainer = EJBContainer.createEJBContainer();
- }
-
- @AfterClass
- public static void tearDown() {
- if (ejbContainer != null) {
- ejbContainer.close();
- }
- }
-
- @Before
- @After
- public void clean() throws Exception {
- MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
- movies.clean();
- }
-
- @Test
- public void testShouldAddAMovie() throws Exception {
- final MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
-
- final Movie movie = new Movie();
- movie.setDirector("Michael Bay");
- movie.setGenre("Action");
- movie.setRating(9);
- movie.setTitle("Bad Boys");
- movie.setYear(1995);
- movies.addMovie(movie);
-
- assertEquals(1, movies.count("title", "Bad Boys"));
- final List<Movie> moviesFound = movies.getMovies(0, 100, "title", "Bad Boys");
- assertEquals(1, moviesFound.size());
- assertEquals("Michael Bay", moviesFound.get(0).getDirector());
- assertEquals("Action", moviesFound.get(0).getGenre());
- assertEquals(9, moviesFound.get(0).getRating());
- assertEquals("Bad Boys", moviesFound.get(0).getTitle());
- assertEquals(1995, moviesFound.get(0).getYear());
- }
-
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class MoviesEmbeddedEJBTest {
+
+ private static EJBContainer ejbContainer;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ if (ejbContainer != null) {
+ ejbContainer.close();
+ }
+ }
+
+ @Before
+ @After
+ public void clean() throws Exception {
+ MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
+ movies.clean();
+ }
+
+ @Test
+ public void testShouldAddAMovie() throws Exception {
+ final MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
+
+ final Movie movie = new Movie();
+ movie.setDirector("Michael Bay");
+ movie.setGenre("Action");
+ movie.setRating(9);
+ movie.setTitle("Bad Boys");
+ movie.setYear(1995);
+ movies.addMovie(movie);
+
+ assertEquals(1, movies.count("title", "Bad Boys"));
+ final List<Movie> moviesFound = movies.getMovies(0, 100, "title", "Bad Boys");
+ assertEquals(1, moviesFound.size());
+ assertEquals("Michael Bay", moviesFound.get(0).getDirector());
+ assertEquals("Action", moviesFound.get(0).getGenre());
+ assertEquals(9, moviesFound.get(0).getRating());
+ assertEquals("Bad Boys", moviesFound.get(0).getTitle());
+ assertEquals(1995, moviesFound.get(0).getYear());
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesTest.java
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesTest.java b/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesTest.java
index fdff9ab..0545c97 100644
--- a/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesTest.java
+++ b/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesTest.java
@@ -1,75 +1,75 @@
-/**
- * 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.moviefun;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import javax.ejb.embeddable.EJBContainer;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-public class MoviesTest {
-
- private static EJBContainer ejbContainer;
-
- @BeforeClass
- public static void setUp() throws Exception {
- ejbContainer = EJBContainer.createEJBContainer();
- }
-
- @AfterClass
- public static void tearDown() {
- if (ejbContainer != null) {
- ejbContainer.close();
- }
- }
-
- @Before
- @After
- public void clean() throws Exception {
- final MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
- movies.clean();
- }
-
- @Test
- public void testShouldAddAMovie() throws Exception {
- final MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
-
- final Movie movie = new Movie();
- movie.setDirector("Michael Bay");
- movie.setGenre("Action");
- movie.setRating(9);
- movie.setTitle("Bad Boys");
- movie.setYear(1995);
- movies.addMovie(movie);
-
- assertEquals(1, movies.count("title", "a"));
- final List<Movie> moviesFound = movies.getMovies(0, 100, "title", "Bad Boys");
- assertEquals(1, moviesFound.size());
- assertEquals("Michael Bay", moviesFound.get(0).getDirector());
- assertEquals("Action", moviesFound.get(0).getGenre());
- assertEquals(9, moviesFound.get(0).getRating());
- assertEquals("Bad Boys", moviesFound.get(0).getTitle());
- assertEquals(1995, moviesFound.get(0).getYear());
- }
-
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class MoviesTest {
+
+ private static EJBContainer ejbContainer;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ if (ejbContainer != null) {
+ ejbContainer.close();
+ }
+ }
+
+ @Before
+ @After
+ public void clean() throws Exception {
+ final MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
+ movies.clean();
+ }
+
+ @Test
+ public void testShouldAddAMovie() throws Exception {
+ final MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
+
+ final Movie movie = new Movie();
+ movie.setDirector("Michael Bay");
+ movie.setGenre("Action");
+ movie.setRating(9);
+ movie.setTitle("Bad Boys");
+ movie.setYear(1995);
+ movies.addMovie(movie);
+
+ assertEquals(1, movies.count("title", "a"));
+ final List<Movie> moviesFound = movies.getMovies(0, 100, "title", "Bad Boys");
+ assertEquals(1, moviesFound.size());
+ assertEquals("Michael Bay", moviesFound.get(0).getDirector());
+ assertEquals("Action", moviesFound.get(0).getGenre());
+ assertEquals(9, moviesFound.get(0).getRating());
+ assertEquals("Bad Boys", moviesFound.get(0).getTitle());
+ assertEquals(1995, moviesFound.get(0).getYear());
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun/pom.xml
----------------------------------------------------------------------
diff --git a/examples/moviefun/pom.xml b/examples/moviefun/pom.xml
index 40766c8..fe32268 100644
--- a/examples/moviefun/pom.xml
+++ b/examples/moviefun/pom.xml
@@ -18,7 +18,7 @@
<groupId>org.superbiz</groupId>
<artifactId>moviefun</artifactId>
<packaging>war</packaging>
- <version>1.1-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<name>OpenEJB :: Web Examples :: Moviefun</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun/src/main/java/org/superbiz/moviefun/ActionServlet.java
----------------------------------------------------------------------
diff --git a/examples/moviefun/src/main/java/org/superbiz/moviefun/ActionServlet.java b/examples/moviefun/src/main/java/org/superbiz/moviefun/ActionServlet.java
index 81e8821..92aecec 100644
--- a/examples/moviefun/src/main/java/org/superbiz/moviefun/ActionServlet.java
+++ b/examples/moviefun/src/main/java/org/superbiz/moviefun/ActionServlet.java
@@ -1,138 +1,138 @@
-/**
- * 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.moviefun;
-
-import org.apache.commons.lang.StringUtils;
-
-import javax.ejb.EJB;
-import javax.servlet.ServletException;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @version $Revision$ $Date$
- */
-@WebServlet("/moviefun/*")
-public class ActionServlet extends HttpServlet {
-
- private static final long serialVersionUID = -5832176047021911038L;
-
- public static int PAGE_SIZE = 5;
-
- @EJB
- private MoviesBean moviesBean;
-
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- process(request, response);
- }
-
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- process(request, response);
- }
-
- private void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String action = request.getParameter("action");
-
- if ("Add".equals(action)) {
-
- String title = request.getParameter("title");
- String director = request.getParameter("director");
- String genre = request.getParameter("genre");
- int rating = Integer.parseInt(request.getParameter("rating"));
- int year = Integer.parseInt(request.getParameter("year"));
-
- Movie movie = new Movie(title, director, genre, rating, year);
-
- moviesBean.addMovie(movie);
- response.sendRedirect("moviefun");
- return;
-
- } else if ("Remove".equals(action)) {
-
- String[] ids = request.getParameterValues("id");
- for (String id : ids) {
- moviesBean.deleteMovieId(new Long(id));
- }
-
- response.sendRedirect("moviefun");
- return;
-
- } else {
- String key = request.getParameter("key");
- String field = request.getParameter("field");
-
- int count = 0;
-
- if (StringUtils.isEmpty(key) || StringUtils.isEmpty(field)) {
- count = moviesBean.countAll();
- key = "";
- field = "";
- } else {
- count = moviesBean.count(field, key);
- }
-
- int page = 1;
-
- try {
- page = Integer.parseInt(request.getParameter("page"));
- } catch (Exception e) {
- }
-
- int pageCount = (count / PAGE_SIZE);
- if (pageCount == 0 || count % PAGE_SIZE != 0) {
- pageCount++;
- }
-
- if (page < 1) {
- page = 1;
- }
-
- if (page > pageCount) {
- page = pageCount;
- }
-
- int start = (page - 1) * PAGE_SIZE;
- List<Movie> range;
-
- if (StringUtils.isEmpty(key) || StringUtils.isEmpty(field)) {
- range = moviesBean.findAll(start, PAGE_SIZE);
- } else {
- range = moviesBean.findRange(field, key, start, PAGE_SIZE);
- }
-
- int end = start + range.size();
-
- request.setAttribute("count", count);
- request.setAttribute("start", start + 1);
- request.setAttribute("end", end);
- request.setAttribute("page", page);
- request.setAttribute("pageCount", pageCount);
- request.setAttribute("movies", range);
- request.setAttribute("key", key);
- request.setAttribute("field", field);
- }
-
- request.getRequestDispatcher("WEB-INF/moviefun.jsp").forward(request, response);
- }
-
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun;
+
+import org.apache.commons.lang.StringUtils;
+
+import javax.ejb.EJB;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@WebServlet("/moviefun/*")
+public class ActionServlet extends HttpServlet {
+
+ private static final long serialVersionUID = -5832176047021911038L;
+
+ public static int PAGE_SIZE = 5;
+
+ @EJB
+ private MoviesBean moviesBean;
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ process(request, response);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ process(request, response);
+ }
+
+ private void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ String action = request.getParameter("action");
+
+ if ("Add".equals(action)) {
+
+ String title = request.getParameter("title");
+ String director = request.getParameter("director");
+ String genre = request.getParameter("genre");
+ int rating = Integer.parseInt(request.getParameter("rating"));
+ int year = Integer.parseInt(request.getParameter("year"));
+
+ Movie movie = new Movie(title, director, genre, rating, year);
+
+ moviesBean.addMovie(movie);
+ response.sendRedirect("moviefun");
+ return;
+
+ } else if ("Remove".equals(action)) {
+
+ String[] ids = request.getParameterValues("id");
+ for (String id : ids) {
+ moviesBean.deleteMovieId(new Long(id));
+ }
+
+ response.sendRedirect("moviefun");
+ return;
+
+ } else {
+ String key = request.getParameter("key");
+ String field = request.getParameter("field");
+
+ int count = 0;
+
+ if (StringUtils.isEmpty(key) || StringUtils.isEmpty(field)) {
+ count = moviesBean.countAll();
+ key = "";
+ field = "";
+ } else {
+ count = moviesBean.count(field, key);
+ }
+
+ int page = 1;
+
+ try {
+ page = Integer.parseInt(request.getParameter("page"));
+ } catch (Exception e) {
+ }
+
+ int pageCount = (count / PAGE_SIZE);
+ if (pageCount == 0 || count % PAGE_SIZE != 0) {
+ pageCount++;
+ }
+
+ if (page < 1) {
+ page = 1;
+ }
+
+ if (page > pageCount) {
+ page = pageCount;
+ }
+
+ int start = (page - 1) * PAGE_SIZE;
+ List<Movie> range;
+
+ if (StringUtils.isEmpty(key) || StringUtils.isEmpty(field)) {
+ range = moviesBean.findAll(start, PAGE_SIZE);
+ } else {
+ range = moviesBean.findRange(field, key, start, PAGE_SIZE);
+ }
+
+ int end = start + range.size();
+
+ request.setAttribute("count", count);
+ request.setAttribute("start", start + 1);
+ request.setAttribute("end", end);
+ request.setAttribute("page", page);
+ request.setAttribute("pageCount", pageCount);
+ request.setAttribute("movies", range);
+ request.setAttribute("key", key);
+ request.setAttribute("field", field);
+ }
+
+ request.getRequestDispatcher("WEB-INF/moviefun.jsp").forward(request, response);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun/src/main/java/org/superbiz/moviefun/Movie.java
----------------------------------------------------------------------
diff --git a/examples/moviefun/src/main/java/org/superbiz/moviefun/Movie.java b/examples/moviefun/src/main/java/org/superbiz/moviefun/Movie.java
index e6ab8de..831fbb9 100644
--- a/examples/moviefun/src/main/java/org/superbiz/moviefun/Movie.java
+++ b/examples/moviefun/src/main/java/org/superbiz/moviefun/Movie.java
@@ -1,104 +1,104 @@
-/**
- * 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.moviefun;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-@Entity
-public class Movie implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private long id;
-
- private String director;
- private String title;
- private int year;
- private String genre;
- private int rating;
-
- public Movie() {
- }
-
- public Movie(String title, String director, String genre, int rating, int year) {
- this.director = director;
- this.title = title;
- this.year = year;
- this.genre = genre;
- this.rating = rating;
- }
-
- public Movie(String director, String title, int year) {
- this.director = director;
- this.title = title;
- this.year = year;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getDirector() {
- return director;
- }
-
- public void setDirector(String director) {
- this.director = director;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public int getYear() {
- return year;
- }
-
- public void setYear(int year) {
- this.year = year;
- }
-
- public String getGenre() {
- return genre;
- }
-
- public void setGenre(String genre) {
- this.genre = genre;
- }
-
- public int getRating() {
- return rating;
- }
-
- public void setRating(int rating) {
- this.rating = rating;
- }
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+@Entity
+public class Movie implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+ private String genre;
+ private int rating;
+
+ public Movie() {
+ }
+
+ public Movie(String title, String director, String genre, int rating, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ this.genre = genre;
+ this.rating = rating;
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getGenre() {
+ return genre;
+ }
+
+ public void setGenre(String genre) {
+ this.genre = genre;
+ }
+
+ public int getRating() {
+ return rating;
+ }
+
+ public void setRating(int rating) {
+ this.rating = rating;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun/src/main/java/org/superbiz/moviefun/MoviesBean.java
----------------------------------------------------------------------
diff --git a/examples/moviefun/src/main/java/org/superbiz/moviefun/MoviesBean.java b/examples/moviefun/src/main/java/org/superbiz/moviefun/MoviesBean.java
index cfee3f8..bb2d708 100644
--- a/examples/moviefun/src/main/java/org/superbiz/moviefun/MoviesBean.java
+++ b/examples/moviefun/src/main/java/org/superbiz/moviefun/MoviesBean.java
@@ -1,115 +1,115 @@
-/**
- * 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.moviefun;
-
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-import javax.persistence.metamodel.EntityType;
-import java.util.List;
-
-@Stateless
-public class MoviesBean {
-
- @PersistenceContext(unitName = "movie-unit")
- private EntityManager entityManager;
-
- public Movie find(Long id) {
- return entityManager.find(Movie.class, id);
- }
-
- public void addMovie(Movie movie) {
- entityManager.persist(movie);
- }
-
- public void editMovie(Movie movie) {
- entityManager.merge(movie);
- }
-
- public void deleteMovie(Movie movie) {
- entityManager.remove(movie);
- }
-
- public void deleteMovieId(long id) {
- Movie movie = entityManager.find(Movie.class, id);
- deleteMovie(movie);
- }
-
- public List<Movie> getMovies() {
- CriteriaQuery<Movie> cq = entityManager.getCriteriaBuilder().createQuery(Movie.class);
- cq.select(cq.from(Movie.class));
- return entityManager.createQuery(cq).getResultList();
- }
-
- public List<Movie> findAll(int firstResult, int maxResults) {
- CriteriaQuery<Movie> cq = entityManager.getCriteriaBuilder().createQuery(Movie.class);
- cq.select(cq.from(Movie.class));
- TypedQuery<Movie> q = entityManager.createQuery(cq);
- q.setMaxResults(maxResults);
- q.setFirstResult(firstResult);
- return q.getResultList();
- }
-
- public int countAll() {
- CriteriaQuery<Long> cq = entityManager.getCriteriaBuilder().createQuery(Long.class);
- Root<Movie> rt = cq.from(Movie.class);
- cq.select(entityManager.getCriteriaBuilder().count(rt));
- TypedQuery<Long> q = entityManager.createQuery(cq);
- return (q.getSingleResult()).intValue();
- }
-
- public int count(String field, String searchTerm) {
- CriteriaBuilder qb = entityManager.getCriteriaBuilder();
- CriteriaQuery<Long> cq = qb.createQuery(Long.class);
- Root<Movie> root = cq.from(Movie.class);
- EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
-
- Path<String> path = root.get(type.getDeclaredSingularAttribute(field, String.class));
- Predicate condition = qb.like(path, "%" + searchTerm + "%");
-
- cq.select(qb.count(root));
- cq.where(condition);
-
- return entityManager.createQuery(cq).getSingleResult().intValue();
- }
-
- public List<Movie> findRange(String field, String searchTerm, int firstResult, int maxResults) {
- CriteriaBuilder qb = entityManager.getCriteriaBuilder();
- CriteriaQuery<Movie> cq = qb.createQuery(Movie.class);
- Root<Movie> root = cq.from(Movie.class);
- EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
-
- Path<String> path = root.get(type.getDeclaredSingularAttribute(field, String.class));
- Predicate condition = qb.like(path, "%" + searchTerm + "%");
-
- cq.where(condition);
- TypedQuery<Movie> q = entityManager.createQuery(cq);
- q.setMaxResults(maxResults);
- q.setFirstResult(firstResult);
- return q.getResultList();
- }
-
- public void clean() {
- entityManager.createQuery("delete from Movie").executeUpdate();
- }
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.moviefun;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import javax.persistence.metamodel.EntityType;
+import java.util.List;
+
+@Stateless
+public class MoviesBean {
+
+ @PersistenceContext(unitName = "movie-unit")
+ private EntityManager entityManager;
+
+ public Movie find(Long id) {
+ return entityManager.find(Movie.class, id);
+ }
+
+ public void addMovie(Movie movie) {
+ entityManager.persist(movie);
+ }
+
+ public void editMovie(Movie movie) {
+ entityManager.merge(movie);
+ }
+
+ public void deleteMovie(Movie movie) {
+ entityManager.remove(movie);
+ }
+
+ public void deleteMovieId(long id) {
+ Movie movie = entityManager.find(Movie.class, id);
+ deleteMovie(movie);
+ }
+
+ public List<Movie> getMovies() {
+ CriteriaQuery<Movie> cq = entityManager.getCriteriaBuilder().createQuery(Movie.class);
+ cq.select(cq.from(Movie.class));
+ return entityManager.createQuery(cq).getResultList();
+ }
+
+ public List<Movie> findAll(int firstResult, int maxResults) {
+ CriteriaQuery<Movie> cq = entityManager.getCriteriaBuilder().createQuery(Movie.class);
+ cq.select(cq.from(Movie.class));
+ TypedQuery<Movie> q = entityManager.createQuery(cq);
+ q.setMaxResults(maxResults);
+ q.setFirstResult(firstResult);
+ return q.getResultList();
+ }
+
+ public int countAll() {
+ CriteriaQuery<Long> cq = entityManager.getCriteriaBuilder().createQuery(Long.class);
+ Root<Movie> rt = cq.from(Movie.class);
+ cq.select(entityManager.getCriteriaBuilder().count(rt));
+ TypedQuery<Long> q = entityManager.createQuery(cq);
+ return (q.getSingleResult()).intValue();
+ }
+
+ public int count(String field, String searchTerm) {
+ CriteriaBuilder qb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Long> cq = qb.createQuery(Long.class);
+ Root<Movie> root = cq.from(Movie.class);
+ EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
+
+ Path<String> path = root.get(type.getDeclaredSingularAttribute(field, String.class));
+ Predicate condition = qb.like(path, "%" + searchTerm + "%");
+
+ cq.select(qb.count(root));
+ cq.where(condition);
+
+ return entityManager.createQuery(cq).getSingleResult().intValue();
+ }
+
+ public List<Movie> findRange(String field, String searchTerm, int firstResult, int maxResults) {
+ CriteriaBuilder qb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Movie> cq = qb.createQuery(Movie.class);
+ Root<Movie> root = cq.from(Movie.class);
+ EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
+
+ Path<String> path = root.get(type.getDeclaredSingularAttribute(field, String.class));
+ Predicate condition = qb.like(path, "%" + searchTerm + "%");
+
+ cq.where(condition);
+ TypedQuery<Movie> q = entityManager.createQuery(cq);
+ q.setMaxResults(maxResults);
+ q.setFirstResult(firstResult);
+ return q.getResultList();
+ }
+
+ public void clean() {
+ entityManager.createQuery("delete from Movie").executeUpdate();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/moviefun/src/test/java/org/superbiz/moviefun/Basedir.java
----------------------------------------------------------------------
diff --git a/examples/moviefun/src/test/java/org/superbiz/moviefun/Basedir.java b/examples/moviefun/src/test/java/org/superbiz/moviefun/Basedir.java
index aaabf36..f7368dc 100644
--- a/examples/moviefun/src/test/java/org/superbiz/moviefun/Basedir.java
+++ b/examples/moviefun/src/test/java/org/superbiz/moviefun/Basedir.java
@@ -1,34 +1,34 @@
-/*
- * 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.moviefun;
-
-import org.apache.ziplock.JarLocation;
-
-import java.io.File;
-
-/**
-* @version $Revision$ $Date$
-*/
-public class Basedir {
-
- public static File basedir(final String s) {
- final File classes = JarLocation.jarLocation(MoviesArquillianHtmlUnitTest.class);
- final File target = classes.getParentFile();
- final File basedir = target.getParentFile();
- return new File(basedir, s);
- }
-}
+/*
+ * 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.moviefun;
+
+import org.apache.ziplock.JarLocation;
+
+import java.io.File;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class Basedir {
+
+ public static File basedir(final String s) {
+ final File classes = JarLocation.jarLocation(MoviesArquillianHtmlUnitTest.class);
+ final File target = classes.getParentFile();
+ final File basedir = target.getParentFile();
+ return new File(basedir, s);
+ }
+}