fabric3
Content
Documentation
Developer Reference
Annotations and the DSL
Annotations and the DSL
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.
<p>Fabric3 supports defining components using annotations, XML, or a DSL. Before discussing other aspects of programming with Fabric3, we will provide an overview of working with annotations and the DSL.</p><h1>Annotation Basics</h1><p>Fabric3 is a modular runtime that is designed to be configured and deployed based on the specific functional requirements of the services it is hosting. For example, if a runtime is to host a service that requires JAX-RS functionality, an image can be assembled from the Fabric3 kernel and JAX-RS extensions; extensions for other technologies such as JMS or WS-* may be excluded.</p><table class="wysiwyg-macro" data-macro-name="info" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm99&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>Fabric3 provides Maven and Gradle plugins for assembling runtime images as part of a build. For details, see <a class="confluence-link" href="/wiki/spaces/FABRIC/pages/1212498/Service+Delivery" data-linked-resource-id="1212498" data-linked-resource-version="10" data-linked-resource-type="page" data-linked-resource-default-alias="Service Delivery" data-base-url="https://fabric3.atlassian.net/wiki">Service Delivery</a>.</p></td></tr></table><p>This modularity is reflected in the structure of the Fabric3 API. The main API module, <code>org.fabric3:fabric3-api</code> contains base annotations for working with Java POJO. Component implementation types (such as the timer component) and bindings also have API modules that extend from the core <code>fabric3-api</code> module. For example, the <code>org.fabric3:fabric3-timer-api</code> contains the <code>Timer</code> annotation used to declare a Java class as timer component. It may therefore be necessary to configure multiple API modules as dependencies in a project build. At runtime, Fabric3 will ensure installed API module classes are visible to applications.</p><p> </p><table class="wysiwyg-macro" data-macro-name="info" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm99&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>Throughout this manual, we refer to Fabric3 modules (JARs) using their coordinate names, e.g. <code>org.fabric3:fabric3-api</code>. These coordinates correspond to <code>[group id:artifact id</code>] and can be used to derive dependency configuration for various build systems such as Maven and Gradle.</p></td></tr></table><p> </p><p>The following table lists the set of Fabric3 API modules:</p><p> </p><table class="confluenceTable"><tbody><tr><th class="confluenceTh">Coordinates</th><th class="confluenceTh">Description</th></tr><tr><td class="confluenceTd"><code>org.fabric3:fabric3-api</code></td><td class="confluenceTd">The base package containing general annotations and API classes</td></tr><tr><td colspan="1" class="confluenceTd"><code>org.fabric3:fabric3-model-api</code></td><td colspan="1" class="confluenceTd">The base package for DSL classes</td></tr><tr><td colspan="1" class="confluenceTd"><code>org.fabric3:fabric3-binding-jms-api</code></td><td colspan="1" class="confluenceTd">Package for JMS annotations and DSL classes</td></tr><tr><td colspan="1" class="confluenceTd"><code>org.fabric3:fabric3-binding-file-api</code></td><td colspan="1" class="confluenceTd"><span>Package for file binding annotations <span>and DSL classes</span></span></td></tr><tr><td class="confluenceTd"><span><code>org.fabric3:fabric3-binding-rs-api</code><br /></span></td><td class="confluenceTd"><span>Package for JAX-RS annotations <span>and DSL classes</span></span></td></tr><tr><td colspan="1" class="confluenceTd"><span><code>org.fabric3:fabric3-binding-ws-api</code><br /></span></td><td colspan="1" class="confluenceTd"><span>Package for JAX-WS annotations </span><span>and DSL classes</span></td></tr><tr><td colspan="1" class="confluenceTd"><span><code>org.fabric3:fabric3-binding-zeromq-api</code><br /></span></td><td colspan="1" class="confluenceTd"><span>Package for ZeroMQ annotations </span><span>and DSL classes</span></td></tr><tr><td colspan="1" class="confluenceTd"><span><code>org.fabric3:fabric3-junit-api</code><br /></span></td><td colspan="1" class="confluenceTd"><span>Package for JUnit annotations</span></td></tr><tr><td colspan="1" class="confluenceTd"><span><code>org.fabric3:fabric3-timer-api</code><br /></span></td><td colspan="1" class="confluenceTd"><span>Package for Timer annotations </span><span>and DSL classes</span></td></tr></tbody></table><h1>Using the DSL</h1><p> </p><p>Components and channels can also be defined using the Fabric3 DSL. To use the DSL, one or more provider classes must be packaged in an application archive under the Java package "f3". Provider classes are invoked by the runtime to programmatically create composites. The following is an example of a provider class:</p><p> </p><table class="wysiwyg-macro" data-macro-name="code" data-macro-parameters="language=java" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6bGFuZ3VhZ2U9amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>package f3; public class TestCompositeProvider { private static final QName QNAME = new QName(Namespaces.F3, "TestComposite"); @Provides public static Composite getComposite() { CompositeBuilder compositeBuilder = CompositeBuilder.newBuilder(QNAME); compositeBuilder.component(JavaComponentDefinitionBuilder.newBuilder(ContributionServiceImpl.class).build()); return compositeBuilder.build(); } }</pre></td></tr></table><p> </p><p>A provider class contains one or more static methods annotated with <code>org.fabric3.api.annotation.model.Provides</code> that returns a Composite. Programmatic configuration is extremely flexible as it can be used to create conditional configuration such as changing binding settings based on the environment. To facilitate this, Fabric3 supports the <code>org.fabric3.api.annotation.model.Environment</code> annotation:</p><p> </p><table class="wysiwyg-macro" data-macro-name="code" data-macro-parameters="language=java" data-macro-schema-version="1" style="background-image: url(https://fabric3.atlassian.net/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6bGFuZ3VhZ2U9amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> public class CompositeProvider { @Provides public static Composite getScannedComposite(@Environment String environment) { if (!"production".equals(environment)) { // create a composite specific to production } else { // create another composite } } }</pre></td></tr></table><p>The <code>Environment</code> annotation signals to Fabric3 to inject the name of the environment the runtime is started with. For example of how to configure the runtime with different environment settings, see <a class="confluence-link" href="/wiki/spaces/FABRIC/pages/524325/Packaging+For+Different+Environments" data-linked-resource-id="524325" data-linked-resource-version="12" data-linked-resource-type="page" data-linked-resource-default-alias="Packaging For Different Environments" data-base-url="https://fabric3.atlassian.net/wiki">Packaging For Different Environments</a>.</p><p>For specific examples of using annotations or the DSL, refer to the sample applications. </p>
Save
Close
Edit
Preview
View changes
Revert to last published version
{"serverDuration": 542, "requestCorrelationId": "e6c1b9e2aaf849459a57a7d40ed90c05"}