You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2011/10/30 04:44:35 UTC
svn commit: r1195109 [17/18] - in /openejb/trunk/openejb/examples:
access-timeout/ application-composer/ applicationexception/ async-methods/
bean-validation-design-by-contract/ cdi-basic/ cdi-interceptors/
cdi-produces-disposes/ component-interfaces/ ...
Modified: openejb/trunk/openejb/examples/webapps/resources-declared-in-webapp/README.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webapps/resources-declared-in-webapp/README.md?rev=1195109&r1=1195108&r2=1195109&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/webapps/resources-declared-in-webapp/README.md (original)
+++ openejb/trunk/openejb/examples/webapps/resources-declared-in-webapp/README.md Sun Oct 30 03:44:33 2011
@@ -1,7 +1,125 @@
+Title: Resources Declared in Webapp
+*Help us document this example! Source available in [svn](http://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/resources-declared-in-webapp) or [git](https://github.com/apache/openejb/tree/trunk/openejb/examples/resources-declared-in-webapp). Open a [JIRA](https://issues.apache.org/jira/browse/TOMEE) with patch or pull request*
-run the command:
-$ mvn clean install t7:run
+## Manager
-then go to http://localhost:1234/resources-declared-in-webapp-1.0-SNAPSHOT/
+ package org.superbiz.bean;
+
+ import org.superbiz.resource.ManagerResource;
+
+ import javax.annotation.Resource;
+ import javax.ejb.Singleton;
+
+ /**
+ * @author rmannibucau
+ */
+ @Singleton
+ public class Manager {
+ @Resource(name = "My Manager Team", type = ManagerResource.class)
+ private ManagerResource resource;
+
+ public String work() {
+ return "manage a resource of type " + resource.resourceType();
+ }
+ }
+## ManagerResource
+
+ package org.superbiz.resource;
+
+ /**
+ * @author rmannibucau
+ */
+ public class ManagerResource {
+ public String resourceType() {
+ return "team";
+ }
+ }
+
+## ManagerServlet
+
+ package org.superbiz.servlet;
+
+ import org.superbiz.bean.Manager;
+
+ 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;
+
+ /**
+ * @author rmannibucau
+ */
+ @WebServlet(name = "manager servlet", urlPatterns = "/")
+ public class ManagerServlet extends HttpServlet {
+ @EJB
+ private Manager manager;
+
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.getOutputStream().print(manager.work());
+ }
+ }
+
+## ejb-jar.xml
+
+ <!--
+ 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.
+ -->
+ <ejb-jar/>
+
+
+## service-jar.xml
+
+ <ServiceJar>
+ <ServiceProvider id="ManagerResource" service="Resource"
+ type="org.superbiz.resource.ManagerResource"
+ class-name="org.superbiz.resource.ManagerResource"/>
+ </ServiceJar>
+
+
+## resources.xml
+
+ <resources>
+ <Resource id="My Manager Team" type="org.superbiz.resource.ManagerResource" provider="org.superbiz#ManagerResource"/>
+ </resources>
+
+
+## web.xml
+
+ <!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+ <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"/>
+
Modified: openejb/trunk/openejb/examples/webapps/rest-example-with-application/README.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webapps/rest-example-with-application/README.md?rev=1195109&r1=1195108&r2=1195109&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/webapps/rest-example-with-application/README.md (original)
+++ openejb/trunk/openejb/examples/webapps/rest-example-with-application/README.md Sun Oct 30 03:44:33 2011
@@ -1,11 +1,15 @@
- package org.superbiz.rest.application;
-
+Title: REST Example with Application
+
+*Help us document this example! Source available in [svn](http://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/rest-example-with-application) or [git](https://github.com/apache/openejb/tree/trunk/openejb/examples/rest-example-with-application). Open a [JIRA](https://issues.apache.org/jira/browse/TOMEE) with patch or pull request*
+
+## ApplicationConfig
+
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-
+
/**
* @author rmannibucau
*/
@@ -15,15 +19,16 @@
return new HashSet<Class<?>>(Arrays.asList(SimpleRESTPojo.class, SimpleRESTEJB.class));
}
}
- package org.superbiz.rest.application;
-
+
+## SimpleRESTEJB
+
import javax.ejb.Lock;
import javax.ejb.LockType;
import javax.ejb.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import java.util.Date;
-
+
/**
* @author rmannibucau
*/
@@ -31,22 +36,37 @@
@Lock(LockType.READ)
@Path("/ejb")
public class SimpleRESTEJB {
- @GET public String ejb() {
+ @GET
+ public String ejb() {
return "ejb ok @ " + new Date().toString();
}
}
- package org.superbiz.rest.application;
-
+
+## SimpleRESTPojo
+
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import java.util.Date;
-
+
/**
* @author rmannibucau
*/
@Path("/pojo")
public class SimpleRESTPojo {
- @GET public String pojo() {
+ @GET
+ public String pojo() {
return "pojo ok @ " + new Date().toString();
}
}
+
+## web.xml
+
+ <web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ <display-name>OpenEJB REST Example</display-name>
+ </web-app>
+
Modified: openejb/trunk/openejb/examples/webapps/rest-example/README.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webapps/rest-example/README.md?rev=1195109&r1=1195108&r2=1195109&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/webapps/rest-example/README.md (original)
+++ openejb/trunk/openejb/examples/webapps/rest-example/README.md Sun Oct 30 03:44:33 2011
@@ -1,74 +1,9 @@
-[INFO] Scanning for projects...
-[INFO]
-[INFO] ------------------------------------------------------------------------
-[INFO] Building OpenEJB :: Web Examples :: REST Example 1.0
-[INFO] ------------------------------------------------------------------------
-[INFO]
-[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ rest-example ---
-[INFO] Deleting /Users/dblevins/examples/webapps/rest-example/target
-[INFO]
-[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ rest-example ---
-[INFO] Using 'UTF-8' encoding to copy filtered resources.
-[INFO] Copying 1 resource
-[INFO]
-[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ rest-example ---
-[INFO] Compiling 12 source files to /Users/dblevins/examples/webapps/rest-example/target/classes
-[INFO]
-[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ rest-example ---
-[INFO] Using 'UTF-8' encoding to copy filtered resources.
-[INFO] skip non existing resourceDirectory /Users/dblevins/examples/webapps/rest-example/src/test/resources
-[INFO]
-[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ rest-example ---
-[INFO] No sources to compile
-[INFO]
-[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ rest-example ---
-[INFO] No tests to run.
-[INFO] Surefire report directory: /Users/dblevins/examples/webapps/rest-example/target/surefire-reports
-
--------------------------------------------------------
- T E S T S
--------------------------------------------------------
-There are no tests to run.
-
-Results :
-
-Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
-
-[INFO]
-[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ rest-example ---
-[INFO] Packaging webapp
-[INFO] Assembling webapp [rest-example] in [/Users/dblevins/examples/webapps/rest-example/target/rest-example-1.0]
-[INFO] Processing war project
-[INFO] Copying webapp resources [/Users/dblevins/examples/webapps/rest-example/src/main/webapp]
-[INFO] Webapp assembled in [32 msecs]
-[INFO] Building war: /Users/dblevins/examples/webapps/rest-example/target/rest-example-1.0.war
-[INFO]
-[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ rest-example ---
-[INFO] Installing /Users/dblevins/examples/webapps/rest-example/target/rest-example-1.0.war to /Users/dblevins/.m2/repository/org/superbiz/rest-example/1.0/rest-example-1.0.war
-[INFO] Installing /Users/dblevins/examples/webapps/rest-example/pom.xml to /Users/dblevins/.m2/repository/org/superbiz/rest-example/1.0/rest-example-1.0.pom
-[INFO] ------------------------------------------------------------------------
-[INFO] BUILD SUCCESS
-[INFO] ------------------------------------------------------------------------
-[INFO] Total time: 2.318s
-[INFO] Finished at: Fri Oct 28 17:03:55 PDT 2011
-[INFO] Final Memory: 10M/81M
-[INFO] ------------------------------------------------------------------------
- /*
- * 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.
- */
+Title: REST Example
+
+*Help us document this example! Source available in [svn](http://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/rest-example) or [git](https://github.com/apache/openejb/tree/trunk/openejb/examples/rest-example). Open a [JIRA](https://issues.apache.org/jira/browse/TOMEE) with patch or pull request*
+
+## CommentDAO
+
package org.superbiz.rest.dao;
import org.superbiz.rest.model.Comment;
@@ -84,7 +19,8 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
*/
@Stateless
public class CommentDAO extends DAO {
- @EJB private DAO dao;
+ @EJB
+ private DAO dao;
public List<Comment> list(long postId) {
Post post = dao.find(Post.class, postId);
@@ -122,23 +58,10 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
comment.setContent(content);
return dao.update(comment);
}
- }
- /*
- * 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.
- */
+ }
+
+## DAO
+
package org.superbiz.rest.dao;
import javax.ejb.Stateless;
@@ -155,7 +78,8 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
*/
@Stateless
public class DAO {
- @PersistenceContext(unitName = "blog") private EntityManager em;
+ @PersistenceContext(unitName = "blog")
+ private EntityManager em;
public <E> E create(E e) {
em.persist(e);
@@ -192,22 +116,9 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
return query;
}
}
- /**
- * 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.
- */
+
+## PostDAO
+
package org.superbiz.rest.dao;
import org.superbiz.rest.model.Post;
@@ -222,7 +133,8 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
*/
@Stateless
public class PostDAO {
- @EJB private DAO dao;
+ @EJB
+ private DAO dao;
public Post create(String title, String content, long userId) {
User user = dao.find(User.class, userId);
@@ -248,12 +160,12 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
public Post update(long id, long userId, String title, String content) {
User user = dao.find(User.class, userId);
if (user == null) {
- throw new IllegalArgumentException("user id " + id + " not found");
+ throw new IllegalArgumentException("user id " + id + " not found");
}
Post post = dao.find(Post.class, id);
if (post == null) {
- throw new IllegalArgumentException("post id " + id + " not found");
+ throw new IllegalArgumentException("post id " + id + " not found");
}
post.setTitle(title);
@@ -262,22 +174,9 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
return dao.update(post);
}
}
- /**
- * 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.
- */
+
+## UserDAO
+
package org.superbiz.rest.dao;
import org.superbiz.rest.model.User;
@@ -291,7 +190,8 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
*/
@Stateless
public class UserDAO {
- @EJB private DAO dao;
+ @EJB
+ private DAO dao;
public User create(String name, String pwd, String mail) {
User user = new User();
@@ -316,7 +216,7 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
public User update(long id, String name, String pwd, String mail) {
User user = dao.find(User.class, id);
if (user == null) {
- throw new IllegalArgumentException("setUser id " + id + " not found");
+ throw new IllegalArgumentException("setUser id " + id + " not found");
}
user.setFullname(name);
@@ -325,23 +225,9 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
return dao.update(user);
}
}
- /*
- * 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.
- */
-
+
+## Comment
+
package org.superbiz.rest.model;
import javax.persistence.Entity;
@@ -361,55 +247,11 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
*/
@Entity
@NamedQueries({
- @NamedQuery(name = "comment.list", query = "select c from Comment c")
- })
- @XmlRootElement(name = "comment")
- public class Comment extends Model {
- @NotNull @Size(min = 1) private String author;
- @NotNull @Size(min = 1) @Lob private String content;
- @ManyToOne @JoinColumn(name = "post_id") @Valid @XmlTransient private Post post;
-
- public void setAuthor(final String author) {
- this.author = author;
- }
-
- public void setContent(final String content) {
- this.content = content;
- }
-
- public void setPost(Post post) {
- post.addComment(this);
- this.post = post;
- }
-
- public String getAuthor() {
- return author;
- }
-
- public String getContent() {
- return content;
- }
-
- public Post getPost() {
- return post;
- }
+ @NamedQuery(name = "comment.list", query = "select c from Comment c")
}
- /*
- * 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.
- */
+
+## DatedModel
+
package org.superbiz.rest.model;
import javax.persistence.MappedSuperclass;
@@ -423,7 +265,8 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
public abstract class DatedModel extends Model {
private Date created;
- @PrePersist public void create() {
+ @PrePersist
+ public void create() {
created = new Date();
}
@@ -434,23 +277,10 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
public void setCreated(Date created) {
this.created = created;
}
- }
- /*
- * 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.
- */
+ }
+
+## Model
+
package org.superbiz.rest.model;
import javax.persistence.Access;
@@ -468,7 +298,10 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class Model {
- @Id @GeneratedValue protected long id;
+
+ @Id
+ @GeneratedValue
+ protected long id;
public long getId() {
return id;
@@ -477,24 +310,10 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
public void setId(long id) {
this.id = id;
}
- }
- /*
- * 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.
- */
-
+ }
+
+## Post
+
package org.superbiz.rest.model;
import javax.persistence.Entity;
@@ -516,68 +335,11 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
*/
@Entity
@NamedQueries({
- @NamedQuery(name = "post.list", query = "select p from Post p")
- })
- @XmlRootElement(name = "post")
- public class Post extends DatedModel {
- @NotNull @Size(min = 1) private String title;
- @NotNull @Size(min = 1) @Lob private String content;
- @ManyToOne @Valid private User user;
- @OneToMany(mappedBy = "post", fetch = FetchType.EAGER) private List<Comment> comments = new ArrayList<Comment>();
-
- public void setTitle(final String title) {
- this.title = title;
- }
-
- public void setContent(final String content) {
- this.content = content;
- }
-
- public void setUser(final User user) {
- this.user = user;
- }
-
- public String getTitle() {
- return title;
- }
-
- public String getContent() {
- return content;
- }
-
- public User getUser() {
- return user;
- }
-
- public List<Comment> getComments() {
- return comments;
- }
-
- public void setComments(List<Comment> comments) {
- this.comments = comments;
- }
-
- public void addComment(final Comment comment) {
- getComments().add(comment);
- }
+ @NamedQuery(name = "post.list", query = "select p from Post p")
}
- /*
- * 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.
- */
-
+
+## User
+
package org.superbiz.rest.model;
import javax.persistence.Entity;
@@ -593,55 +355,11 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
*/
@Entity
@NamedQueries({
- @NamedQuery(name = "user.list", query = "select u from User u")
- })
- @XmlRootElement(name = "user")
- public class User extends Model {
- @NotNull @Size(min = 3, max = 15) private String fullname;
- @NotNull @Size(min = 5, max = 15) private String password;
- @NotNull @Pattern(regexp = ".+@.+\\.[a-z]+") private String email;
-
- public void setFullname(final String fullname) {
- this.fullname = fullname;
- }
-
- public void setPassword(final String password) {
- this.password = password;
- }
-
- public void setEmail(final String email) {
- this.email = email;
- }
-
- public String getFullname() {
- return fullname;
- }
-
- public String getPassword() {
- return password;
- }
-
- public String getEmail() {
- return email;
- }
+ @NamedQuery(name = "user.list", query = "select u from User u")
}
- /*
- * 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.
- */
-
+
+## CommentService
+
package org.superbiz.rest.service;
import org.superbiz.rest.dao.CommentDAO;
@@ -664,44 +382,40 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
@Path("/api/comment")
@Produces({"text/xml", "application/json"})
public class CommentService {
- @EJB private CommentDAO commentDao;
+ @EJB
+ private CommentDAO commentDao;
- @Path("/create") @PUT public Comment create(@QueryParam("author") String author,
- @QueryParam("content") String content,
- @QueryParam("postId") long postId) {
+ @Path("/create")
+ @PUT
+ public Comment create(@QueryParam("author") String author,
+ @QueryParam("content") String content,
+ @QueryParam("postId") long postId) {
return commentDao.create(author, content, postId);
}
- @Path("/list/{postId}") @GET public List<Comment> list(@PathParam("postId") long postId) {
+ @Path("/list/{postId}")
+ @GET
+ public List<Comment> list(@PathParam("postId") long postId) {
return commentDao.list(postId);
}
- @Path("/delete/{id}") @DELETE public void delete(@PathParam("id") long id) {
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
commentDao.delete(id);
}
- @Path("/update/{id}") @POST public Comment update(@PathParam("id") long id,
- @QueryParam("author") String author,
- @QueryParam("content") String content) {
+ @Path("/update/{id}")
+ @POST
+ public Comment update(@PathParam("id") long id,
+ @QueryParam("author") String author,
+ @QueryParam("content") String content) {
return commentDao.update(id, author, content);
}
}
- /*
- * 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.
- */
+
+## PostService
+
package org.superbiz.rest.service;
import org.superbiz.rest.dao.PostDAO;
@@ -723,56 +437,53 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
* @author Romain Manni-Bucau
*/
@Path("/api/post")
- @Produces({ "text/xml", "application/json" })
+ @Produces({"text/xml", "application/json"})
public class PostService {
- @EJB private PostDAO dao;
+ @EJB
+ private PostDAO dao;
- @Path("/create") @PUT public Post create(@QueryParam("title") String title,
- @QueryParam("content") String content,
- @QueryParam("userId") long userId) {
+ @Path("/create")
+ @PUT
+ public Post create(@QueryParam("title") String title,
+ @QueryParam("content") String content,
+ @QueryParam("userId") long userId) {
return dao.create(title, content, userId);
}
- @Path("/list") @GET public List<Post> list(@QueryParam("first") @DefaultValue("0") int first,
- @QueryParam("max") @DefaultValue("20") int max) {
+ @Path("/list")
+ @GET
+ public List<Post> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
return dao.list(first, max);
}
- @Path("/show/{id}") @GET public Post show(@PathParam("id") long id) {
+ @Path("/show/{id}")
+ @GET
+ public Post show(@PathParam("id") long id) {
return dao.find(id);
}
- @Path("/delete/{id}") @DELETE public void delete(@PathParam("id") long id) {
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
dao.delete(id);
}
- @Path("/update/{id}") @POST public Post update(@PathParam("id") long id,
- @QueryParam("userId") long userId,
- @QueryParam("title") String title,
- @QueryParam("content") String content) {
+ @Path("/update/{id}")
+ @POST
+ public Post update(@PathParam("id") long id,
+ @QueryParam("userId") long userId,
+ @QueryParam("title") String title,
+ @QueryParam("content") String content) {
return dao.update(id, userId, title, content);
}
}
- /*
- * 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.
- */
+
+## UserService
+
package org.superbiz.rest.service;
import org.superbiz.rest.dao.UserDAO;
- import org.superbiz.rest.model.Post;
import org.superbiz.rest.model.User;
import javax.ejb.EJB;
@@ -791,156 +502,87 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
* @author Romain Manni-Bucau
*/
@Path("/api/user")
- @Produces({ "text/xml", "application/json" })
+ @Produces({"text/xml", "application/json"})
public class UserService {
- @EJB private UserDAO dao;
+ @EJB
+ private UserDAO dao;
- @Path("/create") @PUT public User create(@QueryParam("name") String name,
- @QueryParam("pwd") String pwd,
- @QueryParam("mail") String mail) {
+ @Path("/create")
+ @PUT
+ public User create(@QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
return dao.create(name, pwd, mail);
}
- @Path("/list") @GET public List<User> list(@QueryParam("first") @DefaultValue("0") int first,
- @QueryParam("max") @DefaultValue("20") int max) {
+ @Path("/list")
+ @GET
+ public List<User> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
return dao.list(first, max);
}
- @Path("/show/{id}") @GET public User show(@PathParam("id") long id) {
+ @Path("/show/{id}")
+ @GET
+ public User show(@PathParam("id") long id) {
return dao.find(id);
}
- @Path("/delete/{id}") @DELETE public void delete(@PathParam("id") long id) {
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
dao.delete(id);
}
- @Path("/update/{id}") @POST public User update(@PathParam("id") long id,
- @QueryParam("name") String name,
- @QueryParam("pwd") String pwd,
- @QueryParam("mail") String mail) {
+ @Path("/update/{id}")
+ @POST
+ public User update(@PathParam("id") long id,
+ @QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
return dao.update(id, name, pwd, mail);
}
}
- package org.superbiz.rest.dao;
-
- import org.junit.AfterClass;
- import org.junit.BeforeClass;
- import org.junit.Test;
- import org.superbiz.rest.model.User;
-
- import javax.ejb.embeddable.EJBContainer;
- import javax.naming.NamingException;
-
- import static junit.framework.Assert.assertNotNull;
-
- /**
- * @author rmannibucau
- */
- public class UserDaoTest {
- private static EJBContainer container;
-
- @BeforeClass public static void start() {
- container = EJBContainer.createEJBContainer();
- }
+
+## persistence.xml
+
+ <persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="blog">
+ <jta-data-source>My DataSource</jta-data-source>
+ <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
+ <class>org.superbiz.rest.model.User</class>
+ <class>org.superbiz.rest.model.Post</class>
+ <class>org.superbiz.rest.model.Comment</class>
+ <class>org.superbiz.rest.model.Model</class>
+ <class>org.superbiz.rest.model.DatedModel</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## web.xml
+
+ <web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
- @AfterClass public static void stop() {
- if (container != null) {
- container.close();
- }
- }
+ <display-name>OpenEJB REST Example</display-name>
+ </web-app>
- @Test public void create() throws NamingException {
- UserDAO dao = (UserDAO) container.getContext().lookup("java:global/rest-example/UserDAO");
- User user = dao.create("foo", "dummy", "foo@bar.org");
- assertNotNull(dao.find(user.getId()));
- }
+
+## UserDaoTest
+
+ packagenull
}
- package org.superbiz.rest.dao;
-
- import org.apache.commons.io.FileUtils;
- import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
- import org.apache.tomee.embedded.EmbeddedTomEEContainer;
- import org.junit.AfterClass;
- import org.junit.BeforeClass;
- import org.junit.Test;
- import org.superbiz.rest.model.User;
-
- import javax.ejb.embeddable.EJBContainer;
- import javax.naming.NamingException;
- import javax.ws.rs.GET;
- import javax.ws.rs.Path;
- import javax.ws.rs.PathParam;
- import javax.ws.rs.Produces;
- import java.io.File;
- import java.io.IOException;
- import java.util.Properties;
-
- import static junit.framework.Assert.assertEquals;
- import static junit.framework.Assert.assertNotNull;
-
- /**
- * @author rmannibucau
- */
- public class UserServiceTest {
- private static EJBContainer container;
- private static File webApp;
-
- @BeforeClass public static void start() throws IOException {
- webApp = createWebApp();
- Properties p = new Properties();
- p.setProperty(EJBContainer.APP_NAME, "test");
- p.setProperty(EJBContainer.PROVIDER, "tomee-embedded"); // need web feature
- p.setProperty(EJBContainer.MODULES, webApp.getAbsolutePath());
- p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, "-1"); // random port
- container = EJBContainer.createEJBContainer(p);
- }
-
- @AfterClass public static void stop() {
- if (container != null) {
- container.close();
- }
- if (webApp != null) {
- try {
- FileUtils.forceDelete(webApp);
- } catch (IOException e) {
- FileUtils.deleteQuietly(webApp);
- }
- }
- }
-
- @Test public void create() throws NamingException {
- UserDAO dao = (UserDAO) container.getContext().lookup("java:global/" + webApp.getName() + "/UserDAO");
- User user = dao.create("foo", "dummy", "foo@dummy.org");
- assertNotNull(dao.find(user.getId()));
-
- String uri = "http://127.0.0.1:" + System.getProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT) + "/" + webApp.getName();
- UserServiceClientAPI client = JAXRSClientFactory.create(uri, UserServiceClientAPI.class);
- User retrievedUser = client.show(user.getId());
- assertNotNull(retrievedUser);
- assertEquals("foo", retrievedUser.getFullname());
- assertEquals("dummy", retrievedUser.getPassword());
- assertEquals("foo@dummy.org", retrievedUser.getEmail());
- }
-
- private static File createWebApp() throws IOException {
- File file = new File(System.getProperty("java.io.tmpdir") + "/tomee-" + Math.random());
- if (!file.mkdirs() && !file.exists()) {
- throw new RuntimeException("can't create " + file.getAbsolutePath());
- }
-
- FileUtils.copyDirectory(new File("target/classes"), new File(file, "WEB-INF/classes"));
-
- return file;
- }
-
- /**
- * a simple copy of the unique method i want to use from my service.
- * It allows to use cxf proxy to call remotely our rest service.
- * Any other way to do it is good.
- */
- @Path("/api/user")
- @Produces({ "text/xml", "application/json" })
- public static interface UserServiceClientAPI {
- @Path("/show/{id}") @GET User show(@PathParam("id") long id);
- }
+
+## UserServiceTest
+
+ packagenull
}
Modified: openejb/trunk/openejb/examples/webapps/struts/README.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webapps/struts/README.md?rev=1195109&r1=1195108&r2=1195109&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/webapps/struts/README.md (original)
+++ openejb/trunk/openejb/examples/webapps/struts/README.md Sun Oct 30 03:44:33 2011
@@ -1,76 +1,9 @@
-[INFO] Scanning for projects...
-[INFO]
-[INFO] ------------------------------------------------------------------------
-[INFO] Building OpenEJB :: Web Examples :: Struts 1.0
-[INFO] ------------------------------------------------------------------------
-[INFO]
-[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ struts ---
-[INFO] Deleting /Users/dblevins/examples/webapps/struts/target
-[INFO]
-[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ struts ---
-[INFO] Using 'UTF-8' encoding to copy filtered resources.
-[INFO] Copying 2 resources
-[INFO]
-[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ struts ---
-[INFO] Compiling 8 source files to /Users/dblevins/examples/webapps/struts/target/classes
-[INFO]
-[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ struts ---
-[INFO] Using 'UTF-8' encoding to copy filtered resources.
-[INFO] skip non existing resourceDirectory /Users/dblevins/examples/webapps/struts/src/test/resources
-[INFO]
-[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ struts ---
-[INFO] No sources to compile
-[INFO]
-[INFO] --- maven-surefire-plugin:2.6:test (default-test) @ struts ---
-[INFO] No tests to run.
-[INFO] Surefire report directory: /Users/dblevins/examples/webapps/struts/target/surefire-reports
-
--------------------------------------------------------
- T E S T S
--------------------------------------------------------
-There are no tests to run.
-
-Results :
-
-Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
-
-[INFO]
-[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ struts ---
-[INFO] Packaging webapp
-[INFO] Assembling webapp [struts] in [/Users/dblevins/examples/webapps/struts/target/struts]
-[INFO] Processing war project
-[INFO] Copying webapp resources [/Users/dblevins/examples/webapps/struts/src/main/webapp]
-[INFO] Webapp assembled in [129 msecs]
-[INFO] Building war: /Users/dblevins/examples/webapps/struts/target/struts.war
-[INFO] WEB-INF/web.xml already added, skipping
-[INFO]
-[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ struts ---
-[INFO] Installing /Users/dblevins/examples/webapps/struts/target/struts.war to /Users/dblevins/.m2/repository/org/superbiz/struts/struts/1.0/struts-1.0.war
-[INFO] Installing /Users/dblevins/examples/webapps/struts/pom.xml to /Users/dblevins/.m2/repository/org/superbiz/struts/struts/1.0/struts-1.0.pom
-[INFO] ------------------------------------------------------------------------
-[INFO] BUILD SUCCESS
-[INFO] ------------------------------------------------------------------------
-[INFO] Total time: 2.987s
-[INFO] Finished at: Fri Oct 28 17:03:38 PDT 2011
-[INFO] Final Memory: 11M/81M
-[INFO] ------------------------------------------------------------------------
- /*
-
- 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.
- */
+Title: Struts
+
+*Help us document this example! Source available in [svn](http://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/struts) or [git](https://github.com/apache/openejb/tree/trunk/openejb/examples/struts). Open a [JIRA](https://issues.apache.org/jira/browse/TOMEE) with patch or pull request*
+
+## AddUser
+
package org.superbiz.struts;
import javax.naming.Context;
@@ -136,48 +69,19 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
return "success";
}
}
- /*
-
- 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.
- */
+
+## AddUserForm
+
package org.superbiz.struts;
import com.opensymphony.xwork2.ActionSupport;
public class AddUserForm extends ActionSupport {
-
}
- /*
-
- 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.
- */
+
+## FindUser
+
package org.superbiz.struts;
import javax.naming.Context;
@@ -232,48 +136,19 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
return "success";
}
}
- /*
-
- 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.
- */
+
+## FindUserForm
+
package org.superbiz.struts;
import com.opensymphony.xwork2.ActionSupport;
public class FindUserForm extends ActionSupport {
-
}
- /*
-
- 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.
- */
+
+## ListAllUsers
+
package org.superbiz.struts;
import javax.naming.Context;
@@ -329,23 +204,9 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
return "success";
}
}
- /*
-
- 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.
- */
+
+## User
+
package org.superbiz.struts;
import javax.persistence.Entity;
@@ -394,25 +255,10 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
public void setLastName(String lastName) {
this.lastName = lastName;
}
-
}
- /*
-
- 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.
- */
+
+## UserService
+
package org.superbiz.struts;
import java.util.List;
@@ -424,23 +270,9 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
public List<User> findAll();
}
- /*
-
- 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.
- */
+
+## UserServiceImpl
+
package org.superbiz.struts;
import javax.ejb.Stateless;
@@ -465,5 +297,92 @@ Tests run: 0, Failures: 0, Errors: 0, Sk
public List<User> findAll() {
return manager.createQuery("select u from User u").getResultList();
}
-
}
+
+## persistence.xml
+
+ </persistence-unit>
+
+ -->
+ </persistence>
+
+## struts.xml
+
+ <struts>
+ <constant name="struts.devMode" value="true"></constant>
+ <package name="default" namespace="/" extends="struts-default">
+ <action name="addUserForm" class="org.superbiz.struts.AddUserForm">
+ <result>/addUserForm.jsp</result>
+ </action>
+ <action name="addUser" class="org.superbiz.struts.AddUser">
+ <result name="success">/addedUser.jsp</result>
+ <result name='failure'>/addUserForm.jsp</result>
+ </action>
+ <action name="findUserForm" class="org.superbiz.struts.FindUserForm">
+ <result>/findUserForm.jsp</result>
+ </action>
+ <action name="findUser" class="org.superbiz.struts.FindUser">
+ <result name='success'>/displayUser.jsp</result>
+ <result name='failure'>/findUserForm.jsp</result>
+ </action>
+ <action name="listAllUsers" class="org.superbiz.struts.ListAllUsers">
+ <result>/displayUsers.jsp</result>
+ </action>
+
+ </package>
+ </struts>
+
+## decorators.xml
+
+ <decorators defaultdir="/decorators">
+ <decorator name="main" page="layout.jsp">
+ <pattern>/*</pattern>
+ </decorator>
+ </decorators>
+
+## web.xml
+
+ <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+ <display-name>Learn EJB3 and Struts2</display-name>
+ <filter>
+ <filter-name>struts2</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
+ <init-param>
+ <param-name>actionPackages</param-name>
+ <param-value>com.lq</param-value>
+ </init-param>
+ </filter>
+ <filter>
+ <filter-name>struts-cleanup</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
+ </filter>
+ <filter>
+ <filter-name>sitemesh</filter-name>
+ <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>struts-cleanup</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>sitemesh</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>struts2</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+ <jsp-config>
+ <jsp-property-group>
+ <description>JSP configuration of all the JSP's</description>
+ <url-pattern>*.jsp</url-pattern>
+ <include-prelude>/prelude.jspf</include-prelude>
+ </jsp-property-group>
+ </jsp-config>
+ </web-app>
+
Modified: openejb/trunk/openejb/examples/webservice-attachments/README.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webservice-attachments/README.md?rev=1195109&r1=1195108&r2=1195109&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/webservice-attachments/README.md (original)
+++ openejb/trunk/openejb/examples/webservice-attachments/README.md Sun Oct 30 03:44:33 2011
@@ -1,100 +1,9 @@
-[INFO] Scanning for projects...
-[INFO]
-[INFO] ------------------------------------------------------------------------
-[INFO] Building OpenEJB :: Examples :: Webservice Attachments 1.0
-[INFO] ------------------------------------------------------------------------
-[INFO]
-[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ webservice-attachments ---
-[INFO] Deleting /Users/dblevins/examples/webservice-attachments/target
-[INFO]
-[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ webservice-attachments ---
-[INFO] Using 'UTF-8' encoding to copy filtered resources.
-[INFO] Copying 1 resource
-[INFO]
-[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ webservice-attachments ---
-[INFO] Compiling 2 source files to /Users/dblevins/examples/webservice-attachments/target/classes
-[INFO]
-[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ webservice-attachments ---
-[INFO] Using 'UTF-8' encoding to copy filtered resources.
-[INFO] skip non existing resourceDirectory /Users/dblevins/examples/webservice-attachments/src/test/resources
-[INFO]
-[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ webservice-attachments ---
-[INFO] Compiling 1 source file to /Users/dblevins/examples/webservice-attachments/target/test-classes
-[INFO]
-[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ webservice-attachments ---
-[INFO] Surefire report directory: /Users/dblevins/examples/webservice-attachments/target/surefire-reports
-
--------------------------------------------------------
- T E S T S
--------------------------------------------------------
-Running org.superbiz.attachment.AttachmentTest
-Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
-http://openejb.apache.org/
-INFO - openejb.home = /Users/dblevins/examples/webservice-attachments
-INFO - openejb.base = /Users/dblevins/examples/webservice-attachments
-INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
-INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
-INFO - Found EjbModule in classpath: /Users/dblevins/examples/webservice-attachments/target/classes
-INFO - Beginning load: /Users/dblevins/examples/webservice-attachments/target/classes
-INFO - Configuring enterprise application: /Users/dblevins/examples/webservice-attachments/classpath.ear
-INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
-INFO - Auto-creating a container for bean AttachmentImpl: Container(type=STATELESS, id=Default Stateless Container)
-INFO - Enterprise application "/Users/dblevins/examples/webservice-attachments/classpath.ear" loaded.
-INFO - Assembling app: /Users/dblevins/examples/webservice-attachments/classpath.ear
-INFO - Created Ejb(deployment-id=AttachmentImpl, ejb-name=AttachmentImpl, container=Default Stateless Container)
-INFO - Started Ejb(deployment-id=AttachmentImpl, ejb-name=AttachmentImpl, container=Default Stateless Container)
-INFO - Deployed Application(path=/Users/dblevins/examples/webservice-attachments/classpath.ear)
-INFO - Initializing network services
-INFO - Creating ServerService(id=httpejbd)
-INFO - Creating ServerService(id=cxf)
-INFO - Creating ServerService(id=admin)
-INFO - Creating ServerService(id=ejbd)
-INFO - Creating ServerService(id=ejbds)
-INFO - Initializing network services
- ** Starting Services **
- NAME IP PORT
- httpejbd 127.0.0.1 4204
- admin thread 127.0.0.1 4200
- ejbd 127.0.0.1 4201
- ejbd 127.0.0.1 4203
--------
-Ready!
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.934 sec
-
-Results :
-
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-
-[INFO]
-[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ webservice-attachments ---
-[INFO] Building jar: /Users/dblevins/examples/webservice-attachments/target/webservice-attachments-1.0.jar
-[INFO]
-[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ webservice-attachments ---
-[INFO] Installing /Users/dblevins/examples/webservice-attachments/target/webservice-attachments-1.0.jar to /Users/dblevins/.m2/repository/org/superbiz/webservice-attachments/1.0/webservice-attachments-1.0.jar
-[INFO] Installing /Users/dblevins/examples/webservice-attachments/pom.xml to /Users/dblevins/.m2/repository/org/superbiz/webservice-attachments/1.0/webservice-attachments-1.0.pom
-[INFO] ------------------------------------------------------------------------
-[INFO] BUILD SUCCESS
-[INFO] ------------------------------------------------------------------------
-[INFO] Total time: 6.450s
-[INFO] Finished at: Fri Oct 28 17:11:04 PDT 2011
-[INFO] Final Memory: 17M/81M
-[INFO] ------------------------------------------------------------------------
- /**
- * 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.
- */
+Title: Webservice Attachments
+
+*Help us document this example! Source available in [svn](http://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/webservice-attachments) or [git](https://github.com/apache/openejb/tree/trunk/openejb/examples/webservice-attachments). Open a [JIRA](https://issues.apache.org/jira/browse/TOMEE) with patch or pull request*
+
+## AttachmentImpl
+
package org.superbiz.attachment;
import javax.activation.DataHandler;
@@ -123,7 +32,6 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
public String stringFromBytes(byte[] data) {
return new String(data);
-
}
public String stringFromDataSource(DataSource source) {
@@ -135,45 +43,25 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
inStr.read(data);
inStr.close();
return new String(data);
-
} catch (IOException e) {
e.printStackTrace();
-
}
return "";
-
}
public String stringFromDataHandler(DataHandler handler) {
try {
return (String) handler.getContent();
-
} catch (IOException e) {
e.printStackTrace();
-
}
return "";
-
}
-
}
- /**
- * 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.
- */
+
+## AttachmentWs
+
package org.superbiz.attachment;
import javax.activation.DataHandler;
@@ -191,24 +79,14 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
//public String stringFromDataSource(DataSource source);
public String stringFromDataHandler(DataHandler handler);
-
}
- /**
- * 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.
- */
+
+## ejb-jar.xml
+
+ <ejb-jar/>
+
+## AttachmentTest
+
package org.superbiz.attachment;
import junit.framework.TestCase;
@@ -274,8 +152,51 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
// Data Handler
response = ws.stringFromDataHandler(new DataHandler(source));
assertEquals(request, response);
-
}
//END SNIPPET: webservice
-
}
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.attachment.AttachmentTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/webservice-attachments
+ INFO - openejb.base = /Users/dblevins/examples/webservice-attachments
+ INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+ INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/webservice-attachments/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/webservice-attachments/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/webservice-attachments/classpath.ear
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean AttachmentImpl: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "/Users/dblevins/examples/webservice-attachments/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/webservice-attachments/classpath.ear
+ INFO - Created Ejb(deployment-id=AttachmentImpl, ejb-name=AttachmentImpl, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=AttachmentImpl, ejb-name=AttachmentImpl, container=Default Stateless Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/webservice-attachments/classpath.ear)
+ INFO - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Creating ServerService(id=cxf)
+ INFO - Creating ServerService(id=admin)
+ INFO - Creating ServerService(id=ejbd)
+ INFO - Creating ServerService(id=ejbds)
+ INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+ -------
+ Ready!
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.034 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+