Why EJB Francesco Ierna
Why EJB Facilità d'uso. Infatti EJB 3 è il più semplice server side development platform around
Stack Server solution Persistence (EntityManager)
Messaging (JMS e MDB)
Scheduling (TimerService)
Remoting (RMI)
Web services
DI (Container)
Interceptors (ICP) Open JAVA EE Standard
Broad Vendor support. Supportato da un grande numero di organizzazioni
Stabile, high quality code base
Clustering, load balancing and failover
DI Il Dipendent Iniection permette di delegare la responsabilità della creazione dei bean dalla classe al container.
Tightly accoppiamento fra EJB e Presentation Layer
Il container crea l'istanza dell'oggetto allo start dell'applicazione o alla richiesta di un client e lo inietta all'interno di una classe in cui lo si vuole usare

More Related Content

PPT
Struts - Overview, Installazione e Setup
PDF
Spring Intro
PDF
Modulo 6 Spring Framework Core E Aop
PPTX
Spring - Ecosistema
PPT
Spring 2.5
PDF
SPRING - MAVEN - REST API (ITA - Luglio 2017)
PPTX
Dependency Injection
PPTX
Microservices
Struts - Overview, Installazione e Setup
Spring Intro
Modulo 6 Spring Framework Core E Aop
Spring - Ecosistema
Spring 2.5
SPRING - MAVEN - REST API (ITA - Luglio 2017)
Dependency Injection
Microservices

Viewers also liked (20)

ODP
SCWCD 2. servlet req - resp (cap3 - cap4)
ODP
SCWCD 1. get post - url (cap1 - cap2 )
PPTX
Blended learning trends in Spain
ODP
Design Pattern - 3. Decorator pattern
ODP
2. wiring beans
ODP
SPRING 1. overview
ODP
SCDJWS 4. UDDI
PDF
La fiesta del té I
DOC
Cisco ccna voice
PDF
Fibrillazione atriale linee guida ita 2006
DOCX
Curso PHP Academia Usero
PPT
PDF
7 habitos para dirigir tu vida
PPTX
Selling in a matrix
PDF
Comscore Chile July2011 English
PDF
Luis Cantarell - The Nestlé Nutrition journey
DOC
Solicitud de voluntariado
PDF
Robotica
PDF
Planeaciones
PPT
Let It Crash (@pavlobaron)
SCWCD 2. servlet req - resp (cap3 - cap4)
SCWCD 1. get post - url (cap1 - cap2 )
Blended learning trends in Spain
Design Pattern - 3. Decorator pattern
2. wiring beans
SPRING 1. overview
SCDJWS 4. UDDI
La fiesta del té I
Cisco ccna voice
Fibrillazione atriale linee guida ita 2006
Curso PHP Academia Usero
7 habitos para dirigir tu vida
Selling in a matrix
Comscore Chile July2011 English
Luis Cantarell - The Nestlé Nutrition journey
Solicitud de voluntariado
Robotica
Planeaciones
Let It Crash (@pavlobaron)
Ad

Similar to SCBCD 1. generic ejb (20)

PPT
J2EE 5 - Esempio Carrello Elettronico
PPT
#dd12 grillo daniele_xpages_tips_tricks_rev2
ODP
Many Designs Elements
PPT
Java Advanced
PPT
Java lezione 17
ODP
Working between the clouds (versione completa)
ODP
April 2010 - Seam unifies JEE5
ODP
Seam unifies Java EE by Massimiliano Ciccazzo
PPTX
Novità di Asp.Net 4.0
PDF
Oracle Application Server 10g
PDF
Struttin' on, novità in casa Struts
PDF
Jug 30 10 04 Jdo
PPTX
Web Api – The HTTP Way
ODP
SCBCD 2. differenze stateless stateful
PDF
September 2010 - Gatein
PDF
Phpday 2009 php e java
PPTX
Introduzione al java
ODP
Working between the clouds
PPTX
Inversion of control e Dependency Injection (ITA)
PPT
Java codestyle & tipstricks
J2EE 5 - Esempio Carrello Elettronico
#dd12 grillo daniele_xpages_tips_tricks_rev2
Many Designs Elements
Java Advanced
Java lezione 17
Working between the clouds (versione completa)
April 2010 - Seam unifies JEE5
Seam unifies Java EE by Massimiliano Ciccazzo
Novità di Asp.Net 4.0
Oracle Application Server 10g
Struttin' on, novità in casa Struts
Jug 30 10 04 Jdo
Web Api – The HTTP Way
SCBCD 2. differenze stateless stateful
September 2010 - Gatein
Phpday 2009 php e java
Introduzione al java
Working between the clouds
Inversion of control e Dependency Injection (ITA)
Java codestyle & tipstricks
Ad

More from Francesco Ierna (8)

ODP
Design Pattern 5. Singleton Pattern
ODP
Design Pattern 4. Factory Pattern
ODP
SCDJWS 6. REST JAX-P
ODP
SCDJWS 5. JAX-WS
ODP
Design Pattern - 2. Observer
ODP
SCDJWS 3. WSDL
ODP
SCDJWS 2. Soap
ODP
SCDJWS 1. xml schema
Design Pattern 5. Singleton Pattern
Design Pattern 4. Factory Pattern
SCDJWS 6. REST JAX-P
SCDJWS 5. JAX-WS
Design Pattern - 2. Observer
SCDJWS 3. WSDL
SCDJWS 2. Soap
SCDJWS 1. xml schema

SCBCD 1. generic ejb

  • 2. Why EJB Facilità d'uso. Infatti EJB 3 è il più semplice server side development platform around
  • 3. Stack Server solution Persistence (EntityManager)
  • 9. Interceptors (ICP) Open JAVA EE Standard
  • 10. Broad Vendor support. Supportato da un grande numero di organizzazioni
  • 13. DI Il Dipendent Iniection permette di delegare la responsabilità della creazione dei bean dalla classe al container.
  • 14. Tightly accoppiamento fra EJB e Presentation Layer
  • 15. Il container crea l'istanza dell'oggetto allo start dell'applicazione o alla richiesta di un client e lo inietta all'interno di una classe in cui lo si vuole usare
  • 16. First taste to EJB Librerie che servono al container EJB per esporre i servizi
  • 17. Le risorse degli EJB non sono condivise con gli altri EJB. Una lookup instanzia un nuovo oggetto solo in questi casi saranno condivise Oggetti immutabili come stringhe
  • 19. Oggetti con JNDI name di tipi condiviso come ORB.
  • 20. Regole Generali EJB Enterprise Bean Provider  : Ejb ed è dichiarato tramite XML attraverso ejb-jar.xml contiene
  • 21. NO GESTIONE Read/write static fields per i problemi relativi all'uso del bean da parte di diverse JVM su diverse application. Infatti i campi statici sono variabili di classe cioè associate al loader della classe da parte della JVM. Cambiando JVM il valore della variabile sarà diverso nelle diverse JVM
  • 22. Thead syncrho . Container già gestisce la concorrenza fra le richieste dei clients
  • 23. No AWT functionality . ES : keyboard etc per problemi relativi alla sicurezza.
  • 24. Java.io.package per provare ad accedere a files e directory, per problemi relativi alla sicurezza.
  • 25. No listen socket , connession su socket or uso di socket per multicast
  • 26. No create, ottenere, context class loader . Settare sicurezza, fermare JVM sono riservati all'EJB Container
  • 28. No accesso a java.package degli EJB . Riservata all'EJB Container
  • 29. No access file descriptor
  • 30. No Security policy per code source, access modify ma riservata all'EJB Container
  • 31. Regole Generali EJB Obbligatorio : Deve essere pubblica, no final e non astratta. Top-Level
  • 34. Metodi dell'interfaccia Opzionale : Implementare the javax.ejb.SessionBean direttamente o indirettamente
  • 38. Può avere superclassi e implementare i metodi di callback o nelle superclassi
  • 41. 7 EJB Roles Enterprise Bean Provider  : Ejb ed è dichiarato tramite XML attraverso ejb-jar.xml contiene ejb Requesting injection of a TimerService object using a Resource annotation, or using the defined name to lookup the TimerService object.
  • 42. Declares roles used in the beans using the security-role-ref elements
  • 43. Se il metodo di business lancia una eccezione il BP deve Si occupa della gestione delle eccezioni catturando le system exception e rilanciandole come EJBException.
  • 44. Should also be an expert in component developm because that's what he creates
  • 45. Fornisce le seguenti classi : Session bean, session bean per 2.1 (home , local, remote) interface, endpoint webservices, interceptors. Application Assembler  : ejb in larger deployable application units. Comportamenti in EJB tramite <assembly-descriptor></assembly-descriptor> in ejb-jar.xml Declares the logical security roles used in the application<security-role>
  • 46. Output file ejb-jar con istruzioni per gli ejb e Link an enterprise bean reference to a target enterprise bean
  • 47. Does not need to have any knowledge of the enterprise Bean's implementation.
  • 48. 7 EJB Roles Deployer : prende gli ejb-jar prodotti da PRV o AA e li deploya in uno specifico enviromnent. External dipendenze dichiarate dal provider
  • 49. Output -> insieme di ejb deployati in un EJB Server e container. Deployer assigns principals to the security roles.
  • 50. Crea e inizializza le variabili d'ambiente che sono dichiarate con annotation o XML.
  • 51. Genera Stub per gli ejb
  • 52. Deployer mappa i ruoli delle applicazioni all'LDAP group EJB Server Provider. It's a specialist in the area of distributed transaction management, distributed objects, and other lower-level system-level services
  • 53. EJB Container Provider. Tools per il deploy ejb e resource.
  • 54. Inietta le variabili d'ambiente dentro i campi degli EJB o i metodi.
  • 55. Runtime name context support per i deployati EJB. Può usare EJBContext per accedere alle risorse dichiarate nell'ambiente
  • 56. Container si occupa delle transazioni, sicurezza, messaging, timerServices, lifecyle
  • 57. 7 EJB Roles Persistence Provider . O/R mapping, query processing and caching. Tools per la gestione O/R di entity e transazioni
  • 58. Operazioni sul DB System Administrator . Configurazione e amministrazione delle networking infrastrutture che includono EJB server e container. Configure the EJB server and EJB container
  • 59. Configure a resource manager connection factory.
  • 60. Is responsible for overseeing the well-being of the deployed EJB appli-cations
  • 61. Definisce e configura LDAP realms
  • 62. Packaging and Deploy Ejb-jar : un contratto fra Bean provider e Application Assembler e fra Application Assembler e Deployer Deve seguire lo schema XML e deve essere inserito sotto META-INF
  • 63. Può contenere Enterprise bean class e interfaccie, web services
  • 65. PK se il bean è un entity Optional. It says, &quot;The ejb-jar file must contain the deployment descriptor (if any) in the format defined The deployment descriptor must be stored with the name META-INF/ejb-jar.xml in the ejb-jar file.&quot;
  • 66. AA non deve configurare i stub di home e objetct. Configurare nell'xml e sarà compito dell'Container generarli per ogni classe che estende Home e Object
  • 67. EJB-Jar.xml DEF BEAN SU EJB-JAR e senza annotation <ejb-jar xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; ….> < enterprise-beans > < session > <ejb-name>TestBean</ejb-name> <env-entry> <description>admin email</description> <env-entry-name>adminEmail</env-entry-name> <env-entry-value>[email protected]</env-entry-value> </env-entry> </session> </enterprise-beans> </ejb-jar> ES: ACCESSO A TUTTI I METODI DI STOCKEJB SOLO DALL'UTENTE CUSTOMER <assembly-descriptor> <security-role> <role-name>customer</role-name> </security-role> <method-permission> <role-name>customer</role-name> <method> <ejb-name>StocksEJB</ejb-name> <method-name>*</method-name> </method> </method-permission> </assembly-descriptor> ES: DICHIARAZIONE MDB <message-driven> <ejb-name>ReportMDB<e/jb-name> <ejb-class>com.enthu.ReportMDB</ejb-class> <transaction-type>Bean</transaction-type> </message-driven>
  • 68. Stateless bean Usati per modellare azioni eseguite in una volta, come aggiungere un elemento in un carrello
  • 69. @Stateless -> dice al container che la classe è una stateless bean. Così facendo avremo gestito dal container concorrenza, thread, pooling and transaction
  • 70. @Local -> può essere accessa localmente attraverso l'interfaccia. Nella stessa applicazione
  • 71. @Remote -> può essere accessa in remote. Cioè in diverse JVM @Stateless public class ExStatelessBean implements ExStateless { ..... public ExStatelessBean(){} public void addBid() { … .. } .... } package capitolo3.esercizio1.stateless; import javax.ejb.Local; @Local public interface ExStateless { void addBid(); }
  • 72. Stateless bean Client (Servlet etc) Usato per usare l'ejb.
  • 73. @EJB -> il container attraverso DI inietta l'EJB nella classe così potremo utilizzarlo. E' l'opposto del JNDI perchè con il JNDI le risorse venivano prese dalla classe e non dal container
  • 74. Il client non ha nessuna conoscenza dell'ejb ma lo utilizza solamente -> basso accoppiamento. public class StatelessServlet extends HttpServlet{ @EJB private ExStateless ejbBean ; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { … . ejbBean .addBid(); ... } }
  • 75. Stateful bean Client si aspetta un insieme di internal state del bean e il conto sullo stato venga mantenuto fra qualunque numero di metodi chiamati
  • 76. Container assicura che l'instanza del bean sarà mantenuta per la durata della sessione senza scrivere codice per la sessione.
  • 77. @Stateful -> dice al container che il bean è di tipo stateful
  • 78. @Remove -> ultimo metodo invocato nel workflow. Quindi è l'ultimo metodo e distrugget il bean deallocando memoria @Stateful public class ExStatefullBean implements ExStatefull { @Override public void addBid() { … .. } @Remove public Long confirm(){ return new Long(0); }} … . @Local public interface ExStatefull { void addBid();}
  • 79. Stateful bean Client (Servlet etc) Usato per usare l'ejb.
  • 80. @EJB -> il container attraverso DI inietta l'EJB nella classe così potremo utilizzarlo. E' l'opposto del JNDI perchè con il JNDI le risorse venivano prese dalla classe e non dal container
  • 81. Il client non ha nessuna conoscenza dell'ejb ma lo utilizza solamente -> basso accoppiamento
  • 82. Uguale al stateless. public class StatefullServlet extends HttpServlet{ @EJB private ExStatefull ejbBean ; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub ejbBean .addBid(); } }