SlideShare uma empresa Scribd logo
1 de 48
Adapter

SENG 609.04 Design Patterns

         Winter, 2003



     Presented by Ming Zhou, Guy Davis
Agenda
      Intent & Motivation
  

      Structure
  

      Applicability
  

      Consequences
  

      Known Uses
  

      Related Patterns
  

      References
  

               - Total 17 pages -   1
What is Adapter?
    Change the interface of a


    class into another interface
    which is expected by the
    client.
    A.K.A. Wrapper





                  - Total 17 pages -   1
What is Adapter?
    Change the interface of a


    class into another interface
    which is expected by the
    client.
    A.K.A. Wrapper





                  - Total 17 pages -   1
What is Adapter?
    Change the interface of a


    class into another interface
    which is expected by the
    client.
    A.K.A. Wrapper





                  - Total 17 pages -   1
Motivation




             - Total 17 pages -   1
Motivation




             - Total 17 pages -   1
Motivation




             - Total 17 pages -   1
Motivation




                                  1   1



             - Total 17 pages -           1
Structure (Class)




           - Total 17 pages -   1
Structure (Object)




           - Total 17 pages -   1
Applicability




            - Total 17 pages -   1
Applicability
    Use an existing class whose interface


    does not match the requirement




                 - Total 17 pages -         1
Applicability
    Use an existing class whose interface


    does not match the requirement
    Create a reusable class though the


    interfaces are not necessary
    compatible with callers




                 - Total 17 pages -         1
Applicability
  Use an existing class whose interface


  does not match the requirement
 Create a reusable class though the

  interfaces are not necessary
  compatible with callers
 Want to use several existing subclasses,
  but it is impractical to subclass
  everyone. (Object Adapter Only)


               - Total 17 pages -       1
Class Adapter Pattern
    Pros


        Only 1 new object, no additional indirection
    


        Less code required than the object Adapter
    


        Can override Adaptee's behaviour as required
    



    Cons


        Requires sub-classing (tough for single
    


        inheritance)
        Less flexible than object Adapter
    




                       - Total 17 pages -              1
Object Adapter Pattern
      Pros
  

          More flexible than class Adapter
      


          Doesn't require sub-classing to work
      


          Adapter works with Adaptee and all of its
      

          subclasses
      Cons
  

          Harder to override Adaptee behavior
      


          Requires more code to implement
      

          properly

                         - Total 17 pages -           1
Pluggable Adapters




    implemented with abstract operations



                   - Total 17 pages -      1
Pluggable Adapters




    implemented with delegate objects

                    - Total 17 pages -   1
Two-way Adapters
                                               class PegAdapter: public SquarePeg,
class SquarePeg {
                                                  RoundPeg {
  public:
    void virtual squarePegOperation()              public:
   { blah }
                                                     void virtual roundPegOperation() {
}
                                                         add some corners;
                                                         squarePegOperation();
class RoundPeg {
                                                     }
    public:
                                                     void virtual squarePegOperation() {
      void virtual roundPegOperation()
                                                         add some corners;
     { blah }
                                                         roundPegOperation();
}
                                                     }
                                               }
                                     - Total 17 pages -                               1
Adapting Local Classes to RMI
Comparison:
 Increases reusability

  of local class
 Improves performance

  of local class
 Doesn't use Java

  single parent by
  subclassing (uses
  composition)
                  - Total 17 pages -   1
Related Patterns
    Adapter can be similar to the remote


    form of Proxy. However, Proxy doesn't
    change interfaces.
    Decorator enhances another object


    without changing its interface.
    Bridge similar structure to Adapter,


    but different intent. Separates
    interface from implementation.
                 - Total 17 pages -         1
Conclusions
    Allows collaboration between classes


    with incompatible interfaces
    Implemented in either class-based


    (inheritance) or object-based
    (composition & delegation) manner
    Useful pattern which promotes reuse


    and allows integration of diverse
    software components
                 - Total 17 pages -        1
References
    Becker, Dan. Design networked applications in RMI using the Adapter design




    pattern. JavaWorld Magazine, May 1999. http://www.javaworld.com/javaworld/
    jw-05-1999/jw-05-networked.html
    Buschmann et al. A System of Patterns: Pattern-Oriented Software Architecture.




    John Wiley and Sons. Chichester. 1996
    Gamma et al. Design Patterns: Elements of Reusable Object-Oriented Software.




    Addison-Wesley. Boston. 1995
    Nguyen, D.X. Tutorial 10: Stacks and Queues: The Adapter Pattern. Rice




    University. 1999. http://www.owlnet.rice.edu/~comp212/99-fall/tutorials/10/
    tutorial10.html
    Whitney, Roger. CS 635 Advanced Object-Oriented Design & Programming. San




    Diego State University. 2001. http://www.eli.sdsu.edu/courses/spring01/cs635/
    notes/proxy/proxy.html#Heading10
    Shalloway, Alan., and Trott, James R., Design Patterns Explained: A New




    Perspective on Object-Oriented Design, Addison-Wesley, 2002.
    Rising, Linda., The Patterns Handbook: Techniques, Strategies, and Applications,




    Cambridge university Press, 1998.


                                     - Total 17 pages -                                1
Questions?




             - Total 17 pages -   1
Questions?




             - Total 17 pages -   1
Java Native Interface (JNI)

SENG 609.04 Design Patterns

Winter, 2003



       Presented by Guy Davis, Ming Zhou
Agenda
      Overview
  

      Justification
  

      Hello World!
  

      Summary
  

      References
  

      Q&A
  




                - Total 17 pages -   1
JNI Overview




          - Total 17 pages -   1
Interactions with Native Code



      Access to Java world from native code




      Access to- native code from Java
                 Total 17 pages -             1
Justification
Pros:
 Reuse: allows access to useful native code
 Efficiency: use best language for the task
Cons:
 Applets: doesn't work as they're mobile
 Portability: native methods aren't portable
 Extra work: javah, create shared native libs

                  - Total 17 pages -         1
HelloWorld.java
class HelloWorld {
public native void displayHelloWorld();
static {
    System.loadLibrary(quot;helloquot;);
}
public static void main(String[] args) {
    new
    HelloWorld().displayHelloWorld();
  }
}
               - Total 17 pages -     1
HelloWorld.java
class HelloWorld {
public native void displayHelloWorld();
static {
    System.loadLibrary(quot;helloquot;);
}
public static void main(String[] args) {
    new
    HelloWorld().displayHelloWorld();
  }
}
               - Total 17 pages -     1
HelloWorld.java
class HelloWorld {
public native void displayHelloWorld();
static {
    System.loadLibrary(quot;helloquot;);
}
public static void main(String[] args) {
    new
    HelloWorld().displayHelloWorld();
  }
}
               - Total 17 pages -     1
HelloWorld.java
class HelloWorld {
public native void displayHelloWorld();
static {
    System.loadLibrary(quot;helloquot;);
}
public static void main(String[] args) {
    new
    HelloWorld().displayHelloWorld();
  }
}
               - Total 17 pages -     1
HelloWorld.h
#include “jni.h”
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
    extern “C” {
#endif

/*
 * Class: HelloWorld
 * Method: displayHelloWorld
 * Signature: ()V
 */
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

                     - Total 17 pages -             1
HelloWorld.h
#include “jni.h”
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
    extern “C” {
#endif

/*
 * Class: HelloWorld
 * Method: displayHelloWorld
 * Signature: ()V
 */
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

                     - Total 17 pages -             1
HelloWorld.h
#include “jni.h”
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
    extern “C” {
#endif

/*
 * Class: HelloWorld
 * Method: displayHelloWorld
 * Signature: ()V
 */
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

                     - Total 17 pages -             1
HelloWorldImp.c

#include <jni.h>
#include quot;HelloWorld.hquot;
#include <stdio.h>

JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
    printf(quot;Hello world!nquot;);
    return;
}




                          - Total 17 pages -           1
HelloWorldImp.c

#include <jni.h>
#include quot;HelloWorld.hquot;
#include <stdio.h>

JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
    printf(quot;Hello world!nquot;);
    return;
}




                          - Total 17 pages -           1
HelloWorldImp.c

#include <jni.h>
#include quot;HelloWorld.hquot;
#include <stdio.h>

JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
    printf(quot;Hello world!nquot;);
    return;
}




                          - Total 17 pages -           1
HelloWorldImp.c

#include <jni.h>
#include quot;HelloWorld.hquot;
#include <stdio.h>

JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
    printf(quot;Hello world!nquot;);
    return;
}




                          - Total 17 pages -           1
Create a Shared Library
class HelloWorld {
   ...
        System.loadLibrary(quot;helloquot;);
   ...
}

 Compile the native code into a shared library:
  (example for MS Windows Visual C++ 4.0)


  cl -Ic:javainclude -Ic:javaincludewin32
     -LD HelloWorldImp.c -Fehello.dll



                            - Total 17 pages -   1
Run the Program
Command:

 java HelloWorld
Result:

 Hello World!

Possible
exceptions:

 java.lang.UnsatisfiedLinkError: no hello in
  shared library path at
  java.lang.Runtime.loadLibrary(Runtime.java)
  at java.lang.System.loadLibrary(System.java)
  at java.lang.Thread.init(Thread.java)


                    - Total 17 pages -      1
Summary
    Connect Java with native languages
    Code reuse
    Powerful
    Compromise of Java safety features,


    cross-platform and dynamic ability
    JNI call is slow and costful


    Not work well for applets



                 - Total 17 pages -       1
References
 Glenn L. Vanderburg. et al., Tricks of the Java
    Programming Gurus, 1996, http://docs.rinet.ru:8080/
    JaTricks/
   Beth Stearns, Trail: Java Native Interface, Sun
    Microsystems, Inc., 2003, http://java.sun.com/docs/
    books/tutorial/native1.1/
   Roedy Green, JNI, The Java Native Interface, Canadian
    Mind Products, 2002, http://mindprod.com/jni.html
   Kong Wenyu, A Brief Introduction to Java Native
    Interface, http://www.geocities.com/kongwenyu/jni.html


                       - Total 17 pages -               1
Questions?




             - Total 17 pages -   1
Questions?




             - Total 17 pages -   1

Mais conteúdo relacionado

Mais procurados

Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesHitesh-Java
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLIDPranalee Rokde
 
Solid principles
Solid principlesSolid principles
Solid principlesToan Nguyen
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Hitesh-Java
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlArjun Thakur
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewShahed Chowdhuri
 

Mais procurados (20)

Solid principles
Solid principlesSolid principles
Solid principles
 
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLID
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
 
Flyweight pattern
Flyweight patternFlyweight pattern
Flyweight pattern
 
Factory Method Pattern
Factory Method PatternFactory Method Pattern
Factory Method Pattern
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
 
Proxy Design Pattern
Proxy Design PatternProxy Design Pattern
Proxy Design Pattern
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
 
Solid principles
Solid principlesSolid principles
Solid principles
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Facade design pattern
Facade design patternFacade design pattern
Facade design pattern
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 

Destaque

ennaji ahmed base de donnees
ennaji ahmed base de donneesennaji ahmed base de donnees
ennaji ahmed base de donneesAHMED ENNAJI
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Patterneprafulla
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator PatternAkshat Vig
 
Design Pattern
Design PatternDesign Pattern
Design PatternHimanshu
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanPriyanka Pradhan
 
Creational pattern
Creational patternCreational pattern
Creational patternHimanshu
 
Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Sameer Rathoud
 
Security and Integrity of Data
Security and Integrity of DataSecurity and Integrity of Data
Security and Integrity of DataAdeel Riaz
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns pptAman Jain
 
Structural patterns
Structural patternsStructural patterns
Structural patternsHimanshu
 

Destaque (13)

ennaji ahmed base de donnees
ennaji ahmed base de donneesennaji ahmed base de donnees
ennaji ahmed base de donnees
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
 
Composite Design Pattern
Composite Design PatternComposite Design Pattern
Composite Design Pattern
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator Pattern
 
Composite Pattern
Composite PatternComposite Pattern
Composite Pattern
 
Composite pattern
Composite patternComposite pattern
Composite pattern
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)
 
Security and Integrity of Data
Security and Integrity of DataSecurity and Integrity of Data
Security and Integrity of Data
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Structural patterns
Structural patternsStructural patterns
Structural patterns
 

Semelhante a Adapter Design Pattern

Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603melbournepatterns
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...Codemotion
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeWaqqas Jabbar
 
Visage Android Hands-on Lab (OSCON)
Visage Android Hands-on Lab (OSCON)Visage Android Hands-on Lab (OSCON)
Visage Android Hands-on Lab (OSCON)Stephen Chin
 
Lecture 8 - Qooxdoo - Rap Course At The University Of Szeged
Lecture 8 - Qooxdoo - Rap Course At The University Of SzegedLecture 8 - Qooxdoo - Rap Course At The University Of Szeged
Lecture 8 - Qooxdoo - Rap Course At The University Of SzegedFabian Jakobs
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008rajivmordani
 
Venkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic LanguagesVenkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic Languagesdeimos
 
Using React with Grails 3
Using React with Grails 3Using React with Grails 3
Using React with Grails 3Zachary Klein
 
Enabling White-Box Reuse in a Pure Composition Language
Enabling White-Box Reuse in a Pure Composition LanguageEnabling White-Box Reuse in a Pure Composition Language
Enabling White-Box Reuse in a Pure Composition Languageelliando dias
 
企业级软件的组件化和动态化开发实践
企业级软件的组件化和动态化开发实践企业级软件的组件化和动态化开发实践
企业级软件的组件化和动态化开发实践Jacky Chi
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James NelsonGWTcon
 
Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...elliando dias
 
Launchpad: Lessons Learnt
Launchpad: Lessons LearntLaunchpad: Lessons Learnt
Launchpad: Lessons LearntTim Penhey
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails IntroductionEric Weimer
 

Semelhante a Adapter Design Pattern (20)

Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603
 
Creational Design Patterns
Creational Design PatternsCreational Design Patterns
Creational Design Patterns
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
jdays 2015
jdays 2015jdays 2015
jdays 2015
 
Anti Object-Oriented Design Patterns
Anti Object-Oriented Design PatternsAnti Object-Oriented Design Patterns
Anti Object-Oriented Design Patterns
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Visage Android Hands-on Lab (OSCON)
Visage Android Hands-on Lab (OSCON)Visage Android Hands-on Lab (OSCON)
Visage Android Hands-on Lab (OSCON)
 
Lecture 8 - Qooxdoo - Rap Course At The University Of Szeged
Lecture 8 - Qooxdoo - Rap Course At The University Of SzegedLecture 8 - Qooxdoo - Rap Course At The University Of Szeged
Lecture 8 - Qooxdoo - Rap Course At The University Of Szeged
 
Redux vs GraphQL
Redux vs GraphQLRedux vs GraphQL
Redux vs GraphQL
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008
 
Venkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic LanguagesVenkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic Languages
 
Using React with Grails 3
Using React with Grails 3Using React with Grails 3
Using React with Grails 3
 
Enabling White-Box Reuse in a Pure Composition Language
Enabling White-Box Reuse in a Pure Composition LanguageEnabling White-Box Reuse in a Pure Composition Language
Enabling White-Box Reuse in a Pure Composition Language
 
ArangoDB
ArangoDBArangoDB
ArangoDB
 
企业级软件的组件化和动态化开发实践
企业级软件的组件化和动态化开发实践企业级软件的组件化和动态化开发实践
企业级软件的组件化和动态化开发实践
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson
 
Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Launchpad: Lessons Learnt
Launchpad: Lessons LearntLaunchpad: Lessons Learnt
Launchpad: Lessons Learnt
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails Introduction
 

Mais de guy_davis

Adopting Scrum and Agile
Adopting Scrum and AgileAdopting Scrum and Agile
Adopting Scrum and Agileguy_davis
 
Pragmatic Programmer
Pragmatic ProgrammerPragmatic Programmer
Pragmatic Programmerguy_davis
 
Content Caching with Rails
Content Caching with RailsContent Caching with Rails
Content Caching with Railsguy_davis
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguy_davis
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Javaguy_davis
 
Agile Software Development Methodologies
Agile Software Development MethodologiesAgile Software Development Methodologies
Agile Software Development Methodologiesguy_davis
 
Project Monitoring and Control
Project Monitoring and ControlProject Monitoring and Control
Project Monitoring and Controlguy_davis
 
The Human Side of Software Development
The Human Side of Software DevelopmentThe Human Side of Software Development
The Human Side of Software Developmentguy_davis
 
Software Quality Plan
Software Quality PlanSoftware Quality Plan
Software Quality Planguy_davis
 
Unified Process
Unified ProcessUnified Process
Unified Processguy_davis
 
Software Configuration Management
Software Configuration ManagementSoftware Configuration Management
Software Configuration Managementguy_davis
 
Quality Function Deployment
Quality Function DeploymentQuality Function Deployment
Quality Function Deploymentguy_davis
 

Mais de guy_davis (12)

Adopting Scrum and Agile
Adopting Scrum and AgileAdopting Scrum and Agile
Adopting Scrum and Agile
 
Pragmatic Programmer
Pragmatic ProgrammerPragmatic Programmer
Pragmatic Programmer
 
Content Caching with Rails
Content Caching with RailsContent Caching with Rails
Content Caching with Rails
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
Agile Software Development Methodologies
Agile Software Development MethodologiesAgile Software Development Methodologies
Agile Software Development Methodologies
 
Project Monitoring and Control
Project Monitoring and ControlProject Monitoring and Control
Project Monitoring and Control
 
The Human Side of Software Development
The Human Side of Software DevelopmentThe Human Side of Software Development
The Human Side of Software Development
 
Software Quality Plan
Software Quality PlanSoftware Quality Plan
Software Quality Plan
 
Unified Process
Unified ProcessUnified Process
Unified Process
 
Software Configuration Management
Software Configuration ManagementSoftware Configuration Management
Software Configuration Management
 
Quality Function Deployment
Quality Function DeploymentQuality Function Deployment
Quality Function Deployment
 

Último

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Adapter Design Pattern

  • 1. Adapter SENG 609.04 Design Patterns Winter, 2003 Presented by Ming Zhou, Guy Davis
  • 2. Agenda Intent & Motivation  Structure  Applicability  Consequences  Known Uses  Related Patterns  References  - Total 17 pages - 1
  • 3. What is Adapter? Change the interface of a  class into another interface which is expected by the client. A.K.A. Wrapper  - Total 17 pages - 1
  • 4. What is Adapter? Change the interface of a  class into another interface which is expected by the client. A.K.A. Wrapper  - Total 17 pages - 1
  • 5. What is Adapter? Change the interface of a  class into another interface which is expected by the client. A.K.A. Wrapper  - Total 17 pages - 1
  • 6. Motivation - Total 17 pages - 1
  • 7. Motivation - Total 17 pages - 1
  • 8. Motivation - Total 17 pages - 1
  • 9. Motivation 1 1 - Total 17 pages - 1
  • 10. Structure (Class) - Total 17 pages - 1
  • 11. Structure (Object) - Total 17 pages - 1
  • 12. Applicability - Total 17 pages - 1
  • 13. Applicability Use an existing class whose interface  does not match the requirement - Total 17 pages - 1
  • 14. Applicability Use an existing class whose interface  does not match the requirement Create a reusable class though the  interfaces are not necessary compatible with callers - Total 17 pages - 1
  • 15. Applicability Use an existing class whose interface  does not match the requirement  Create a reusable class though the interfaces are not necessary compatible with callers  Want to use several existing subclasses, but it is impractical to subclass everyone. (Object Adapter Only) - Total 17 pages - 1
  • 16. Class Adapter Pattern Pros  Only 1 new object, no additional indirection  Less code required than the object Adapter  Can override Adaptee's behaviour as required  Cons  Requires sub-classing (tough for single  inheritance) Less flexible than object Adapter  - Total 17 pages - 1
  • 17. Object Adapter Pattern Pros  More flexible than class Adapter  Doesn't require sub-classing to work  Adapter works with Adaptee and all of its  subclasses Cons  Harder to override Adaptee behavior  Requires more code to implement  properly - Total 17 pages - 1
  • 18. Pluggable Adapters implemented with abstract operations  - Total 17 pages - 1
  • 19. Pluggable Adapters implemented with delegate objects  - Total 17 pages - 1
  • 20. Two-way Adapters class PegAdapter: public SquarePeg, class SquarePeg { RoundPeg { public: void virtual squarePegOperation() public: { blah } void virtual roundPegOperation() { } add some corners; squarePegOperation(); class RoundPeg { } public: void virtual squarePegOperation() { void virtual roundPegOperation() add some corners; { blah } roundPegOperation(); } } } - Total 17 pages - 1
  • 21. Adapting Local Classes to RMI Comparison:  Increases reusability of local class  Improves performance of local class  Doesn't use Java single parent by subclassing (uses composition) - Total 17 pages - 1
  • 22. Related Patterns Adapter can be similar to the remote  form of Proxy. However, Proxy doesn't change interfaces. Decorator enhances another object  without changing its interface. Bridge similar structure to Adapter,  but different intent. Separates interface from implementation. - Total 17 pages - 1
  • 23. Conclusions Allows collaboration between classes  with incompatible interfaces Implemented in either class-based  (inheritance) or object-based (composition & delegation) manner Useful pattern which promotes reuse  and allows integration of diverse software components - Total 17 pages - 1
  • 24. References Becker, Dan. Design networked applications in RMI using the Adapter design  pattern. JavaWorld Magazine, May 1999. http://www.javaworld.com/javaworld/ jw-05-1999/jw-05-networked.html Buschmann et al. A System of Patterns: Pattern-Oriented Software Architecture.  John Wiley and Sons. Chichester. 1996 Gamma et al. Design Patterns: Elements of Reusable Object-Oriented Software.  Addison-Wesley. Boston. 1995 Nguyen, D.X. Tutorial 10: Stacks and Queues: The Adapter Pattern. Rice  University. 1999. http://www.owlnet.rice.edu/~comp212/99-fall/tutorials/10/ tutorial10.html Whitney, Roger. CS 635 Advanced Object-Oriented Design & Programming. San  Diego State University. 2001. http://www.eli.sdsu.edu/courses/spring01/cs635/ notes/proxy/proxy.html#Heading10 Shalloway, Alan., and Trott, James R., Design Patterns Explained: A New  Perspective on Object-Oriented Design, Addison-Wesley, 2002. Rising, Linda., The Patterns Handbook: Techniques, Strategies, and Applications,  Cambridge university Press, 1998. - Total 17 pages - 1
  • 25. Questions? - Total 17 pages - 1
  • 26. Questions? - Total 17 pages - 1
  • 27. Java Native Interface (JNI) SENG 609.04 Design Patterns Winter, 2003 Presented by Guy Davis, Ming Zhou
  • 28. Agenda Overview  Justification  Hello World!  Summary  References  Q&A  - Total 17 pages - 1
  • 29. JNI Overview - Total 17 pages - 1
  • 30. Interactions with Native Code Access to Java world from native code Access to- native code from Java Total 17 pages - 1
  • 31. Justification Pros:  Reuse: allows access to useful native code  Efficiency: use best language for the task Cons:  Applets: doesn't work as they're mobile  Portability: native methods aren't portable  Extra work: javah, create shared native libs - Total 17 pages - 1
  • 32. HelloWorld.java class HelloWorld { public native void displayHelloWorld(); static { System.loadLibrary(quot;helloquot;); } public static void main(String[] args) { new HelloWorld().displayHelloWorld(); } } - Total 17 pages - 1
  • 33. HelloWorld.java class HelloWorld { public native void displayHelloWorld(); static { System.loadLibrary(quot;helloquot;); } public static void main(String[] args) { new HelloWorld().displayHelloWorld(); } } - Total 17 pages - 1
  • 34. HelloWorld.java class HelloWorld { public native void displayHelloWorld(); static { System.loadLibrary(quot;helloquot;); } public static void main(String[] args) { new HelloWorld().displayHelloWorld(); } } - Total 17 pages - 1
  • 35. HelloWorld.java class HelloWorld { public native void displayHelloWorld(); static { System.loadLibrary(quot;helloquot;); } public static void main(String[] args) { new HelloWorld().displayHelloWorld(); } } - Total 17 pages - 1
  • 36. HelloWorld.h #include “jni.h” /* Header for class HelloWorld */ #ifndef _Included_HelloWorld #define _Included_HelloWorld #ifdef __cplusplus extern “C” { #endif /* * Class: HelloWorld * Method: displayHelloWorld * Signature: ()V */ JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif - Total 17 pages - 1
  • 37. HelloWorld.h #include “jni.h” /* Header for class HelloWorld */ #ifndef _Included_HelloWorld #define _Included_HelloWorld #ifdef __cplusplus extern “C” { #endif /* * Class: HelloWorld * Method: displayHelloWorld * Signature: ()V */ JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif - Total 17 pages - 1
  • 38. HelloWorld.h #include “jni.h” /* Header for class HelloWorld */ #ifndef _Included_HelloWorld #define _Included_HelloWorld #ifdef __cplusplus extern “C” { #endif /* * Class: HelloWorld * Method: displayHelloWorld * Signature: ()V */ JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif - Total 17 pages - 1
  • 39. HelloWorldImp.c #include <jni.h> #include quot;HelloWorld.hquot; #include <stdio.h> JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj) { printf(quot;Hello world!nquot;); return; } - Total 17 pages - 1
  • 40. HelloWorldImp.c #include <jni.h> #include quot;HelloWorld.hquot; #include <stdio.h> JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj) { printf(quot;Hello world!nquot;); return; } - Total 17 pages - 1
  • 41. HelloWorldImp.c #include <jni.h> #include quot;HelloWorld.hquot; #include <stdio.h> JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj) { printf(quot;Hello world!nquot;); return; } - Total 17 pages - 1
  • 42. HelloWorldImp.c #include <jni.h> #include quot;HelloWorld.hquot; #include <stdio.h> JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj) { printf(quot;Hello world!nquot;); return; } - Total 17 pages - 1
  • 43. Create a Shared Library class HelloWorld { ... System.loadLibrary(quot;helloquot;); ... } Compile the native code into a shared library: (example for MS Windows Visual C++ 4.0) cl -Ic:javainclude -Ic:javaincludewin32 -LD HelloWorldImp.c -Fehello.dll - Total 17 pages - 1
  • 44. Run the Program Command: java HelloWorld Result: Hello World! Possible
exceptions: java.lang.UnsatisfiedLinkError: no hello in shared library path at java.lang.Runtime.loadLibrary(Runtime.java) at java.lang.System.loadLibrary(System.java) at java.lang.Thread.init(Thread.java) - Total 17 pages - 1
  • 45. Summary Connect Java with native languages Code reuse Powerful Compromise of Java safety features,  cross-platform and dynamic ability JNI call is slow and costful  Not work well for applets  - Total 17 pages - 1
  • 46. References  Glenn L. Vanderburg. et al., Tricks of the Java Programming Gurus, 1996, http://docs.rinet.ru:8080/ JaTricks/  Beth Stearns, Trail: Java Native Interface, Sun Microsystems, Inc., 2003, http://java.sun.com/docs/ books/tutorial/native1.1/  Roedy Green, JNI, The Java Native Interface, Canadian Mind Products, 2002, http://mindprod.com/jni.html  Kong Wenyu, A Brief Introduction to Java Native Interface, http://www.geocities.com/kongwenyu/jni.html - Total 17 pages - 1
  • 47. Questions? - Total 17 pages - 1
  • 48. Questions? - Total 17 pages - 1

Notas do Editor

  1. Java Native Interface provides an means of interacting with native platform classes and functions through the creation of shared libraries. JNI can be used with most languages such as C, C++, Fortran, Cobol, etc...
  2. Full two-way interaction. Native code can interact with Java objects and their methods. Can also generate and throw exceptions that can be handled by Java code. Java code has full access to functionality contained with the native code through the generated interface definitions. Full passing of primitive parameters after conversion (strings to UTF)
  3. There is a ton of existing useful code in &#x201C;native&#x201D; languages: Numerical analysis libraries like LAPACK and BLAS in Fortran Lots of business logic contained with Cobol code Much high-speed code is written in C or assembly
  4. Keyword 'native' used to indicate methods that are available through shared libraries of native code.
  5. Loading the library: On Unix, looks for &#x201C;libhello.so&#x201D; or similar On Win, looks for &#x201C;hello.dll&#x201D; Show how to generate library later...
  6. Once library is loaded, can call native methods defined earlier. Finally, compile the class with: javac HelloWorld.java
  7. Autogenerated with call to: javah -jni HelloWorld
  8. Signature indicates no parameters being passed and void return clause.
  9. The JNIEXPORT and JNICALL macros are defined in jni_md.h which contains platform specific definitions. JNIENV is an interface pointer used to invoke JNI calls. jobject is the Java object on which the call is invoked.
  10. The JNIEXPORT and JNICALL macros are defined in jni_md.h which contains platform specific definitions. JNIENV is an interface pointer used to invoke JNI calls. jobject is the Java object on which the call is invoked.
  11. The JNIEXPORT and JNICALL macros are defined in jni_md.h which contains platform specific definitions. JNIENV is an interface pointer used to invoke JNI calls. jobject is the Java object on which the call is invoked.
  12. The JNIEXPORT and JNICALL macros are defined in jni_md.h which contains platform specific definitions. JNIENV is an interface pointer used to invoke JNI calls. jobject is the Java object on which the call is invoked.
  13. The JNIEXPORT and JNICALL macros are defined in jni_md.h which contains platform specific definitions. JNIENV is an interface pointer used to invoke JNI calls. jobject is the Java object on which the call is invoked.