Wednesday, 3 February 2010

GlassFish v3 and Java EE 6 Sun-Oracle roadshow - key notes

GlassFish Roadshow 2010 - London 03-02-2010

The following is some notes I took down during the above event.

In brief summary of GlassFish v3 and Java EE 6, here are some of the key takeaways:

  • GlassFish v3 continues to be developed and supported, as the Java EE 5 & 6 RI app server
  • GlassFish v3 currently has no clustering, but offers OSGi modularization and extensibility
  • Supports and takes advantage of new Java EE 6 specifications
  • Big push on modularity and flexibility in both GlassFish and Java EE 6
  • Java EE 6 supports annotation based EJBs, RESTful web services
  • Java EE 6 greatly simplified configuration, optional web-inf.xml etc
  • Java EE 6 simplied simple class EJBs and improved JPA specification
  • Ongoing road-map for GlassFish, details TBA later this year


Java EE 6 (Roberto Chinnici):

Released Dec 10 2009

Key new features: New API, Web profiles, Pluggabiliy, dependancy injection

New technologies:
  • Jax-RS 1.1
  • Bean validation 1.0
  • DI 1.0
  • CDI 1.0
  • Managed beans 1.0
Closed down gap between EJB and POJO with unification and annotations

CDI works with POJO and EJB classes

Unification of platform types, more uniform programming model

  • EJB 3.1
  • JPA 2.0
  • Servlet 3.0
  • JSF 2.0
  • Connectors 1.6
  • Interceptors 1.1
  • JAX-WS 2.2
  • JSR-109 1.3
  • JSP 2.2
  • JSR-250 1.1
  • JACC 1.4
  • JASPIC 1.1

Key goal in Java EE 6 - flexibility, pruning, extensibility and web profiles


Profiles:

Bundles of technologies targeting specific classes of applications
Decoupled from each other and the platform
Guarantees compatibility of required technologies, individually and in combination - must satisfy all joint requirements


Web Profile:

Modern Java web application stack
First profile to be definite
Mid sized, fully functional (expected 80% web-app coverage), add additional components via extensibility (such as web services API, 3rd party frameworks)


Web profile contents:

Servlet, JSP/EL, JSTL, JSF, Bean Validation, EJB Lite, JPA, JTA, Di, CDI, Managed beans, Interceptors, JSR-250


Pruning:

Goal - to address bloat concerns

2 step process:
Declare components as "Proposed optional"
The make fully optional for the next release

Proposed optional technologies:

JAX-RPC (JAX-WS)
EJB 2.x Entity beans (JPA entity classes)
JAXR (little use)
JSR-88 (deployment, tools API - not used)

* Don't use - use replacements / alternatives


Pluggability / extensibility:

Focus on web tier
Level playing field for 3-rd party libraries and frameworks
Two major extensibility points: Servlets and CDI
Simplify packaging of web-apps
Zero-configuration!


Modular Web applications:

Libraries can contain web-fragment.xml descriptor
web.xml is now optional
Can server resources out of jars with: /META-INF/resources

e.g.
/WEB-INF/lib/catalog.jar
/META-INF/resources/catalog/books.html

e.g. Dojo jar in resources


Web fragments in servlet 3.0:

META-INF.web-fragment.xml

same structure as web.xml, can override in web.xml


Servlet container pluggability:

ServletContainerInitializer interface implements by extensions

@HandlesTypes to declare interest in on or more annotation types

ServletContext now contains method to dynamically register servlets and filters
i.e. ServletContext API has been extended

Registered using META-INF/services


onStartup method gets called with a Set of classes available

** Can only add services at startup, not dynamically once running


Asynchronous HTTP processing:

New programming model for async request processing
e.g. Comet, char, push apps
Opt-in model
Threads are managed by the container

@WebServlet(asyncSupported=true)
public class MyServlet extends HTTPServlet {

}

Goal - Decouple requests from threads

* Changes to the way filters work - thread not attached to the socket, response not written. Filters modified to make safe - option than can be turned on to identify asyncSupported=true
- do this on servlet and any filter involved in the chain

Ideal when waiting for some external resource etc.
Low level API - not very elegant
Idea is that frameworks will use this - see for example Atmosphere framework which is based on annotations - under the hood this async API is used.


JSF 2.0:

Facelet as a standard view declaration language
Composite components
Ajax (declarative and programmatic) e.g. f:ajax tag
Partial state saving (track deltas and sends changes in response, previously all would have been sent even if not changed!)
System events e.g. f:event tag
Resources
Validation e.g. new f:validateBean tag (better integration, validation API. can handle multiple errors, not first one at a time!)


EJB 3.1:

@Singleton beans
@Startup beans (invoked at app startup, works well with Singleton pattern)
@Asynchronous invocations (biggest change, allows non-blocking sync EJB invocations as first class call. Method must be either void or return a Future object)
No interface view (bean impl does not need an interface anymore, now 1 class = 1 EJB!)
Define EJBs directly inside a web app, inside a war file
New API - EJBContainer API works on Java SE, can bootstrap an EJB container in a Java SE application (ideal for testing/development, could be useful in client applications)


Simplified packaging:

EJB class directly into the war file
Previously must built an EJB jar to be included


EJB 3.1 lite:

A subset of EJB 3.1
All types of session beans (stageful, stateless, singleton) - other bean types not supported (timer, entity etc)
Declarative transactions and security
Interceptors
ejb-jar.xml descriptor allows (is optional, probably not useful)

* Class loading, new visibility rules in Java EE spec

Slight differences in class loading rules - if in doubt check the specs


New JNDI Namespaces:

Until now - only java:comp
Now added:
java:module - a module (war, ejb, jar)
java:app - an application
java:global the whole server / cluster

e.g. @Resource(lookup="java:app/CustomerDB") DataSource db;

EJB components have global names now:

e.g. java:global/app1/module2/SomeBeanIcom.acme.Foo

Helps solve problem of remote EJB communication in same app server


Dependency injection (DI):

Combination of DI 1.0 / CDI 1.0
New @Inject annotation
@Inject @LoggedIn User user; (@LoggedIn = "Which one", User = "What")
Beans auto-discovered at start-up
Extensible
Injection metamodel (BeanManager API)
@Resource still available for container resources

* Identified by type and qualifiers (no longer just a string name alone)

* No bean declaration as per Spring declaration, bean discovery at startup
* Injection errors all reported at startup, rather than on use at runtime

Beans can be associated with session - i.e. loggedIn
Beans can be more ephemeral, i.e. for request
Beans can be more long lived, i.e. shopping cart conversation flows
Can add class for beans on the fly, via APIs at runtime

Example of DI annotation:

@Inject
CheckoutHandler(
@LoggedIn User user,
@Reliable @PayBy(CREDIT_CARD)
PaymentProcessor processor,
@Default Cart cart)

* Note that constructor injection is possible
* Note different scopes, PaymentProcessor is probably conversation scope, LoggedIn is session, PaymentProcessor is probably application scope singleton

* Instance and state management handled "for free" by framework/APIs

JAX-RS 1.1:
Already widely adoped
Really a high level HTTP API
Annotation-based programming model
Programmatic API when needed

* think of it as the new HTTP level API (higher level than HTTPServlets, remove low level detail and tedium)

Jax-RS resource class, example:

Identified by the @Path annotation

@Path("widgets./{id}")
@Produces("application/widgets+xml")
public class WidgetResource {
pubic WidgetResource(@PathParam("id") String id { … }

@GET
Widget getWidget() { … }
}

Provides higher level HTTP handling, more declarative, better match with conceptual needs of developer


Bean Validation 1.0:

Integrated with JSF, JPA
Constraints represented by annotations

e.g.

@NotNull
@Size(max=40)
String address;

Fully extensible
@Email
String recipient;

Validation API's for validation directly, create a new validation object etc
Validation of trees of objects is possible (including loops)


JPA 2.0:

Supported for collections of basic types and embeddable objects
JPQL enhancements e.g. CASE WHEN, NULLIF
Pessimistic locking added (annotations added)
Criteria API for dynamic query construction

Criteria API: Uses the canonical metamodel classes

CriteriaBuilder, create criteria
CriterialQuery, typed criteria

Strongly types checking, type parasitised equals checking, compiler errors generated if query does not have the right types etc, so robust and safe query (rather than say String SQL construction directly).

Connectors 1.6 added too (not covered in any detail)


Summary overview:

Improved, more powerful, more flexible, more extensible, easier to use

http://java.sun.com/javaee


--

GlassFish V3 (Alexis Moussine-Pouchkine):

Java EE 6 Reference Implementation (RI)

Geographic download map:

http://maps.glassfish.org/server

Healthy increase in downloads and usage over time

GlassFish V1 first shipped 2006, reusing much from Tomcat

V2.1.1 Nov 2009, V3 (Java EE 6) Dec 10th 2009

GlassFish V3 Open Source CDDL, GPL (with 'classpath exception') licensing

Java EE 5 & 6, enterprise quality - full support is available.

Sub projects:
  • Jersey (JAX-RS)
  • Metro (JAX-WS)
  • Grizzly (NIO)
  • Atmosphere (Comet)
  • OpenMQ (JMS)
  • and scripting jRoR Grails and now Django (python)

Main difference from Tomcat - Grizzly core (rewritten)

Netbeans 6.8 tooling
Support available in Eclipse too

GlassFish development continues
Support contracts through to 2017+ unlimited
Remains the Java EE reference implementation
Now also sold with WebLogic and standalone

Roadmap -> expected soon for remaining year

Don't have to deliver as much standard runtime / frameworks jars as part of the application jar

Netbeans in-place edit of classes, incremental compilation, deploy on save, GF v3 preserves session across redeployments(!)

Session retention:
Deployment option to maintain statefull sessions across re-deployments!


GlassFish v3 key goals:

Modular and dynamic
Modular: Apache Felix (OSGi)
Extensible: HK2 (100k kernel)
Still very fast!

Centralized configuration, modules configured through centralised control


Key Features:

No ejbjar.xml needed, no web.xml, annotation driven, EJB's as single classes

Declarative annotations:

@Stateless annotation for class stateless bean
@Schedule annotation for timers

Eclipse - GlassFish tool bundle for eclipse (contains everything!)

Ultra fast auto-deploy of all Java EE and static artefacts

Maven support: mvn gf:run gf:start gf-deploy

Containers can be added / removed dynamically


New API for EJB testing (EJBContainer):

Example:

EJBContainer c = EJBContainer.createEJBContainer();
Context ice = c.getContext();
SimpleEjb ejb (SImpleEjb)ic.lookup("java:global/sample/SimpleEjb");
ejb.sayHello();


GlassFish "Embedded" - allows all features of GlassFish to be automated

org.glassfish.api.embedded.Server server;
Server.Build builder = new Server.Builder();
server = builder.build();
ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
server.addContainer(b);

File archive = new File("hello.war");
server.getDeployer().deply(archive);

i.e. Ship app server inside an application!


OSGi:

GlassFish runs on top of OSGi (Felix by default)
Also runs unmodified on Knopflerfish and Equinox
GlassFish ships with 200+ bundles
Can run without OSGi (static mode based on HK2)
Can use OSGi management tools (CLI or Web)

Any OSGi bundles will run in GlassFish v3
Drop it in glassfish/modules

Servlets can get hold of OSGi bundles (using @Resource DI)


Update centre:

Graphical tool (GlassFish does not need to be started), available in web admin console
CLI version available
Was in v2.x but not from admin console


RESTful admin API:

JAX-RS/Jersey + Grizzly to provide REST interfaces to
Configure runtime (via GET, POST, DELETE)
Invoke commands (restart, stop, deploy, etc)
Monitoring (GET only)
Log rotation etc

e.g. Available from:
localhost:4848/management/domain
localhost:4848/monitoring/domain


Further advantages:

Dynamic language support via modules:
Rails, Grails, Django, Scala/Lift


Comet:
Cometd/Bayeux
Atmosphere

Full support for:
mod_jk
WebDAV, CGI, SSI

OpenMQ 4.4

Web Services Metro 1.4
.NET 3.5 interoperability


v3 Clustering:
Lower priority after Java EE 6 and modularity, so not yet...
Clustering is not built in as per v2
More similar to v1, single instance
Have to take on own clustering (load balancing, deployment)
See roadmap for details...


Doing More with GlassFish (Steve Elliott):

GlassFish v3 - Management and monitoring

Management:

User Friendly, pluggable and extensible for administration
Feature rich Admin console (GUI)
Easy to use Command Line Interface (CLI)
RESTful management and monitoring API
Fully documented AMX API (app server management API)
All management features built on AMX API

OSGi, load on demand = fast initial start up

v3 AdminConsole:
Frame-set removed, now Ajax based pages
Pluggable console (admin panes, trees etc loaded on demand)


Monitoring:

Lightweight prode architecture
Ad hoc monitoring in Production
Client-scripting (JavaScript)
DTrace integration on Solaris (similar to OS probes, uniform tracing experience with MySQL etc)
Extensibility / Pluggability

No overhead when there is no monitoring
Allows Monitoring to be turned on in a production environment with minimal impact
Generate and listen to only interested
Turn on monitoring when needed
BTrace integration
Portable and dynamic


Instrumentation:

Modules expose probes
POJO with annotations
XML

Modules register probe listeners

In code, POJO annotations can be used

@ProbeProvider(providername="glassfish", modulename="web")

ProbeProvider XML configuration also possible

ProbeListeners
JMX exposed

@ManagedAttribute(id="jspcount")


OSGi:

big move to OSGi technology
Big move to more modular development approach

Demands and enforces stronger modularity

OSGi is largely under the covers
Visible to GlassFish developers, but not to GlassFish users


Service based architecture:

Core modules loaded on app startup
Rest loaded on demand

Module Management:
add, remove, update installed modules

OSGi as a container


Web services - Metro : JAX-WS / Jersey : JAX-RS

Metro - SOAP-based web services stack
Built into GlassFish
Works with any servlet 2.5 compliant web container
WebLogic, WebSphere, JBoss, Tomcat
Also standalone
Advances interoperability with .NET 3.x/4.0

Project Tango - focused on interoperability with .NET

JAXB based XML Data Binding (XSD, XPATH)

SOAP Messaging MTOM etc

Bi-directional interoperability with .NET (Java or .NET as client or server)


Standards:

JCP: JAX-WS 2.2 & JAXB 2.2
W3C SPAP 1.1/1.2 WSDL 1.1, WS-Addressing
… etc


JAX-RS:

JAX-RS 1.1 is final and part of EE6

Not a web profile
but included with GlassFish v3 web profile
JCP 311
Spec - JSR 311

http://www.oracle.com/java
Contains links to GlassFish etc


.

40 comments:

資料 said...

很耐斯的部落格,留言支持你繼續加油........................................

開心唷 said...

pleasure to find such a good artical! please keep update!! ........................................

任安任安 said...

都都成人站哈雷聊天室919sex色片直播網ao3美女圖sexsun comaaaaa7777788卡提諾成人日本a片-aa片免費看av999免費影片250av女優免費影片日本影片自拍日本影片區日本巨乳a片日本屎尿片日本少女寫真集dvd專賣店日本學生偷情影片日本學生寫真集日本寫真美女 dvd日本寫真集 rain日本寫真集女星美女 視訊美女 視訊免費線上成人影片戀愛ing聊天室免費聊天firework嘿咻kiss168cu成人bt情色 網援交友留言聊天室找一夜666成人無碼免費girl5320視訊做愛色美媚歐美模特兒寫真天空交友八國聯軍成人曼雪兒成人文學小說曼雪兒成人文學曼雪兒情色文學成人小說曼雪兒成人曼雪兒成人免費小說

林淑凡 said...

我從來不認為不同意我的看法就是冒犯........................................

陳石薇 said...

may the blessing be with you.........................................

0221DallasCockburn said...

wonderful...................................................

PorshaCoghlan梁子珠 said...

I do like ur article~!!! ........................................

巧生 said...

haha~ funny! thank you for your share~ ........................................

俊冠樺宇 said...

來看看你囉~blog很棒! ........................................

瑋玲 said...

I love readding, and thanks for your artical.........................................

韋于倫成 said...

肯定與支持你!!!加油囉~........................................

517SeritaG_Jamar0 said...

微風成人wellen 台灣無碼女優 av女優短片 性趣 十足,性愛教學 85cc成人片 av美美色網影片 成人小遊戲 成人 影片,性愛故事 後宮視訊聊天 正妹交友hibb tw 免費成人情色 線上看av 5278影片網 免費線上 aa 片試看成人論壇 tvnet 影音聊天室 八大娛樂網 ut387視訊聊天 百人斬視訊妹真人真事 hilive,蔡依林性感影片 視訊sex888movie影城 視訊辣妹,網路援交 拓網免費視訊辣妹 視訊kk69 85cc免費視訊辣妹脫衣秀 情色視訊做愛 080情人網,免費a片欣賞 sex520-視訊 桃園援交小魔女自拍天堂 視訊聊天室777美女 av短片-免費a片 Alice Japan免費影片 成人情色 ez打砲 性愛情慾視訊自拍aio 視訊交友90739南台灣視訊 sod特輯 免費av自拍影片成人 情色 日本avdvd光碟 天下第一色站 浪漫月光論壇 dudu sex,av無碼 甜心寶貝視訊妹 xxxpanda com 免費影片-無碼a片 免費線上歐美A片段觀看 黃金girls色論 34C正妹拓網交友 xvediox免費a片 金瓶梅視訊聊天室 卡通美女短片免費試看

桂竹 said...

人不可以求其備,必捨其所短,取其所長 ............................................................

伯臻伯臻 said...

當一個人內心能容納兩樣相互衝突的東西,這個人便開始變得有價值了。...............................................................

burtong said...

More haste, less speed.............................................................

vickiekurt said...

The shortest answer is doing. ............................................................

鈺苓賴 said...

you did a good job..................................................

俊偉 said...

這麼好的部落格,以後看不到怎麼辦啊!!......................................................................

博行 said...

休息才能再次出發-隨時保持好體力-加油.................................................................

廷雯 said...

死亡是悲哀的,但活得不快樂更悲哀。......................................................................

嘉惠 said...

Poverty is stranger to industry.................................................................

郁雯郁雯 said...

一個人的價值,應該看他貢獻了什麼,而不是他取得了什麼............................................................

香昱信張君林 said...

如果成為一支火柴,也要點亮一個短暫的宇宙;如果是一隻烏鴉,也要叫疼閉塞的耳膜。.................................................................

竹青 said...

很榮幸能到你的BLOG留言o^~^o..................................................................

溫緯李娟王季 said...

感謝你的分享 要繼續發表好文章喔..................................................................

tuckerdarrell翁tuckerdarrell怡婷 said...

累了嗎?來杯咖啡休息一下吧!............................................................

李建彰 said...

很喜歡你的部落格 留言支持你 祝你人氣長紅~~~ ..................................................................

淑慧淑慧 said...

留言支持,請繼續加油,謝謝您囉~~............................................................

思恬 said...

優質的好部落格,需要大家的支持!............................................................

CedricD_Mccloud07043.3 said...

喜歡自己的另一層意義是「接納自己」。..................................................

吳淑芬吳淑芬 said...

If you can not be kind, at least have the decency to be vague.............................................................

家唐銘 said...

初次造訪,感謝你的分享............................................................

宛淑芳真 said...

Readiness is all.............................................................

家唐銘 said...

It is easier to get than to keep it.......................................................................

黃子黃麗旺軒 said...

Offence is the best defence.............................................................

章鱼 said...

河水永遠是相同的,可是每一剎那又都是新的。. . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4464 said...

這麼好的部落格,以後看不到怎麼辦啊!!!............................................................

靜錢錢錢怡錢錢錢錢 said...

我在戀愛著?--------是的,因為我在等待著.....................................................................

群育航學 said...

may the blessing be always with you!!............................................................

王雅俊 said...

知識可以傳授,智慧卻不行。每個人必須成為他自己。............................................................