modularity n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Modularity… PowerPoint Presentation
Download Presentation
Modularity…

Loading in 2 Seconds...

play fullscreen
1 / 17

Modularity… - PowerPoint PPT Presentation


  • 149 Views
  • Uploaded on

Modularity…. ‘Modularity’ includes…. packaging/bundles, access and visibility discovery classloading instantiation (including deferred or lazy) managing dependencies - dependency injection vs. service locator declarative approaches (i.e. using annotations) life cycle management

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Modularity…' - neena


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
modularity includes
‘Modularity’ includes…
  • packaging/bundles, access and visibility
  • discovery
  • classloading
  • instantiation (including deferred or lazy)
  • managing dependencies - dependency injection vs. service locator
  • declarative approaches (i.e. using annotations)
  • life cycle management
  • registration
  • deployment and execution
  • resource loading
modules
Modules
  • Aggregates of classes
  • Contain one or more packages
  • Have their own visibility rules
  • Have a version tag
  • Declare versioned dependencies
  • No more global classpath with modules!
modular applications
Modular Applications
  • Discover their components at runtime
    • Modules (bundles)
    • Handles the lifecycle
  • Dynamic loading / reloading
    • May add/remove/reload components at runtime
  • Service Registry
    • Must satisfy dependencies between components
  • Have API contracts between components
  • Light container / framework
    • Run inside a runtime container
modularity approaches options
Modularity Approaches/Options
  • Classloader
  • JDK ServiceLoader
  • NetBeans Lookup API
  • OSGi
lookup netbeans modularity solution
Lookup – NetBeans Modularity 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
similarities between lookup and osgi
Similarities between Lookup and OSGi
  • Runtime container manages lifecycle and dependencies of modules
  • Both are packaged as JAR, metadata stored in META-INF/MANIFEST.MF and some other information
  • Runtime starts up, read meta information and sets up dependencies
  • Every module has its own classloader loading explicitly declared dependencies only
  • Dynamic
osgi netbeans
OSGi & NetBeans
  • http://wiki.apidesign.org/wiki/OSGiAndNetBeans
  • As of NetBeans 6.9, much support for OSGi.
  • A Service Registry for OSGi Using NetBeans Lookup API
  • http://kenai.com/projects/osgilookups

ServiceLookupForPath

BundleWrapperClassLoader

looking at lookup
Looking at Lookup
  • Specific uses of this API:
  • As a Service loader
    • Lookup.getDefault()
  • Communication among components...
    • LookupListener
  • Global Selection Management
    • Utilities.actionsGlobalContext()
    • Selections, Actions, enablement
service registry separating api and spi
Service Registry - Separating API and SPI

public interface MyService { ... }

MyService s = Lookup.getDefault().lookup(MyService.class);

  • Would return an implementation class
  • Possibly from a different module

Collection<? extends MyService> s = Lookup.getDefault().lookupAll(MyService.class);

meta inf services mechanism
META-INF/services mechanism
  • (Since JDK 1.3)
  • Somewhere in classpath the file:

META-INF/services/mypackage.MyClass

  • with a single line containing the name of the implementation class; for instance:

myotherpackage.MyClassImpl

@serviceprovider annotation
@ServiceProvider Annotation

package my.module;

import org.netbeans.spi.whatever.Thing;

import org.openide.util.lookup.ServiceProvider;

@ServiceProvider(service=Thing.class)

public class MyThing implements Thing {...}

would result in a resource file

META-INF/services/org.netbeans.spi.whatever.Thing

containing the single line of text:

my.module.MyThing

  • Declarative Registration Using Annotations
  • See: http://wiki.netbeans.org/DeclarativeRegistrationUsingAnnotations