You are on page 1of 30

MIDDLE WARE TECHNOLOGIES

B.TECH III YR II SEMESTER(TERM 08-09) UNIT 7 PPT SLIDES TEXT BOOKS 1.Client/Server programming with Java and CORBA Robert Orfali and Dan Harkey, John Wiley & Sons,SPD 2nd Edition 2. Java programming with CORBA 3rd Edition, G.Brose, A Vogel and K.Duddy, Wiley-dreamtech, India John wiley and sons

INDEX
S.NO. 1. TOPIC

UNIT 7 PPT SLIDES


LECTURE NO. PPTSLIDES L50 L51 L52 L53 L54 L55 L56 L57 L1.1 TO L1.3 L1.1 TO L1.3 L1.1 TO L1.3 L1.1 TO L1.3 L1.1 to L1.3 L1.1 to L1.3 L1.1 TO L1.4 L1.1 TO L1.5

Events

2. 3. 4. 5.

properties Persistency Introspective of beans. CORBA Beans

UNIT 7 SYLLABUS
Java Bean Component Model: Events, properties, persistency , Introspective of beans, CORBA Beans

Lecture 1 slide 1

Bean
Java beans are the software components that has been designed to be reusable in a variety of different environments

Lecture 1 slide 1

Java bean is basically a java class with the following rules

1.All the instance variables must be private 2. Access to the instance variables should be provided by using setXXX() and getXXX() methods 3.There should be a zero parameter constructor in the class

Lecture 1 slide 2

Bean program
Ex: class Mybean { private int htno; Mybean() { } void setHtno( int x ) { htno = x; } int getHtno() { return htno; } }

Lecture 1 slide 3

BDK
BDK stands for BEAN DEVELOPEMENT KIT

Beans are two types


1. Executing the Existing Beans 2. Executing the User-Defined Beans

For Executing the JavaBeans Using BDK Compulsory You Have To Install JDK
Lecture 2 slide 1

BDK components
BDK Contains 3 types of Components: 1) Tool Box 2) Bean Box 3) Property Sheet

Lecture 2 slide 2

Bean development kit

Lecture 2 slide 3

Executing existing beans


Position the cursor on the tool box entry labeled juggler and click left mouse button. Move the cursor to the bean box area and click the left mouse button. Position the cursor on the tool box entry labeled Our Button and click left mouse button. Move the cursor to the bean box area and click the left mouse button. Go to the properties window and change the label
Lecture 3 slide 1

Executing existing beans


By selecting the button, go to the menu bar of the Bean Box and select Edit Events actionaction Performed. You should see a line extending from the button to the cursor Move the cursor so that the line drop inside the display area of juggler, and click left mouse button. Now you should see the Event Target Dialog Box. The dialog box allows you to choose a method that should be invoked when the button is clicked
Lecture 3 slide 2

Executing existing beans

Lecture 3 slide 3

Executing existing beans

Lecture 4 slide 1

Executing existing beans

Lecture 4 slide 2

Procedure to executing user defined bean


For Executing the User Defined Beans with BDK we require 2 files 1. JAR File 2. Manifest File

Lecture 4 slide 3

JAR
JAR File stands for JAVA ARCHIEVE FILE JAR Files are Javas Version of zip Files There are Two main uses for JAR files 1) The first use is to compress (make a smaller size) a number of files into one file (archiving) 2) It makes easy to download
Lecture 5 slide 1

jar
JAR files can be opened with WinZip or Winrar. In terms of Java applications, the ability to archive any number of source or class files into one single archive represents the biggest advantage distributing one file containing hundreds of files is so much easier than distributing hundreds of files separately
Lecture 5 slide 2

Creation of jar
Creating a Jar file:

The syntax of utility used to create jar file is


Jar options (list of files) List of Options:

c: Create a new archive (jar) f : The first element in the file list is the name of the jar that is to be created or accessed m: The second element in the file list is the name of the external manifest file t : Tabulate the contents of jar u: Update the jar file x: Extract the files from jar 0: Do not use compression v: Generate verbose output on standard output file

Lecture 5 slide 3

Multiple options can be used together. They all must appear after the "jar" command with no white space
separating them

Examples: creating a jar file with name MT.jar that contains all the .class and .gif files of the current directory Jar cf MT.jar *.class *.gif

And with the above if we have a manifest file that is to be added Then the above statement will become Jar cfm MT.jar Manf.mf *.class *.gif
Lecture 6 slide 1

Example
Manifest file: A developer must provide a manifest file to indicate What are the components of a jar file and Which of these components in a jar file are java beans

Ex :
name: sunw\demo\slides\fig1.gif name: sunw\demo\slides\fig2.gif name: sunw\demo\slides\slide.class Java-bean: true

Lecture 6 slide 2

Example
import java.awt.*; import java.awt.event.*; public class Colors extends Canvas { private Color color; private boolean rectangular; public Colors() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { change(); } });

Lecture 6 slide 3

Example
rectangular=false; setSize(200, 100); change(); } public boolean getRectangular() { return rectangular; } public void setRectangular(boolean flag) { this. rectangular = flag; repaint(); }

Lecture 7 slide 1

Example
public void change() { color = randomColor(); repaint(); } private Color randomColor() { int r = (int)(255*Math.random()); int g = (int)(255*Math.random()); int b = (int)(255*Math.random()); return new Color(r,g,b); }
Lecture 7 slide 2

Example
public void paint (Graphics g) { Dimension d = getSize(); int h = d.height; int w = d.width; g.setColor(color); if(rectangular) { g.fillRect(0, 0, w-1, h-1); } else { g.fillOval(0, 0, w-1, h-1); } } }
Lecture 7 slide 3

Executing existing beans


Compile the Colors. java file using Command Prompt Create The Manifest file Create Jar File Load The Jar File into Bdk

Lecture 7 slide 4

Creating manifest file


Name: Colors. class Java-Bean: True

Save this file in the form of manifest.mft

Lecture 8 slide 1

Creating jar file


Start Command Prompt. Navigate to the folder that holds your class files: C:\>rams Compile your classes: C:\rams> javac *.java Then create Manifest file Create a jar file: C:\rams> jar cvfm bdk.jar manifest.mft *.class
Lecture 8 slide 2

MVC
MVC ( Model View Controller) The MVC design pattern is the basis for the most web-application frameworks today Ex: Struts, JSF, Spring are all implementations of MVC design concept The new programming environment called Ruby on rails is entirely based on MVC design pattern

In MVC the Controller is implemented by using a servlet View is implemented by JSP and the Model by Java beans
Lecture 8 slide 3

MVC
A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications access via a request-response programming model

Java Server Pages (JSP) is a technology based on the Java language and enables the development of dynamic web sites. JSP was developed by Sun Microsystems to allow server side development. JSP files are HTML files with special Tags, containing Java source code that provide the dynamic content
Lecture 8 slide 4

JSP tags
There are four main tags: 1. Declaration tag ( <%! %> ) 2. Expression tag ( <%= %>) 3. Directive Tag ( <%@ directive %>) 4. Scriptlet tag ( <% %> ) 5. Action tag (<jsp : usebean ----%> )

Lecture 8 slide 5

You might also like