fabric3
Content
Documentation
Developer Reference
Modularity
Contribution Modularity
Contribution Modularity
search
attachments
weblink
advanced
image-effects
image-attributes
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
Colour picker
More colours
Formatting
Strikethrough
Subscript
Superscript
Monospace
Clear formatting
Bullet list
Numbered list
Task list
Outdent
Indent
Align left
Align center
Align right
Page layout
Link
Table
Insert
Insert content
Files and images
Link
Symbol
Emoticon
Markup
Horizontal rule
Insert macro
User mention
Jira Issue/Filter
Info
Status
Gallery
Table of Contents
Jira timeline
Lucidchart Diagrams
Trello Board
Other macros
Page layout
No layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Find/Replace
Keyboard shortcuts help
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account.
<h2>Contribution Imports and Exports</h2><p>Embedding artifacts and libraries in the META-INF/lib directory of a contribution is simple but lacks the flexibility required by many applications. For example, several applications may need to share the same WSDL document or library. Fabric3 supports three forms of sharing:</p><ul><li><span style="line-height: 1.4285715;">Java package sharing</span></li><li>XML resource sharing</li><li>Java contribution sharing</li></ul><p>In all cases, a resource (or set of resources) are <strong><em>exported</em></strong> by one contribution and *<em>imported</em>*by another. Imports and exports are specified in the contribution manifest file.</p><h2><span style="line-height: 1.5;">Java Package Sharing</span></h2><p>Java resources (i.e. classes) are shared by exporting and importing their packages. Java package sharing in Fabric3 is based on OSGi, so if you are familiar with that technology, you already understand Fabric3's approach and capabilities. Classes contained in Java packages are made available to other contributions using the <export.java> element in the contribution manifest:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"> <export.java package="com.foo.bar" version="1.0"/> </contribution> </pre></td></tr></table><p>Exported packages may then be imported using the <import.java> element in the manifest of another contribution:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"> <import.java package="com.foo.bar" version="1.0"/> </contribution> </pre></td></tr></table><p>The previous examples make classes in the <em>com.foo.bar</em> package available to the importing contribution.</p><h2>Fabric3 and OSGi Classloading</h2><p>Fabric3 loads contributions in separate classloaders using OSGi. This provides contribution isolation (Java classes and artifacts are not visibile to other contributions unless they are exported, thereby reducing the potential for conflicts) and allows versioning. Further, each contribution is associated a classloader space. When a package is imported, a "wire" is created between the importing and exporting contribution. This wire is used by the importing contribution's classloader to load classes belonging to the package using the exporting conribution's classloader. A classloader space therefore consists of the contribution classloader and the classloaders it is wired to via a set of import/export pairs.</p><p>Since package imports and exports can specify versions, it is possible to control contribution isolation is a very precise manner. For example, by specifying a version, is is possible for two contributions to use different versions of the same package. For example, versions 1.0 and 2.0 of package <em>com.bar.foo</em> can be provided by using the @version attribute of the <export.java> element:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"> <export.java uri="com.foo.bar"/> </contribution> </pre></td></tr></table><p>An importing contribution can control which version it receives by specifying the @version attribute of the <import.java> element:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"> <export.java uri="com.foo.bar"/> </contribution> </pre></td></tr></table><p>Often, it is useful to specify a version range instead of an exact version. This can be done using the @min, @minInclusive, @max, and @maxInclusive attributes of the <import.java> element:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><import.java package="org.foo.bar" min=1.0.0" minInclusive="false" max="2.0.0" maxInclusive="true"/> </pre></td></tr></table><p>By default, @minInclusive and @maxInclusive are true.<br /> It is also possible to specify a '*' wildcard when exporting and importing packages. For example, the following will export packages <em>com.foo.bar</em> and <em>com.foo.baz</em>:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><export.java package="org.foo.*"/> </pre></td></tr></table><p>Imports can also be made optional by setting the @required attribute to false. In this case, if a matching export is not found, the contribution will still be loaded :</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><import.java package="org.foo.bar" version="1.0.0" required="false"/> </pre></td></tr></table><h2>XML Resource Sharing</h2><p>XML resources are shared by exporting and importing their qualified name (qname). For example, assume a set of portTypes in a WSDL document need to be shared among several contributions. The contribution manifest file contining the WSDL document will export the document's qname using the <export> element:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"> <export name={"urn:somenamespace:1.0"/> </contribution> </pre></td></tr></table><p>Contributions that require access to the portTypes defined in the <strong>u</strong><strong><em><a href="http://rnsomenamespace:1.0">rn:somenamespace:1.0</a></em></strong> namespace may import it using the <import> element in their manifest:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"> <import name="urn:somenamespace:1.0"/> </contribution> </pre></td></tr></table><p>When the qname is imported, Fabric3 will ensure the portTypes may be referenced by artifacts such as composite files contained in the importing contribution.</p><h2>Contribution Imports and Exports</h2><p>Fabric3 supports the ability to export and import all Java packages from a contribution using <export.contribution> and <import.contribution>. Matching is done using a symbolic name provided by the @uri attribute:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><export.contribution uri="MyContribution"/> </pre></td></tr></table><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><import.contribution uri="MyContribution"/> </pre></td></tr></table><p>It is recommended to use <export.java>/<import.java> instead of contribution importing to avoid unnecessary coupling between contributions. However, contribution importing is useful when an application is composed of multiple Maven modules where one module performs integration tests and requires access to non-public classes provided by the other.</p>
Save
Close
Edit
Preview
View changes
Revert to last published version
{"serverDuration": 465, "requestCorrelationId": "b66c6e50006a4a0ab68db04c3a688fde"}