Introduction to Entity Beans



Similar documents
Aufgabenstellung. Aufgabenstellung

Java E-Commerce Martin Cooke,

Enterprise JavaBeans Fundamentals

EJB 3.0 and IIOP.NET. Table of contents. Stefan Jäger / stefanjaeger@bluewin.ch

How To Write A Bean In Java (Java) (Java 2.4.2) (Java.Net) (Javax) 2 (Java Bean) ( Java Bean) 2-4.5

Software Development using MacroMedia s JRun

Lösungsvorschläge zum Übungsblatt 13: Fortgeschrittene Aspekte objektorientierter Programmierung (WS 2005/06)

Objectives. Software Development using MacroMedia s JRun. Enterprise Application Model. Topics for Discussion

Automatic generation of distributed dynamic applications in a thin client environment

WebOTX Application Server

EJB & J2EE. Component Technology with thanks to Jim Dowling. Components. Problems with Previous Paradigms. What EJB Accomplishes

Java OGSI Hosting Environment Design A Portable Grid Service Container Framework

MDA Overview OMG. Enterprise Architect UML 2 Case Tool by Sparx Systems by Sparx Systems

Java 2 Platform, Enterprise Edition (J2EE) Bruno Souza Java Technologist, Sun Microsystems, Inc.

CGI Vs. Java - Which is Better For Marketing

We are not repeating all the basics here. Have a look at the basic EJB tutorials before you start this tutorial.

Programming on the Web(CSC309F) Tutorial: Servlets && Tomcat TA:Wael Aboelsaadat

Enabling Grids for E-sciencE. Web services tools. David Fergusson. INFSO-RI

Java EE 5, 6 et les EJBs 3.1

The Evolution to Components. Components and the J2EE Platform. What is a Component? Properties of a Server-side Component

Anno Accademico 2004/2005. Sperimentazione di Ingegneria del Software II. Giovanna Petrone J2EE. Laboratorio

Load Balancing in Cluster

Application Notes for Packaging and Deploying Avaya Communications Process Manager Sample SDK Web Application on a JBoss Application Server Issue 1.

Implementing a Web Service Client using Java

Oracle WebLogic Server

Java 2 Platform, Enterprise Edition (J2EE): Enabling Technologies for EAI

TP JSP : déployer chaque TP sous forme d'archive war

J2EE Web Development. Agenda. Application servers. What is J2EE? Main component types Application Scenarios J2EE APIs and Services.

WebLogic 8.1 Student Guide V1.1

Component Middleware. Sophie Chabridon. INT - INF Department - Distributed Systems team 2006

Developing an EJB3 Application. on WebSphere 6.1. using RAD 7.5

Plugin JUnit. Contents. Mikaël Marche. November 18, 2005

Enterprise Applications

Web Application Architecture (based J2EE 1.4 Tutorial)

Connecting Custom Services to the YAWL Engine. Beta 7 Release

Work with XI 3.0 Java Proxies

WHAT ARE PACKAGES? A package is a collection of related classes. This is similar to the notion that a class is a collection of related methods.

How To Test A Load Test On A Java Testnet 2.5 (For A Testnet) On A Test Server On A Microsoft Web Server On An Ipad Or Ipad (For An Ipa) On Your Computer Or Ipa

Creating Custom Web Pages for cagrid Services

CACHÉ: FLEXIBLE, HIGH-PERFORMANCE PERSISTENCE FOR JAVA APPLICATIONS

Developer's Guide: Driving Tivoli Workload Automation

Java Web Services Developer Pack. Copyright 2003 David A. Wilson. All rights reserved.

Web Programming II JSP (Java Server Pages) ASP request processing. The Problem. The Problem. Enterprise Application Development using J2EE

IBM Academic Initiative

Jiří Tomeš. Nástroje pro vývoj a monitorování SW (NSWI026)

CI/CD Cheatsheet. Lars Fabian Tuchel Date: 18.March 2014 DOC:

Password-based authentication

White Paper. Fabasoft app.test Load Testing. Fabasoft app.test 2015 Update Rollup 2. Fabasoft app.test Load Testing 1

Overview of Web Services API

JUnit Howto. Blaine Simpson

Services. Custom Tag Libraries. Today. Web Development. Role-Based. Development. Code Reuse. Tag Libraries Custom Tags. Tag Lifecycle.

Kotlin for Android Developers

HOW-TO : Création d un Web Service Java avec AXIS 1.2. Déploiement sous Jboss 4. Création automatique d'un client à partir du WSDL

AmbrosiaMQ-MuleSource ESB Integration

Geronimo Quartz Plugins

Web Application Programmer's Guide

Development of Web Applications

INF 212 ANALYSIS OF PROG. LANGS ADVERSITY. Instructors: Crista Lopes Copyright Instructors.

Simplify Your Web App Development Using the Spring MVC Framework

RPC over XML. Web services with Java. How to install it? Reference implementation. Setting the environment variables. Preparing the system

Autoboxing/Autounboxing

E-invoice manual Instruction for a client implementation of the B2B web service

Dozer v User's Guide

Builder User Guide. Version 5.4. Visual Rules Suite - Builder. Bosch Software Innovations

Team Name : PRX Team Members : Liang Yu, Parvathy Unnikrishnan Nair, Reto Kleeb, Xinyi Wang

Web Applications. Originals of Slides and Source Code for Examples:

PHP on the D-BUS. Welcome!

Development. with NetBeans 5.0. A Quick Start in Basic Web and Struts Applications. Geertjan Wielenga

TIBCO Enterprise Message Service Application Integration Guide. Software Release 6.0 July 2010

Extend WTP Server Tools for your application server. Tim deboer Gorkem Ercan

Service Data and Notifications

Java Server Pages and Java Beans

Source code security testing

Web Service Caching Using Command Cache

Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1

PowerTier Web Development Tools 4

2. Follow the installation directions and install the server on ccc

A Flexible Security Architecture for the EJB Framework

Developing Web Services with Apache CXF and Axis2

Remote Method Invocation

>

In this chapter, we lay the foundation for all our further discussions. We start

Oracle Hyperion Financial Management Custom Pages Development Guide

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

The Duke s Bank Application

Lecture 7: Class design for security

Oracle Hyperion Financial Management Developer and Customization Guide

CS 111 Classes I 1. Software Organization View to this point:

OTN Developer Day Enterprise Java. Hands on Lab Manual JPA 2.0 and Object Relational Mapping Basics

OSWorkflow. A guide for Java developers and architects to integrating open-source Business Process Management products

Reading and Writing PCD Files The PCD File Format The Grabber Interface Writing a Custom Grabber PCL :: I/O. Suat Gedikli, Nico Blodow

5- Web application deployment

SA8 T1 Meeting 3 JANUS Basics and Applications

Replaceable Components and the Service Provider Interface

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

DTS Web Developers Guide

Web Services and their support in Java

IBATIS - DYNAMIC SQL

Beginning POJOs. From Novice to Professional. Brian Sam-Bodden

JAHIA CMS AND PORTAL SERVER

Transcription:

Introduction to Entity Beans An example: part 1-the server La struttura dei files packages Client.class jndi.properties packages Jboss ejb.jar.java ejb-jar.xml jboss.sml 1 1

structure of the jar file In this directory, run jar cvf converter.jar * META-INF mydemo this directory(ies) reflect the package hierarchy ejb-jar.xml ConverterBean.class Converter.class ConverterHome.class Watch out! Packages often make life complex. (it s easy to make mistakes) Try first without packages. Esempio 1 1. CabinRemote package com.titan.cabin; import java.rmi.remoteexception; La classe deve estendere EJBObject public interface CabinRemote extends javax.ejb.ejbobject { public String getname() throws RemoteException; public void setname(string str) throws RemoteException; public int getdecklevel() throws RemoteException; public void setdecklevel(int level) throws RemoteException; public int getshipid() throws RemoteException; public void setshipid(int sp) throws RemoteException; public int getbedcount() throws RemoteException; public void setbedcount(int bc) throws RemoteException; } DEFINIRE l interfaccia per i metodi di accesso ai dati 2 2

Esempio 1 1. CabinBean La classe deve implementare package com.titan.cabin; EntityBean import javax.ejb.entitycontext; import javax.ejb.createexception; public abstract class CabinBean implements javax.ejb.entitybean { public Integer ejbcreate(integer id) throws CreateException { this.setid(id); return null; } public void ejbpostcreate(integer id) {} DEFINIRE ejbcreate E ejbpostcreate (Anche se vuoto) Esempio 1 1. CabinBean public abstract void setid(integer id); public abstract Integer getid(); public abstract void setshipid(int ship); public abstract int getshipid(); public abstract void setname(string name); public abstract String getname(); public abstract void setbedcount(int count); public abstract int getbedcount(); public abstract void setdecklevel(int level); public abstract int getdecklevel(); DEFINIRE I METODI ASTRATTI DI ACCESSO AI DATI (quelli definiti dall interfaccia) 3 3

Esempio 1 1. CabinBean public void setentitycontext(entitycontext ctx) { // Not implemented } public void unsetentitycontext() { // Not implemented } } public void ejbactivate() { // Not implemented } public void ejbpassivate() { // Not implemented } public void ejbload() { // Not implemented } public void ejbstore() { // Not implemented } public void ejbremove() { // Not implemented } OBBLIGATORIO IMPLEMENTARE LE CALLBACK ANCHE SE VUOTE Esempio 1 1. CabinHomeRemote package com.titan.cabin; import java.rmi.remoteexception; import javax.ejb.createexception; import javax.ejb.finderexception; L interfaccia deve estendere EJBHome public interface CabinHomeRemote extends javax.ejb.ejbhome { public CabinRemote create(integer id) throws CreateException, RemoteException; } public CabinRemote findbyprimarykey(integer pk) throws FinderException, RemoteException; DEFINIRE il metodo create e i finder 4 4

ejb-jar.xml <?xml version="1.0"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejbjar_2_0.dtd"> <ejb-jar> <enterprise-beans> </enterprise-beans> <assembly-descriptor> </assembly-descriptor> </ejb-jar> ejb-jar.xml <enterprise-beans> <entity> <ejb-name>cabinejb</ejb-name> <home>com.titan.cabin.cabinhomeremote</home> <remote>com.titan.cabin.cabinremote</remote> <ejb-class>com.titan.cabin.cabinbean</ejb-class> <persistence-type>container</persistence-type> <prim-key-class>java.lang.integer</prim-key-class> <reentrant>false</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>cabin</abstract-schema-name> <cmp-field><field-name>id</field-name></cmp-field> <cmp-field><field-name>name</field-name></cmp-field> <cmp-field><field-name>decklevel</field-name></cmp-field> <cmp-field><field-name>shipid</field-name></cmp-field> <cmp-field><field-name>bedcount</field-name></cmp-field> <primkey-field>id</primkey-field> <security-identity><use-caller-identity/></security-identity> </entity> </enterprise-beans> 5 5

ejb-jar.xml <assembly-descriptor> <security-role> <description> This role represents everyone who is allowed full access to the Cabin EJB. </description> <role-name>everyone</role-name> </security-role> <method-permission> <role-name>everyone</role-name> <method> <ejb-name>cabinejb</ejb-name> <method-name>*</method-name> </method> </method-permission> <container-transaction> <method> <ejb-name>cabinejb</ejb-name> <method-name>*</method-name> </method> <trans-attribute>required</trans-attribute> </container-transaction> </assembly-descriptor> mysql-ds.xml <datasources> <local-tx-datasource> <jndi-name>cabin</jndi-name> <connection-url> jdbc:mysql://localhost:3306/cabin</connectionurl> <driver-class>org.gjt.mm.mysql.driver</driver-class> <user-name>root</user-name> <password/> </local-tx-datasource> </datasources> 6 6

Introduction to Entity Beans An example: part 2-using ant The build.xml <?xml version="1.0"?> <!-- JBoss build file --> <project name="jboss" default="ejbjar" basedir="."> <property environment="env"/> <property name="src.dir" value="${basedir}/src/main"/> <property name="src.resources value="${basedir}/src/resources"/> <property name="jboss.home" value="${env.jboss_home}"/> <property name="build.dir" value="${basedir}/build"/> <property name="build.classes.dir" value="${build.dir}/classes"/> <!-- Build classpath --> <path id="classpath"> <fileset dir="${jboss.home}/client"> <include name="**/*.jar"/> </fileset> <pathelement location="${build.classes.dir}"/> <!-- So that we can get jndi.properties for InitialContext --> <pathelement location="${basedir}/jndi"/> </path> 7 7

The build.xml <property name="build.classpath" refid="classpath"/> <!-- Prepares the build directory --> <target name="prepare" > <mkdir dir="${build.dir}"/> <mkdir dir="${build.classes.dir}"/> <!-- Compiles the source code --> <target name="compile" depends="prepare"> <javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="on" deprecation="on" optimize="off" includes="**"> <classpath refid="classpath"/> </javac> The build.xml <target name="ejbjar" depends="compile"> <jar jarfile="build/titan.jar"> <fileset dir="${build.classes.dir}"> <include name="com/titan/cabin/*.class"/> </fileset> <fileset dir="${src.resources}/"> <include name="**/*.xml"/> </fileset> </jar> <copy file="build/titan.jar" todir="${jboss.home}/server/default/deploy"/> <!-- Cleans up generated stuff --> <target name="clean.db"> <delete dir="${jboss.home}/server/default/db/hypersonic"/> <target name="clean"> <delete dir="${build.dir}"/> <delete file="${jboss.home}/server/default/deploy/titan.jar"/> 8 8

The build.xml <target name="run.client" depends="ejbjar"> <java classname="com.titan.clients.client_1" fork="yes" dir="."> <classpath refid="classpath"/> <arg value="${arg1}"/> <arg value="${arg2}"/> </java> </project> NOTA: lanciare con $ant run.client Darg1=update Darg2=pippo 9 9