Plug-In Architecture Pattern

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

Goals Give you a feeling of what Eclipse is.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
Distributed Application Development B. Ramamurthy.
1 Introducing Collaboration to Single User Applications A Survey and Analysis of Recent Work by Brian Cornell For Collaborative Systems Fall 2006.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of Creating Eclipse plug-ins.
1 Plug-in Development Environment (PDE) Guide. 2 Introduction to PDE l What is PDE: »a tool designed to help you develop platform plug-ins while working.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
ODBC and JDBC What are they – libraries of function calls that support SQL statements Why do we need them –Provide a way for an application to communicate.
CVSQL 2 The Design. System Overview System Components CVSQL Server –Three network interfaces –Modular data source provider framework –Decoupled SQL parsing.
6/1/2001 Supplementing Aleph Reports Using The Crystal Reports Web Component Server Presented by Bob Gerrity Head.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Lesley Bross, August 29, 2010 ArcGIS 10 add-in glossary.
Stimulsoft Reports.Net 20 Problems which Stimulsoft Reports.Net solves
Writing Widgets & Custom Script API for BOY Xihui Chen
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
POS 406 Java Technology And Beginning Java Code
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Hands-On Microsoft Windows Server Implementing Microsoft Internet Information Services Microsoft Internet Information Services (IIS) –Software included.
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 14 Database Connectivity and Web Technologies.
What's New in Kinetic Calendar 2.0 Jack Boespflug Kinetic Data.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
12/6/2015B.Ramamurthy1 Java Database Connectivity B.Ramamurthy.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
CITA 310 Section 7 Installing and Testing a Programming Environment (Textbook Chapter 7)
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
JDBC CS 260 Database Systems. Overview  Introduction  JDBC driver types  Eclipse project setup  Programming with JDBC  Prepared statements  SQL.
Design Patterns. Outline Purpose Purpose Useful Definitions Useful Definitions Pattern Overview Pattern Overview.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
 Project Team: Suzana Vaserman David Fleish Moran Zafir Tzvika Stein  Academic adviser: Dr. Mayer Goldberg  Technical adviser: Mr. Guy Wiener.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
The Holmes Platform and Applications
Topic 2: Hardware and Software
DEPTT. OF COMP. SC & APPLICATIONS
Business Directory REST API
Goals Give you a feeling of what Eclipse is.
Servlet Fudamentals.
Writing simple Java Web Services using Eclipse
Play Framework: Introduction
Remote Method Invocation
The Improvement of PaaS Platform ZENG Shu-Qing, Xu Jie-Bin 2010 First International Conference on Networking and Distributed Computing SQUARE.
PHP / MySQL Introduction
CMPE419 Mobile Application Development
Objectives In this lesson you will learn about: Need for servlets
MySQL Migration Toolkit
Java Database Connectivity
Chapter 7 –Implementation Issues
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Constructors, GUI’s(Using Swing) and ActionListner
(Computer fundamental Lab)
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Java Remote Method Invocation
Software Design Lecture : 38.
Computer Programming-1 CSC 111
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
CMPE419 Mobile Application Development
Web Application Development Using PHP
Java Chapter 7 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Plug-In Architecture Pattern

Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment extensions is large Specific details on future extensions are not available, but their general nature is predictable It should be possible to extend the system without access to the system's source code, by people who were not the system's original developers It should be easy to add and remove extensions in whatever combination is desired by the customer

Example : Syntax Highlighting You are writing a text editor intended for use by software developers You want to support syntax highlighting, but the set of possible programming languages is unbounded Even if you could list all of the possible languages, you don't have enough resources to implement syntax highlighting for them all Third-party developers and end-users will need the ability to add syntax highlighting for their favorite languages without your help

Solution Define an abstract interface that captures the general nature of the necessary extensions interface ISyntaxHighlighter { … } Extensions are components that implement the abstract interface class PerlSyntaxHighlighter implements ISyntaxHighlighter { … } How does the application know when to use our plug-in class? How can the application instantiate our plug-in class? It doesn’t know the class name to call “new” on (PerlSyntaxHighlighter) At installation time, a new plug-in has to “register” with the application

Solution Extensions are called "plug-ins" because they can be "plugged in" to the system without recompilation The system instantiates plug-in components indirectly through a registry The system invokes plug-in functionality through an abstract interface

Solution

Dynamic Behavior : Plug-in Registration

Dynamic Behavior : Plug-in Selection and Execution

Dynamic Behavior : Plug-in Un-registration

Known Uses Web browser plug-ins for different file formats PDF, PowerPoint, Word, etc. Web servers Apache Modules SSL, user authentication, caching, logging, etc. IIS ISAPI Extensions MS-Windows compound documents "Insert Object" menu in many Windows applications

Known Uses Syntax Highlighting Eclipse Framework for building integrated development environments (IDEs) Provides basic shell for IDE UI All actual work is done by plug-ins for specific development tasks Editors, compilers, debuggers, wizards Database drivers Generic database APIs: ODBC, JDBC Plug-in drivers for specific DBs: SqlServer, MySQL, Postgres, etc.

Consequences Results in a system that can be extended: After it's shipped By people other than the original developers Without recompiling the system Users are free to choose which plug-ins they want to install Commercial opportunities for third-party plug-in developers Buggy plug-ins can destabilize the system since they're usually loaded directly into the host application process (crashes, memory leaks, etc.)

Implementation: Windows Plug-ins are frequently implemented as dynamically-linked libraries in Windows applications The host application loads the plug-in DLLs that have been registered Registration techniques Just copy the plug-in DLL into a special directory. The host application loads all DLLs in the plug-in directory, and queries each DLL for information about its plug-in Installer puts an entry in a configuration file that indicates where the plug-in DLL is located

Implementation: Java In Java a plug-in could be a .class file containing the plug-in class In most cases, plugins will consist of multiple classes, so they will exist in a .jar file Registration could be as simple as putting the name of the plug-in jar file name and implementation class in a configuration file The host application uses reflection to instantiate plug-in classes by name, which causes the classes to be loaded into the JVM Plugins are meant to be loaded dynamically, meaning they aren’t on the application’s classpath. Use a Java classloader to make the class(es) from the plugin’s .jar file available to the application at runtime.

A Simple Plugin Example: The Plugin Interface package plugin; public interface MessagePlugin { String getMessage(); } Needs to be in two places The application that will load the plugin The plugin that will be loaded In Intellij (similar in other IDEs): Put the interface in a separate module in the application’s project so you can generate a jar file containing only the interface Include the interface jar file as an external dependency in the plugin project

A Simple Plugin Example: The Application public class Application { public static final void main(String [] args) throws Exception { if(args.length != 3) { printUsage(); } else { Application application = new Application(); application.start(args[0], args[1], args[2]); } } public static void printUsage() { System.out.println("Usage: java Application pluginDirectory " + "pluginJarFileName pluginClassName"); } …

A Simple Plugin Example: The Application … private void start(String pluginDirectory, String pluginJarName, String pluginClassName) throws Exception { MessagePlugin messagePlugin = getMessagePluginInstance( pluginDirectory, pluginJarName, pluginClassName); System.out.println(messagePlugin.getMessage()); } private MessagePlugin getMessagePluginInstance(String pluginDirectory, String pluginJarName, String pluginClassName) throws Exception { // Get a class loader and set it up to load the jar file File pluginJarFile = new File(pluginDirectory, pluginJarName); URL pluginURL = pluginJarFile.toURI().toURL(); URLClassLoader loader = new URLClassLoader(new URL[]{pluginURL}); // Load the jar file's plugin class, create and return an instance Class<? extends MessagePlugin> messagePluginClass = (Class<MessagePlugin>) loader.loadClass(pluginClassName); return messagePluginClass.getDeclaredConstructor(null).newInstance(); } }

A Simple Plugin Example: The Plugin import plugin.MessagePlugin; public class HelloMessage implements MessagePlugin { @Override public String getMessage() { return "Hello from the plugin"; } } Exists in a separate project (separate from the application) Has a dependency on the MessagePlugin jar Create a jar containing the HelloMessage class and place it in some directory Specify the directory, jar file name, and class name (HelloMessage in this case) when invoking the application that uses the plugin