Modular Applications and the Lookup API Geertjan Wielenga NetBeans Team.

Slides:



Advertisements
Similar presentations
Chapter 1: Computer Systems
Advertisements

Goals Give you a feeling of what Eclipse is.
DT228/3 Web Development Introduction to Java Server Pages (JSP)
Apache Axis2 - OSGi Integration in WSO2 Carbon Platform
Notes to the presenter. I would like to thank Jim Waldo, Jon Bostrom, and Dennis Govoni. They helped me put this presentation together for the field.
Liang,Introduction to Java Programming,revised by Dai-kaiyu 1 Chapter 10 Object-Oriented Modeling.
DISTRIBUTED FILE SYSTEM USING RMI
Eclipse Architecture Dwight Deugo Nesa Matic
Introduction to Java Programming
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of Creating Eclipse plug-ins.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Java Beans Component Technology Integrated, Visual Development Environments Reusable Platform-Independent Modular.
 Proteus Framework Redefining the plugin. Why a new framework?  Present approaches (e.g. OSGi) use non-standard approaches that create too many breaking.
Component-Based Software Engineering Introduction to Java Beans Paul Krause and Sotiris Moschoyiannis.
Lecture Roger Sutton CO530 Automation Tools 5: Class Libraries and Assemblies 1.
Visual Basic: An Object Oriented Approach 12 – Creating and using ActiveX objects.
Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
© 2005 by IBM; made available under the EPL v1.0 | March 1, 2005 Tim deBoer Gorkem Ercan Extend WTP Server Tools for your.
Tuscany 2.x Extensibility and SPIs Raymond Feng. Tuscany Extensibility Cx2x/Tuscany+2.x+Extensibility+and+SPIs#extensions.
Java 2 security model Valentina Casola. Components of Java the development environment –development lifecycle –Java language features –class files and.
Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02.
OSGi Enablement for Tuscany Raymond Feng. Overview.
SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
CS 501: Software Engineering Fall 1999 Lecture 12 System Architecture III Distributed Objects.
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.
Creating Modular CRUD Desktop Applications Jiri Rechtacek Geertjan Wielenga.
Introduction to business component technologies. Component definitions Szyperski: A software component is a unit of composition with contractually specified.
ETICS All Hands meeting B ologna, October , 2006 WP4 Test and Metrics Plugin Framework (WP4) (WP4) Eva TAKACS.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
Java High level programming language ◦ Sun Microsystems ◦ ORACLE acquired Java Development Kit – JDK Java Runtime Environment – JRE Java Virtual Machine.
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
JavaOne 2010 Patterns for Modularity Anton Epple, Eppleton IT Consulting Jaroslav Tulach, NetBeans Team, Oracle, Prague Zoran Sevarac, Faculty of Organizational.
Introduction to the NetBeans Platform Certified Training Course Geertjan Wielenga Sun Microsystems.
Getting Started with the NetBeans Platform. Extending NetBeans Possibilities > single module > suite of modules > standalone application > like a suite.
NetBeans Platform intro Emilian Bold. What's it about ? ● Contains usual desktop application items: – Window management – Menu & tool bar management –
Modular Applications and the Lookup API Tim Boudreau Senior Staff Engineer Sun Microsystems.
NetBeans Rich Client Platform Alex Kotchnev Software Developer Commerce Technologies Inc. Alex Kotchnev Software Developer Commerce Technologies Inc.
Modular Applications and the Lookup API David Štrupl Sun Microsystems.
System FileSystem Everything is a Stream. What is it? General registry of configuration data.
January 26, Ann Wollrath Copyright 1999 Sun Microsystems, Inc., all rights reserved. Java ™ RMI Overview Ann Wollrath Senior Staff Engineer Sun Microsystems,
Hello NetBeans Platform
Object Oriented Programming in
Java Interview Questions
CSE775 - Distributed Objects, Spring 2006
Working with Java.
MVC in NetBeans and other modular applications Jaroslav Tulach.
Recap Modules: dependency management, revisioning, information hiding
OpenLegacy Training Day Four Introduction to Microservices
Goals Give you a feeling of what Eclipse is.
Chapter 5 Remote Procedure Call
Nodes and Explorer NetBeans ~ JavaBeans Tim Boudreau
Chapter 11 Object-Oriented Design
Java Beans Sagun Dhakhwa.
Distribution and components
Project Topic 2: Migration to Java 9
OpenOffice.org API Plugin for NetBeans- a look under the hood
Contributing to Open Source Projects
Contributing to Open Source Projects
Lecture 1: Multi-tier Architecture Overview
More Model Elements.
Distributed System using Web Services
Java History, Editions, Version Features
Dynamic Exchange of Capabilities Between Mobile Agents
Distributed System using Web Services
Plug-In Architecture Pattern
Introduction to Classes and Objects
Presentation transcript:

Modular Applications and the Lookup API Geertjan Wielenga NetBeans Team

Certified Engineer Course The Need for Modular Applications

Certified Engineer Course The Need for Modular Applications

Certified Engineer Course The Need for Modular Applications

Certified Engineer Course The Need for Modular Applications Applications get more complex Assembled from pieces Developed by distributed teams Components have complex dependencies Healthy architecture: > Know your dependencies > Manage your dependencies

Certified Engineer Course The Entropy of Software Version 1.0 is cleanly designed...

Certified Engineer Course The Entropy of Software Version a few expedient hacks...we'll clean those up in 2.0

Certified Engineer Course The Entropy of Software Version oops...but...it works!

Certified Engineer Course The Entropy of Software Version Help! Whenever I fix one bug, I create two more!

Certified Engineer Course The Entropy of Software Version 4.0 is cleanly designed. It's a complete rewrite. It was a year late, but it works...

Certified Engineer Course The Entropy of Software Version does this look familiar?....

Certified Engineer Course The Entropy of Software TO BE CONTINUED....

Certified Engineer Course Modular Applications Discover their components at runtime May add/remove/reload components at runtime Must satisfy dependencies between components Have API contracts between components Run inside a runtime container

Certified Engineer Course What Does a Runtime Container Do? Application lifecycle > Starts and exits your application > Modules are installed and ununistalled Module discovery and management Classloading and code isolation Service registration/discovery facility

Certified Engineer Course What is the NetBeans Runtime Container?

Certified Engineer Course Demo 1: NetBeans Runtime Container

Certified Engineer Course NetBeans Runtime Container 5 NetBeans Platform modules These 5 together compile & run, nothing more required. Only these are required by all NetBeans Platform applications So... by default, NetBeans Platform applications are not all client applications Modular server applications on the NetBeans Platform?

Certified Engineer Course What is a NetBeans Module? It is just a JAR file – no magic > Has some special manifest entries to describe it to NetBeans > Editable in the Project Properties dialog for module projects Distributed in an NBM file > Basically a signed JAR file > Contains metadata about the module > May contain 3 rd party JARs or anything else that needs to be on the system

Certified Engineer Course Demo 2: Creating a NetBeans Module

Certified Engineer Course Demo 3: Distributing a NetBeans Module

Certified Engineer Course NetBeans Module Manifest Manifest-Version: 1.0 Ant-Version: Apache Ant Created-By: 1.5.0_14-b03 (Sun Microsystems Inc.) OpenIDE-Module-Public-Packages: - OpenIDE-Module-Module-Dependencies: org.netbeans.api.java/1,... OpenIDE-Module-Java-Dependencies: Java > 1.5 OpenIDE-Module-Build-Version: OpenIDE-Module-Specification-Version: OpenIDE-Module: org.netbeans.modules.java.editor/1 OpenIDE-Module-Implementation-Version: 4 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/editor/Bundle.properties

Certified Engineer Course NetBeans Module Manifest OpenIDE-Module-Install: org/netbeans/modules/java/editor/JavaEditorModule.class OpenIDE-Module-Layer: org/netbeans/modules/java/editor/resources/layer.xml OpenIDE-Module-Requires: org.openide.modules.ModuleFormat1 AutoUpdate-Show-In-Client: false

Certified Engineer Course Runtime Container Tasks Ensure that dependencies are satisfied > Including requiring > version n of a module Not allow illegal dependencies Allow legal dependencies Instantiate components of the system at runtime

Certified Engineer Course Enforcing Module Dependencies

Certified Engineer Course Demo 4: Dependency Management

Certified Engineer Course Use an Existing Runtime Container Rest In Peace, Home-made Frameworks

Certified Engineer Course Module Dependencies

Certified Engineer Course Separate Implementations from API API can be in one module, implementation in another Modules needing the API only install if dependencies are satisfied

Certified Engineer Course Modular Libraries and Discovery

Certified Engineer Course Discovery and Dependencies ? ● So how will the SpellChecker API find its implementation?

Certified Engineer Course Discovery and Dependencies ? ● So how will the SpellChecker API find its implementation? ● In general, how do NetBeans modules find each other within the application?

Certified Engineer Course The Java Extension Mechanism (almost it) In JDK since 1.3 Easy with JDK 6's ServiceLoader.load() Declarative registration > No startup penalty Plain-text file in META-INF/services > Name is interface > Content is FQN of implementation

Certified Engineer Course Demo 5: ServiceLoader Interface public interface TextFilter { String process(String s); } Implementation public class UpperCaseFilter implements TextFilter{ public String process(String s) { return s.toUpperCase(); } }

Certified Engineer Course Demo 5: ServiceLoader Register the Implementation Load the Interface String s = textArea.getText(); ServiceLoader filters = ServiceLoader.load(TextFilter.class); for (TextFilter textFilter : filters) { if (filters != null) { s = textFilter.process(s); } } textArea.setText(s);

Certified Engineer Course Demo 6: Lookup/Dependency Management String s = textArea.getText(); Collection filters = Lookup.getDefault().lookupAll(TextFilter.class); for (TextFilter textFilter : filters) { if (!filters.isEmpty()) { s = textFilter.process(s); } textArea.setText(s);

Certified Engineer Course Lookup – NetBeans Solution Small, NetBeans independent library > Part of NetBeans org-openide-util.jar > org.openide.util.Lookup Works with any version of Java (unlike JDK's ServiceLoader) A Lookup is dynamic > Can fire changes A Lookup is instantiable > You can make one and use it Lookups are composable > ProxyLookup can combine and switch between other lookups and fire changes

Certified Engineer Course A Lookup is a place A space objects swim into and out of You can observe when specific types of object appear and disappear You can get a collection all of the instances of a type in a Lookup

Certified Engineer Course So...What's So Special About This? ? What if objects had Lookups? What if Lookups could proxy each other?

Certified Engineer Course Objects Have Lookups Too! TopComponent Node DataObject

Certified Engineer Course Demo 7: TopComponent Lookup

Certified Engineer Course Demo: TopComponent Lookup SaveActionEditor give me a SaveCookie s s == null ? yes disable action no enable action on action invocation: call s.save() interface SaveCookie { void save(); }

Certified Engineer Course Demo 8: TopComponent Lookup private InstanceContent content;... content = new InstanceContent(); associateLookup(new AbstractLookup(content));... content.add(s);

Certified Engineer Course Demo 8: TopComponent Lookup private Lookup.Result result;... result = Utilities.actionsGlobalContext().lookupResult(String.class); result.addLookupListener(new LookupListener() public void resultChanged(LookupEvent e) { textArea2.setText(result.allInstances().toString()); } });

Certified Engineer Course Conclusion Lookup is used pervasively throughout NetBeans APIs It is used for > Declaratively registered global services > Instantiation on demand – reduce startup time > Separation of API and implementation  One module can provide an API  Another module provides the implementation > Context sensitivity, e.g., action enablement It is the most important APIs to play with!

Certified Engineer Course The Need for Modular Applications

Certified Engineer Course Revision of New Concepts Application Entropy Modularity Dependency Management Runtime Container NetBeans Module NBM File API vs Implementation META-INF/services ServiceLoader vs. Lookup Listening to the Lookup Context sensitivity via Lookup

Certified Engineer Course Questions & Answers