Skip to content

Commit

Permalink
Document out the module.xml schema, fix problems in the module ID val…
Browse files Browse the repository at this point in the history
…idation
  • Loading branch information
dmlloyd committed Jan 14, 2011
1 parent 2e4e73a commit fc36308
Show file tree
Hide file tree
Showing 2 changed files with 310 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jboss/modules/ModuleIdentifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public final class ModuleIdentifier implements Serializable {

private static final long serialVersionUID = 118533026624827995L;

private static Pattern MODULE_NAME_PATTERN = Pattern.compile("[a-zA-Z_][-a-zA-Z0-9_]*(?:\\.[a-zA-Z0-9_][-a-zA-Z0-9_]*)*");
private static Pattern MODULE_NAME_PATTERN = Pattern.compile("[a-zA-Z0-9_](?:[-a-zA-Z0-9_]*[a-zA-Z0-9_])?(?:\\.[a-zA-Z0-9_](?:[-a-zA-Z0-9_]*[a-zA-Z0-9_])?)*");
private static Pattern SLOT_PATTERN = Pattern.compile("[-a-zA-Z0-9_+*.]+");
private static String DEFAULT_SLOT = "main";

Expand Down
339 changes: 309 additions & 30 deletions src/main/resources/schema/module-1_0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -30,78 +30,357 @@
version="1.0">

<!-- Root element -->
<xsd:element name="module" type="moduleType"/>
<xsd:element name="module" type="moduleType">
<xsd:annotation>
<xsd:documentation>
Root element for a module declaration.
</xsd:documentation>
</xsd:annotation>
</xsd:element>

<xsd:complexType name="moduleType">
<xsd:annotation>
<xsd:documentation>
The module declaration type; contains dependencies, resources, and the main class
specification.
</xsd:documentation>
</xsd:annotation>
<xsd:all>
<xsd:element name="dependencies" type="dependenciesType" minOccurs="0"/>
<xsd:element name="resources" type="resourcesType" minOccurs="0"/>
<xsd:element name="main-class" type="nameType" minOccurs="0"/>
<xsd:element name="dependencies" type="dependenciesType" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
Lists the dependencies of this module (optional).
</documentation>
</annotation>
</xsd:element>
<xsd:element name="resources" type="resourcesType" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
Lists the resource roots of this module (optional).
</documentation>
</annotation>
</xsd:element>
<xsd:element name="main-class" type="classNameType" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
Specifies the main class of this module; used to run the module from the command-line
(optional).
</documentation>
</annotation>
</xsd:element>
</xsd:all>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="name" type="moduleNameType" use="required">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The name of this module (required).
</documentation>
</annotation>
</xsd:attribute>
<xsd:attribute name="slot" type="moduleSlotType" use="optional">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The version slot of this module (optional).
</documentation>
</annotation>
</xsd:attribute>
</xsd:complexType>

<xsd:simpleType name="moduleNameType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A module name, which consists of one or more dot (.)-separated segments. Each segment must begin and end
with an alphanumeric or underscore (_), and may otherwise contain alphanumerics, underscores, and hypens
(-).
</documentation>
</annotation>
<xsd:restriction base="xsd:string">
<xsd:pattern value="[a-zA-Z0-9_]([-a-zA-Z0-9_]*[a-zA-Z0-9_])?(\.[a-zA-Z0-9_]([-a-zA-Z0-9_]*[a-zA-Z0-9_])?)*"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="moduleSlotType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A module version slot. A slot may consist of one or more alphanumerics, hyphens (-), underscores (_),
plus signs (+), asterisks (*), or dots (.).
</documentation>
</annotation>
<xsd:restriction base="xsd:string">
<xsd:pattern value="[-a-zA-Z0-9_+*.]+"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="dependenciesType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A list of zero or more module dependencies.
</documentation>
</annotation>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="module" type="moduleDependencyType"/>
<xsd:element name="module" type="moduleDependencyType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A specified module dependency.
</documentation>
</annotation>
</xsd:element>
</xsd:choice>
</xsd:complexType>

<xsd:complexType name="moduleDependencyType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A single module dependency expression.
</documentation>
</annotation>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="exports" type="filterType"/>
<xsd:element name="imports" type="filterType"/>
<xsd:element name="exports" type="filterType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A filter used to restrict what packages or directories from this dependency are re-exported by
this module. See also the "export" and "services" attributes. The default action of this filter
list is controlled by the value of the "export" attribute. Regardless of the setting of these
attributes, this filter always behaves as if it has a final entry which rejects META-INF and
all of its subdirectories.
</documentation>
</annotation>
</xsd:element>
<xsd:element name="imports" type="filterType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A filter used to restrict what packages or directories from this dependency are visible to this
module. See also the "services" attribute. The default action of this filter list is to reject
a path if not matched.
</documentation>
</annotation>
</xsd:element>
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="export" type="xsd:boolean" use="optional" default="false"/>
<xsd:attribute name="services" type="importDispositionType" use="optional" default="none"/>
<xsd:attribute name="optional" type="xsd:boolean" use="optional" default="false"/>
<xsd:attribute name="name" type="moduleNameType" use="required">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The dependency module name (required).
</documentation>
</annotation>
</xsd:attribute>
<xsd:attribute name="slot" type="moduleSlotType" use="optional">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The dependency module version slot (optional).
</documentation>
</annotation>
</xsd:attribute>
<xsd:attribute name="export" type="xsd:boolean" use="optional" default="false">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
Specifies whether this module dependency is re-exported by default (default is "false"). Setting
this attribute to true sets the default action for the export filter list to "accept"; leaving it
as false sets the default action to "reject". Thus you can still export dependency resources even
if this attribute is false by listing explicit paths for the export list.
</documentation>
</annotation>
</xsd:attribute>
<xsd:attribute name="services" type="serviceDispositionType" use="optional" default="none">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
Specifies whether and how services found in this dependency are used (default is "none"). Specifying
a value of "import" for this attribute is equivalent to adding a filter at the end of the import
filter list which includes the META-INF/services path from the dependency module. Setting a value
of "export" for this attribute is equivalent to the same action on the export filter list.
</documentation>
</annotation>
</xsd:attribute>
<xsd:attribute name="optional" type="xsd:boolean" use="optional" default="false">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
Specifies whether this dependency is optional (defaults to false). An optional dependency will not
cause the module to fail to load if not found; however if the module is added later, it will not be
retroactively linked into this module's dependency list.
</documentation>
</annotation>
</xsd:attribute>
</xsd:complexType>

<xsd:simpleType name="importDispositionType">
<xsd:simpleType name="serviceDispositionType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The requested behavior for service handling on a dependency.
</documentation>
</annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="none"/>
<xsd:enumeration value="import"/>
<xsd:enumeration value="export"/>
<xsd:enumeration value="none">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
Do not import or export services from this dependency.
</documentation>
</annotation>
</xsd:enumeration>
<xsd:enumeration value="import">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
Import, but do not re-export, services from this dependency.
</documentation>
</annotation>
</xsd:enumeration>
<xsd:enumeration value="export">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
Import and re-export services found in this dependency.
</documentation>
</annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="nameType">
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:complexType name="classNameType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A class name.
</documentation>
</annotation>
<xsd:attribute name="name" type="xsd:string" use="required">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The class name.
</documentation>
</annotation>
</xsd:attribute>
</xsd:complexType>

<xsd:complexType name="pathType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A filesystem path name.
</documentation>
</annotation>
<xsd:attribute name="name" type="xsd:string" use="required">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The path name.
</documentation>
</annotation>
</xsd:attribute>
</xsd:complexType>

<xsd:complexType name="resourcesType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A list of zero or more resource roots for this deployment.
</documentation>
</annotation>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="resource-root" type="resourceType"/>
<xsd:element name="resource-root" type="resourceType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A resource root within this deployment.
</documentation>
</annotation>
</xsd:element>
</xsd:choice>
</xsd:complexType>

<xsd:complexType name="resourceType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A resource root within a deployment.
</documentation>
</annotation>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="exports" type="filterType"/>
<xsd:element name="exports" type="filterType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The list of path filters corresponding to resources exported by this resource root. By default
all paths are exported.
</documentation>
</annotation>
</xsd:element>
</xsd:choice>
<!-- If unspecified, name defaults to path -->
<xsd:attribute name="name" type="xsd:string" use="optional"/>
<!-- Relative path of resource from module.xml file -->
<xsd:attribute name="path" type="xsd:string" use="required"/>
<xsd:attribute name="name" type="xsd:string" use="optional">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The name of this resource root (optional). If not specified, defaults to the value of the path
attribute.
</documentation>
</annotation>
</xsd:attribute>
<xsd:attribute name="path" type="pathType" use="required">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The path of this resource root, relative to the path in which the module.xml file is found.
</documentation>
</annotation>
</xsd:attribute>
</xsd:complexType>

<xsd:complexType name="filterType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A filter specification, consisting of zero or more filter items.
</documentation>
</annotation>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="include" type="pathSpecType" minOccurs="0"/>
<xsd:element name="exclude" type="pathSpecType" minOccurs="0"/>
<xsd:element name="include-set" type="pathSetType" minOccurs="0"/>
<xsd:element name="exclude-set" type="pathSetType" minOccurs="0"/>
<xsd:element name="include" type="pathSpecType" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A path to include. The path value can be a path name or a "glob" which may include the special
wildcards "*", "**", and "?".
</documentation>
</annotation>
</xsd:element>
<xsd:element name="exclude" type="pathSpecType" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A path to exclude. The path value can be a path name or a "glob" which may include the special
wildcards "*", "**", and "?".
</documentation>
</annotation>
</xsd:element>
<xsd:element name="include-set" type="pathSetType" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A set of literal path names to include. Wildcards are not supported.
</documentation>
</annotation>
</xsd:element>
<xsd:element name="exclude-set" type="pathSetType" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A set of literal path names to exclude. Wildcards are not supported.
</documentation>
</annotation>
</xsd:element>
</xsd:choice>
</xsd:complexType>

<xsd:complexType name="pathSpecType">
<xsd:attribute name="path" type="xsd:string" use="required"/>
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A path specification type, which may include wildcards.
</documentation>
</annotation>
<xsd:attribute name="path" type="xsd:string" use="required">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The path name, which can be a literal path name or it may include the special wildcards "*", "**",
and "?".
</documentation>
</annotation>
</xsd:attribute>
</xsd:complexType>

<xsd:complexType name="pathSetType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A set of literal path names which can be used for efficient matching against multiple possible values.
</documentation>
</annotation>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="path" type="nameType" minOccurs="0"/>
<xsd:element name="path" type="pathType" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The path name to include in the set.
</documentation>
</annotation>
</xsd:element>
</xsd:choice>
</xsd:complexType>

Expand Down

0 comments on commit fc36308

Please sign in to comment.