2007 JavaOneSM Conference | Session TS-3316 |
TS-3316
Why Spaghetti Is Not Tasty: Architecting Full-Scale Swing Apps
Jasper Potts SwingTeam Sun Microsystems Inc http://jasperpotts.com
Why Spaghetti Is Not Tasty: Architecting Full-Scale Swing Apps - - PowerPoint PPT Presentation
Why Spaghetti Is Not Tasty: Architecting Full-Scale Swing Apps Jasper Potts SwingTeam Sun Microsystems Inc http://jasperpotts.com TS-3316 2007 JavaOne SM Conference | Session TS-3316 | The Goals What you will take away from this session
2007 JavaOneSM Conference | Session TS-3316 |
TS-3316
Jasper Potts SwingTeam Sun Microsystems Inc http://jasperpotts.com
2007 JavaOneSM Conference | Session TS-3316 | 2
A understanding of some of the key issues
Why you need to think about these problems early on and some ways to tackle them.
What you will take away from this session
2007 JavaOneSM Conference | Session TS-3316 | 3
GIS and Image Processing
2007 JavaOneSM Conference | Session TS-3316 | 4
you today?
2007 JavaOneSM Conference | Session TS-3316 | 5
2007 JavaOneSM Conference | Session TS-3316 | 6
2007 JavaOneSM Conference | Session TS-3316 | 7
2007 JavaOneSM Conference | Session TS-3316 | 8
Frame MainPanel Copy Action Quit Action Paste Action Editor Save Action
2007 JavaOneSM Conference | Session TS-3316 | 9
Frame MainPanel Copy Action Quit Action Paste Action Editor Save Action Application Core
2007 JavaOneSM Conference | Session TS-3316 | 10
Application Core
2007 JavaOneSM Conference | Session TS-3316 | 11
Frame MainPanel Copy Action Quit Action Paste Action Editor Save Action Application Core
2007 JavaOneSM Conference | Session TS-3316 | 12
Frame MainPanel Copy Action Quit Action Paste Action Editor Save Action Application Core Frame MainPanel Copy Action Quit Action Paste Action Editor Save Action Application Core
Big Application
2007 JavaOneSM Conference | Session TS-3316 | 13
How to draw the lines
2007 JavaOneSM Conference | Session TS-3316 | 14
2007 JavaOneSM Conference | Session TS-3316 | 15
2007 JavaOneSM Conference | Session TS-3316 | 16
2007 JavaOneSM Conference | Session TS-3316 | 17
2007 JavaOneSM Conference | Session TS-3316 | 18
2007 JavaOneSM Conference | Session TS-3316 | 19
2007 JavaOneSM Conference | Session TS-3316 | 20
Source: Simple line count of Java,XML,MF,C,CPP,H files including comments and excluding test code.
2007 JavaOneSM Conference | Session TS-3316 | 21
Source: Simple line count of Java,XML,MF,C,CPP,H files including comments and excluding test code.
50,000
2007 JavaOneSM Conference | Session TS-3316 | 22
technologies of the time
2007 JavaOneSM Conference | Session TS-3316 | 23
2007 JavaOneSM Conference | Session TS-3316 | 24
manageable modules is well known.
frameworks like: Java Platform, Enterprise Edition (Java EE platform)
applications is plugin frameworks.
2007 JavaOneSM Conference | Session TS-3316 | 25
Programming Language
2007 JavaOneSM Conference | Session TS-3316 | 26
http://platonos.sourceforge.net
simpler to understand.
applications
2007 JavaOneSM Conference | Session TS-3316 | 27
http://jpf.sourceforge.net/
it went OSGi
looks like there are people using it for serious applications
2007 JavaOneSM Conference | Session TS-3316 | 28
http://platform.netbeans.org
Rich Client Programming: Plugging into the NetBeans™ Platform (ISBN: 0132354802)
2007 JavaOneSM Conference | Session TS-3316 | 29
http://www.osgi.org
cars, cell(mobile) phones, industrial automation, building automation, PDAs, servers, and of course desktop applications with Eclipse and its RCP apps.
OSGi http://www.bejug.org/confluenceBeJUG/display/PARLEYS/Spring%20OSGi
http://osgi.org/osgi_technology/download_specs.asp
2007 JavaOneSM Conference | Session TS-3316 | 30
and runtime support
NetBeans software will be able to be take advantages of these new core functionality.
Offer first-class modularity, packaging and deployment support in the next generation Java SE platform.
2007 JavaOneSM Conference | Session TS-3316 | 31
attributes in its manifest file
2007 JavaOneSM Conference | Session TS-3316 | 32
Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: SPAR UI Bundle-SymbolicName: com.xerto.spar.ui; singleton:=true Bundle-Version: 1.0.0 Bundle-Vendor: XERTO Bundle-Activator: com.xerto.spar.ui.internal.SparUiActivator Export-Package: com.xerto.spar.ui, com.xerto.spar.ui.actions, … Require-Bundle: org.eclipse.core.runtime, com.xerto.spar Bundle-Classpath: ., swing-worker.jar Eclipse-AutoStart: false Spar-Runlevel: 10
2007 JavaOneSM Conference | Session TS-3316 | 33
2007 JavaOneSM Conference | Session TS-3316 | 34
2007 JavaOneSM Conference | Session TS-3316 | 35
How do you connect all these plugins together
plugin ‘B’
like a Image Viewer Panel which ‘B’ is then using in its UI
2007 JavaOneSM Conference | Session TS-3316 | 36
How does one plugin use another plugin’s classes
classes package in its manifest:
Bundle-Name: Plugin A Bundle-SymbolicName: com.abc.A; singleton:=true Export-Package: com.abc.components.imagepanel
Bundle-Name: Plugin B Bundle-SymbolicName: com.abc.B; singleton:=true Require-Bundle: com.abc.A
2007 JavaOneSM Conference | Session TS-3316 | 37
import com.abc.components.imagepanel.ImagePanel; public class ExmpleB { private ImagePanel ip = new ImagePanel(); … }
2007 JavaOneSM Conference | Session TS-3316 | 38
2nd form of connecting plugins together
‘D’ provides an extension for
readers and ‘D’ provides a implementation
http://www.eclipsezone.com/articles/extensions-vs-services/
2007 JavaOneSM Conference | Session TS-3316 | 39
to extend it.
they are added functionality by the Eclipse implementation.
XML file called “plugin.xml” in the root of the plugins(bundles) jar file.
2007 JavaOneSM Conference | Session TS-3316 | 40
For plugin ‘C’
<plugin> <extension-point id=”imageReaders” name="imageReaders"/> </plugin>
For plugin ‘D’
<plugin> <extension point="com.abc.C.imageReaders"> <format name=“Jpeg” ext=“jpg,jpeg” bean=“JpegImageReader”/> </extension> </plugin>
2007 JavaOneSM Conference | Session TS-3316 | 41
For plugin ‘C’
IExtensionRegistry extReg = Platform.getExtensionRegistry(); IExtensionPoint extPoint = extReg.getExtensionPoint( "com.abc.C", "imageReaders"); for (IExtension ext : extPoint.getExtensions()) { for (IConfigurationElement element : ext.getConfigurationElements()){ registerImageReader( element.getAttribute("name"), element.getAttribute("ext"), (IImageReader)springRegistry.getBean( extension, element.getAttribute("bean")) ); } }
2007 JavaOneSM Conference | Session TS-3316 | 42
(Inversion Of Control) with the Eclipse OSGi implementation.
the implementation comes from.
2007 JavaOneSM Conference | Session TS-3316 | 43
3rd form of plugin connections
plugin ‘B’
service that can load up images in any of the formats provided to it though its extension point. ‘B’ Could then use that service to load a image to display in the Image Panel from ‘A’
2007 JavaOneSM Conference | Session TS-3316 | 44
1. A Map<String,Object> of beans called a BeanFactory 2. A engine that reads XML files and populates the map, calling constructors and/or set methods as it goes.
a top level that is a wrapper around OSGi Services and a local bean factory for each plugin.
Services Bean Factory Plugin A BeanFactory Plugin B BeanFactory Plugin C BeanFactory Plugin D BeanFactory
2007 JavaOneSM Conference | Session TS-3316 | 45
2007 JavaOneSM Conference | Session TS-3316 | 46
How do events get from one part of the system to another
Listener.
2007 JavaOneSM Conference | Session TS-3316 | 47
2007 JavaOneSM Conference | Session TS-3316 | 48
2007 JavaOneSM Conference | Session TS-3316 | 49
2007 JavaOneSM Conference | Session TS-3316 | 50
interconnections.
Selection Changed Filter Changed
2007 JavaOneSM Conference | Session TS-3316 | 51
to do things like:
2007 JavaOneSM Conference | Session TS-3316 | 52
2007 JavaOneSM Conference | Session TS-3316 | 53
modules with defined interfaces
application
tools to help you do that
built for Imagery:
2007 JavaOneSM Conference | Session TS-3316 | 54
Jasper Potts