<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sysbliss Blog &#187; General Development</title>
	<atom:link href="http://blog.sysbliss.com/category/general-dev/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.sysbliss.com</link>
	<description>On the never-ending quest for systems bliss</description>
	<lastBuildDate>Wed, 20 Jan 2010 20:44:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Atlassian&#174; as a Web-App Framework</title>
		<link>http://blog.sysbliss.com/general-dev/atlassian-as-a-web-app-framework.html</link>
		<comments>http://blog.sysbliss.com/general-dev/atlassian-as-a-web-app-framework.html#comments</comments>
		<pubDate>Thu, 31 Dec 2009 18:11:04 +0000</pubDate>
		<dc:creator>jdoklovic</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[atlassian]]></category>

		<guid isPermaLink="false">http://blog.sysbliss.com/?p=107</guid>
		<description><![CDATA[News Flash: I&#8217;m a big fan of Atlassian&#174;.
Not only are all of their apps highly useful, but they are, for the most part, pretty consistent when it comes to installation and plugin management.
Essentially, you extract a zip of the app, edit a [app-name]-init.properties file and include a path where you&#8217;d like the app&#8217;s home directory [...]]]></description>
			<content:encoded><![CDATA[<p>News Flash: I&#8217;m a big fan of <a href="http://www.atlassian.com">Atlassian&reg;</a>.</p>
<p>Not only are all of their apps highly useful, but they are, for the most part, pretty consistent when it comes to installation and plugin management.</p>
<p>Essentially, you extract a zip of the app, edit a [app-name]-init.properties file and include a path where you&#8217;d like the app&#8217;s home directory to live, and start the app. At this point, the app is running with some pre-bundled plugins and provides a plugins folder within the specified home directory where you can drop in new plugins.</p>
<p>Simple.</p>
<p>Now if you&#8217;re like me, at some point you&#8217;ll think that it would be pretty awesome if there was an easy way to make your own webapps behave in this same way including full spring support, auto-home directory creation, bundled plugins, etc, etc.</p>
<p>Lucky for you, I&#8217;ve done all the ground work, and I&#8217;ve packaged it up into something I call the Atlas Webapp Kit</p>
<div class='stb-info_box' >Although I&#8217;ve called it the Atlas Webapp Kit, I am in no way associated with Atlassian&reg;.<br />
This Project is solely a result of my own tinkering.</div>
<h3>Source</h3>
<p>The result of this project will be a war file that can be used as a starting point to build an Atlassian&reg;-like webapp.</p>
<p>The source code can be checked out from subversion:</p>
<pre>svn co http://svn.sysbliss.com/public/atlassian-webappkit/trunk</pre>
<p>Alternatively, you can <a href="http://www.sysbliss.com/downloads/atlas-webappkit-webapp-1.0-src.tar.gz">download a source gzip file.</a></p>
<p>Lastly, you can <a href="http://www.sysbliss.com/downloads/atlas-webappkit-webapp-1.0.war">download a binary of the war file.</a></p>
<h3>Project Structure</h3>
<p>The project is structured as a maven multi-module project with a parent module and two children:</p>
<ul>
<li><strong>atlas-webappkit</strong> &#8211; the parent pom
<ul>
<li><strong>atlas-webappkit-core</strong> &#8211; all of the java code for the app</li>
<li><strong>atlas-webappkit-webapp</strong> &#8211; the webapp descriptors and such</li>
</ul>
</li>
</ul>
<h3>The Parent POM</h3>
<p>Rather than waste bits by listing the parent pom, just take a look at it&#8217;s source.<br />
It&#8217;s pretty basic in that it lists our child modules, sets up dependency and plugin versions and lists the repositories needed.<br />
That&#8217;s it.</p>
<h3>The Webapp</h3>
<p><img src="http://blog.sysbliss.com/wp-content/uploads/2009/12/screenshot_007.png" alt="refplatform-webapp-structure" title="refplatform-webapp-structure" width="352" height="401" class="alignleft size-full wp-image-122"/></p>
<p>We&#8217;re starting with the webapp since it&#8217;s pretty simple and will provide us with some context when we get to the core project.</p>
<p>First let&#8217;s do a quick overview of the files since there are only a few of them:</p>
<ul>
<li><strong>bundled-plugins.xml</strong> &#8211; a simple descriptor used by the maven assembly plugin to zip up any plugins we want to bundle</li>
<li><strong>applicationContextBootstrap.xml</strong> &#8211; a spring beans file for use during the bootstrap process</li>
<li><strong>applicationContextPlugins.xml</strong> &#8211; a spring beans file for initializing the plugins framework</li>
<li><strong>log4j.properties</strong> &#8211; you should know what this is</li>
<li><strong>refplatform-init.properties</strong> &#8211; the properties file that holds our home directory path</li>
<li><strong>context.xml</strong> &#8211; the file to map our url/context in tomcat</li>
<li><strong>web.xml</strong> &#8211; the main web app descriptor</li>
<li><strong>index.jsp</strong> &#8211; just a placeholder jsp</li>
</ul>
<p>Since we are doing a couple of interesting things during the build, I think it&#8217;s worthwhile to have a look at the pom.xml for the webapp module&#8230;.</p>
<p><br clear="all"/></p>
<h3>Webapp POM</h3>
<p>The top of the pom is pretty normal, just inherits the parent pom and sets the project details and so we&#8217;ll skip to the interesting stuff.</p>
<h4>Defining Bundled Plugins</h4>
<p>Lines 23-82 are used to configure the maven-dependency plugin which we&#8217;re using to resolve the plugin artifacts we want to bundle with our app and copy them to the ${pluginBundleDirectory}</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-dependency-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>copy-bundled-plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>generate-resources<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>copy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;outputDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${pluginBundleDirectory}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/outputDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactItems<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.felix<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.felix.webconsole<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.2.10<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
                                !!! Others Removed To Save Space !!!
&nbsp;
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactItems<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Lines 84-102 use the maven assembly plugin to create a zip file containing the bundled plugins we just copied and put it in the classpath of the resulting war</p>
<p>Notice on line 87 we specify the <strong>finalName</strong> as atlassian. This will result in our zip file being named atlassian-bundled-plugins.zip<br/>We&#8217;ll need to use this name later to extract the bundle.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-assembly-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;finalName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>atlassian<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/finalName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;descriptors<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;descriptor<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>src/main/assembly/bundled-plugins.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/descriptor<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/descriptors<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;outputDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${project.build.outputDirectory}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/outputDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>create-bundled-plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>process-resources<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>attached<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The next section of the full pom sets up cargo for testing and is not listed here.</p>
<h4>Creating our context</h4>
<p>Remember the context.xml file? It&#8217;s used to map our context url to our webapp, however since our final war contains a version number which may change, we need to use some maven &#8220;magic&#8221; to ensure tomcat maps it properly.</p>
<p>Notice our context.xml uses the ${project.version} maven variable</p>
<p><strong>context.xml</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Context</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;/atlas-webappkit&quot;</span> <span style="color: #000066;">docBase</span>=<span style="color: #ff0000;">&quot;webapps/atlas-webappkit-webapp-${project.version}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>And on lines 126-141 of our pom, we use the maven-war-plugin to process and filter the context.xml which does the variable substitution for us</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-war-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;webResources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;webResource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${basedir}/src/main/webapp/META-INF<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>context.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;targetPath<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>META-INF<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/targetPath<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filtering<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filtering<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/webResource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/webResources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<h4>Dependencies</h4>
<p>Since we&#8217;ve split out all the actual java code to a separate module, our dependency list for the webapp is tiny.<br/>We just need our core jar and log4j</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>145
146
147
148
149
150
151
152
153
154
155
156
157
158
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.refplatform<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>atlas-webappkit-core<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${parent.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>log4j<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>log4j<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.2.9<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>And finally, we need to define the <strong>pluginBundleDirectory</strong> property that we used above to bundle plugins.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>160
161
162
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pluginBundleDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>target/bundled-plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pluginBundleDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<h3>The Webapp Descriptor (web.xml)</h3>
<p>Now that our pom is all in order let&#8217;s look at the web.xml file.</p>
<p>The top of the web.xml is pretty standard as it defines the web-app tag and our application name.</p>
<p>Lines 11-16 define our list of Spring beans files we want to load. Notice that we&#8217;re only including the <strong>applicationContextPlugins.xml</strong> and not the bootstrap file.<br/>Also note that this is where you can define any other app-specifc spring files to be loaded.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;web-app</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/j2ee&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/j2ee</span>
<span style="color: #009900;">         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.4&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>The Atlassian Reference Application<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;display-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Atlassian RefApp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/display-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>contextConfigLocation<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                classpath:/applicationContextPlugins.xml
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<h4>Servlet Filters</h4>
<p>Lines 19-62 setup some servlet filters. Each filter uses the class <strong>RefPlatformServletFilterModuleContainerFilter</strong><br/>This filter is used by the Atlassian&reg; Plugins Framework to build a filter chain from any plugins that include servlet filters.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>filter-plugin-dispatcher-after-encoding<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.refplatform.web.servlet.RefPlatformServletFilterModuleContainerFilter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>location<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>after-encoding<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>filter-plugin-dispatcher-before-decoration<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.refplatform.web.servlet.RefPlatformServletFilterModuleContainerFilter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>location<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>before-decoration<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>filter-plugin-dispatcher-before-dispatch<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.refplatform.web.servlet.RefPlatformServletFilterModuleContainerFilter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>location<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>before-dispatch<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>filter-plugin-dispatcher-after-encoding<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>filter-plugin-dispatcher-before-decoration<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>filter-plugin-dispatcher-before-dispatch<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<h4>Listeners</h4>
<p>Lines 64-73 setup 2 listeners. The first listener is a bootstrap listener which will be used to load the <strong>applicationContextBootstrap.xml</strong> context and bootstrap the application.<br/>The next listener is a special Spring context loader that will be used to merge our bootstrap context with the rest of the files listed at the top of the web.xml<br/>The second listener is also where we&#8217;ll initialize the plugins framework.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>64
65
66
67
68
69
70
71
72
73
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #808080; font-style: italic;">&lt;!-- ============ Listeners ============== --&gt;</span>
    <span style="color: #808080; font-style: italic;">&lt;!-- Loads the Bootstrap context for minimal app startup --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.refplatform.web.listener.BootstrapLoaderListener<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- Loads the Spring servlet context if / when the app has been setup --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.refplatform.web.listener.BootstrappedContextLoaderListener<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<h4>Servlets and Mappings</h4>
<p>At the end of our web.xml file we define a single servlet and a mapping for it as well as our welcome list.</p>
<p>The servlet is provided by the Atlassian&reg; Plugins Framework and is used to enable any servlets that other plugins may contribute.<br/>The servlet is mapped to <strong>/plugins/servlet/*</strong> This will be the base url where all other plugin servlets will be located.</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.plugin.servlet.ServletModuleContainerServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/plugins/servlet/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;welcome-file-list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;welcome-file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>index.jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/welcome-file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/welcome-file-list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/web-app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<h3>Spring Context Files</h3>
<p>The base platform requires 2 spring contexts; One for our bootstrapping process, and the other for the Atlassian&reg; Plugins Framework.</p>
<h4>applicationContextBootstrap.xml</h4>
<p>This file holds all the beans we&#8217;ll need during the bootstrapping process of our application. Since all we need to do during bootstrap is ensure the application&#8217;s home directory exists, this file is rather small.</p>
<p>It&#8217;s also good to note that this file is loaded by the BootstrapLoaderListener servlet listener and not a &#8220;normal&#8221; context loader listener.</p>
<p>In this file we define 2 beans, the homeLocator, and the bootstrapManager that is wired up with the homeLocator. We&#8217;ll get into the specifics of these a bit later.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">xmlns:plugin</span>=<span style="color: #ff0000;">&quot;http://atlassian.com/schema/spring/plugin&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd</span>
<span style="color: #009900;">           http://atlassian.com/schema/spring/plugin http://atlassian.com/schema/spring/plugin.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;homeLocator&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.atlassian.refplatform.core.DefaultHomeLocator&quot;</span> <span style="color: #000066;">plugin:available</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;propertiesFile&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;refplatform-init.properties&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;initPropertyName&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;refplatform.home&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;configFileName&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;refplatform.cfg.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;bootstrapManager&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.atlassian.refplatform.web.setup.DefaultBootstrapManager&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;homeLocator&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">local</span>=<span style="color: #ff0000;">&quot;homeLocator&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<div class='stb-info_box' >The bootstrap context only contains the required beans to create the home directory.<br />
In a &#8220;real&#8221; app, you may add more beans to this file to handle things like database setup, etc.</div>
<h4>applicationContextPlugins.xml</h4>
<p>This file holds all the beans required by the Atlassian&reg; Plugins Framework and gets loaded by our special BootstrappedContextLoaderListener.</p>
<p>Most of the beans listed in this file are provided by the plugins framework and have to do with iniializing the OSGi system. For that reason, I&#8217;ll only cover the customized beans in this file.</p>
<p>Lines 11-24 define the <strong>pluginManager</strong>. This is a very simple extension of the DefaultPluginManager provided by Atlassian&reg; and is the class used to initialize the entire plugin system.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;pluginManager&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.atlassian.refplatform.plugins.RefPlatformPluginManager&quot;</span> <span style="color: #000066;">plugin:available</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;pluginStateStore&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;classpathPluginLoader&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;bundledPluginLoader&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;directoryPluginLoader&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;moduleDescriptorFactory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;pluginEventManager&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;hostContainer&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;pluginDirectoryLocator&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Lines 26-28 define the <strong>pluginDirectoryLocator</strong>. This interface/class provides methods for looking up the various plugin paths that the framework needs. i.e. bundled, plugins, and cache directories.</p>
<p>This is a convenience class that we&#8217;ll use in other beans instead of passing a bunch of strings around.</p>
<div class='stb-info_box' >Note the reference to the homeLocator bean we defined in the previous bootstrap context.</div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>26
27
28
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;pluginDirectoryLocator&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.atlassian.refplatform.plugins.DefaultPluginDirectoryLocator&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;homeLocator&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>A little futher down on line 83 we define the <strong>bundledPluginLoader</strong>. This is a factory bean that returns a provided BundledPluginLoader. We have created our own factory here that can make use of our pluginDirectoryLocator.</p>
<p>Note that the last constructor arg is the name of our bundled plugins zip file. If you change the <strong>finalName</strong> property in the pom (maven-seembly-plugin), you&#8217;ll need to update this arg as well.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>83
84
85
86
87
88
89
90
91
92
93
94
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;bundledPluginLoader&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.atlassian.refplatform.plugins.loader.BundledPluginLoaderFactory&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;pluginDirectoryLocator&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;osgiPluginFactory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;osgiBundleFactory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;xmlDynamicPluginFactory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;pluginEventManager&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;atlassian-bundled-plugins.zip&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Jumping to line 146 we define the servletContextFactory bean. This is just a simple implementation that can be autowired with and return the servletContext.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>146
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;servletContextFactory&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.atlassian.refplatform.web.servlet.RefPlatformServletContextFactory&quot;</span> <span style="color: #000066;">autowire</span>=<span style="color: #ff0000;">&quot;byType&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>Line 150 defines the <strong>hostContainer</strong> This is a class reuiqred by the plugins framework to create and return plugin modules. Our implementation simply pulls them out of the spring context.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>150
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;hostContainer&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.atlassian.refplatform.plugins.RefPlatformHostContainer&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>Finally, lines 154-168 define some string values for use in other beans. All of these strings are created through various spring factory beans.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;applicationKey&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.beans.factory.config.FieldRetrievingFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;staticField&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;com.atlassian.refplatform.util.RefPlatformUtils.APPLICATION_KEY&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;pluginDescriptorFilename&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.beans.factory.config.FieldRetrievingFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;staticField&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;com.atlassian.refplatform.plugins.DefaultPluginDirectoryLocator.PLUGIN_DESCRIPTOR&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;pluginCacheDirectory&quot;</span> <span style="color: #000066;">factory-bean</span>=<span style="color: #ff0000;">&quot;pluginDirectoryLocator&quot;</span> <span style="color: #000066;">factory-method</span>=<span style="color: #ff0000;">&quot;getPluginCachesDirectory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;pluginDirectory&quot;</span> <span style="color: #000066;">factory-bean</span>=<span style="color: #ff0000;">&quot;pluginDirectoryLocator&quot;</span> <span style="color: #000066;">factory-method</span>=<span style="color: #ff0000;">&quot;getPluginsDirectory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;characterEncoding&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.beans.factory.config.FieldRetrievingFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;staticField&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;com.atlassian.refplatform.util.RefPlatformUtils.DEFAULT_CHARACTER_ENCODING&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>That wraps up the webapp module. Now on to the core module</p>
<h3>The Core Module</h3>
<p><img src="http://blog.sysbliss.com/wp-content/uploads/2009/12/refplatform-core-structure.png" alt="refplatform-core-structure" title="refplatform-core-structure" width="469" height="801" class="alignleft size-full wp-image-140"/></p>
<p>As you can see, the core module contains a lot of files but don&#8217;t worry as most of these are simply default implementations/extensions of classes provided by the Atlassian&reg; Plugins Framework.</p>
<p>I&#8217;ll save you the excruciatingly boring overview of every file and just jump right to the pom.</p>
<p>This makes the post look a bit uglier, but come on, take the .7 second and scroll dear reader, scroll.</p>
<p><br clear="all"/></p>
<h3>Core POM</h3>
<p>Once again, the top of the pom is pretty normal, just inherits the parent pom and sets the project details.</p>
<h4>Running ANT inside of Maven? This is a joke, right??</h4>
<p>No joke&#8230; On lines 16-44 we&#8217;re including the maven-ant-run plugin and telling it to run the build-utils.ant file located in our etc folder.</p>
<p>This is going to generate a new java source file in our generated-sources folder called <strong>BuildUtils.java</strong></p>
<p>This class will be used by our other classes to grab the version number and build date of our app mainly for logging purposes.</p>
<h4>pom.xml</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-antrun-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>generate-version-class<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>generate-sources<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>run<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tasks<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ant</span> <span style="color: #000066;">antfile</span>=<span style="color: #ff0000;">&quot;src/main/etc/build-utils.ant&quot;</span> <span style="color: #000066;">inheritAll</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">inheritRefs</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;version&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${project.version}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;src.dir&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${project.build.directory}/generated-sources&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ant<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tasks<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sourceRoot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                ${project.build.directory}/generated-sources
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sourceRoot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<h4>etc/build-utils.ant</h4>
<p>The build-utils.ant file is a very simple script that simply echoes a small java source file to our generated-sources folder which will then be compiled by maven.</p>
<p>The script has a single target named generate-version which is the default target. The script expects the version and path to generated-sources to be passed in.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;..&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;generate-version&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;generate-version&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tstamp<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;format</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;build.date&quot;</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;MM/dd/yyyy HH:mm:ss&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tstamp<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${src.dir}/com/atlassian/refplatform/core/util/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${src.dir}/com/atlassian/refplatform/core/util/BuildUtils.java&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>package com.atlassian.refplatform.core.util;
            /** Automatically generated by ant. */
            public class BuildUtils {
            private static final String VERSION = &quot;${version}&quot;;
            private static final String BUILD_DATE = &quot;${build.date}&quot;;
&nbsp;
            public static String getCurrentBuildDate()
            {
            return BUILD_DATE;
            }
&nbsp;
            public static String getCurrentVersion()
            {
            return VERSION;
            }
&nbsp;
            }
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<h4>Core Dependencies</h4>
<p>The rest of our pom just contains the required dependencies for our core project.</p>
<p>These contain the Spring Framework, the Atlassian-Spring bridge, the Atlassian&reg; Plugins Framework and some base plugins we need.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.spring<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>atlassian-spring<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>atlassian-plugins-core<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>atlassian-plugins-webfragment<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>atlassian-plugins-webresource<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>atlassian-plugins-servlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>atlassian-plugins-osgi<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.atlassian.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>atlassian-plugins-spring<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javax.servlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>servlet-api<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>provided<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>spring<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.slf4j<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>slf4j-log4j12<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Onto the code&#8230; I&#8217;ll start with the BootstrapLoaderListener which is the starting point of our app.</p>
<h3>BootstrapLoaderListener</h3>
<p>This class runs when our webapp context is initialized. It&#8217;s responsible for doing any setup that our app needs to run. In our case it ensures our home directory exists, however this is the class to customize if you need to do database setup or other tasks.</p>
<p>Let&#8217;s take a look at the only functional method: contextInitialized:</p>
<p><strong>line 25:</strong> Create a Spring context by loading our applicationContextBootstrap.xml file</p>
<p><strong>line 28:</strong> Bootstrap the app with the help of our BootstrapUtils class.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> contextInitialized<span style="color: #009900;">&#40;</span>ServletContextEvent event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ApplicationContext bootstrapContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ClassPathXmlApplicationContext<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;applicationContextBootstrap.xml&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            BootstrapUtils.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span>bootstrapContext, event.<span style="color: #006633;">getServletContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>BootstrapException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            log.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;An error was encountered while bootstrapping atlas-webappkit (see below): <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        startupLog.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Starting Atlassian RefPlatform &quot;</span> <span style="color: #339933;">+</span> BuildUtils.<span style="color: #006633;">getCurrentVersion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h4>BootstrapUtils</h4>
<p>In the previous code, we delegated the bootstrapping to a BootstrapUtils class.</p>
<p>This is a convenience class to encapsulate the initialization of the bootstrapManager and the homeLocator and provides a place to store/retrieve our bootstrap spring context</p>
<p>Not a very interesting class, but the init method is worth reviewing.</p>
<p><strong>line 27:</strong> Get our homeLocator and try to set the home path from the servlet context if available.</p>
<p><strong>line 29:</strong> Store the bootstrap spring context so other classes can get to it easily.</p>
<p><strong>lines 30-35:</strong>Get the bootstrapManager from the context and initialize it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span>ApplicationContext bootstrapContext, ServletContext servletContext<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> BootstrapException
    <span style="color: #009900;">&#123;</span>
        <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>HomeLocator<span style="color: #009900;">&#41;</span>bootstrapContext.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;homeLocator&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">lookupServletHomeProperty</span><span style="color: #009900;">&#40;</span>servletContext<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        setBootstrapContext<span style="color: #009900;">&#40;</span>bootstrapContext<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        BootstrapManager bootstrapManager <span style="color: #339933;">=</span> getBootstrapManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bootstrapManager <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> BootstrapException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not initialise boostrap manager&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        bootstrapManager.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>bootstrapManager.<span style="color: #006633;">isBootstrapped</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> BootstrapException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unable to bootstrap application: &quot;</span> <span style="color: #339933;">+</span> bootstrapManager.<span style="color: #006633;">getBootstrapFailureReason</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h4>HomeLocator</h4>
<p>It&#8217;s now time to review the HomeLocator. We have the HomeLocator interface and an implementation called DefaultHomeLocator.</p>
<p>This class is responsible for, as it&#8217;s name suggests, locating the application&#8217;s home directory. To do this it looks in the following places in the following order: </p>
<ol>
<li>A System Property named <strong>refplatform.home</strong> (defined in applicationContextBootstrap.xml)</li>
<li>The refplatform.home property defined in <strong>refplatform-init.properties</strong></li>
<li>The refplatform.home property defined as a servletContext init parameter.</li>
</ol>
<p>Since this class simply returns the value found in one of these places and <strong>does not actually create the directory</strong> I won&#8217;t bother listing it&#8217;s contents here.</p>
<h4>BootstrapManager</h4>
<p>Like the HomeLocator, the BootstrapManager is and interface with a DefaultBootstrapManager implementation.</p>
<p>For our purposes, the BootstrapManager is simply responsible for getting the home path from the HomeLocator and creating the directory if it doesn&#8217;t already exist.</p>
<p>We&#8217;ve de-coupled all of this functionality so that custom implementations can be easily provided in case more steps are needed in the bootstrap process.</p>
<p>Again, this class is not listed here since it&#8217;s fairly straightforward. See the source provided for the full details.</p>
<h3>BootstrappedContextLoaderListener</h3>
<p>In the context of running the app, at this point the bootstrap is complete and an empty home directory has been created if needed. Now it&#8217;s time to init the plugin system and load any app-sepcific Spring contexts</p>
<p>This is the function of the BootstrappedContextLoaderListener which is an extension of the provided ContainerContextLoaderListener.</p>
<p>Our custom implementation provides some extra functionality to merge our bootstrap context with the other provided Spring contexts and initializes the plugin system.</p>
<p><strong>lines 28-42</strong> &#8211; canInitialiseContainer: simply ensure we&#8217;ve been bootstrapped before loading the contexts</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> canInitialiseContainer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        BootstrapManager bootstrapManager <span style="color: #339933;">=</span> BootstrapUtils.<span style="color: #006633;">getBootstrapManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bootstrapManager <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>bootstrapManager.<span style="color: #006633;">isBootstrapped</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>lines 44-47</strong> &#8211; override the getNewSpringContainerContext method to return a custom BootstrappedContainerContext (listed later)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>44
45
46
47
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    @Override
    <span style="color: #000000; font-weight: bold;">protected</span> SpringContainerContext getNewSpringContainerContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> BootstrappedContainerContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>lines 52-55</strong> &#8211; override the createContextLoader method to return a custom BootstrappedContextLoader (listed later)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>52
53
54
55
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    @Override
    <span style="color: #000000; font-weight: bold;">public</span> ContextLoader createContextLoader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> BootstrappedContextLoader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>lines 57-65</strong> &#8211; a little more interesting&#8230; Our context is initialized and so we pull our pluginManager bean out of the context and call it&#8217;s init method which kicks off the entire plugin framework initialization</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    @Override
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> postInitialiseContext<span style="color: #009900;">&#40;</span>ServletContextEvent event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">postInitialiseContext</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        ApplicationContext ctx <span style="color: #339933;">=</span> WebApplicationContextUtils.<span style="color: #006633;">getWebApplicationContext</span><span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getServletContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        RefPlatformPluginManager pluginManager <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>RefPlatformPluginManager<span style="color: #009900;">&#41;</span> ctx.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pluginManager&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        pluginManager.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h4>BootstrappedContainerContext</h4>
<p>This is a simple extension of the provided SpringContainerContext in whic we simply override the refresh method so that we can use our custom BootstrappedContextLoader to reload the application context</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">void</span> refresh<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        ContextLoader loader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BootstrappedContextLoader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// if we have an existing spring context, ensure we close it properly</span>
        ApplicationContext ctx <span style="color: #339933;">=</span> WebApplicationContextUtils.<span style="color: #006633;">getWebApplicationContext</span><span style="color: #009900;">&#40;</span>getServletContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ctx <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            loader.<span style="color: #006633;">closeWebApplicationContext</span><span style="color: #009900;">&#40;</span>getServletContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        loader.<span style="color: #006633;">initWebApplicationContext</span><span style="color: #009900;">&#40;</span>getServletContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>getApplicationContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            setApplicationContext<span style="color: #009900;">&#40;</span>WebApplicationContextUtils.<span style="color: #006633;">getWebApplicationContext</span><span style="color: #009900;">&#40;</span>getServletContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        contextReloaded<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h4>BootstrappedContextLoader</h4>
<p>This is a simple extension of the Spring provided ContextLoader class that overrides the loadParentContext and uses our BootstrapUtils class to return our previously loaded bootstrap context. This essentially makes the bootstrap context beans available to all other contexts.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>17
18
19
20
21
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    @Override
    <span style="color: #000000; font-weight: bold;">protected</span> ApplicationContext loadParentContext<span style="color: #009900;">&#40;</span>ServletContext servletContext<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> BeansException
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> BootstrapUtils.<span style="color: #006633;">getBootstrapContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>The other custom classes</h3>
<p>During the explanation of the applicationContextPlugins.xml file, I mentioned a few other custom classes that we haven;t covered. Specifically these are:</p>
<ul>
<li>BundledPluginLoaderFactory</li>
<li>RefPlatformHostContainer</li>
<li>RefPlatformPluginManager</li>
</ul>
<p>I&#8217;m not going to go into detail on these classes since they are simple extensions of Atlassian&reg; provided default classes that just add the ability to make use of our PluginDirectoryLocator.</p>
<p>That being said, it is worth covering the PluginDirectoryLocator itself&#8230;</p>
<h4>DefaultPluginDirectoryLocator</h4>
<p>This class is responsible for determining and creating the bundled plugins, user added plugins, and plugins cache directories.</p>
<p>This class gets the homeLocator injected into it to use as the base path for all of the above mentioned folders.</p>
<p>Although the implementation is very simple, I wanted to list it since this is the place you can customize where plugins get added/stored.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> BUNDLED_PLUGINS_DIRECTORY <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;bundled-plugins&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> DIRECTORY_PLUGINS_DIRECTORY <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;plugins&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> PLUGIN_CACHES_DIR_NAME <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;caches&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> PLUGIN_DESCRIPTOR <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;atlassian-plugin.xml&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> HomeLocator homeLocator<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> DefaultPluginDirectoryLocator<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> HomeLocator homeLocator<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">homeLocator</span> <span style="color: #339933;">=</span> homeLocator<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">File</span> getPluginsDirectory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> getHomeSubDirectory<span style="color: #009900;">&#40;</span>homeLocator, DIRECTORY_PLUGINS_DIRECTORY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">File</span> getBundledPluginsDirectory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> getHomeSubDirectory<span style="color: #009900;">&#40;</span>homeLocator, BUNDLED_PLUGINS_DIRECTORY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">File</span> getPluginCachesDirectory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> getHomeSubDirectory<span style="color: #009900;">&#40;</span>homeLocator, PLUGIN_CACHES_DIR_NAME<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getPluginDescriptorFilename<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> PLUGIN_DESCRIPTOR<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">File</span> getHomeSubDirectory<span style="color: #009900;">&#40;</span>HomeLocator homeLocator, <span style="color: #003399;">String</span> subDirectory<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">File</span> homePath <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>homeLocator.<span style="color: #006633;">getHomePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">File</span> directory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>homePath, subDirectory<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>directory.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            directory.<span style="color: #006633;">mkdir</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> directory<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>Non-Used Classes</h3>
<p>In the source tree there are 2 classes that aren&#8217;t currently used.</p>
<ul>
<li>RefPlatformModuleDescriptorFactory</li>
<li>AbstractRefPlatformModuleDescrptor</li>
</ul>
<p>These classes are here in case you want to add &#8220;built-in&#8221; plugins to your app.</p>
<p>To do so, simply replace the</p>
<pre>&lt;bean id="moduleDescriptorFactory" class="com.atlassian.plugin.DefaultModuleDescriptorFactory"&gt;</pre>
<p>in the applicationContextPlugins.xml file with</p>
<pre>&lt;bean id="moduleDescriptorFactory" class="com.atlassian.refplatform.plugins.descriptor.RefPlatformModuleDescriptorFactory"&gt;</pre>
<p>In the RefPlatformModuleDescriptorFactory you can then add any custom module descriptors you want to provide to your app</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> RefPlatformModuleDescriptorFactory<span style="color: #009900;">&#40;</span>HostContainer hostContainer<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>hostContainer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//you can add any custom plugins here:</span>
        <span style="color: #666666; font-style: italic;">// addModuleDescriptor(&quot;myCustomPlugin&quot;,MyCustomModuleDescriptor.class);</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Each module descriptor you add should extend AbstractRefPlatformModuleDescriptor</p>
<p>For a (very) little more on module descriptors, see: <a href="http://confluence.atlassian.com/display/PLUGINFRAMEWORK/Quick+Start+Guide+to+Embedding">http://confluence.atlassian.com/display/PLUGINFRAMEWORK/Quick+Start+Guide+to+Embedding</a></p>
<h3>Building the app</h3>
<p>So now that we have all the build and source files, you should be able to easily build and run this with a few short maven steps:</p>
<ol>
<li>Run the <strong>install</strong> goal on atlas-webappkit-core</li>
<li>Run the <strong>package</strong> goal on atlas-webappkit-webapp</li>
<li>Run the <strong>cargo:start</strong> goal on atlas-webappkit-webapp</li>
</ol>
<p>After cargo starts up you&#8217;ll be able to see the junk jsp at http://localhost:8080/atlas-webappkit/index.jsp</p>
<p>Added bonus&#8230; you can access the <a href="http://felix.apache.org/site/apache-felix-web-console.html">Felix Web Console</a> at http://localhost:8080/atlas-webappkit/plugins/servlet/system/console/</p>
<h3>Topics Not Covered</h3>
<p>At this point you now have an app that can bootstrap itself, create a home directory, create the plugin directories, extract any bundled plugins, load the bundled plugins, load user added plugins, and process any Spring files. HOORAY!</p>
<p>There are however a few things not covered by this post that I&#8217;m going to leave for other posts or for you to figure out on your own:</p>
<ul>
<li>Assembling a zipped tomcat with the war already exploded and ready to run</li>
<li>Enabling the webapp to show a first-time setup wizard</li>
<li>Using AMPS to build plugins for your custom app</li>
<li>Adding other various Atlassian&reg; plugins (i.e. rest support)</li>
</ul>
<p>Although the above topics were left out, I hope you&#8217;ve found this post helpful.</p>
<p>As always, any comments, suggestions or improvements are very welcomed.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sysbliss.com/general-dev/atlassian-as-a-web-app-framework.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Atlassian Bamboo Post Build Command Runner Plugin</title>
		<link>http://blog.sysbliss.com/general-dev/atlassian-bamboo-post-build-command-runner-plugin.html</link>
		<comments>http://blog.sysbliss.com/general-dev/atlassian-bamboo-post-build-command-runner-plugin.html#comments</comments>
		<pubDate>Fri, 28 Mar 2008 17:30:00 +0000</pubDate>
		<dc:creator>jdoklovic</dc:creator>
				<category><![CDATA[General Development]]></category>

		<guid isPermaLink="false">http://blog.sysbliss.com/?p=4</guid>
		<description><![CDATA[Overview
We use Atlassian Bamboo as our continuous build server and for a while I&#8217;ve wanted to kick off arbitrary command line commands after a build is completed.  Apparently some other developers have been asking for this as well: BAM-679.
In response, I&#8217;ve written this plugin that can run an arbitrary command when a build passes [...]]]></description>
			<content:encoded><![CDATA[<h2>Overview</h2>
<p>We use <a href="http://www.atlassian.com/software/bamboo/">Atlassian Bamboo</a> as our continuous build server and for a while I&#8217;ve wanted to kick off arbitrary command line commands after a build is completed.  Apparently some other developers have been asking for this as well: <a href="http://jira.atlassian.com/browse/BAM-679">BAM-679.</a></p>
<p>In response, I&#8217;ve written this plugin that can run an arbitrary command when a build passes or fails. The pass and fail commands are specified on the Post Actions configuration page.</p>
<p>The plugin is now hosted on the Atlassian Developer Network.<br />
Please <a href="http://confluence.atlassian.com/display/BAMEXT/Pre-Post+Build+Command+Plugin">visit the plugin homepage</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sysbliss.com/general-dev/atlassian-bamboo-post-build-command-runner-plugin.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
