Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Java Session 4 New York University School of Continuing and Professional Studies.

Similar presentations


Presentation on theme: "Advanced Java Session 4 New York University School of Continuing and Professional Studies."— Presentation transcript:

1

2 Advanced Java Session 4 New York University School of Continuing and Professional Studies

3 2 Objectives Network programming basics –Sockets, TCP/IP stack, telnet Java Network Programming –Creating sockets –Implementing servers Java Beans –BDK and Beanbox –Naming patterns for Bean properties and events –Bean Property types and custom bean events

4 3 ISO stack and TCP/IP stack Application Presentation Session Transport Network Data Link Physical Application Transport (TCP & UDP) Internet (IP) Network Interface ISO Reference Model TCP Reference Model

5 4 Network Communications Application Transport Internet Network Interface Application Transport Internet Network Interface Machine AMachine B

6 5 Sockets and Ports Source ip Source port Destination ip Destination port

7 6 TCP/IP Session Source machine creates a socket and attempts to connect to a destination machine by giving its “ip” and “port” numbers Source machine responds with ConnectionAccepted If the destination machine is listening on that port “and” accepts this connection it responds with “request accepted” Data can now be transferred until an EOF is seen or a Network Error occurs

8 7 Examples SocketTest.java –Simple socket client SocketOpenerTest.java –Timeout while opening a socket

9 8 Network Security and Applets Can’t connect to servers other than the one it was downloaded from. Can’t access local hard disk Signed applets may be permitted to override the security – provided that the user permits it.

10 9 Java Beans “a reusable software component based on Sun’s JavaBeans specification that can be manipulated visually” A well designed Java Class that follows certain patterns for its instance fields and methods as defined in the JavaBeans specifications

11 10 Bean Development Kit Free download from http://java.sun.com/beans Provides an environment similar to Visual tools to test your bean Allows you to create an application by putting beans together visually.

12 11 Bean Development Kit Free download from http://java.sun.com/beans Provides an environment similar to Visual tools to test your bean Allows you to create an application by putting beans together visually.

13 12 Naming Patterns for Properties Generic Format –public get () –public void set ( value) –public boolean is () –public void set (boolean value); For Example –public int getWidth() –public void setWidth(int w) –public boolean isRunning() –public void setRunning(boolean t)

14 13 Naming Patterns for Events Generic Format –public void add Listener( Listener e) –public void remove Listener( Listener e) For Example –public void addTimerListener(TimerListener e) –public void removeTimerListener(TimerListener e)

15 14 Bean Property Types Simple Properties Indexed Properties Bound Properties Constrained Properties

16 15 Adding Custom Bean Events Write a class Event that extends EventObject Write an interface Listener with a single notification method with any name that takes a single parameter Event and return type of “void” Supply the following two methods in the bean – –public void add Listener( Listener e) –public void remove Listener( Listener e)

17 16 Thank you


Download ppt "Advanced Java Session 4 New York University School of Continuing and Professional Studies."

Similar presentations


Ads by Google