Professional Documents
Culture Documents
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
Events
2. 3. 4. 5.
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
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
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
Lecture 2 slide 3
Lecture 3 slide 3
Lecture 4 slide 1
Lecture 4 slide 2
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:
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
Lecture 7 slide 4
Lecture 8 slide 1
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