http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movie.java ---------------------------------------------------------------------- diff --git a/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movie.java b/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movie.java index 8d6eed4..d893c25 100644 --- a/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movie.java +++ b/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movie.java @@ -1,68 +1,68 @@ -/** - * 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.injection.h3jpa; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class Movie { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String director; - private String title; - private int year; - - public Movie() { - } - - public Movie(String director, String title, int year) { - this.director = director; - this.title = title; - this.year = year; - } - - 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; - } - -} +/** + * 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.injection.h3jpa; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Movie { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String director; + private String title; + private int year; + + public Movie() { + } + + public Movie(String director, String title, int year) { + this.director = director; + this.title = title; + this.year = year; + } + + 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; + } + +}
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movies.java ---------------------------------------------------------------------- diff --git a/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movies.java b/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movies.java index af15cff..e268eb9 100644 --- a/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movies.java +++ b/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movies.java @@ -1,45 +1,45 @@ -/** - * 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.injection.h3jpa; - -import javax.ejb.Stateful; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.PersistenceContextType; -import javax.persistence.Query; -import java.util.List; - -@Stateful -public class Movies { - - @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED) - private EntityManager entityManager; - - public void addMovie(Movie movie) throws Exception { - entityManager.persist(movie); - } - - public void deleteMovie(Movie movie) throws Exception { - entityManager.remove(movie); - } - - public List<Movie> getMovies() throws Exception { - Query query = entityManager.createQuery("SELECT m from Movie as m"); - return query.getResultList(); - } - -} +/** + * 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.injection.h3jpa; + +import javax.ejb.Stateful; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.PersistenceContextType; +import javax.persistence.Query; +import java.util.List; + +@Stateful +public class Movies { + + @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED) + private EntityManager entityManager; + + public void addMovie(Movie movie) throws Exception { + entityManager.persist(movie); + } + + public void deleteMovie(Movie movie) throws Exception { + entityManager.remove(movie); + } + + public List<Movie> getMovies() throws Exception { + Query query = entityManager.createQuery("SELECT m from Movie as m"); + return query.getResultList(); + } + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/jpa-hibernate/src/test/java/org/superbiz/injection/h3jpa/MoviesTest.java ---------------------------------------------------------------------- diff --git a/examples/jpa-hibernate/src/test/java/org/superbiz/injection/h3jpa/MoviesTest.java b/examples/jpa-hibernate/src/test/java/org/superbiz/injection/h3jpa/MoviesTest.java index 4f73ead..93f8d39 100644 --- a/examples/jpa-hibernate/src/test/java/org/superbiz/injection/h3jpa/MoviesTest.java +++ b/examples/jpa-hibernate/src/test/java/org/superbiz/injection/h3jpa/MoviesTest.java @@ -1,53 +1,53 @@ -/** - * 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.injection.h3jpa; - -import junit.framework.TestCase; - -import javax.ejb.embeddable.EJBContainer; -import javax.naming.Context; -import java.util.List; -import java.util.Properties; - -/** - * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ - */ -public class MoviesTest extends TestCase { - - public void test() throws Exception { - final Properties p = new Properties(); - p.put("movieDatabase", "new://Resource?type=DataSource"); - p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver"); - p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb"); - - final Context context = EJBContainer.createEJBContainer(p).getContext(); - Movies movies = (Movies) context.lookup("java:global/jpa-hibernate/Movies"); - - movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992)); - movies.addMovie(new Movie("Joel Coen", "Fargo", 1996)); - movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998)); - - List<Movie> list = movies.getMovies(); - assertEquals("List.size()", 3, list.size()); - - for (Movie movie : list) { - movies.deleteMovie(movie); - } - - assertEquals("Movies.getMovies()", 0, movies.getMovies().size()); - } -} +/** + * 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.injection.h3jpa; + +import junit.framework.TestCase; + +import javax.ejb.embeddable.EJBContainer; +import javax.naming.Context; +import java.util.List; +import java.util.Properties; + +/** + * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ + */ +public class MoviesTest extends TestCase { + + public void test() throws Exception { + final Properties p = new Properties(); + p.put("movieDatabase", "new://Resource?type=DataSource"); + p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver"); + p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb"); + + final Context context = EJBContainer.createEJBContainer(p).getContext(); + Movies movies = (Movies) context.lookup("java:global/jpa-hibernate/Movies"); + + movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992)); + movies.addMovie(new Movie("Joel Coen", "Fargo", 1996)); + movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998)); + + List<Movie> list = movies.getMovies(); + assertEquals("List.size()", 3, list.size()); + + for (Movie movie : list) { + movies.deleteMovie(movie); + } + + assertEquals("Movies.getMovies()", 0, movies.getMovies().size()); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java ---------------------------------------------------------------------- diff --git a/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java b/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java index 817be8a..a0cfaa5 100644 --- a/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java +++ b/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java @@ -1,28 +1,28 @@ -/** - * 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.jsf; - -import javax.ejb.Stateless; - -@Stateless -public class Calculator { - - public double add(double x, double y) { - return x + y; - } - -} +/** + * 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.jsf; + +import javax.ejb.Stateless; + +@Stateless +public class Calculator { + + public double add(double x, double y) { + return x + y; + } + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java ---------------------------------------------------------------------- diff --git a/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java b/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java index 4dc2a16..84654ac 100644 --- a/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java +++ b/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java @@ -1,25 +1,25 @@ -/** - * 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.jsf; - -import javax.ejb.Remote; - -@Remote -public interface Calculator { - - public double add(double x, double y); -} +/** + * 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.jsf; + +import javax.ejb.Remote; + +@Remote +public interface Calculator { + + public double add(double x, double y); +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java ---------------------------------------------------------------------- diff --git a/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java b/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java index 43bedd0..a89b3af 100644 --- a/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java +++ b/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java @@ -1,28 +1,28 @@ -/** - * 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.jsf; - -import javax.ejb.Stateless; - -@Stateless -public class CalculatorImpl implements Calculator { - - public double add(double x, double y) { - return x + y; - } - -} +/** + * 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.jsf; + +import javax.ejb.Stateless; + +@Stateless +public class CalculatorImpl implements Calculator { + + public double add(double x, double y) { + return x + y; + } + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/BlueBean.java ---------------------------------------------------------------------- diff --git a/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/BlueBean.java b/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/BlueBean.java index 468cba0..c7d4ebf 100644 --- a/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/BlueBean.java +++ b/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/BlueBean.java @@ -1,39 +1,39 @@ -/** - * 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.ejblookup; - -import javax.ejb.EJBException; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -//START SNIPPET: code -public class BlueBean implements Friend { - - public String sayHello() { - return "Blue says, Hello!"; - } - - public String helloFromFriend() { - try { - Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); - return "My friend " + friend.sayHello(); - } catch (NamingException e) { - throw new EJBException(e); - } - } -} -//END SNIPPET: code +/** + * 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.ejblookup; + +import javax.ejb.EJBException; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +//START SNIPPET: code +public class BlueBean implements Friend { + + public String sayHello() { + return "Blue says, Hello!"; + } + + public String helloFromFriend() { + try { + Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); + return "My friend " + friend.sayHello(); + } catch (NamingException e) { + throw new EJBException(e); + } + } +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/Friend.java ---------------------------------------------------------------------- diff --git a/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/Friend.java b/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/Friend.java index 7778acc..b499fb0 100644 --- a/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/Friend.java +++ b/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/Friend.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 - * <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.ejblookup; - -/** - * This is an EJB 3 local business interface - * A local business interface may be annotated with the @Local - * annotation, but it's optional. A business interface which is - * not annotated with @Local or @Remote is assumed to be Local - * if the bean does not implement any other interfaces - */ -//START SNIPPET: code -public interface Friend { - - public String sayHello(); - - public String helloFromFriend(); - -} -//END SNIPPET: code +/** + * 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.ejblookup; + +/** + * This is an EJB 3 local business interface + * A local business interface may be annotated with the @Local + * annotation, but it's optional. A business interface which is + * not annotated with @Local or @Remote is assumed to be Local + * if the bean does not implement any other interfaces + */ +//START SNIPPET: code +public interface Friend { + + public String sayHello(); + + public String helloFromFriend(); + +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/RedBean.java ---------------------------------------------------------------------- diff --git a/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/RedBean.java b/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/RedBean.java index 4c95b70..c0cadec 100644 --- a/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/RedBean.java +++ b/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/RedBean.java @@ -1,39 +1,39 @@ -/** - * 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.ejblookup; - -import javax.ejb.EJBException; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -//START SNIPPET: code -public class RedBean implements Friend { - - public String sayHello() { - return "Red says, Hello!"; - } - - public String helloFromFriend() { - try { - Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); - return "My friend " + friend.sayHello(); - } catch (NamingException e) { - throw new EJBException(e); - } - } -} +/** + * 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.ejblookup; + +import javax.ejb.EJBException; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +//START SNIPPET: code +public class RedBean implements Friend { + + public String sayHello() { + return "Red says, Hello!"; + } + + public String helloFromFriend() { + try { + Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); + return "My friend " + friend.sayHello(); + } catch (NamingException e) { + throw new EJBException(e); + } + } +} //END SNIPPET: code \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/lookup-of-ejbs-with-descriptor/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java ---------------------------------------------------------------------- diff --git a/examples/lookup-of-ejbs-with-descriptor/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java b/examples/lookup-of-ejbs-with-descriptor/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java index 78f5686..1aa061c 100644 --- a/examples/lookup-of-ejbs-with-descriptor/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java +++ b/examples/lookup-of-ejbs-with-descriptor/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java @@ -1,54 +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 - * <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.ejblookup; - -import junit.framework.TestCase; - -import javax.ejb.embeddable.EJBContainer; -import javax.naming.Context; - -//START SNIPPET: code -public class EjbDependencyTest extends TestCase { - - private Context context; - - protected void setUp() throws Exception { - context = EJBContainer.createEJBContainer().getContext(); - } - - public void testRed() throws Exception { - - Friend red = (Friend) context.lookup("java:global/wombat/RedBean"); - - assertNotNull(red); - assertEquals("Red says, Hello!", red.sayHello()); - assertEquals("My friend Blue says, Hello!", red.helloFromFriend()); - - } - - public void testBlue() throws Exception { - - Friend blue = (Friend) context.lookup("java:global/wombat/BlueBean"); - - assertNotNull(blue); - assertEquals("Blue says, Hello!", blue.sayHello()); - assertEquals("My friend Red says, Hello!", blue.helloFromFriend()); - - } - -} -//END SNIPPET: code +/** + * 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.ejblookup; + +import junit.framework.TestCase; + +import javax.ejb.embeddable.EJBContainer; +import javax.naming.Context; + +//START SNIPPET: code +public class EjbDependencyTest extends TestCase { + + private Context context; + + protected void setUp() throws Exception { + context = EJBContainer.createEJBContainer().getContext(); + } + + public void testRed() throws Exception { + + Friend red = (Friend) context.lookup("java:global/wombat/RedBean"); + + assertNotNull(red); + assertEquals("Red says, Hello!", red.sayHello()); + assertEquals("My friend Blue says, Hello!", red.helloFromFriend()); + + } + + public void testBlue() throws Exception { + + Friend blue = (Friend) context.lookup("java:global/wombat/BlueBean"); + + assertNotNull(blue); + assertEquals("Blue says, Hello!", blue.sayHello()); + assertEquals("My friend Red says, Hello!", blue.helloFromFriend()); + + } + +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/BlueBean.java ---------------------------------------------------------------------- diff --git a/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/BlueBean.java b/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/BlueBean.java index e84823c..65b42e3 100644 --- a/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/BlueBean.java +++ b/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/BlueBean.java @@ -1,43 +1,43 @@ -/** - * 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.ejblookup; - -import javax.ejb.EJB; -import javax.ejb.EJBException; -import javax.ejb.Stateless; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -//START SNIPPET: code -@Stateless -@EJB(beanInterface = Friend.class, beanName = "RedBean", name = "myFriend") -public class BlueBean implements Friend { - - public String sayHello() { - return "Blue says, Hello!"; - } - - public String helloFromFriend() { - try { - Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); - return "My friend " + friend.sayHello(); - } catch (NamingException e) { - throw new EJBException(e); - } - } -} -//END SNIPPET: code +/** + * 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.ejblookup; + +import javax.ejb.EJB; +import javax.ejb.EJBException; +import javax.ejb.Stateless; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +//START SNIPPET: code +@Stateless +@EJB(beanInterface = Friend.class, beanName = "RedBean", name = "myFriend") +public class BlueBean implements Friend { + + public String sayHello() { + return "Blue says, Hello!"; + } + + public String helloFromFriend() { + try { + Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); + return "My friend " + friend.sayHello(); + } catch (NamingException e) { + throw new EJBException(e); + } + } +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/Friend.java ---------------------------------------------------------------------- diff --git a/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/Friend.java b/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/Friend.java index 8a3c836..04803a2 100644 --- a/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/Friend.java +++ b/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/Friend.java @@ -1,37 +1,37 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <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.ejblookup; - -import javax.ejb.Local; - -/** - * This is an EJB 3 local business interface - * A local business interface may be annotated with the @Local - * annotation, but it's optional. A business interface which is - * not annotated with @Local or @Remote is assumed to be Local - * if the bean does not implement any other interfaces - */ -//START SNIPPET: code -@Local -public interface Friend { - - public String sayHello(); - - public String helloFromFriend(); - -} -//END SNIPPET: code +/** + * 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.ejblookup; + +import javax.ejb.Local; + +/** + * This is an EJB 3 local business interface + * A local business interface may be annotated with the @Local + * annotation, but it's optional. A business interface which is + * not annotated with @Local or @Remote is assumed to be Local + * if the bean does not implement any other interfaces + */ +//START SNIPPET: code +@Local +public interface Friend { + + public String sayHello(); + + public String helloFromFriend(); + +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/RedBean.java ---------------------------------------------------------------------- diff --git a/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/RedBean.java b/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/RedBean.java index 6e76c893..ac853da 100644 --- a/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/RedBean.java +++ b/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/RedBean.java @@ -1,43 +1,43 @@ -/** - * 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.ejblookup; - -import javax.ejb.EJB; -import javax.ejb.EJBException; -import javax.ejb.Stateless; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -//START SNIPPET: code -@Stateless -@EJB(beanInterface = Friend.class, beanName = "BlueBean", name = "myFriend") -public class RedBean implements Friend { - - public String sayHello() { - return "Red says, Hello!"; - } - - public String helloFromFriend() { - try { - Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); - return "My friend " + friend.sayHello(); - } catch (NamingException e) { - throw new EJBException(e); - } - } -} +/** + * 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.ejblookup; + +import javax.ejb.EJB; +import javax.ejb.EJBException; +import javax.ejb.Stateless; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +//START SNIPPET: code +@Stateless +@EJB(beanInterface = Friend.class, beanName = "BlueBean", name = "myFriend") +public class RedBean implements Friend { + + public String sayHello() { + return "Red says, Hello!"; + } + + public String helloFromFriend() { + try { + Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); + return "My friend " + friend.sayHello(); + } catch (NamingException e) { + throw new EJBException(e); + } + } +} //END SNIPPET: code \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/lookup-of-ejbs/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java ---------------------------------------------------------------------- diff --git a/examples/lookup-of-ejbs/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java b/examples/lookup-of-ejbs/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java index b3b6504..a3bee25 100644 --- a/examples/lookup-of-ejbs/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java +++ b/examples/lookup-of-ejbs/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java @@ -1,54 +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 - * <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.ejblookup; - -import junit.framework.TestCase; - -import javax.ejb.embeddable.EJBContainer; -import javax.naming.Context; - -//START SNIPPET: code -public class EjbDependencyTest extends TestCase { - - private Context context; - - protected void setUp() throws Exception { - context = EJBContainer.createEJBContainer().getContext(); - } - - public void testRed() throws Exception { - - final Friend red = (Friend) context.lookup("java:global/lookup-of-ejbs/RedBean"); - - assertNotNull(red); - assertEquals("Red says, Hello!", red.sayHello()); - assertEquals("My friend Blue says, Hello!", red.helloFromFriend()); - - } - - public void testBlue() throws Exception { - - final Friend blue = (Friend) context.lookup("java:global/lookup-of-ejbs/BlueBean"); - - assertNotNull(blue); - assertEquals("Blue says, Hello!", blue.sayHello()); - assertEquals("My friend Red says, Hello!", blue.helloFromFriend()); - - } - -} -//END SNIPPET: code +/** + * 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.ejblookup; + +import junit.framework.TestCase; + +import javax.ejb.embeddable.EJBContainer; +import javax.naming.Context; + +//START SNIPPET: code +public class EjbDependencyTest extends TestCase { + + private Context context; + + protected void setUp() throws Exception { + context = EJBContainer.createEJBContainer().getContext(); + } + + public void testRed() throws Exception { + + final Friend red = (Friend) context.lookup("java:global/lookup-of-ejbs/RedBean"); + + assertNotNull(red); + assertEquals("Red says, Hello!", red.sayHello()); + assertEquals("My friend Blue says, Hello!", red.helloFromFriend()); + + } + + public void testBlue() throws Exception { + + final Friend blue = (Friend) context.lookup("java:global/lookup-of-ejbs/BlueBean"); + + assertNotNull(blue); + assertEquals("Blue says, Hello!", blue.sayHello()); + assertEquals("My friend Red says, Hello!", blue.helloFromFriend()); + + } + +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/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 00c2eb3..8d28ecb 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 - * <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"; - } -} +/** + * 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/6e2a4f7c/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 b74daf0..8714350 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 - * <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(); - } -} +/** + * 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/6e2a4f7c/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 bbeec38..4e067bb 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 - * <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; - } +/** + * 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/6e2a4f7c/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 ff94d67..2580c9f 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 - * <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(); - } +/** + * 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/6e2a4f7c/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 7466bb4..65c89fd 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 - * <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)); - } +/** + * 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/6e2a4f7c/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 a2b23d8..6969221 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 - * <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)); - } - +/** + * 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/6e2a4f7c/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 946513c..335052a 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 - * <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); - } - +/** + * 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