Jump to: navigation, search

Difference between revisions of "Hello XML World Example (Buckminster)"

(Demo flow)
(Demo flow)
Line 89: Line 89:
 
*** A mapping that translates the component name into what the actual file on Ibiblio is called is then declared (i.e. mapping <tt>se.tada.util.sax</tt> to <tt>tada-sax</tt>).
 
*** A mapping that translates the component name into what the actual file on Ibiblio is called is then declared (i.e. mapping <tt>se.tada.util.sax</tt> to <tt>tada-sax</tt>).
  
 +
==The CSPEC in Component C==
 +
Since component C - <tt>org.demo.worlds</tt> is not a plugin and thus lack meta data that describes its dependencies, and
 +
how to produce it, we need to add this information.
 +
We decide to use Buckminster's [[Buckminster Component Specification|CSPEC]] XML language. This is what we place in a file called <tt>buckminster.cspec</tt> inside component C:
 +
<pre>
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.demo.worlds">
 +
    <cs:artifacts>
 +
    <cs:public name="source" path="src/"/>
 +
    </cs:artifacts>
 +
    <cs:actions>
 +
        <cs:public name="java.binary.archives" actor="ant">
 +
            <cs:actorProperties>
 +
                <cs:property key="buildFile" value="make/build.xml"/>
 +
            </cs:actorProperties>
 +
            <cs:prerequisites alias="input">
 +
                <cs:local attribute="eclipse.build"/>
 +
            </cs:prerequisites>
 +
            <cs:products alias="output" base="bin/jars/">
 +
                <cs:path path="worlds.jar"/>
 +
            </cs:products>
 +
        </cs:public>
 +
        <cs:private name="eclipse.build">
 +
            <cs:prerequisites>
 +
                <cs:local attribute="source"/>
 +
            </cs:prerequisites>
 +
            <cs:products base="bin/classes/">
 +
                <cs:path path="."/>
 +
            </cs:products>
 +
        </cs:private>
 +
    </cs:actions>
 +
    <cs:groups>
 +
    <cs:public name="java.binaries">
 +
    <cs:local attribute="eclipse.build"/>
 +
    </cs:public>
 +
    </cs:groups>
 +
</cs:cspec>
 +
</pre>
 +
 +
This meta data does the following:
 +
* First two lines declare that this is XML, and that it follows the CSPEC format, and it describes a component called org.demo.worlds
 +
* Next section lists the component attributes that are artifacts (i.e. a static declaration of paths).
 +
** There is only one declaration, a public attribute called <tt>src</tt> that is mapped to a directory called <tt>src</tt>. Notice that the name ends with a slash to denote that we refer to the directory.
 +
* Next section lists the component attributes that are implemented as actions (i.e. computed attribute values).
 +
** <tt>java.binary.archives</tt> is the first
 +
*** It is implemented using an ANT action, and parameters are set
 +
*** Then there is one pre-requisite - the local attribute eclipse.build is needed before this action can execute.
 
==Demo flow==
 
==Demo flow==
 
The following takes place when Buckminster resolves the query.
 
The following takes place when Buckminster resolves the query.

Revision as of 12:22, 9 October 2006

< To: Buckminster Project
This examples shows several Buckminster features in action. Here is an overview of what is going on:

HelloDemo.gif

  • The A component is called org.demo.hello.xml.world
    • It lives in a CVS repository
    • It is an Eclipse plugin - it has some meta data
    • A has a dependency on B
  • The B component is called org.demo.xml.provider
    • It lives in a CVS repository
    • It is an Eclipse plugin - it has some meta data
    • It requires two jars; the jar in component D, and a jar that is built by component C.
  • Component C is called org.demo.worlds
    • It lives in a CVS repository
    • Although it is an Eclipse project, it is not an Eclipse plugin.
  • Component D is a sax parser called se.tada.util.sax
    • It lives in binary form in the maven repository at Ibiblio

To run the example, use the File > Open dialog in Eclipse, and enter this URL:

That will start the Buckminster materialization of the project.

The CQUERY

The CQuery looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<cq:componentQuery xmlns:cq="http://www.eclipse.org/buckminster/CQuery-1.0"
resourceMap="http://www.eclipse.org/buckminster/samples/rmaps/demo.rmap">
    <cq:rootRequest name="org.demo.hello.xml.world" category="plugin" versionType="OSGi"/>
</cq:componentQuery>

This is what the XML in the CQUERY means:

  • The first three lines are the usual XML incantations - this is XML, and this is the syntax of the XML - i.e. CQuery-1.0 and the namespace is called "cq".
  • Next line declares where the resource map to use when resolving components is found (we will look at the resource map next).
  • Next line states that the wanted (root) component is called org.demo.hello.xml.world, that is is a plugin and that it follows the OSGi versioning scheme.

For more details see CQUERY

The RMAP

This is what the RMAP looks like:

<?xml version="1.0" encoding="UTF-8"?>
<rm:rmap
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:rm="http://www.eclipse.org/buckminster/RMap-1.0"
    xmlns:mp="http://www.eclipse.org/buckminster/MavenProvider-1.0"
    xmlns:bc="http://www.eclipse.org/buckminster/Common-1.0">

    <rm:searchPath name="default">
        <rm:provider readerType="cvs" componentType="eclipse-project" mutable="true" source="true">
            <rm:uri format=":pserver:anonymous@dev.eclipse.org:/cvsroot/technology,org.eclipse.buckminster/org.eclipse.buckminster/demo/{0}">
                <bc:propertyRef key="buckminster.component" />
            </rm:uri>
        </rm:provider>
    </rm:searchPath>

    <rm:searchPath name="maven">
        <rm:provider xsi:type="mp:MavenProvider" readerType="maven" componentType="maven" mutable="false" source="false">
            <rm:uri format="http://www.ibiblio.org/maven"/>
            <mp:mappings>
                <mp:entry name="se.tada.util.sax" groupId="se.tada" artifactId="tada-sax"/>
            </mp:mappings>
        </rm:provider>
    </rm:searchPath>

    <rm:locator searchPathRef="maven" pattern="^se\.tada\..*" />
    <rm:locator searchPathRef="default" pattern="^org\.demo\..*" />

</rm:rmap>

This is what the RMAP XML means:

  • The 6 first lines declares the name spaces and syntax of the rmap and the repository providers needed.
  • Below that you see two major elements declaring search paths, the first is called default, and the second is called maven.
  • Continue down and you see two locator declarations...
    • the first states that if a component name starts with se.tada. then the maven search path should be used.
    • and the second locator states that if the name starts with org.demo. then the default path should be used.
  • Back to the paths:
    • The default path:
      • The default path declares that the repository is in CVS and that what we find is an eclipse project
      • We do not need to commit changes back (mutable=false), and we do not want source (source=false).
      • The URI to the CVS repository is stated next
      • This URI ends with the name of the component. This name is obtained from the preset property buckminster.component which contains the name of the component being matched.
    • The maven path:
      • The maven path declares that it uses a maven provider and a reader type of maven and that the component type is also a maven component. Further the mutable=false says that we are not interested in comitting any changes back to the repository, and source=false says that we are not interested in source.
      • A URI to the maven repository at Ibiblio is declared
      • A mapping that translates the component name into what the actual file on Ibiblio is called is then declared (i.e. mapping se.tada.util.sax to tada-sax).

The CSPEC in Component C

Since component C - org.demo.worlds is not a plugin and thus lack meta data that describes its dependencies, and how to produce it, we need to add this information. We decide to use Buckminster's CSPEC XML language. This is what we place in a file called buckminster.cspec inside component C:

<?xml version="1.0" encoding="UTF-8"?>
<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.demo.worlds">
    <cs:artifacts>
    	<cs:public name="source" path="src/"/>
    </cs:artifacts>
    <cs:actions>
        <cs:public name="java.binary.archives" actor="ant">
            <cs:actorProperties>
                <cs:property key="buildFile" value="make/build.xml"/>
            </cs:actorProperties>
            <cs:prerequisites alias="input">
                <cs:local attribute="eclipse.build"/>
            </cs:prerequisites>
            <cs:products alias="output" base="bin/jars/">
                <cs:path path="worlds.jar"/>
            </cs:products>
        </cs:public>
        <cs:private name="eclipse.build">
            <cs:prerequisites>
                <cs:local attribute="source"/>
            </cs:prerequisites>
            <cs:products base="bin/classes/">
                <cs:path path="."/>
            </cs:products>
        </cs:private>
    </cs:actions>
    <cs:groups>
    	<cs:public name="java.binaries">
    		<cs:local attribute="eclipse.build"/>
    	</cs:public>
    </cs:groups>
</cs:cspec>

This meta data does the following:

  • First two lines declare that this is XML, and that it follows the CSPEC format, and it describes a component called org.demo.worlds
  • Next section lists the component attributes that are artifacts (i.e. a static declaration of paths).
    • There is only one declaration, a public attribute called src that is mapped to a directory called src. Notice that the name ends with a slash to denote that we refer to the directory.
  • Next section lists the component attributes that are implemented as actions (i.e. computed attribute values).
    • java.binary.archives is the first
      • It is implemented using an ANT action, and parameters are set
      • Then there is one pre-requisite - the local attribute eclipse.build is needed before this action can execute.

Demo flow

The following takes place when Buckminster resolves the query.

  1. Resolving the CSPEC for all components
    1. The name of the top component in the CQUERY is resolved to the default searchPath in the RMAP.
    2. The CVS provider of this RMAP is chosen (it's the only one)
    3. The eclipse.project componentType will obtain the ProjectDescriptor (the .project) from the eclipse project.
    4. From the natures of that descriptor, it will conclude that the component is a plugin.
    5. The component type will use a PluginBuilder to create a CSPEC from the plugin manifest files.
    6. This CSPEC will contain a dependency to the org.demo.xml.provider component.
    7. Buckminster now resolves that component in the exact same #1 to #6
    8. The CSPEC from org.demo.xml.provider is augmented with a CSPEC extension (CSPEX) that adds the jar dependencies (since those cannot be fully expressed in the plugin manifest)
    9. The first jar dependency is resolved using the same provider as before but the ProjectDescriptor has no plugin nature this time so the CSPEC that has been checked in with the component instead.
    10. The second jar is resolved using the maven search path and the maven repository.
  2. Materializing and binding the components
    1. All components are copied (by Buckminster) to the local disk using the chosen providers.
    2. The bind phase starts and components are bound in dependency order.
    3. The first component that becomes known to Eclipse is org.demo.worlds (i.e. C)
    4. The CSPEX of the second component, org.demo.xml.provider (i.e. B) contains a prebind action that:
      1. Builds component C to a jar and copies that jar into the jars directory of component B.
      2. Copies the component D from a cache location into the jars directory of component B.
    5. Once the prebind actions have completed, the B component bound to the workspace.
    6. Component A is bound last.
    7. Eclipse receives a lot of events and thus, rebuilds the workspace.

Note that the tada-sax (i.e. D) was never bound to the workspace since it is not an Eclipse project.