Modularity for Java and How OSGi Can Help

Similar documents
Java Modularity Support in OSGi R4. Richard S. Hall ApacheCon (San Diego) December 14 th, 2005

Mokka, main guidelines and future

Natural Language Based User Interface for On-Demand Service Composition

BoxPlot++ Zeina Azmeh, Fady Hamoui, Marianne Huchard. To cite this version: HAL Id: lirmm

Setup of epiphytic assistance systems with SEPIA

Teaching Encapsulation and Modularity in Object-Oriented Languages with Access Graphs

How to simulate a volume-controlled flooding with mathematical morphology operators?

Service Reconfiguration in the DANAH Assistive System

Catalogue of architectural patterns characterized by constraint components, Version 1.0

Multimedia CTI Services for Telecommunication Systems

Linux: Understanding Process-Level Power Consumption

Tacked Link List - An Improved Linked List for Advance Resource Reservation

Linked data from your pocket: The Android RDFContentProvider

Change Detection System for the Maintenance of Automated Testing

Hierarchical Multi-Views Software Architecture

Comparator: A Tool for Quantifying Behavioural Compatibility

IntroClassJava: A Benchmark of 297 Small and Buggy Java Programs

YANG-Based Configuration Modeling - The SecSIP IPS Case Study

QuickRanking: Fast Algorithm For Sorting And Ranking Data

Fault-Tolerant Storage Servers for the Databases of Redundant Web Servers in a Computing Grid

SIM-Mee - Mobilizing your social network

Open Digital Forms. Hiep Le, Thomas Rebele, Fabian Suchanek. HAL Id: hal

Real-Time Collision Detection for Dynamic Virtual Environments

Blind Browsing on Hand-Held Devices: Touching the Web... to Understand it Better

Relabeling nodes according to the structure of the graph

Formal modelling of ontologies within Event-B

HySCaS: Hybrid Stereoscopic Calibration Software

Multi-atlas labeling with population-specific template and non-local patch-based label fusion

A N-dimensional Stochastic Control Algorithm for Electricity Asset Management on PC cluster and Blue Gene Supercomputer

DANCer: Dynamic Attributed Network with Community Structure Generator

Taking Benefit from the User Density in Large Cities for Delivering SMS

The Sissy Electro-thermal Simulation System - Based on Modern Software Technologies

Simulations of VANET Scenarios with OPNET and SUMO

FStream: a decentralized and social music streamer

An FCA Framework for Knowledge Discovery in SPARQL Query Answers

Study on Feebly Open Set with Respect to an Ideal Topological Spaces

Comparison of spatial indexes

Very Tight Coupling between LTE and WiFi: a Practical Analysis

The Connectivity Order of Links

KeyGlasses : Semi-transparent keys to optimize text input on virtual keyboard

Open Source Software Developer and Project Networks

Assisted Policy Management for SPARQL Endpoints Access Control

FIT IoT-LAB: The Largest IoT Open Experimental Testbed

The optimal routing of augmented cubes.

Reverse-engineering of UML 2.0 Sequence Diagrams from Execution Traces

A Practical Evaluation Method of Network Traffic Load for Capacity Planning

Representation of Finite Games as Network Congestion Games

Syrtis: New Perspectives for Semantic Web Adoption

Generic Design Space Exploration for Reconfigurable Architectures

Real-time FEM based control of soft surgical robots

Moveability and Collision Analysis for Fully-Parallel Manipulators

BugMaps-Granger: A Tool for Causality Analysis between Source Code Metrics and Bugs

Regularization parameter estimation for non-negative hyperspectral image deconvolution:supplementary material

lambda-min Decoding Algorithm of Regular and Irregular LDPC Codes

Experimental Evaluation of an IEC Station Bus Communication Reliability

Comparison of radiosity and ray-tracing methods for coupled rooms

X-Kaapi C programming interface

MUTE: A Peer-to-Peer Web-based Real-time Collaborative Editor

JSR 277, 291 and OSGi, Oh My! - OSGi and Java Modularity

Branch-and-price algorithms for the Bi-Objective Vehicle Routing Problem with Time Windows

Leveraging ambient applications interactions with their environment to improve services selection relevancy

Rule-Based Application Development using Webdamlog

YAM++ : A multi-strategy based approach for Ontology matching task

Real-Time and Resilient Intrusion Detection: A Flow-Based Approach

NP versus PSPACE. Frank Vega. To cite this version: HAL Id: hal

Temperature measurement in the Intel CoreTM Duo Processor

The New Territory of Lightweight Security in a Cloud Computing Environment

Every 3-connected, essentially 11-connected line graph is hamiltonian

Application of RMAN Backup Technology in the Agricultural Products Wholesale Market System

From medical imaging to numerical simulations

Computing and maximizing the exact reliability of wireless backhaul networks

SDLS: a Matlab package for solving conic least-squares problems

Quality of Service Enhancement by Using an Integer Bloom Filter Based Data Deduplication Mechanism in the Cloud Storage Environment

Robust IP and UDP-lite header recovery for packetized multimedia transmission

Fuzzy sensor for the perception of colour

A Resource Discovery Algorithm in Mobile Grid Computing based on IP-paging Scheme

A Voronoi-Based Hybrid Meshing Method

Self-optimisation using runtime code generation for Wireless Sensor Networks Internet-of-Things

Structuring the First Steps of Requirements Elicitation

Use of the Hydra/Sufia repository and Portland Common Data Model for research data description, organization, and access

The Proportional Colouring Problem: Optimizing Buffers in Radio Mesh Networks

A 64-Kbytes ITTAGE indirect branch predictor

Implementing an Automatic Functional Test Pattern Generation for Mixed-Signal Boards in a Maintenance Context

A million pixels, a million polygons: which is heavier?

Malware models for network and service management

The Athena data dictionary and description language

A Generic Architecture of CCSDS Low Density Parity Check Decoder for Near-Earth Applications

Lossless and Lossy Minimal Redundancy Pyramidal Decomposition for Scalable Image Compression Technique

Security Concepts as Add-On for Process Models

Mapping classifications and linking related classes through SciGator, a DDC-based browsing library interface

Deformetrica: a software for statistical analysis of anatomical shapes

Sliding HyperLogLog: Estimating cardinality in a data stream

Cloud My Task - A Peer-to-Peer Distributed Python Script Execution Service

THE KINEMATIC AND INERTIAL SOIL-PILE INTERACTIONS: CENTRIFUGE MODELLING

Decentralised and Privacy-Aware Learning of Traversal Time Models

Constraints driven subscription using Confidence Interval model

Zigbee Wireless Sensor Network Nodes Deployment Strategy for Digital Agricultural Data Acquisition

Equinox OSGi: Pervasive Componentization

An Experimental Assessment of the 2D Visibility Complex

Scan chain encryption in Test Standards

Transcription:

Modularity for Java and How OSGi Can Help Richard Hall To cite this version: Richard Hall. Modularity for Java and How OSGi Can Help. présentation invitée à DECOR04. 2004. <hal-00003299> HAL Id: hal-00003299 https://hal.archives-ouvertes.fr/hal-00003299 Submitted on 16 Nov 2004 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

Modularity for Java and How OSGi Can Help DECOR October 28 th, 2004 Richard S. Hall

Software Deployment Life Cycle Development Release Producer-side Retire Consumer-side Install Update Reconfig Adapt Activate Remove Deactivate

Traditional Focus of Software Deployment Site (or host) The nuts and bolts of deployment Copying, extracting, configuring, localizing, state changes, and registrations, local policies

Traditional Focus of Software Deployment Enterprise Higher-level, sophisticated Coordinated, multi-site, multi-domain, transactional, phased in, global policies Site (or host) The nuts and bolts of deployment Copying, extracting, configuring, localizing, state changes, and registrations, local policies

A New Focus for Software Deployment Enterprise Higher-level, sophisticated Coordinated, multi-site, multi-domain, transactional, phased in, global policies Site (or host) The nuts and bolts of deployment Copying, extracting, configuring, localizing, state changes, and registrations, local policies Extensible systems Fine-grained, dynamic reconfiguration Requires similar aspects of site deployment, but tied more closely to execution environment

Extensible Systems Focus of my research Popularized by Java because of its simple dynamic code loading mechanisms,.net continues this trend Extensible systems provide core functionality that is extended at run time by a modularity mechanism Software deployment at a lower level i.e., a single process or virtual machine

Software Deployment in Extensible Systems Modules must be packaged in an archive for release along with meta-data Potentially supported by repositories or discovery services for advertising and dissemination Module archives must be installed, reconfigured, adapted, and removed May include downloading, extracting, localizing, and versioning Deployment activities occur at run time Module activation and deactivation are central activities Modules are dynamically integrated at run time Existing modules are impacted by continuous deployment activities

Extensible Systems & Modularity What is modularity? (Desirable) property of a system, such that individual components can be examined, modified and maintained independently of the remainder of the system. Objective is that changes in one part of a system should not lead to unexpected behavior in other parts. www.maths.bath.ac.uk/~jap/math0015/glossary.html For my purposes, this must also include the notion of independent packaging Extensible systems require some form of modularity mechanism The Java world has many frameworks and systems reinventing this wheel e.g., component frameworks, plugin mechanisms, application servers, etc.

Importance of Modularity Not specific to extensible systems, impacts all systems Improves system design Helps developers achieve encapsulation and consistency Brings deployment concepts to the forefront Defines a unit of modularity at a minimum May go as far as to define deployment processes for modules Close relationship to execution environment's code loading mechanisms (e.g., class loading in Java)

Modularity in Java Modularity support in Java is primitive Closest analogy is the JAR file Contains Java classes and resources No real connection to deployment No inherent support for dynamically extensible systems Lags behind.net in certain areas Assemblies are treated as a first class concept, as opposed to JAR files Assemblies have explicit versioning rules Assemblies can be shared via GAC Assemblies auto-install is supported

Class Loaders Are Not Modules Too low-level Class loaders are details of Java execution environment Do not provide proper abstraction Complicated to implement Difficult to reuse Not related to deployment Not possible to package nor to perform software deployment processes on them

Related Work for Java Module mechanisms MJ: A Rational Module System for Java and its Applications (J. Corwin et al IBM) Mechanisms for Secure Modular Programming in Java (L. Bauer et al Princeton University) Units: Cool Modules for HOT Languages (M. Flatt and M. Felleisen Rice University) Evolving Software with Extensible Modules (M. Zenger École Polytechnique Fédérale de Lausanne) Component and extensible frameworks EJB, Eclipse, NetBeans

Modularity Requirements Defined in terms of Java packages Well-defined concept in Java Maps nicely to class loaders Explicitly defined boundaries Explicitly defined dependencies Support for versioning Flexible, must support Small to large systems Static to dynamic systems Arbitrary component models Arbitrary interaction patterns

OSGi Framework Multi-client access Television Refrigerator Set-top box Application servers Digital camera Computer Washer and dryer Service providers and administrators

OSGi and Modularity Defines a very simple component and packaging model JAR files, called bundles, contain Java classes, resources, and meta-data Meta-data explicitly defines boundaries and dependencies in terms of Java package imports/exports Dependencies and associated consistency are automatically managed Defines a bundle life cycle that relates directly to deployment processes Explicitly considers dynamic scenarios

Bundle Life Cycle install INSTALLED uninstall resolve update UNINSTALLED uninstall start RESOLVED STARTING STOPPING explicit automatic ACTIVE stop

Deployment and the Bundle Life Cycle install retrieve bundle JAR file into framework, generally from a URL resolve satisfy all package import dependencies, which enables export packages (implicit) start / stop life cycle methods used to create and initialize components contained in bundle update retrieve a new bundle JAR file, generally from a URL (deferred) uninstall remove a bundle JAR file from framework (deferred)

OSGi Component Model By default, a single component is delivered in the bundle JAR file install bundle.jar existing bundle component OSGi framework

OSGi Component Model By default, a single component is delivered in the bundle JAR file start bundle activator existing bundle component OSGi framework

OSGi Component Model By default, a single component is delivered in the bundle JAR file automatic package dependency resolution existing bundle component OSGi framework

OSGi Component Model By default, a single component is delivered in the bundle JAR file manual service dependency resolution OSGi framework existing bundle component

Benefits of OSGi Modularity Definitely more advanced than standard Java support for modularity In some ways, more advanced than.net modularity Better support for dynamics More complete support for deployment life cycle But...

OSGi Modularity Issues (1) Package sharing is only global Cannot have multiple shared versions Simplistic versioning semantics Always backwards compatible Not intended for sharing implementation packages Only for specification packages, which was why the version model is simple Package provider selection is always anonymous No way to influence selection

OSGi Modularity Issues (2) Consistency model is simplistic and coarse grained No way to declare dependencies among packages No way to declare dependencies between a module's imports and exports Maintains Java's coarse-grained package visibility rules Classes in a package are either completely visible to everyone or hidden

To Be Fair It is important to point out that the preceding slides do not necessarily describe shortcomings of OSGi OSGi was not designed to be a modularity layer, so it makes sense that it does not do it perfectly OSGi was used for a modularity layer by developers because it was simple and filled a specific need

To Be Clear The following proposed OSGi framework extensions are purely for discussion purposes They are not endorsed by OSGi The proposals and presented syntax are not currently OSGi compliant, nor may they ever be

Potential OSGi Extensions (1) Explicit support for multiple versions of shared packages in memory at the same time This is purely a general change to the prior OSGi philosophy Has deep impact on service aspects as well as modularity Service aspects are ignored here

Potential OSGi Extensions (2) Import version ranges Exporters still export a precise version, but importers may specify an open or closed version range Eliminates existing backwards compatibility requirement

Potential OSGi Extensions (2) Import version ranges Exporters still export a precise version, but importers may specify an open or closed version range Eliminates existing backwards compatibility requirement These first two extensions help to enable implementation package sharing

Potential OSGi Extensions (3) Arbitrary export/import attributes Exporters may attach arbitrary attributes to their exports, importers can match against these arbitrary attributes Some attributes may be declared as mandatory Mandatory attributes allow exporters to essentially limit visibility of packages Importers influence package selection using arbitrary attribute matching

Potential OSGi Extensions (4) Improved package consistency model Exporters may declare package groups Packages in a group cannot be used a la carte If you use one from the group, then if you use any of the others they must come from the same group Exporters may declare that some imports are propagated through an export Ensures that importers of a module's exports have consistent class definitions

Potential OSGi Extensions (5) Improved Java package visibility rules via package filtering Exporters may declare that certain classes are included/excluded from the exported package When combined with mandatory attributes, allows exporters to provide midpoints between public and package private visibility

Multiple Version Example Bundle A import javax.servlet; version= 2.1.0 Bundle B version= 2.1.0 Bundle C import javax.servlet; version= 2.2.0

Multiple Version Example Bundle A import javax.servlet; version= 2.1.0 Bundle B version= 2.1.0 Resolving A binds it to B's export, like normal. Bundle C import javax.servlet; version= 2.2.0

Multiple Version Example Bundle A import javax.servlet; version= 2.1.0 Bundle B version= 2.1.0 Resolving C is not possible, like normal. Bundle C import javax.servlet; version= 2.2.0

Multiple Version Example Bundle A import javax.servlet; version= 2.1.0 Bundle B version= 2.1.0 If D is installed, then it is possible to resolve C. Bundle C import javax.servlet; version= 2.2.0 Bundle D version= 2.2.0

Multiple Version Example Bundle A import javax.servlet; version= 2.1.0 Bundle B version= 2.1.0 Bundle C import javax.servlet; version= 2.2.0 Bundle D version= 2.2.0 This is possible due to support for multiple package versions in memory at the same time, but it provides a different visibility semantic than R3.

Multiple Version Example Bundle A import javax.servlet; version= 2.1.0 Bundle B version= 2.1.0 What happens if the framework is refreshed? Bundle C import javax.servlet; version= 2.2.0 Bundle D version= 2.2.0

Multiple Version Example Bundle A import javax.servlet; version= 2.1.0 Bundle B version= 2.1.0 Bundle C import javax.servlet; version= 2.2.0 Bundle D version= 2.2.0 Every bundle ends up resolved to D, the newest version, just like normal for R3 semantics.

Version Range and Arbitrary Attribute Example Bundle A import javax.servlet; version= [2.0.0,2.1.0) Bundle B version= 2.1.0 Bundle C import javax.servlet; version= 2.2.0 ; vendor= org.apache Bundle D version= 2.2.0 Version ranges and arbitrary attributes influence provider selection Bundle E version= 2.2.0 ; vendor= org.apache

Version Range and Arbitrary Attribute Example Bundle A import javax.servlet; version= [2.0.0,2.1.0) Bundle B version= 2.1.0 Bundle C import javax.servlet; version= 2.2.0 ; vendor= org.apache Bundle D version= 2.3.0 Due to version ranges, A can only bind to B. Due to attribute matching, C can only bind to E. Bundle E version= 2.2.0 ; vendor= org.apache

Package Grouping Example Bundle A import javax.servlet; javax.servlet.http; version= 2.2.0 Bundle B version= 2.2.0 Bundle D javax.servlet.http; version= 2.2.0 group:= foo Package grouping is a directive to the dependency resolver to help it maintain consistency when packages cannot be used independently.

Package Grouping Example Bundle A import javax.servlet; javax.servlet.http; version= 2.2.0 Bundle B version= 2.2.0 Bundle D javax.servlet.http; version= 2.2.0 group:= foo If the resolver attempts to resolve A's dependency on javax.servlet to B, then it will fail when trying to resolve javax.servlet.http.

Package Grouping Example Bundle A import javax.servlet; javax.servlet.http; version= 2.2.0 Bundle B version= 2.2.0 Bundle D javax.servlet.http; version= 2.2.0 group:= foo In this case, the only option is to resolve A to both exports of D.

Package Propagation Example Bundle A version= [2.2.0,2.2.0] Bundle B import javax.servlet; version= 2.2.0 export org.osgi.service.http; version= 1.1.0 ; propagates:= javax.servlet Bundle C import org.osgi.service.http, javax.servlet Bundle D version= 2.3.0 Package propagation is a directive to the dependency resolver to help it maintain consistency when module imports are visible via its exports (i.e., public versus private imports).

Package Propagation Example Bundle A version= 2.2.0 Bundle B import javax.servlet; version= [2.2.0,2.2.0] export org.osgi.service.http; version= 1.1.0 ; propagates:= javax.servlet Bundle C import org.osgi.service.http, javax.servlet Bundle D version= 2.3.0 It is not possible for C to be resolved to the newest version of javax.servlet if it gets org.osgi.service.http from C, because it propagates javax.servlet to importers.

Package Propagation Example Bundle A version= 2.2.0 Bundle B import javax.servlet; version= [2.2.0,2.2.0] export org.osgi.service.http; version= 1.1.0 ; propagates:= javax.servlet Bundle C import org.osgi.service.http, javax.servlet Bundle D version= 2.3.0 The only option is to resolve C to the same version of javax.servlet that is used by B.

Package Propagation Example Bundle A version= 2.2.0 Bundle B import javax.servlet; version= [2.2.0,2.2.0] export org.osgi.service.http; version= 1.1.0 ; propagates:= javax.servlet Bundle C import org.osgi.service.http, javax.servlet; version= 2.3.0 Bundle D version= 2.3.0 Of course, given certain sets of constraints, such as if C requires a version of javax.servlet that is different than the one used by B, then it will not be possible to resolve C.

Package Propagation Example Bundle A version= 2.2.0 Bundle B import javax.servlet; version= [2.2.0,2.2.0] export org.osgi.service.http; version= 1.1.0 ; propagates:= javax.servlet Bundle C import org.osgi.service.http, javax.servlet Bundle D version= 2.3.0 In practice, though, importers of packages that propagate other packages, should not specify constraints on the propagated packages so they automatically resolve to the appropriate package.

Package Filtering Example Bundle A import org.foo; version= 1.1.0 Bundle C import org.foo; attribute= value Bundle B export org.foo; version= 1.1.0 ; exclude:= org.foo.private, org.foo; version= 1.1.0 ; attribute= value ; mandatory:= attribute Package filtering is a directive to the underlying module layer to limit class visibility beyond what is possible with standard Java constructs. Combined with mandatory attributes, it is possible to have a friend concept.

Package Filtering Example Bundle A import org.foo; version= 1.1.0 Bundle A import org.foo; attribute= value Bundle B export org.foo; version= 1.1.0 ; exclude:= org.foo.private, org.foo; version= 1.1.0 ; attribute= value ; mandatory:= attribute In order to get visibility to all classes in the package, a friend must specify the mandatory attribute. This is not completely strict, security must be used if guarantees are required.

Why the Complexity? Sharing of implementation packages leads to complex possibilities Dependencies are more precise and rigid, unlike specification dependencies Results in the need to allow multiple package versions in memory A generic modularity mechanism must have sophisticated constructs Necessary to support complex and/or legacy systems It is unavoidable in extensible systems Support for these issues must be addressed, either ad hoc or systematically

Challenges Manage the complexity Maintain conceptual integrity Keep the simple cases simple Complexity should only be visible when it is required Avoid bloat, still need to target small devices

Challenges Manage the complexity Maintain conceptual integrity Keep the simple cases simple Complexity should only be visible when it is required Avoid bloat, still need to target small devices The good news so far, is that these proposed changes generally only affect the dependency resolving algorithm.

Conclusions Extensible systems are very popular and highlight the need for modularity mechanisms Java lacks good modularity mechanisms, lags behind.net Nearly all applications could benefit from improved modularity support in Java The OSGi framework provides a starting point for Java modularity, but does not go far enough It is possible to extend OSGi to support sophisticated modularity constructs