Talk on Framework architectures given at SAP Labs India for Eclipse Day India 2011 - Code attached Here: https://sites.google.com/site/anshunjain/eclipse-presentations
Understanding Framework Architecture using Eclipse
1. Eclipse as a framework of frameworks (Please view in presentation mode for desired flow of information) Anshu Jain IBM Research - India [email_address] anshunjain {gmail, twitter, googlesites)
2.
3.
4.
5. What are we doing today Building a VERY simple calculator
9. The only constant - Change 1. Add new features – New functions 2. Fix existing features – Divide by Zero
10. The only constant – Change..!! private void addFunctions(Composite functionComposite) { … … Button xpoweryButton = new Button(functionComposite, SWT. NONE ); xpoweryButton.addSelectionListener( new ButtonSelectionListener( "+" )); xpoweryButton.setLayoutData(data); xpoweryButton.setText( "x^y" ); Button modButton = new Button(functionComposite, SWT. NONE ); addButton.addSelectionListener( new ButtonSelectionListener( "Mod" )); modButton.setLayoutData(data); modButton.setText( "Mod" ); private int divide( int a, int b) { if (b == 0) { text .setText( "DivideBy0 Error!" ); return -1; } else { if (a % b == 0) { text .setText( "Not absolute" ); return a % b; } return a / b; } }
24. V5 – Dynamic Runtime - Dynamic loading of this jar (Classloading) - Dynamic instantiation of this class(Reflection)
25. V6 - Dynamic Discovery and Loading public void load(Calculator_Original calculator, String installDirectory) throws InstantiationException, IllegalAccessException { try { String[] nameOfFunctions = loadFunctionsFromDirectory(installDirectory); IFunction[] functions = new IFunction[nameOfFunctions. length ]; MyCustomClassLoader loader = new MyCustomClassLoader( installDirectory); for (IFunction function : functions) { Class functionClass = loader.loadClass( "" ); function = (IFunction) functionClass.newInstance(); function.setCalculator(calculator); } } catch (ClassNotFoundException e) { // Handle this } }
26.
27.
28. Revisiting our framework Separation of Concern Componentization Abstraction/Interface Registration and Discovery Dynamic Loading
29.
30.
31.
32.
33.
34.
35. Component Model - Identification - add.cff - add.jar - Component Identifier - Component runtime info
36. Component Model - Identification BUNDLES - Manifest.MF - <bundlename>.jar - Bundle ID - Runtime Info: Classpath - blah..blah..
37.
38. Component Model – Other APIs Framework for observing other components and services Resource and class loading Dynamic management of dependencies Hooks to component lifecycle Service oriented component management
39.
40. Framework for discovery Who wants to let others extend them? Who wants to extend? Who is extending me? Configuration provided by the extenders Properties of extenders I am lazy to even load the runtime Dynamic management of extenders