JBoss.orgCommunity Documentation
The Scribble architecture is based on OSGi, to provide a means of managing the individual modules, but without causing tight coupling.
Service bundles enable implementations to be specified that implement defined interfaces. Other services can then request access to services that implement a particular interface.
The OSGi service container takes responsibility of managing the services, and providing access to requesting components.
This provides flexibility for Scribble tooling in two respects:
The implementation of a particular Scribble interface can easily be replaced. This enables different research or industry groups to replace specific modules, with alternative implementations, while still reusing other modules.
Some aspects of the architecture allow for multiple implementations of the same interface. Therefore, using OSGi, enables additional implementations of the same interface to be easily plugged in, without having to define any additional configuration information.
There is a generic logging API within the Scribble framework that can be used for reporting errors, warnings, information or debuging details. This API is org.scribble.common.logging.ScribbleLogger.
The methods generally take two parameters, a message and a property map. The message is simply a description of the issue being reported. The property map contain specific details about the issue being reported.
For example, when the parser detects a problem, it can report the nature of the problem, and provide the location of the issue in the source file.
To enable errors reported from the Scribble parser and validation modules, in a number of different languages, internationalization should be used.
The following code fragment provides an example of how internationalization can be achieved, using parameterised messages.
logger.error(org.scribble.common.util.MessageUtil.format( java.util.PropertyResourceBundle.getBundle( "org.scribble.common.validation.rules.Messages"), "_EXISTING_DECLARATION", new String[]{elem.getName()}), obj.getProperties());
The main message content is obtained from a
properties file, with the name being supplied
as the first parameter to the getBundle
method. The property file must be placed
the correct package within the
src/main/resources
folder, to
ensure the properties are correctly packaged
by maven.
The messages within the property files can have values that include parameters. Parameters are numbered in sequential order, and defined between curly braces (e.g. {n} where 'n' is the number). For example,
_EXISTING_DECLARATION=Declaration already exists for name '{0}'
This message only has a single parameters.
In the previous code fragment, the MessageUtil.format() method takes the message as the first parameter, and an array of strings as the parameter values to be substituted in the message. So in the code fragment, the value in the elem.getName() would be substituted in the {0} parameter of the _EXISTING_DECLARATION message, and then reported to the Scribble logger.
Placeholder for component to resolve references from one model to other models and types. This will be required where one protocol references an external protocol - to enable other validation to span across the multiple protocols seemlessly.
The validation manager, when used in a OSGi runtime
environment, will listen for the activation of any
implementations of the
org.scribble.protocol.validation.Validator
interface.
This means that the validation of any model can be
performed using the
org.scribble.protocol.validation.ValidationManager,
rather than having to obtain instances of
multiple implementations of the Validator
interface.
When the ValidatorManager
is used
outside of an OSGi environment, it is necessary for the
validators to be added to the manager by other means.
The first step is to define the command implementation of the org.scribble.command.Command interface. This can be created in the org.scribble.command Eclipse plugin.
To the initialise the command, as part of an OSGi runtime environment, the command implementation can be instantiated in the org.scribble.command plugin's Activator, and then registered with the bundle context.
If the command requires other OSGi services, then these can be established by setting up service listeners for the relevant service interface classes. When OSGi services are registered, then the relationship can be established.
This command mechanism will generally only be used as part of the command line approach, and therefore does not need to be initialised in other ways. However other dependency injection techniques could be used if appropriate.
The only remaining step is to create the scripts
necessary to enable a user to invoke the command.
This can be achieved by copying one of the existing
scripts, in the distribution/src/main/release
folder (such as parse.sh
),
and modify the parameter details as necessary.
The first parameter of the Java application, invoked within the script, must be the name of the command. This must match the value returned by the getName() method on the command interface.