Welcome!

Eclipse Authors: Ernest de Leon, RealWire News Distribution, Adam Blum, Aditya Banerjee, Jeff Anders

Related Topics: Eclipse, Adobe Flex

Eclipse: Article

A Runtime Integration Approach to Application Development

Plug-in Integrator Pattern

Annexure –A: Configurator Schema XSD

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:complexType name="containerConfigurationType">
        <xsd:sequence>
            <xsd:element ref="keepStaticChildren"/>
            <xsd:element name="pluginComponent" type="pluginComponentType" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="clazz" type="xsd:string" use="required"/>
        <xsd:attribute name="pluginInterface" type="xsd:string" use="required"/>
    </xsd:complexType>
    <xsd:element name="keepStaticChildren" type="xsd:string"/>
    <xsd:complexType name="pluginComponentType">
        <xsd:sequence>
            <xsd:element name="property" type="propertyType" maxOccurs="unbounded"/>
            <xsd:element ref="moduleURL"/>
            <xsd:element ref="asClass"/>
            <xsd:element name="initParam" type="initParamType" maxOccurs="unbounded"/>
            <xsd:element name="msgMap" type="msgMapType" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="id" type="xsd:string" use="required"/>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
    </xsd:complexType>
    <xsd:element name="moduleURL" type="xsd:string"/>
    <xsd:complexType name="initParamType">
        <xsd:sequence>
            <xsd:element name="selfFunction" type="selfFunctionType" minOccurs="0"/>
        </xsd:sequence>
        <xsd:attribute name="type" use="required">
            <xsd:simpleType>
                <xsd:restriction base="xsd:NMTOKEN">
                    <xsd:enumeration value="funcHookup"/>
                    <xsd:enumeration value="varHookup"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="bindToContainerProperty" type="xsd:string" use="required"/>
        <xsd:attribute name="selfpropertyName" type="xsd:string"/>
    </xsd:complexType>
    <xsd:complexType name="selfFunctionType">
        <xsd:sequence>
            <xsd:element name="arg" type="argType" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
    </xsd:complexType>
    <xsd:complexType name="argType">
        <xsd:choice>
            <xsd:element name="objectRef" type="objectRefType"/>
            <xsd:element name="object" type="objectType"/>
        </xsd:choice>
        <xsd:attribute name="name" use="required"/>
    </xsd:complexType>
    <xsd:element name="asClass" type="xsd:string"/>
    <xsd:complexType name="propertyType">
        <xsd:choice>
            <xsd:element ref="value"/>
            <xsd:element name="object" type="objectType"/>
            <xsd:element name="objectRef" type="objectRefType"/>
        </xsd:choice>
        <xsd:attribute name="name" use="required"/>
    </xsd:complexType>
    <xsd:complexType name="srcExtentionPointType">
        <xsd:choice>
            <xsd:element name="srcMsg" type="srcMsgType"/>
            <xsd:element name="srcCallBackFunc" type="srcCallBackFuncType"/>
        </xsd:choice>
    </xsd:complexType>
    <xsd:complexType name="destHandlerType">
        <xsd:choice>
            <xsd:element name="destMsg" type="destMsgType"/>
            <xsd:element name="destHandlerFunc" type="destHandlerFuncType"/>
        </xsd:choice>
    </xsd:complexType>
    <xsd:complexType name="msgMapType">
        <xsd:sequence>
            <xsd:element name="srcExtentionPoint" type="srcExtentionPointType"/>
            <xsd:element name="destHandler" type="destHandlerType"/>
        </xsd:sequence>
        <xsd:attribute name="id" type="xsd:string" use="required"/>
        <xsd:attribute name="handler" use="required">
            <xsd:simpleType>
                <xsd:restriction base="xsd:NMTOKEN">
                    <xsd:enumeration value="event"/>
                    <xsd:enumeration value="function"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:complexType>
    <xsd:complexType name="srcCallBackFuncType">
        <xsd:sequence>
            <xsd:element name="arg" type="argType" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
    </xsd:complexType>
    <xsd:complexType name="destHandlerFuncType">
        <xsd:sequence>
            <xsd:element name="arg" type="argType" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
    </xsd:complexType>
    <xsd:complexType name="destMsgType">
        <xsd:sequence>
            <xsd:element name="object" type="objectType"/>
        </xsd:sequence>
        <xsd:attribute name="id" type="xsd:string" use="required"/>
        <xsd:attribute name="pluginCompid" type="xsd:string" use="required"/>
        <xsd:attribute name="type" type="xsd:string" use="required"/>
    </xsd:complexType>
    <xsd:complexType name="evaluateType">
        <xsd:attribute name="expr" use="required">
            <xsd:simpleType>
                <xsd:restriction base="xsd:NMTOKEN">
                    <xsd:enumeration value="aproperty"/>
                    <xsd:enumeration value="aproperty.internal"/>
                    <xsd:enumeration value="aproperty.internalproperty"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:complexType>
    <xsd:complexType name="objectType">
        <xsd:sequence>
            <xsd:element name="property" type="propertyType" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="clazz" use="required"/>
    </xsd:complexType>
    <xsd:complexType name="objectRefType">
        <xsd:sequence>
            <xsd:element name="evaluate" type="evaluateType"/>
        </xsd:sequence>
        <xsd:attribute name="srcObject" use="required"/>
    </xsd:complexType>
    <xsd:complexType name="srcMsgType">
        <xsd:attribute name="id" type="xsd:string" use="required"/>
        <xsd:attribute name="pluginCompid" type="xsd:string" use="required"/>
        <xsd:attribute name="type" type="xsd:string" use="required"/>
    </xsd:complexType>
    <xsd:element name="value" type="xsd:string"/>
    <xsd:element name="response">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="status"/>
                <xsd:element name="data" type="dataType"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="status" type="xsd:string"/>
    <xsd:complexType name="dataType">
        <xsd:sequence>
            <xsd:element name="containerConfiguration" type="containerConfigurationType" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Annexure –B: Configuration file for Sample Application

<?xml version="1.0" encoding="UTF-8"?>
<containerConfiguration clazz="sample::PlugInIntegratorContainer" pluginInterface="mx.core::IUIComponent">
    <keepStaticChildren>true</keepStaticChildren>
    <pluginComponent id="12345679" name="View1">
        <property name="label">
            <value><![CDATA[Chart View]]></value>
        </property>
        <moduleURL>/an/external/module/url-view1</moduleURL>
        <asClass>sample.plugincomp.ViewOne</asClass>
        <initParam type="varHookup" bindToContainerProperty="editingObject" selfpropertyName="myData"/>
        <msgMap id="123456789" handler="event">
            <srcExtentionPoint>
                <srcMsg id="draw" pluginCompid="333345678" type="somepkg::GraphEvent"/>
            </srcExtentionPoint>
            <destHandler>
                <destMsg id="graphIt" type="some.pkg::SomeEvent">
                    <object clazz="some.pkg::SomeEvent">
                        <property name="any">
                            <objectRef srcObject="srcEvent">
                                <evaluate expr="an.exp.to.get.req.data"/>
                            </objectRef>
                        </property>
                    </object>
                </destMsg>
            </destHandler>
        </msgMap>
        <!-- Other way to define msgMap hooked up to dest handler function
        <msgMap id="123456789" handler="function">
            <srcExtentionPoint>
                <srcMsg id="draw" pluginCompid="333345678" type="somepkg::GraphEvent"/>
            </srcExtentionPoint>
            <destHandler>
                <destHandlerFunc name="graphIthandlerFunc">
                    <arg name="param1">
                        <object clazz="some.pkg::SomeEvent">
                            <property name="any">
                                <objectRef srcObject="srcEvent">
                                    <evaluate expr="an.exp.to.get.req.data"/>
                                </objectRef>
                            </property>
                        </object>                        
                    </arg>                    
                </destHandlerFunc>
            </destHandler>
        </msgMap>
        -->
    </pluginComponent>
    <pluginComponent id="22345678" name="View2">
        <property name="label">
            <value><![CDATA[Grid Data View]]></value>
        </property>
        <moduleURL>/an/external/module/url-view2</moduleURL>
        <initParam type="varHookup" bindToContainerProperty="editingObject" selfpropertyName="myData"/>
        <initParam type="funcHookup" bindToContainerProperty="editingObject">
            <selfFunction name="initMyData">
                <arg name="param1">
                    <objectRef srcObject="editingObject">
                        <evaluate expr="aproperty"/>
                    </objectRef>
                </arg>
                <arg name="param2">
                    <objectRef srcObject="editingObject">
                        <evaluate expr="aproperty.internalproperty"/>
                    </objectRef>
                </arg>
                <arg name="param3">
                    <object clazz="String">
                        <property name="default">
                            <value>str value</value>
                        </property>
                    </object>
                </arg>                
            </selfFunction>
        </initParam>        
    </pluginComponent>
    <pluginComponent id="333345678" name="View3">
        <property name="label">
            <value><![CDATA[Stats View]]></value>
        </property>
        <moduleURL>/an/external/module/url-view3</moduleURL>
        <initParam type="funcHookup" bindToContainerProperty="editingObject">
            <selfFunction name="initStatsData">
                <arg name="param1">
                   <objectRef srcObject="editingObject">
                        <evaluate expr="dataSeries"/>
                   </objectRef>
                </arg>
                <arg name="param2">
                   <objectRef srcObject="editingObject">
                    <evaluate expr="dataSeries.processLength"/>
                   </objectRef>
                </arg>                            
            </selfFunction>
        </initParam>                
    </pluginComponent>
</containerConfiguration>

More Stories By Indroniel Deb Roy

Indroniel Deb Roy works as an UI Architect for BlueCoat Systems.He has more than 10 years of development experience in the fields of J2EE and Web Application development. In his past he worked in developing web applications for Oracle, Novell, Packeteer, Knova etc. He has a passion for innovation and works with various Web2.0 & J2EE technologies and recently started on Smart Phone & IPhone Development.

More Stories By Alex Nhu

Alex Nhu works as a manager, UI Development at Packeteer Inc. He has more than 11 years of work experience designing and architecting complex server-side J2EE and XML applications. He loves developing Web applications with Flex now after getting a taste of developing UI using other RIA platforms.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.