<<

Further Component Oriented Systems

Deepak Dhungana [email protected] Institute for System Engineering and Automation

Thomas Wuerthinger [email protected] Institute for System Software

Johannes Kepler University Linz, Austria http://www.jku.at On the agenda today

• Plux.NET • Mozilla • COM • Visual Studio Plux.NET OSGi

package host; class PrintItem interface IMenuItem { implements IMenuItem { ...... Host.java } PrintItem.java } void start(BundleContext bc) { Dictionary p = new Properties(); void start(BundleContext bc) { props.put("Text", "Print"); bc.addServiceListener(this, props.put("Icon", "Print.ico"); "(&(objectclass=IMenuItem))") bc.registerService( } IMenuItem.class.getName(), Activator.java void serviceChanged(...) { ... } Activator.java new PrintItem(), p); }

Manifest-Version: 1.0 Manifest-Version: 1.0 Bundle-Name: Host Bundle-Name: PrintItem Bundle-Activator: Activator Bundle-Activator: Activator host.mf Export-Package: host host.mf Import-Package: host Eclipse

11 schema="schema.exsd"/> 66 Text="Print" plugin. Icon="Print.ico"/> 22 schema.exsd

same as OSGi same as OSGi

33 44 55 77 88 99 Host.java Activator.java host.mf PrintItem.javaActivator.java host.mf Plux.NET

Host.cs PrintItem.cs

[Extension("PrintItem")] [Plug("MenuItem")] [SlotDefinition("MenuItem")] [ParamValue("Text", "Print")] [Param("Text", typeof(string))] [ParamValue("Icon", "Print.ico")] [Param("Icon", typeof(string))] class PrintItem: IMenuItem { interface IMenuItem { ...... } }

Wolfinger, R., Dhungana, D., Prähofer, H., and Mössenböck, H.: A Component Plug-in Architecture for the .NET Platform. 7th Joint Modular Languages Conference (JMLC), 2006. Plux.NET •Adopt and adapt plug-in components to domain of enterprise applications.

Today's enterprise application New architecture

Voucher Dunning Voucher Dunning Slot Balance Sheet Budget Balance Sheet

Customer Data Debit Customer Data Costing Debit Core Application

• coarse-grained components • slim core application • monolithic piece of software • extend with features - plug into core application - integrate seamlessly - as simple as dropping an executable into the application folder - dynamic addition/removal/replacement • unlimited but controlled extensibility Define a Slot

A slot definition specifies how a host A host extension opens a slot and ... wants to be extended [Extension(“E1”)] •contract specifies expected behaviour [Slot(“S1”)] class E1 { ... } [SlotDefinition(“S1”)] interface IContract { void Foo(); E2 S1 Value2 } E1 Name S1 E3 • parameters specify metadata S1 Value3 - can be determined w/o loading code - choose from different contributors contributor extensions fill a slot. - integrate statically (lazy load) [Extension(“E2”)] [Param(“Name”, typeof(string)] [Plug(“S1”)] [SlotDefinition(“S1”)] [ParamValue(“Name”, “Value”)] interface IContract { class E2 : IContract { ... } void Foo(); } Attach to a Slot

To attach means to notify a host that To detach means to notify a host that a contributor has been added contributor has been removed •parameter values can be read •plug-in removed •configuration changed

E2 S1 Value 2 E2 E1 S1 Value2 Name S1 E1 E3 Name S1 S1 Value3

[Slot(“S1”, OnAttached=”S1_Attached”)] [Slot(“S1”, OnDetached=”S1_Detached”)] class E1 { class E1 { void S1_Attached(object s, AttachEventArgs args) { void S1_Detached(object s, AttachEventArgs args) { string v = args.GetParamValue(“Name”); // disintegrate extension // integrate extension } } } }

• for instance create UI widgets • remove UI widgets - based on metadata - defer loading until widget is clicked • extensions not qualified for slot definition are not attached Plug into a Slot

To plug means to instantiate contributor and To unplug means to stop communication start communication with slot and release contributor •plug-in removed E2 •configuration changed S1 Value2 E2 S1 E1 Name S1 E2 S1 Value2 E3 S1 Value3 E1 Name S1 E3 [Slot(“S1”, OnPlugged=”S1_Plugged”)] S1 Value3 class E1 { void S1_Plugged(object s, PlugEventArgs args) { [Slot(“S1”, OnUnplugged=”S1_Unplugged”)] IContract obj = (IContract) args.Extension; class E1 { obj.Foo(); void S1_Unplugged(object s, PlugEventArgs args) { } // release references to contributor } } } • host uses contributor Secure Extensibility

[SlotDefinition(“S1”)] Constrain what extensions can do E1 S1 [ProtectedSlot] •based on digitally signed plug-ins Trusted [AllowOpen( -creator always trusted “Trusted.certificate”] E2 •compositional constraints S1 interface IContract { ... } Unknown -who can use a slot definition Protected Slot Definition → Protected Slot Definition -who can attach to slot [Extension(“E1”)] E2 → Public Slot, Private Slot S1 [PrivateSlot(“S1”)] Trusted -who can open slots E1 [AllowAttach( S1 “Trusted.certificate”] → Bounded Slot E3 class E1 { ... } S1 •code access constraints Private Slot Unknown -what can plug-in do → Secure Slot [PublicSlot(“S1”, Bounded=true)] E2 S1 S2 [AllowPlug(“Trusted.certificate”, Trusted E1 PermissionSet=”Full”] S1 [AllowPlug( E3 PermissionSet=”Sandbox”)] S1 S3 Public Slot Unknown class E1 { ... } Secure Slot Bounded Slot Sandbox Integrationsmodelle (1)

•Tightly Coupled - no Isolation –Host und Plug-in teilen eine AppDomain • für Komponenten der Kernapplikation

AppDomain Workbench

Startup MenuItem

ApplicationWorkbench PrintItem

[Extension(Name="Workbench", Slot="Startup")] [Extension(Name="PrintItem", Slot="MenuItem")] [Isolation(None)][Domain("Workbench")] [Domain("Workbench")] class Workbench : IStartup { class PrintItem : IMenuItem { ...... } } Integrationsmodelle (2)

•AppDomain Isolation AppDomain AppDomain –Plug-in in separater AppDomain aktivieren Workbench Print • Plug-in entladen • beschränken was Plug-in darf Startup MenuItem

[Slot("MenuItem")][Security(Permissi ApplicationWorkbench PrintItem onSet=Internet)] interface IMenuItem { ... FullTrust Internet }

[Extension(Name="Workbench", Slot="Startup")] [Isolation(AppDomain)] [Extension(Name="PrintItem", Slot="MenuItem")] [Domain("Workbench")] [Domain("Print")] class Workbench : IStartup { class PrintItem : IMenuItem { ...... } } Integrationsmodelle (3)

•Process Isolation –Plug-in in separatem Prozess aktivieren • schützt Host vor Absturz .NET Remoting

Process Process Workbench Print

Startup MenuItem

ApplicationWorkbench PrintItem FullTrust Internet

[Extension(Name="Workbench", Slot="Startup")] [Extension(Name="PrintItem", Slot="MenuItem")] [Isolation(Process)][Domain("Workbench.Workbench") [Domain("Print.Print")] ] class PrintItem : IMenuItem { class Workbench : IStartup { ...... } } Motivating Scenarios

–Developed together with our industry partner BMD Systemhaus •Szenario 1: On-the-fly product customization –Live-Preview of application, “I know it when I see it” •Szenario 2: Guided system upgrades –Which additional features are possible with current configuration? •Szenario 3: Renting features –Use features for limited time period •Szenario 4: Instant help desk support –Transmit and replicate user configuration at help desk Scenario 5: Role Change

In the morning Maria works as an ...and in the afternoon she changes her accountant... role to controller.

Dunning Balance Sheet

Debit Voucher Budget Costing

Enterprise Application Enterprise Application Enterprise Application Enterprise Application

Adapt your user interface on the fly matching the current role. Tailor your application at run time! Scenario 6: Optimized Training

Lesson 1: How to book an outgoing invoice

Debit Trainee can focus on content to trained in lesson 1. Enterprise Application

Lesson 2: How to determines bills due

Trainee can focus on content to be Debit Voucher trained in lesson II and integrate with knowledge from previous Enterprise Application lessons.

Lesson 3: How to generate dunning letters

Dunning Incrementally build up system Debit Voucher alongside with trainee’s learning progress. Enterprise Application Mozilla Mozilla Extensions ://developer.mozilla.org/en/Extensions

Flat structure – no dependencies between modules One module can be plugged into different applications (e.g. Thunderbird, Firefox, ...)

Versioning: - Plugins have a version number - Plugins can specify the supported application version numbers

Plugin1 Plugin2 Plugin3 Plugin4

Application Application Architecture of Mozilla

XBL

Apply to MathML template XUL RDF XHTML DOM User-defined tags SVG Javascript XPCONNECT XPCOM Layers under XPCOM Technologies in Use

Defines presentation

Controls all parts

Builds architectural framework

Black box for specialized tasks What is required? overlay.xul

1. 2. 4. 5. 8. 9. install.rdf

1. 2. 4. 5. [email protected] 6. 2 7. Hello, world! 8. 0.1 9. My first extension. 10. eDeepak 11. http://dhungana.at 12. 13. 14. {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 15. 2.0 16. 2.0.0.* 17. 18. 19. chrome.manifest

1.content helloworld chrome/content/ 2.overlay chrome://browser/content/browser.xul chrome://helloworld/content/overlay.xul chrome.manifest(2)

2.overlay chrome://browser/content/browser.xul chrome://helloworld/content/overlay.xul

overlay.xul browser.xul browser.xul Deployment XUL

• XUL stands for XML User-Interface Language which is a cross- platform language for describing user interfaces of applications. • Most of the Mozilla applications such as the browser, addressbook, DOM inspector are written in XUL. • A very good tutorial (go through some examples)

http://www.xulplanet.com/tutorials/xultu/ • Examples: DOM inspector, a prototype of an equation editor, GeoSVg

css"?>