You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@tomee.apache.org by bu...@apache.org on 2012/08/15 21:05:02 UTC
svn commit: r829040 - in /websites/staging/openejb/trunk: cgi-bin/ content/
content/examples-trunk/jsf-cdi-and-ejb/
content/examples-trunk/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/
Author: buildbot
Date: Wed Aug 15 19:05:01 2012
New Revision: 829040
Log:
Staging update by buildbot for openejb
Removed:
websites/staging/openejb/trunk/content/examples-trunk/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java
websites/staging/openejb/trunk/content/examples-trunk/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java
Modified:
websites/staging/openejb/trunk/cgi-bin/ (props changed)
websites/staging/openejb/trunk/content/ (props changed)
websites/staging/openejb/trunk/content/examples-trunk/jsf-cdi-and-ejb/README.html
websites/staging/openejb/trunk/content/examples-trunk/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java
websites/staging/openejb/trunk/content/sitemap.html
websites/staging/openejb/trunk/content/sitemap.xml
websites/staging/openejb/trunk/content/tomee-and-eclipse.html
Propchange: websites/staging/openejb/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Aug 15 19:05:01 2012
@@ -1 +1 @@
-1372843
+1373572
Propchange: websites/staging/openejb/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Aug 15 19:05:01 2012
@@ -1 +1 @@
-1372843
+1373572
Modified: websites/staging/openejb/trunk/content/examples-trunk/jsf-cdi-and-ejb/README.html
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/jsf-cdi-and-ejb/README.html (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/jsf-cdi-and-ejb/README.html Wed Aug 15 19:05:01 2012
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
- <title>JSF</title>
+ <title>JSF-CDI-EJB</title>
<meta name="description" content="">
<meta name="author" content="">
@@ -70,7 +70,7 @@
};
function twshare () {
window.open(
- "https://twitter.com/intent/tweet?url="+document.URL+"&text=JSF",
+ "https://twitter.com/intent/tweet?url="+document.URL+"&text=JSF-CDI-EJB",
'Share on Twitter',
'width=800,height=526');
};
@@ -143,7 +143,7 @@
</div>
<div class="page-header">
-<h1>JSF
+<h1>JSF-CDI-EJB
<div style="float: right; position: relative; bottom: -10px; ">
<a onclick="javascript:gpshare()" class="gp-share sprite" title="share on Google+">share [gp]</a>
@@ -154,12 +154,8 @@
</h1>
</div>
-<p>A simple web-app showing how to use dependency injection in JSF managed beans using TomEE.</p>
-
-<p>It contains a Local Stateless session bean (CalculatorImpl) which adds two numbers and returns the result.</p>
-
-<p>The application also contains a CDI managed bean (CalculatorBean), which uses the EJB to add two numbers
-and display the results to the user. The EJB is injected in the managed bean using @EJB annotation.</p>
+<p>The simple application contains a CDI managed bean <code>CalculatorBean</code>, which uses the <code>Calculator</code> EJB to add two numbers
+and display the results to the user. The EJB is injected in the managed bean using @Inject annotation.</p>
<p>You could run this in the latest Apache TomEE <a href="https://repository.apache.org/content/repositories/snapshots/org/apache/openejb/apache-tomee/">snapshot</a></p>
@@ -233,38 +229,26 @@ in the bean and then the commandButton-a
<p>In this case, CalculatorBean#add() is invoked.</p>
<p>Calculator#add() delegates the work to the ejb, gets the result, stores it
-and then instructs what view is to be rendered.</p>
+and then returns what view is to be rendered.</p>
-<p>You're right. The return value "success" is checked up in faces-config navigation-rules
+<p>The return value "success" is checked up in faces-config navigation-rules
and the respective page is rendered.</p>
-<p>In our case, 'result.xhtml' page is rendered.</p>
-
-<p>The request scoped 'calculatorBean' is available here, and we use EL to display the values.</p>
+<p>In our case, 'result.xhtml' page is rendered where
+use EL and display the result from the request-scoped <code>calculatorBean</code>.</p>
<h1>Source Code</h1>
-<h2>Calculator</h2>
-
-<pre><code>package org.superbiz.jsf;
-
-import javax.ejb.Remote;
-
-@Remote
-public interface Calculator {
- public double add(double x, double y);
-}
-</code></pre>
-
<h2>CalculatorBean</h2>
<pre><code>import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
+import javax.inject.Inject;
@RequestScoped
@Named
public class CalculatorBean {
- @EJB
+ @Inject
Calculator calculator;
private double x;
private double y;
@@ -301,14 +285,14 @@ public class CalculatorBean {
}
</code></pre>
-<h2>CalculatorImpl</h2>
+<h2>Calculator</h2>
<pre><code>package org.superbiz.jsf;
import javax.ejb.Stateless;
@Stateless
-public class CalculatorImpl implements Calculator {
+public class Calculator{
public double add(double x, double y) {
return x + y;
@@ -424,10 +408,9 @@ public class CalculatorImpl implements C
<div class="page-header"> </div>
<h4>APIs Used</h4>
-<ul><li><a href="http://docs.oracle.com/javaee/6/api/javax/ejb/EJB.html">javax.ejb.EJB</a></li>
-<li><a href="http://docs.oracle.com/javaee/6/api/javax/ejb/Remote.html">javax.ejb.Remote</a></li>
-<li><a href="http://docs.oracle.com/javaee/6/api/javax/ejb/Stateless.html">javax.ejb.Stateless</a></li>
+<ul><li><a href="http://docs.oracle.com/javaee/6/api/javax/ejb/Stateless.html">javax.ejb.Stateless</a></li>
<li><a href="http://docs.oracle.com/javaee/6/api/javax/enterprise/context/RequestScoped.html">javax.enterprise.context.RequestScoped</a></li>
+<li><a href="http://docs.oracle.com/javaee/6/api/javax/inject/Inject.html">javax.inject.Inject</a></li>
<li><a href="http://docs.oracle.com/javaee/6/api/javax/inject/Named.html">javax.inject.Named</a></li>
</ul>
Modified: websites/staging/openejb/trunk/content/examples-trunk/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java Wed Aug 15 19:05:01 2012
@@ -18,14 +18,14 @@
*/
package org.superbiz.jsf;
-import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
import javax.inject.Named;
@RequestScoped
@Named
public class CalculatorBean {
- @EJB
+ @Inject
Calculator calculator;
private double x;
private double y;
Modified: websites/staging/openejb/trunk/content/sitemap.html
==============================================================================
--- websites/staging/openejb/trunk/content/sitemap.html (original)
+++ websites/staging/openejb/trunk/content/sitemap.html Wed Aug 15 19:05:01 2012
@@ -405,7 +405,7 @@
<li><a href="tomcat-object-factory.html">Tomcat Object Factory</a></li>
<li><a href="tomcat.html">Tomcat</a></li>
<li><a href="tomee-1.0.0-beta-1.html">Downloads</a></li>
-<li><a href="tomee-and-eclipse.html">tomee-and-eclipse.html</a></li>
+<li><a href="tomee-and-eclipse.html">TomEE and Eclipse</a></li>
<li><a href="tomee-and-hibernate.html">TomEE and Hibernate</a></li>
<li><a href="tomee-and-security.html">Apache TomEE and security</a></li>
<li><a href="tomee-directory-structure.html">tomee-directory-structure.html</a></li>
Modified: websites/staging/openejb/trunk/content/sitemap.xml
==============================================================================
--- websites/staging/openejb/trunk/content/sitemap.xml (original)
+++ websites/staging/openejb/trunk/content/sitemap.xml Wed Aug 15 19:05:01 2012
@@ -695,6 +695,10 @@
<priority>0.9</priority>
</url>
<url>
+ <loc>http://tomee.apache.org/examples-trunk/jsf-cdi-and-ejb/README.html</loc>
+ <priority>0.9</priority>
+ </url>
+ <url>
<loc>http://tomee.apache.org/examples-trunk/jsf-managedBean-and-ejb/README.html</loc>
<priority>0.9</priority>
</url>
Modified: websites/staging/openejb/trunk/content/tomee-and-eclipse.html
==============================================================================
--- websites/staging/openejb/trunk/content/tomee-and-eclipse.html (original)
+++ websites/staging/openejb/trunk/content/tomee-and-eclipse.html Wed Aug 15 19:05:01 2012
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
- <title></title>
+ <title>TomEE and Eclipse</title>
<meta name="description" content="">
<meta name="author" content="">
@@ -70,7 +70,7 @@
};
function twshare () {
window.open(
- "https://twitter.com/intent/tweet?url="+document.URL+"&text=",
+ "https://twitter.com/intent/tweet?url="+document.URL+"&text=TomEE and Eclipse",
'Share on Twitter',
'width=800,height=526');
};
@@ -136,7 +136,7 @@
<div class="page-header">
<small><a href="./index.html">Home</a></small><br>
-<h1>
+<h1>TomEE and Eclipse
<div style="float: right; position: relative; bottom: -10px; ">
<a onclick="javascript:gpshare()" class="gp-share sprite" title="share on Google+">share [gp]</a>
@@ -147,58 +147,78 @@
</h1>
</div>
-<h1>TomEE and Eclipse:</h1>
+<p>Using TomEE in Eclipse is pretty simple since it uses the existing Tomcat 7 server adaptor that comes
+with Eclipse.</p>
-<p>Using TomEE in eclipse is pretty simple. There are no special plugins required. </p>
+<h2>Quick Start:</h2>
-<p>The Tomcat 7 server adaptor would do just fine. But remember this little trick:</p>
+<p>An excellent instructional video with step-by-step instructions on how to install Eclipse, TomEE
+and create/deploy your first project is available on YouTube here: <a href="http://www.youtube.com/watch?v=Lr8pxEACVRI" title="Getting Started with Apache TomEE">Getting Started with Apache TomEE</a>.</p>
-<h3>Method1:</h3>
+<ol>
+<li>Download and install both Apache TomEE and Eclipse. </li>
+<li>Start Eclipse and from the main menu go to File - New - Dynamic Web Project </li>
+<li>Enter a new project name</li>
+<li>In the <strong>Target Runtime</strong> section click on the <strong>New Runtime</strong> button.</li>
+<li>Pick <strong>Apache Tomcat v7.0</strong> and click Next</li>
+<li>Change the <strong>Name</strong> field to <em>TomEE</em> to indicate that this is a TomEE server rather than a Tomcat server.</li>
+<li>Set the <strong>Tomcat installation directory</strong> by clicking the <strong>Browse</strong> button and selecting the folder
+where you extracted TomEE</li>
+<li>Click <strong>Finish</strong> to return to the New Project dialog</li>
+<li>Click <strong>Finish</strong> to complete creating your new Project</li>
+<li>When you're ready to deploy your project, right-click your project and select Run As - Run On Server</li>
+<li>Make sure that the <em>TomEE</em> environment is selected in the <strong>Server runtime environment</strong></li>
+<li>On the <strong>Run on Server</strong> dialog, click the <strong>Always use this server when running this project</strong> checkbox</li>
+<li>Click <strong>Finish</strong> - Eclipse will start TomEE and deploy your project</li>
+</ol>
+
+<h2>Advanced installation</h2>
+
+<ol>
+<li>In Eclipse, click on the <strong>Servers</strong> tab, right click and select New - Server. </li>
+<li>Select <strong>Apache - Tomcat v7.0 Server</strong> and click <strong>Next</strong> </li>
+<li>Set the <strong>Tomcat installation directory</strong> by clicking the <strong>Browse</strong> button and selecting the folder
+where you extracted TomEE</li>
+<li>Add your webapp to the server. Click <strong>Finish</strong>. </li>
+<li>In the <strong>Servers</strong> tab, double click on your server to open up the <strong>Overview</strong> page.
+Click on the <strong>Modules</strong> tab </li>
+<li>Click <strong>Add External Web Module</strong>. In the <strong>Add Web Module</strong> dialog, for document base, browse
+to <code><TomEE>/webapps/tomee</code>. Set <strong>Path:</strong> to <code>/tomee</code>. Uncheck <strong>Auto reloading enabled</strong>. Click OK. </li>
+<li>Return to the <strong>Overview</strong> tab for the server. </li>
+<li>Deselect the <strong>Modules auto reload by default</strong> checkbox.</li>
+<li>If you do not want Eclipse to take control of your TomEE installation, select <strong>Use Workspace Metadata</strong>
+under <strong>Server Locations</strong>. Please review the <em>Workspace Metadata Installation</em> section below for additional steps
+in this scenario. Otherwise, select <strong>Use Tomcat Installation</strong></li>
+<li>Click the Save button in Eclipse so the server configuration gets saved. </li>
+<li>Click on your webapp project, then select Project - clean. Hit OK. This will cause
+Eclipse to clean and rebuild </li>
+<li>In the <strong>Servers</strong> tab, right click on the server and select <strong>Publish</strong>. </li>
+<li>Start the server.</li>
+</ol>
+
+<h3>Workspace Metadata Installation</h3>
+
+<p>If you used <strong>Use Workspace Metadata</strong> in the <strong>Server Locations</strong> definition of the TomEE server,
+you will have to add TomEE specific configuration files to your Servers project in your workspace
+in case you need to change system properties or add containers / resources and have those reflected in the
+server running under Eclipse.</p>
+
+<ol>
+<li>Locate your TomEE server configuration in Workspace / Servers</li>
+<li>Right-click the server project and select <strong>Import</strong></li>
+<li>Select General - File System and click <strong>Next</strong></li>
+<li>Browse to your <code><TomEE>/conf</code> folder</li>
+<li>Select the following files for import: <code>logging.properties</code>, <code>system.properties</code> and <code>tomee.xml</code></li>
+<li>Click <strong>Finish</strong> to import the files.</li>
+<li>In the <strong>Servers</strong> tab, right-click the TomEE server and select <strong>Publish</strong> to publish the files to the
+Eclipse metadata folder</li>
+</ol>
+
+<p>If you need to modify system properties or change your TomEE resources, containers, etc., you now need to make
+those changes in the Workspace / Servers / <code><</code>Your Server<code>></code> location and publish them to the server for
+the changes to take effect.</p>
-<pre><code>1. Download and install an Apache TomEE Web Profile server.
-
-2. In eclipse, click on the Servers tab, right click and select New->Server.
-
-3. Select Apache->Tomcat v7.0 Server and click "Next >"
-
-4. Set the "Tomcat installation directory" to the location of your Apache TomEE Web Profile server installation. Click Next.
-
-5. Add your webapp to the server. Click "Finish".
-
-6. In the Servers tab, double click on your server to open up the "Overview" page. Click on the "modules" tab
-
-7. Choose the 'Use Tomcat installation' option as shown below:
-</code></pre>
-
-<p><img src="http://people.apache.org/~tveronezi/tomee_eclipse_trick.png" height="90%" width="80%"></p>
-
-<p><em>Though this ensures that the tomee web-app is running, the other apps in your <tomcat>/webapps
-are also started up and adds up to the start time</em></p>
-
-<h3>Method 2:</h3>
-
-<pre><code>1. Download and install an Apache TomEE Web Profile server.
-
-2. In eclipse, click on the Servers tab, right click and select New->Server.
-
-3. Select Apache->Tomcat v7.0 Server and click "Next >"
-
-4. Set the "Tomcat installation directory" to the location of your Apache TomEE Web Profile server installation. Click Next.
-
-5. Add your webapp to the server. Click "Finish".
-
-6. In the Servers tab, double click on your server to open up the "Overview" page. Click on the "modules" tab
-
-7. Click "Add External Web Module". In the "Add Web Module" dialog, for document base, browse to <tomeeInstallDir>/webapps/tomee. Set Path: to "/tomee". Uncheck "Auto reloading enabled". Click OK.
-
-8. Click on the <your web app> module and click the "Edit..." button. Uncheck the "Auto reloading enabled" checkbox and click OK. Then click the save button in eclipse so the server configuration gets saved.
-
-9. In eclipse, click on your webapp project, then select "Project->clean". Hit OK. This will cause eclipse to clean and rebuild
-
-10. In the Servers tab, right click on the server and select "Publish".
-
-11. Start the server.
-</code></pre>
+<h3>JSP Hot Deployment</h3>
<p>If jsp changes are not being hot deployed then this is because the jsp servlet is set to development=false in the web.xml file. To allow jsp hot deployment alter this value to true and restart Tomee.</p>
@@ -207,19 +227,12 @@ are also started up and adds up to the s
<pre><code><servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
- <init-param>
- <param-name>fork</param-name>
- <param-value>false</param-value>
- </init-param>
- <init-param>
- <param-name>xpoweredBy</param-name>
- <param-value>false</param-value>
- </init-param>
+ ....
<init-param>
<param-name>development</param-name>
- <param-value>*false*</param-value>
+ <param-value>true</param-value>
</init-param>
- <load-on-startup>3</load-on-startup>
+ ....
</servlet>
</code></pre>