Advanced Programming Rabie A. Ramadan 7.

Slides:



Advertisements
Similar presentations
JNDI Java Naming Directory Interface JNDI is an API specified in Java that provides naming and directory functionality to applications written in Java.
Advertisements

Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Generator Design Patterns: The Factory Patterns.
Nov R McFadyen1 Design Patterns (GoF) contains the creational patterns: Abstract factory Builder Factory method (section 23.3 has a Simple.
Patterns Reusable solutions to common object-oriented programming problems When given a programming problem, re-use an existing solution. Gang of Four.
Java Naming and Directory Interface JNDI. v001025JNDI2 Topics Naming and Directory Services JNDI Overview Features and Code Samples JNDI Providers References.
Object-Oriented PHP (1)
05/26/2004www.indyjug.net1 Indy Java User’s Group June Knowledge Services, Inc.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 14: Naming.
Directory & Naming Services CS-328 Dick Steflik. A Directory.
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
March R McFadyen1 GoF (Gang of Four): Gamma, Johnson, Helm & Vlissides Book: Design Patterns: Elements of Reusable Object-Oriented Software.
Basics of JNDI Alessio Bechini June Naming and Directory Services: Rationale A fundamental element in every application is the capability to find.
Chapter 10 Classes Continued
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Factory Method Design Pattern (1) –A creational design.
Design Patterns Standardized Recurring model Fits in many location Opposite of customization Fundamental types of pattern Choose and use as desired and.
卓越計劃進度報告 JNDI Java Naming and Directory Interface 網際網路實驗室 報告人 潘燕弘.
Corso di Formazione Sodalia “Enterprise Java Beans” JNDI Java Naming and Directory Interface.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
CS 325: Software Engineering March 17, 2015 Applying Patterns (Part A) The Façade Pattern The Adapter Pattern Interfaces & Implementations The Strategy.
Topic : JNDI Kaster Nurmukan. JNDI2(c)CDAC(Formerly NCST) What is JNDI? Naming and Directory Services Naming Concepts Issues JNDI Architecture Programming.
Middleware Technology (J2EE/EJB) RMI-IIOP/JNDI. 2 Distributed Objects EJB components are based on distributed objects. A distributed object can be called.
Chapter 26 GoF Design Patterns. The Adapter Design Pattern.
Java Naming and Directory Interfaces. A naming service is an entity that performs the following tasks:  It associates names with objects. Similar to.
Objected Oriented Programming & Design JAVA Shishir Gupta (704) (704)
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
Design Patterns Gang Qian Department of Computer Science University of Central Oklahoma.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Singleton and Basic UML CS340100, NTHU Yoshi. What is UML Unified Modeling Language A standardized general-purpose modeling language in the field of software.
Programming in Java CSCI-2220 Object Oriented Programming.
Enterprise Integration Patterns CS3300 Fall 2015.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
July 28, 2015IAT 2651 Design Patterns. “Gang of Four” July 28, 2015IAT 2652.
CSE 332: Design Patterns Review: Design Pattern Structure A design pattern has a name –So when someone says “Adapter” you know what they mean –So you can.
CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Ch- 8. Class Diagrams Class diagrams are the most common diagram found in modeling object- oriented systems. Class diagrams are important not only for.
Architecture View Models A model is a complete, simplified description of a system from a particular perspective or viewpoint. There is no single view.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
Singleton Pattern Presented By:- Navaneet Kumar ise
Overview of Creational Patterns ©SoftMoore ConsultingSlide 1.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Java Naming and Directory Interface. Contents Naming and directory services JNDI RMI Conclusion.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
1 C++ Classes & Object Oriented Programming Overview & Terminology.
CS 116 Object Oriented Programming II Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
Creational Patterns C h a p t e r 3 – P a g e 14 Creational Patterns Design patterns that deal with object creation mechanisms and class instantiation,
Generator Design Patterns: Singleton and Prototype
Unit II-Chapter No. : 5- design Patterns
Chapter 5:Design Patterns
MPCS – Advanced java Programming
Intent (Thanks to Jim Fawcett for the slides)
Advanced Programming Behnam Hatami Fall 2017.
Object Oriented Design Patterns - Creational Patterns
Factory Pattern.
DESIGN PATTERNS : Introduction
Lesson 5: More on Creational Patterns
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
The OOTP is intended to get you thinking about how OO concepts are used in designing object-oriented systems. Note: not talking about OO technologies that.
Presentation transcript:

Advanced Programming Rabie A. Ramadan 7

Topics to be Covered 2 JAVA Naming and Directory Interface (JNDI) Java Design Patterns

JAVA Naming and Directory Interface (JNDI) 3 A naming service associates names with objects. Thus, you can look up an object by its name. A directory service associates names and attributes with objects. Thus, you not only can look up an object by its name but also get the object's attributes or search for the object based on its attributes. Common Naming/directory services: DNS RMI Registry CORBA naming service Lightweight Directory Access Protocol (LDAP) OS File system. Windows registry Windows Active Directory JNDI provides a unified approach (API) to access any naming/directory service.

JNDI Overview 4 JNDI is an Application Programming Interface (API) that provides naming and directory functionality to JAVA applications. It is defined to be independent of any specific directory service implementation. Thus a variety of directories--new, emerging, and already deployed--can be accessed in a common way. Java 2 SDK, v1.3 already includes the JNDI classes. More service providers can be implemented or downloaded from Sun’s website.

Javax.naming package: 5 Context The javax.naming package defines a Context interface, which is the core interface for looking up, binding/unbinding, renaming objects and creating and destroying subcontexts. The most commonly used operation is lookup(). You supply lookup() the name of the object you want to look up, and it returns the object bound to that name. Printer printer = (Printer)ctx.lookup("treekiller"); printer.print(report);

Java Design Patterns 6

7 Design Patterns have two main usages in software development: Common platform for developers Design patterns provide a standard terminology and are specific to particular scenario For example, a singleton design pattern signifies use of single object so all developers familiar with single design pattern will make use of single object and they can tell each other that program is following a singleton pattern. Best Practices Design patterns have been evolved over a long period of time and they provide best solutions to certain problems faced during software development.

Types of Design Pattern 8 there are 23 design patterns in three different categories : Creational Patterns A way to create objects while hiding the creation logic, rather than instantiating objects directly using new operator. Structural Patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.

Types of Design Pattern 9 Behavioral Patterns These design patterns are specifically concerned with communication between objects.

Factory Pattern 10 Comes under creational pattern as this pattern provides one of the best ways to create an object Implementation - Create a Shape interface and concrete classes implementing the Shape interface. - A factory class ShapeFactory is defined as a next step. - FactoryPatternDemo, our demo class will use ShapeFactory to get a Shape object. It will pass information (CIRCLE / RECTANGLE / SQUARE) to ShapeFactory to get the type of object it needs.

Factory Pattern- Class Diagram 11

Factory Pattern- Implementation 12 Step 1: Create an interface.

Factory Pattern- Implementation 13 Step 2: Create concrete classes implementing the same interface.

Factory Pattern- Implementation 14

Factory Pattern- Implementation 15 Step 3 : Create a Factory to generate object of concrete class based on given information.

Factory Pattern- Implementation 16 Step 4: Use the Factory to get object of concrete class by passing an information such as type.

Factory Pattern- Implementation 17 Step 5: Verify the output.

Singleton Design Pattern 18 Creational pattern as this pattern provides one of the best way to create an object. Involves a single class which is responsible to create its own object while making sure that only single object get created.

Singleton Design Pattern 19 Implementation SingleObject class have its constructor as private and have a static instance of itself. SingleObject class provides a static method to get its static instance to outside world

Singleton Design Pattern 20 Step 1: Create a Singleton Class

Singleton Design Pattern 21 Step 2: Get the only object from the singleton class.

Singleton Design Pattern 22 Step 3: Verify the output

Prototype Design Pattern 23 Comes under creational pattern Creating duplicate object while keeping performance in mind. Involves implementing a prototype interface which tells to create a clone of the current object. This pattern is used when creation of object directly is costly.

Prototype Design Pattern 24 Implementation Create an abstract class Shape and concrete classes extending the Shape class. A class ShapeCache is defined as a next step which stores shape objects in a Hashtable and returns their clone when requested. PrototypPatternDemo, our demo class will use ShapeCache class to get a Shape object.

Prototype Design Pattern 25 Class Diagram

Prototype Design Pattern 26 Step 1: Create an abstract class implementing Clonable interface.

27

Prototype Design Pattern 28 Step 2: Create concrete classes extending the above class. }}

Prototype Design Pattern 29

Prototype Design Pattern 30

Prototype Design Pattern 31 Step 3: Create a class to get concrete classes from database and store them in a Hashtable.

32

Prototype Design Pattern 33

Prototype Design Pattern 34 Step 4: PrototypePatternDemo uses ShapeCache class to get clones of shapes stored in a Hashtable.

Prototype Design Pattern 35 Step 5: Verify the output.