JBoss Fundamentals with JBuilder: Session #3110 Ken Sipe Code Mentor, Inc. Nov. 5, 2005.

Slides:



Advertisements
Similar presentations
JBoss Seam: Contextual Components Jason Bechtel
Advertisements

Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
Java 2 – Enterprise Edition Kevin J. LaFata April 21, 2003 UM – St. Louis.
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
© 2005, Cornell University. Rapid Application Development using the Kuali Architecture (Struts, Spring and OJB) A Case Study Bryan Hutchinson
Introduction to EJB INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
1 Lecture 18 George Koutsogiannakis/Spring 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
Introduction to the JBoss Presented by: Hao Shi. Agenda Application Servers What is JBoss JBoss features Architecture of JBoss Installation and running.
2007 JavaOne SM Conference | Session BOF-4181 | BOF-4181 Migrating a Spring/Hibernate Application to Java Platform, Enterprise Edition (Java EE) 5 Adrian.
4-Tier Model Client Tier Web Tier Business Tier EIS Tier.
1 Session Bean Chuyên đề Lập trình Java & J2EE Chương 14 Biên soạn: Th.S Nguyễn văn Lành.
J2EE Part 2: Enterprise JavaBeans CSCI 4300 Images and code samples from jGuru EJB tutorial,
Notes of J2EE Tutorial Matt Tsai. 2 Outline Chapter 1: Overview Chapter 1: Overview Chapter 2: Understanding XML Chapter 2: Understanding XML Chapter.
Ing. Ignacio Roqueta ARTech GeneXus and J2EE.
Enterprise JavaBeans EJB Container Services. EJB container Enterprise JavaBeans are deployed in an EJB container within the application server EJB container.
© D. Wong  Indexes  JDBC  JDBC in J2EE (Java 2 Enterprise Edition)
Entity Java Beans Jorg Janke Open Source ERP & CRM.
Bologna, September 2003 Giorgia Lodi Department of Computer Science University of Bologna V.Ghini, F. Panzieri.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
EJB 3.0 Persistence Sang Shin Java Technology Architect
Introduction to J2EE Architecture Portions by Kunal Mehta.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
TDDD05 EJB Lab (Part of slides reused from Mikhail’s) Lu Li
JBoss at Work JAW Motors Application Chapter 1-3 Jeff Schmitt October 9, 2006.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
JBoss Seam Presented by Andy Nguyen Truc Pham. What is JBoss Seam? Created by Gavin King Created by Gavin King A lightweight framework for Java EE 5.0.
Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.
1162 JDK 5.0 Features Christian Kemper Principal Architect Borland.
JavaEE Seams Easy JBoss Seam: A Web Application Component Framework for EJB3, JPA, JSF and AJAX.
Topic : JPA Kaster Nurmukan. Overview of JPA EntityManager.
JBoss Overview J2EE Sig Presenter: Steve Davidson Stephen Davidson & Associates, INC.
Ch 2 – Application Assembly and Deployment COSC 617 Jeff Schmitt September 14, 2006.
Fall CIS 764 Database Systems Engineering L7. EJB’s.
1 Apache TomEE // JavaEE Web Profile on Tomcat Jonathan #TomEE.
1 Architectural Overview For application developers, assembling enterprise beans requires little or no expertise in the complex system-level issues that.
RandoNode IT Conference Sept 17, /17/08 RandoNode IT Conference 2 Development Environment Setup System Environment Windows OS –JAVA_HOME - where.
JAVA EE 6 Best Practices for Migrating Spring to WTF ?!?
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
SCA and Java n SCA provides support for multiple Java-based component implementation types l Java POJOs (implementation.java) l Spring Beans (implementation.spring)
Java Persistence API part 1 INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
v110912Java Persistence: EntityManager2 Overview Earlier versions of EJB Specification defined the persistence layer –javax.ejb.EntityBean Java EE 5 moved.
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
DEVELOPING ENTERPRISE APPLICATIONS USING EJB
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Enterprise JavaBeans: Fundamentals. EJB Fundamentals(c)CDAC(Formerly NCST)2 Contents Introduction Technology Overview EJB Architecture EJB Specification.
Introduction – ORM, Helloworld Application
Enterprise Java v JNDI Enterprise Naming Conext (ENC) and Injection JNDI ENC.
17 Copyright © 2004, Oracle. All rights reserved. Integrating J2EE Components.
1 EJB 3.0: There’s Something Different About You Martin Jäkle, TSBU Middleware.
Apache TomEE Tomcat with a kick. Apache TomEE: Overview ● Java EE 6 Web Profile certification in progress ● Apache TomEE Includes support for: ● Servlet.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
J2EE Lecture 10: EJB 3.0 Overview
Java Servlets By: Tejashri Udavant..
Advanced Java Programming
Introduction to J2EE Architecture
J2EE Application Development
Understanding and Designing with EJB
Introduction to JBoss application server
ESIS Consulting LLC (C) ESIS Consulting LLC. All rights reserved
Enterprise Java Beans Bina Ramamurthy 1/13/2019 B.Ramamurthy.
Enterprise Java Beans Bina Ramamurthy 4/5/2019 B.Ramamurthy.
Developing and testing enterprise Java applications
Enterprise Java Beans.
Introduction to Session beans
Knowledge Byte In this section, you will learn about:
Presentation transcript:

JBoss Fundamentals with JBuilder: Session #3110 Ken Sipe Code Mentor, Inc. Nov. 5, 2005

2October 16, 2005 Agenda  JBoss Introduction  JBuilder JBoss Server Configuration  JBoss Services  EJB 3 Introduction  Annotations  EJB Annotation  Persistence Model

3October 16, 2005 What is JBoss?  Open Source J2EE Application Server ++  Versions  2.4.x  J2EE 1.3 Spec   J2EE 1.4 Spec  Refactor Server  (current)  EJB 3 Capable

4October 16, 2005 JBoss Installation  Version <  unzip or extract tar to a directory  /usr/local$ sudo tar xf jboss tar  Version  New Java-based installer  From Web Start or  ~/downloads$ jar./jboss-4.0.3RC1-installer.jar

5October 16, 2005 JBoss Directory Structure  jboss  bin – run / stops scripts  client – client needed jars  docs – dtds, schemas and examples  lib – server side jars  server  default  conf – server instance configuration files  data – server instance db file (hypersonic)  deploy – deployment directory  lib – server instance libraries  log – server instance logs  tmp – location deployments are extracted to  work – web work directory

6October 16, 2005 Configuration of JBuilder  Enterprise --> Configure Servers  Select Jboss  Configure home directory

7October 16, 2005 Starting a Project  Copy the preferred server configuration  Create JB project select this new server configuration for the deployment.  Create EJBs... etc.

8October 16, 2005 Managing JBoss  Jboss is running and ready when you see  14:59:11,304 INFO [Server] JBoss (MX MicroKernel) [4.0.3 (build: CVSTag=JBoss_4_0_3 date= )] Started in 34s:106ms  Web administration   Tomcat status  JMX Console  Jboss Web Console

DEMO – Stateless Session

10October 16, 2005 Tricks and Tips  Multi-Server  List deployments  Disable services

11October 16, 2005 Multi-Server  Configure JBoss for EJBs  Configure Tomcat for WAR. DEMO

12October 16, 2005 Agenda  JBoss Introduction  JBuilder JBoss Server Configuration  JBoss Services  EJB 3 Introduction  Annotations  EJB Annotation  Persistence Model

13October 16, 2005 SAR – Service ARchive  JAR with a SAR extension  JBoss specific  JMX components

14October 16, 2005 Creating SAR  Create JMX MBean  Create SAR  New Object Gallery  Select Enterprise --> Jboss Service Module  Assign Mbean class  Assign Name  JBuilder is misleading the name must have a domain!!!

15October 16, 2005 Agenda  JBoss Introduction  JBuilder JBoss Server Configuration  JBoss Services  EJB 3 Introduction  Annotations  EJB Annotation  Persistence Model

16October 16, 2005 Because of EJBs...  I became an expert at:  class loading  Transaction management  I got to jump through hoops  ejbPassivate.... for my stateless session bean ???  In the end...  was I more productive?  was the end result portable?

17October 16, 2005 EJB 3 Specification  JSR 220  public Review 27 Jun, 2005  3 Specification Documents  EJB 3.0 Simplified API  Quick Reference with great sample code  Java Persistence API  Lightweight (replacement) persistence framework  EJB Core Contracts  EJB Details outside of persistence

18October 16, 2005 EJB 3 Contributions  The EJB 2.1 Specification (JSR 153, Enterprise JavaBeans 2.1)  The J2EE 1.4 Platform Specification (JSR 151)  JSR 14 Add Generic Types to the JavaTM Programming Language  JSR 175 A Metadata Facility for the JavaTM Programming Language  JSR 181 Web Services Metadata for the JavaTM Platform  JSR 201 Enumerations, Autoboxing, Enhanced for loops and Static Import  JAX-RPC 2.0  JDBC 4.0

19October 16, 2005 EJB 3 Goals  The EJB 3.0 release is focused on a simplification of the Enterprise JavaBeans architecture from the developer’s point of view.  Elimination of requirements for:  home and component interfaces  the specification of the javax.ejb.EnterpriseBean interfaces.  Definition of a dependency injection  Facility and simpler look-up APIs.  Java metadata annotations vs. deployment descriptors.  Simplification of object persistence by the definition of a light-weight object/relational mapping  facility based on the direct use of Java classes rather than persistent components.

20October 16, 2005 Agenda  EJB 3 Introduction  Annotations  EJB Annotation  Persistence Model

21October 16, 2005 MetaData is Required in EJB 3  Annotations (JSR-175) were incorporated in JDK 1.5  Annotations seem like JavaDoc but are quite different. JavaDoc /** */ public void doThis() {... } ??? public void doThis() {... }

22October 16, 2005 Annotation Types  Marker Annotations  Single-value Annotations  Full Annotations value1=”x”, value2=”y”)

23October 16, 2005 JDK Built-in Annotations  Override  Marker to indicate the intention to override  Deprecated  Marker (which is a duplication of javadoc)  SuppressWarnings  Suppresses warnings public class DeprecatedUser2 public static void main(String[] args) { DeprecatedExample2.foo(); }

24October 16, 2005 Agenda  EJB 3 Introduction  Annotations  EJB Annotation  Persistence Model

25October 16, 2005 EJB 3 Annotations t

26October 16, 2005 EJB 3 Annotations

27October 16, 2005 Field Level Injection  Resource evaluates to JNDI name of resource  java:/com/env/com.codementor.devcon/ejbDS  Alternatively it can be declared ass) package com.codementor.devcon; import javax.ejb.*; import public class StatefulBean implements javax.sql.DataSource javax.mail.Session ejbmailSession; }

28October 16, 2005 Setter Injection  Same example on the setter of the public void setDataSource(DataSource myDB) { this.ds = myDB; } private DataSource myDB;

29October 16, 2005 EJB References  The following are examples of references to EJBs in JEE LocalStatelessInterface LocalStatelessInterface RemoteStatelessHome slessHome;

30October 16, 2005 Explicit Dependency Lookup EJB 2.1: Initial Context ic=new InitialContext(); Object o=ic.lookup("ejb/FirstStateless"); statelessHome= (StatelessRemoteHome)PortableRemoteObject.narrow(objref, StatelessRemoteHome.class); EJB SessionContect sc public void setup(){ FirstStatelessInterface fi=(FirstStatelessInterface)sc.lookup("ejb/FirstStateless"); }

31October 16, 2005 Stateless Session public class ConferenceBean implements Conference private EntityManager em; private ConfSession session; public ConfSession findSessionByID(int sessionID) { return ((ConfSession) em.find(ConfSession.class, sessionID)); } public void addSession(long sessionID, String title, Date date) { session = new ConfSession(); session.setTitle(title); session.setDate(date); session.setId(sessionID); em.persist(session); }

32October 16, 2005 Agenda  EJB 3 Introduction  Annotations  EJB Annotation  Persistence Model

33October 16, 2005 Persistence Framework  Packaging  Annotations / Mapping  API – EntityManager

34October 16, 2005 There's a new Archive in Town - PAR  PAR – Persistence Archive  Contains “persistence units”  Portability...  Contains persistence.xml  Details for the entity manager  provider  jta-data-source  non-jta-data-source  mapping-file  jar-file  class  properties

35October 16, 2005 Persistence.xml em1 com.acme.persistence jdbc/MyDB ormap.xml MyApp.jar com.widgets.Order com.widgets.Customer

36October 16, 2005 With or Without You  Any PAR without a persistence.xml will get the container defaults.

37October 16, 2005 Persistence Framework  Packaging  Annotations / Mapping  API – EntityManager

38October 16, 2005 EJB 3 Persistence  Good Bye Entity Beans!!!  EJB 3 Provides an ORM framework similar to Hibernate / JDO  No Descriptors necessary  Annotated POJOs are the persistent classes

39October 16, 2005 Entity Annotations  named used to refer to persistent class  name – property defaults to name of class  access – property or field access  Callbacks

40October 16, 2005 Entity Annotations  Provides EntityManager  Provides EntityManagerFactory

41October 16, 2005 Life-Cycle public class AccountBean implements Account { Long accountId; Integer balance; boolean preferred; public Long getAccountId() {... } public Integer getBalance() {... // because status depends upon non-persistent context public boolean isPreferred() {... } public void deposit(Integer amount) {... } public Integer withdraw(Integer amount) throws NSFException {... public void validateCreate() { if (getBalance() < MIN_REQUIRED_BALANCE) throw new AccountException("Insufficient balance to open an account"); public void adjustPreferredStatus() { preferred = (getBalance() >= AccountManager.getPreferredStatusLevel()); }

42October 16, 2005 Life-Cycle Example Complete public class AlertMonitor public void newAccountAlert(Account acct) { Alerts.sendMarketingInfo(acct.getAccountId(), acct.getBalance()); }

43October 16, 2005 Persistence Framework  Packaging  Annotations / Mapping  API – EntityManager

44October 16, 2005 EJB3 Persistence Interfaces  EntityManager  Interface to interact with persistence context.  EntityManagerFactory  Creates an EntityManager  Query  Queries made through this interface

45October 16, 2005 EJB Bean – Getting an Entity Manager Example public EntityManager em; Example EntityManager em; //here only one persistence unit EntityManager orderEM;

46October 16, 2005 Persisting with the Manager public void addSession(long sessionID, String title, Date date) { session = new ConfSession(); session.setTitle(title); session.setDate(date); session.setId(sessionID); em.persist(session); }

47October 16, 2005 Querying the public class ConferenceEJB implements Conference {... public ConfSession findSessionByTitle(String title) { String query = "SELECT OBJECT(session) FROM ConfSession “ + ”conSession WHERE conSession.title = :sessionName"; ConfSession session = (ConfSession)em.createQuery(query).setParameter("sessionName", title).getSingleResult(); return session; }

48October 16, 2005 EJB Sample public class ShoppingCartImpl implements ShoppingCart EntityManager em; public Order getOrder(Long id) { return em.find(Order.class, id); } public Product getProduct(String name) { return (Product) em.createQuery("select p from Product p where p.name = :name").setParameter("name", name).getSingleResult(); } public LineItem createLineItem(Order order, Product product, int quantity) { LineItem li = new LineItem(order, product, quantity); order.getLineItems().add(li); em.persist(li); return li; } Notice whats missing!

49October 16, 2005 Agenda  EJB 3 Introduction  Annotations  EJB Annotation  Persistence Model

50October 16, 2005 EAR Configuration  EAR  contains an application.xml in the META-INF  contains EJB, PAR and WAR modules  PAR  contains persistence.xml... maybe  contains persistence classes  EJB  contains EJB classes  WAR  contains JSP, servlet classes  web.xml

51October 16, 2005 Questions

52October 16, 2005 Session 3110 – JBoss Fundamentals with JBuilder Thank You 3110 JBoss Fundamentals with JBuilder Please fill out the speaker evaluation You can contact me further at … Thank You