Thursday November 05, 2009
Java EE 6 & GlassFish v3 swimming to Amsterdam - JFall 2009
![]() |
JFall is the annual conference of NL JUG - the 11 year old JUG of Netherlands. This year its happening on Nov 11 at SPANT!
I'll be speaking on Java EE 6 & GlassFish v3 (14:20 - 15:10) there and have lots of cool demos to show through out the talk. And also stay tuned for a brand new demo that shows JavaFX and GlassFish v3 integration. With over 1000 attendees, the conference is already sold out so if you have not registered yet then you have to wait until next year :) |
Here is the list of several Sun sessions:
Here are the sessions that I'd like to attend:
Most of the sessions are in Dutch so may have to fall back on English speaking sessions :(
Here are some quick data points ...
Also trying to arrange a slot in the local Amsterdam Ruby Meetup to talk about JRuby/Rails/GlassFish, lets see if it works out. Otherwise we might somewhere in the hotel lobby :)
And as always, I'm looking for running trails in Amsterdam & Bussum. Any body interested in running together ?
Technorati: glassfish v3 javaee javafx sun amsterdam nljug jfall ams.rb meetup
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Thursday October 08, 2009
TOTD #112: Exposing Oracle database tables as RESTful entities using JAX-RS, GlassFish, and NetBeans
Content available at: http://blog.arungupta.me/2009/10/totd-112-exposing-oracle-database-tables-as-restful-entities-using-jax-rs-glassfish-and-netbeans/.
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Wednesday October 07, 2009
TOTD #111: Rails Scaffold for a pre-existing table using Oracle and GlassFish
Content available at: http://blog.arungupta.me/2009/10/totd-111-rails-scaffold-for-a-pre-existing-table-using-oracle-and-glassfish/.
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Tuesday October 06, 2009
TOTD #110: JRuby on Rails application using Oracle on GlassFish
Content available at: http://blog.arungupta.me/2009/10/totd-110-jruby-on-rails-application-using-oracle-on-glassfish/.
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Friday October 02, 2009
TOTD #109: How to convert a JSF managed bean to JSR 299 bean (Web Beans) ?
Content available at http://blog.arungupta.me/2009/10/totd-109-how-to-convert-a-jsf-managed-bean-to-jsr-299-bean-web-beans/>.
Posted by Arun Gupta in General | Comments[3]
|
|
|
|
|
Wednesday September 23, 2009
Content available at: http://blog.arungupta.me/2009/09/totd-104-glassfish-v3-monitoring-how-to-monitor-a-rails-app-using-asadmin-javascript-jconsole-rest/
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Friday September 18, 2009
Popular Ruby-on-Rails applications on GlassFish v3 – Redmine, Typo, Substruct
Content available at: http://blog.arungupta.me/2009/09/redmine-typo-mephisto-on-glassfish-v3/
Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Wednesday September 16, 2009
FishCAT – GlassFish v3 Community Acceptance Testing
Content available at http://blog.arungupta.me/2009/09/fishcat-glassfish-v3-community-acceptance-testing/.
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Tuesday September 15, 2009
TOTD #103: GlassFish v3 with different OSGi runtimes – Felix, Equinox, and Knoplerfish
Content available at http://blog.arungupta.me/2009/09/totd-103-glassfish-v3-with-different-osgi-runtimes-felix-equinox-and-knoplerfish/.
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Monday September 14, 2009
TOTD #102: Java EE 6 (Servlet 3.0 and EJB 3.1) wizards in Eclipse
Content available at http://blog.arungupta.me/2009/09/totd-102-java-ee-6-servlet-3-0-and-ejb-3-1-wizards-in-eclipse/.
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Friday September 04, 2009
TOTD #101: Applying Servlet 3.0/Java EE 6 “web-fragment.xml” to Lift – Deploy on GlassFish v3
TOTD #100 explained how to deploy Lift framework applications on GlassFish v3. As explained in TOTD #91, Java EE 6 defines how the framework configuration deployment descriptor can be defined in “META-INF/web-fragment.xml” in the JAR file of the framework instead of mixing it with "WEB-INF/web.xml" which is intended for application deployment descriptor aspects.
This Tip Of The Day (TOTD) explains how to leverage ”web-fragment.xml” to deploy a Lift application on a Java EE 6 compliant container. The original "lift-*.jar" files are untouched and instead a new JAR file is included that contains only the framework configuration deployment descriptor.
The generated "web.xml" from TOTD #100 looks like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<filter>
<filter-name>LiftFilter</filter-name>
<display-name>Lift Filter</display-name>
<description>The Filter that intercepts lift calls</description>
<filter-class>net.liftweb.http.LiftFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LiftFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
The deployment descriptor defines a Servlet Filter (LiftFilter) that registers the Lift framework with the Web container. And then it defines a URL mapping to "/*". All of this information is required by the Lift framework for request dispatching. And so that makes this fragment suitable for "web-fragment.xml".
Here are simple steps to make this change:
<dependencies>
. . .
<!– web-fragment –>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>lift-web-fragment</artifactId>
<version>1.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
. . .
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>
This file contains only “META-INF/web-fragment.xml” with the following content:
<web-fragment>
<filter>
<filter-name>LiftFilter</filter-name>
<display-name>Lift Filter</display-name>
<description>The Filter that intercepts lift calls</description>
<filter-class>net.liftweb.http.LiftFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LiftFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-fragment>
<build>
. . .
<plugins>
. . .
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
That's it, now now you can create a WAR file using “mvn package” and deploy this web application on GlassFish v3 latest promoted build (61 as of today) as explained in TOTD #100.
Technorati: totd glassfish v3 lift scala javaee6 servlet web-fragment
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Thursday September 03, 2009
TOTD #100: Getting Started with Scala Lift on GlassFish v3
Content available at: http://blog.arungupta.me/2009/09/totd-100-getting-started-with-scala-lift-on-glassfish-v3/.
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Wednesday August 19, 2009
GlassFish
Monitoring allows you to monitor the state of various runtime
components of the application server. This information is used to
identify performance bottlenecks and tuning the system for optimal
performance, to aid capacity planning, to predict failures, to do root
cause analysis in case of failures and sometimes to just ensure that
everything is functioning as expected.
GlassFish Management allows you to manage the running Application
Server instance such as query/create/delete resources (JDBC, JMS, etc),
stop/restart the instance, rotate the log and other similar functions.
GlassFish v3 exposes Monitoring and Management data using a REST
Interface. This Tip
Of The Day (TOTD) shows how
to play with this new functionality. Rajeshwar's blog
has lot of useful information on this topic.
Most of the functionality available in
web-based Admin Console and CLI (asadmin) is now available using the
REST interface. Both of these are pre-built
tools that ships with the GlassFish bundle. The REST interface is a
lower level API that enables toolkit developers and IT administrators
to write their custom scripts/clients using language of their choice
such as Java, JavaScript, Ruby or Groovy.
The default URL for the REST interface of monitoring is
"http://localhost:4848/monitoring/domain" and for the management is
"http://localhost:4848/management/domain". Each URL provides an XML,
JSON and HTML representation of the
resources. If a web browser is used then a HTML representation is
returned and displayed nicely in the browser. Rajeshwar's
blog described a Java
client written using Jersey
Client APIs that can be used to make all the
GET/PUT/POST/DELETE requests. This blog will use something more basic,
and extremely popular,
to make all the RESTful invocations - cURL.
At this time the monitoring resources are read-only (GET) and
management can
be done using GET/POST/DELETE methods. POST is used for creating and
updating resources/objects and the updates can be partial.
Lets get started.
| ~/tools/glassfish/v3/2023/glassfishv3 >./bin/asadmin start-domain
--verbose Aug 19, 2009 9:52:45 AM com.sun.enterprise.admin.launcher.GFLauncherLogger info INFO: JVM invocation command line: /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java -cp . . . INFO: felix.fileinstall.dir /Users/arungupta/tools/glassfish/v3/2023/glassfishv3/glassfish/domains/domain1/autodeploy-bundles Aug 19, 2009 9:53:05 AM INFO: felix.fileinstall.debug 1 Aug 19, 2009 9:53:05 AM INFO: felix.fileinstall.bundles.new.start true |
| ~/tools/glassfish/v3/2023/glassfishv3 >curl -H "Accept:
application/json" http://localhost:4848/monitoring/domain -v * About to connect() to localhost port 4848 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4848 (#0) > GET /monitoring/domain HTTP/1.1 > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 > Host: localhost:4848 > Accept: application/json > < HTTP/1.1 200 OK < Content-Type: application/json < Transfer-Encoding: chunked < Date: Wed, 19 Aug 2009 17:40:29 GMT < {Domain:{},"child-resources":["http://localhost:4848/monitoring/domain/server"]} * Connection #0 to host localhost left intact * Closing connection #0 |
| {Domain:{},"child-resources":["http://localhost:4848/monitoring/domain/server"]} |
| ~/tools/glassfish/v3/2023/glassfishv3 >curl -H "Accept: application/xml"
http://localhost:4848/monitoring/domain -v * About to connect() to localhost port 4848 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4848 (#0) > GET /monitoring/domain HTTP/1.1 > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 > Host: localhost:4848 > Accept: application/xml > < HTTP/1.1 200 OK < Content-Type: application/xml < Transfer-Encoding: chunked < Date: Wed, 19 Aug 2009 17:43:51 GMT < <Domain> <child-resource>http://localhost:4848/monitoring/domain/server</child-resource> </Domain> * Connection #0 to host localhost left intact * Closing connection #0 |
| <Domain> <child-resource>http://localhost:4848/monitoring/domain/server</child-resource> </Domain> |

| </tools/glassfish/v3/2023/glassfishv3
>curl -H "Accept:
application/json" http://localhost:4848/monitoring/domain/server -v * About to connect() to localhost port 4848 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4848 (#0) > GET /monitoring/domain/server HTTP/1.1 > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 > Host: localhost:4848 > Accept: application/json > < HTTP/1.1 200 OK < Content-Type: application/json < Transfer-Encoding: chunked < Date: Wed, 19 Aug 2009 17:56:41 GMT < {Server:{},"child-resources":["http://localhost:4848/monitoring/domain/server/webintegration", "http://localhost:4848/monitoring/domain/server/transaction-service", "http://localhost:4848/monitoring/domain/server/network", "http://localhost:4848/monitoring/domain/server/jvm", "http://localhost:4848/monitoring/domain/server/web", "http://localhost:4848/monitoring/domain/server/realm", "http://localhost:4848/monitoring/domain/server/http-service"]} * Connection #0 to host localhost left intact * Closing connection #0 |

| ~/tools/glassfish/v3/2023/glassfishv3 >curl -X OPTIONS
http://localhost:4848/management/domain -v * About to connect() to localhost port 4848 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4848 (#0) > OPTIONS /management/domain HTTP/1.1 > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 > Host: localhost:4848 > Accept: */* > < HTTP/1.1 200 OK < Content-Type: application/json < Transfer-Encoding: chunked < Date: Wed, 19 Aug 2009 18:07:14 GMT < { "Method":"GET" "Method":"PUT" } * Connection #0 to host localhost left intact * Closing connection #0 |
| ~/tools/glassfish/v3/2023/glassfishv3 >curl -H "Accept:
application/json" http://localhost:4848/management/domain -v * About to connect() to localhost port 4848 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4848 (#0) > GET /management/domain HTTP/1.1 > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 > Host: localhost:4848 > Accept: application/json > < HTTP/1.1 200 OK < Content-Type: application/json < Transfer-Encoding: chunked < Date: Wed, 19 Aug 2009 18:14:46 GMT < {Domain:{"log-root" : "${com.sun.aas.instanceRoot}/logs","application-root" : "${com.sun.aas.instanceRoot}/applications","locale" : "","version" : "re-continuous"},"child-resources":["http://localhost:4848/management/domain/configs", "http://localhost:4848/management/domain/resources","http://localhost:4848/management/domain/servers", "http://localhost:4848/management/domain/property","http://localhost:4848/management/domain/applications", "http://localhost:4848/management/domain/system-applications","http://localhost:4848/management/domain/stop", "http://localhost:4848/management/domain/restart","http://localhost:4848/management/domain/uptime", "http://localhost:4848/management/domain/version","http://localhost:4848/management/domain/rotate-log", "http://localhost:4848/management/domain/host-port"]} * Connection #0 to host localhost left intact * Closing connection #0 |
| curl -H "Accept: application/json" http://localhost:4848/management/domain/host-port -v |
| {"GetHostAndPort":{"value" : "dhcp-usca14-132-79.SFBay.Sun.COM:8080"}} |
| curl -H "Accept: application/json" http://localhost:4848/management/domain/system-applications/application/__admingui -v |
| {__admingui:{"libraries" : "","availability-enabled" : "false","enabled" : "true","context-root" : "","location" : "${com.sun.aas.installRootURI}/lib/install/applications/__admingui","description" : "","name" : "__admingui","directory-deployed" : "true","object-type" : "system-admin"},"child-resources":["http://localhost:4848/management/domain/system-applications/application/__admingui/module"]} |
| curl -H "Accept: application/json" http://localhost:4848/management/domain/configs/config/server-config/monitoring-service/module-monitoring-levels -v |
| {ModuleMonitoringLevels:{"transaction-service" : "OFF","ejb-container" : "OFF","jdbc-connection-pool" : "OFF","orb" : "OFF","http-service" : "OFF","connector-connection-pool" : "OFF","jms-service" : "OFF","connector-service" : "OFF","jvm" : "OFF","thread-pool" : "OFF","web-container" : "OFF"},"child-resources":[]} |
| ~/tools/glassfish/v3/2023/glassfishv3 >curl -X POST -d
"web-container=ON" -H "Accept: application/json"
http://localhost:4848/management/domain/configs/config/server-config/monitoring-service/module-monitoring-levels
-v * About to connect() to localhost port 4848 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4848 (#0) > POST /management/domain/configs/config/server-config/monitoring-service/module-monitoring-levels HTTP/1.1 > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 > Host: localhost:4848 > Accept: application/json > Content-Length: 16 > Content-Type: application/x-www-form-urlencoded > < HTTP/1.1 200 OK < Content-Type: application/json < Transfer-Encoding: chunked < Date: Wed, 19 Aug 2009 22:01:31 GMT < * Connection #0 to host localhost left intact * Closing connection #0 "http://localhost:4848/management/domain/configs/config/server-config/monitoring-service/module-monitoring-levels" updated successfully |
| ~/tools/glassfish/v3/2023/glassfishv3 >curl -H "Accept:
application/json"
http://localhost:4848/management/domain/configs/config/server-config/monitoring-service/module-monitoring-levels
-v * About to connect() to localhost port 4848 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4848 (#0) > GET /management/domain/configs/config/server-config/monitoring-service/module-monitoring-levels HTTP/1.1 > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 > Host: localhost:4848 > Accept: application/json > < HTTP/1.1 200 OK < Content-Type: application/json < Transfer-Encoding: chunked < Date: Wed, 19 Aug 2009 22:36:47 GMT < * Connection #0 to host localhost left intact * Closing connection #0 {ModuleMonitoringLevels:{"transaction-service" : "OFF","ejb-container" : "OFF","jdbc-connection-pool" : "OFF","orb" : "OFF","http-service" : "OFF","connector-connection-pool" : "OFF","jms-service" : "OFF","connector-service" : "OFF","jvm" : "OFF","thread-pool" : "OFF","web-container" : "ON"},"child-resources":[]} |
| curl -H "Accept: application/json" http://localhost:4848/management/domain/stop -v |
| curl -H "Accept: application/json" http://localhost:4848/management/domain/restart -v |
| curl -H "Accept: application/json" http://localhost:4848/management/domain/resources -v |
| {Resources:{},"child-resources":["http://localhost:4848/management/domain/resources/jdbc-connection-pool", "http://localhost:4848/management/domain/resources/jdbc-resource"]} |
| curl -H "Accept: application/json" http://localhost:4848/management/domain/resources/jdbc/connection-pool -v |
| {JdbcConnectionPool:{},"child-resources":["http://localhost:4848/management/domain/resources/jdbc-connection-pool/__TimerPool", "http://localhost:4848/management/domain/resources/jdbc-connection-pool/DerbyPool"]} |
| curl "Accept: application/json" http://localhost:4848/management/domain/resources/jdbc-resource -v |
| {JdbcResource:{},"child-resources":["http://localhost:4848/management/domain/resources/jdbc-resource/jdbc/__TimerPool", "http://localhost:4848/management/domain/resources/jdbc-resource/jdbc/__default"]} |
| curl -X OPTIONS -H "Accept: application/json" http://localhost:4848/management/domain/resources/jdbc-resource -v |
| { "Method":"POST", "Message Parameters":{ "id":{"Acceptable Values":"","Default Value":"","Type":"class java.lang.String","Optional":"false"}, "enabled":{"Acceptable Values":"","Default Value":"true","Type":"class java.lang.Boolean","Optional":"true"}, "description":{"Acceptable Values":"","Default Value":"","Type":"class java.lang.String","Optional":"true"}, "target":{"Acceptable Values":"","Default Value":"","Type":"class java.lang.String","Optional":"true"}, "property":{"Acceptable Values":"","Default Value":"","Type":"class java.util.Properties","Optional":"true"}, "connectionpoolid":{"Acceptable Values":"","Default Value":"","Type":"class java.lang.String","Optional":"false"} } "Method":"GET" |
| ~/tools/glassfish/v3/2023/glassfishv3 >curl -d
"id=jdbc/sample&connectionpoolid=DerbyPool"
http://localhost:4848/management/domain/resources/jdbc-resource -v * About to connect() to localhost port 4848 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4848 (#0) > POST /management/domain/resources/jdbc-resource HTTP/1.1 > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 > Host: localhost:4848 > Accept: */* > Content-Length: 42 > Content-Type: application/x-www-form-urlencoded > < HTTP/1.1 201 Created < Content-Type: text/html < Transfer-Encoding: chunked < Date: Wed, 19 Aug 2009 20:45:51 GMT < * Connection #0 to host localhost left intact * Closing connection #0 "http://localhost:4848/management/domain/resources/jdbc-resource/jdbc/sample" created successfully. |
| curl -H "Accept: application/json" http://localhost:4848/management/domain/resources/jdbc-resource -v |
| {JdbcResource:{},"child-resources":["http://localhost:4848/management/domain/resources/jdbc-resource/jdbc/__TimerPool", "http://localhost:4848/management/domain/resources/jdbc-resource/jdbc/__default", "http://localhost:4848/management/domain/resources/jdbc-resource/jdbc/sample"]} |
| ~/tools/glassfish/v3/2023/glassfishv3 >curl -H "Accept: application/xml"
http://localhost:4848/management/domain -v * About to connect() to localhost port 4848 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4848 (#0) > GET /management/domain HTTP/1.1 > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 > Host: localhost:4848 > Accept: application/xml > < HTTP/1.1 200 OK < Content-Type: application/xml < Transfer-Encoding: chunked < Date: Wed, 19 Aug 2009 18:17:07 GMT < <Domain log-root="${com.sun.aas.instanceRoot}/logs" application-root="${com.sun.aas.instanceRoot}/applications" locale="" version="re-continuous"> <child-resource>http://localhost:4848/management/domain/configs</child-resource> <child-resource>http://localhost:4848/management/domain/resources</child-resource> <child-resource>http://localhost:4848/management/domain/servers</child-resource> <child-resource>http://localhost:4848/management/domain/property</child-resource> <child-resource>http://localhost:4848/management/domain/applications</child-resource> <child-resource>http://localhost:4848/management/domain/system-applications</child-resource> <child-resource>http://localhost:4848/management/domain/stop</child-resource> <child-resource>http://localhost:4848/management/domain/restart</child-resource> <child-resource>http://localhost:4848/management/domain/uptime</child-resource> <child-resource>http://localhost:4848/management/domain/version</child-resource> <child-resource>http://localhost:4848/management/domain/rotate-log</child-resource> <child-resource>http://localhost:4848/management/domain/host-port</child-resource> * Connection #0 to host localhost left intact * Closing connection #0 |

Posted by Arun Gupta in General | Comments[8]
|
|
|
|
|
Monday August 17, 2009
TOTD
#93
showed how to get started with Java EE 6
using NetBeans
6.8 M1 and
GlassFish v3 by
building a simple Servlet 3.0 + JPA 2.0 web
application. TOTD
#94 built upon it by using Java Server Faces 2 instead of
Servlet 3.0 for displaying the results. However we are still using a
POJO
for all the database interactions. This works fine if we are only
reading values from the database but that's not how a typical web
application behaves. The web application would typically perform all
CRUD operations. More typically they like to perform one or more CRUD
operations within the context of a transaction. And how do you do
transactions in the context of a web application ? Java EE 6 comes to
your rescue.
The EJB 3.1
specification (another new specification in Java EE 6) allow
POJO classes to be annotated with @EJB and bundled within
WEB-INF/classes of a WAR file. And so you get all transactional
capabilities in your web application very easily.
This Tip
Of The Day (TOTD) shows how
to enhance the application created in TOTD #94 and use EJB 3.1 instead
of the JSF managed bean
for
performing the business logic. There are two ways to achieve this
pattern as described below.
Lets call this TOTD #95.1
| @javax.ejb.Stateless @ManagedBean public class StateList { @PersistenceUnit EntityManagerFactory emf; public List<States> getStates() { return emf.createEntityManager().createNamedQuery("States.findAll").getResultList(); } } |


| @Stateless public class StateBeanBean { @PersistenceUnit EntityManagerFactory emf; public List<States> getStates() { return emf.createEntityManager().createNamedQuery("States.findAll").getResultList(); } } |
| @ManagedBean public class StateList { @EJB StateBeanBean bean; public List<States> getStates() { return bean.getStates(); } } |
| @Stateless public class StateBeanBean { @PersistenceContext EntityManager em; public List<States> getStates() { return em.createNamedQuery("States.findAll").getResultList(); } } |

Posted by Arun Gupta in General | Comments[1]
|
|
|
|
|
Friday August 14, 2009
TOTD
#93
showed how to get started with Java EE 6
using NetBeans
6.8 M1 and
GlassFish v3 by
building a simple Servlet 3.0 + JPA 2.0 web
application. JPA 2.0 + Eclipselink was used for the database
connectivity
and Servlet 3.0 was used for displaying the results to the user. The
sample demonstrated how the two technologies can be mixed to create a
simple web application. But Servlets are meant for server-side
processing rather than displaying the results to end user. JavaServer
Faces 2 (another new specification in Java EE 6) is designed
to fulfill
that purpose.
This Tip
Of The Day (TOTD) shows how
to enhance the application created in TOTD #93 and use JSF 2 for
displaying the results.


| package server; import java.util.List; import javax.faces.bean.ManagedBean; import javax.persistence.EntityManagerFactory; import javax.persistence.PersistenceUnit; import states.States; /** * @author arungupta */ @ManagedBean public class StateList { @PersistenceUnit EntityManagerFactory emf; public List<States> getStates() { return emf.createEntityManager().createNamedQuery("States.findAll").getResultList(); } } |
| Show States |
|
<h:dataTable var="state" value="#{stateList.states}"
border="1"> <h:column><h:outputText value="#{state.abbrev}"/></h:column> <h:column><h:outputText value="#{state.name}"/></h:column> </h:dataTable> |


Posted by Arun Gupta in General | Comments[3]
|
|
|
|
|
Today's Page Hits: 2760
Total # blog entries: 994
| « November 2009 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
1 | 2 | 4 | 6 | 7 | ||
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | |||||
| Today | ||||||