Class SchemaLocation
When a location is based on an EBX® module, this implies that the data model is packaged inside the specified module (which is commonly a web application). This approach has several benefits:
- an easier and standardized deployment procedure for different application servers;
- more independence regarding physical deployment;
- the packaging of resources used by the data model (constraints, functions, bean editors, etc.) in the module.
EBX® defines specific URNs to identify a data model location. The following table describe all supported URNs.
| URN | Description |
|---|---|
urn:ebx:publication: |
Identifies an embedded data model, where
is the name of a
publication that was created by publishing an embedded data model in the data model assistant.
|
urn:ebx:module: |
Identifies a packaged data model inside a module, where is
the name
of the module containing the data model and is the path of
the data model
inside the module.
|
As the above URNs are specific to EBX®, they will not be able to be resolved by external tools. Thus, when using an external editor to edit any XML Schema Documents that contain these URNs, the editor may report errors. To workaround this issue, you can manually substitute the physical locations of the targeted XML Schema documents for the URNs during editing of the XML Schema document using an external editor.
-
Method Summary
Modifier and TypeMethodDescriptionstatic final SchemaLocationforLocation(String aBaseOrNull, String aURI) Returns a reference to an embedded data model (not packaged inside an EBX® module).abstract Stringformat()Returns a string representation of the location of this data model.static final SchemaLocationforPathInModule(String aPathInModule, String aModuleName) Returns a reference to a data model that is packaged inside an EBX® module.abstract FileIf this location resolves to a file, returns that file, otherwise returnsnull.abstract InputStreamDeprecated.abstract InputStreamgetInputStream(Repository aRepository) Returns a stream for reading the content of the corresponding data model.abstract StringReturns the name of the module that contains the resource or, if this instance is URI based, returns the default module name.Returns the location of the related data model inside its container module if it is packaged in a module.Returns the name of the publication if this instance is an embedded data model.abstract booleanReturnstrueif this instance is a module-based location.abstract booleanReturnstrueif this instance refers to a publication.abstract booleanReturnstruefor data models that are managed by EBX®.abstract booleanisURI()Returnstrueif this instance is a URL-based location.static final SchemaLocationReturns aSchemaLocationbased on the string specified.abstract SchemaLocationReturns the most accurate locator constituting the real target with this current instance as the base name.abstract StringtoStringInfo(Locale aLocale) Returns a string that identifies this location.
-
Method Details
-
forLocation
public static final SchemaLocation forLocation(String aBaseOrNull, String aURI) throws IllegalArgumentException Returns a reference to an embedded data model (not packaged inside an EBX® module).Warning: Beyond simple test cases, it is generally recommended to use data models that are packaged inside EBX® modules (see
forPathInModule(String, String)).The location of the data model is determined as follows:
- If
aURIis absolute, the location isaURI. - If
aURIis relative, it usesaBaseOrNullas the base URI for resolving the location. IfaBaseOrNullisnull, it uses the current user directory, as defined byFile, as the base URI.
- Parameters:
aBaseOrNull- used only ifaURIis relativeaURI- an absolute or relative URI- Throws:
IllegalArgumentException- if an argument is not a well-formed URI- See Also:
- If
-
forPathInModule
Returns a reference to a data model that is packaged inside an EBX® module.Example
SchemaLocation dataModelLocation = SchemaLocation.forPathInModule( "/WEB-INF/schemas/main.xsd", "sample");where "sample" is the module name.- Parameters:
aPathInModule- path of the data model inside the module (see example above). The path must be specified according to the rules detailed inServletContext.getResource(String)).aModuleName- identifies the module that contains the data model (the name of a module is defined in the document/WEB-INF/ebx/module.xml, by the element/module/name).
-
getFileOrNull
If this location resolves to a file, returns that file, otherwise returnsnull.Generally, a location is able to resolve to a file if this location is URL-based with the protocol
file:, or if this location is module-based and the application server is able to translate the module location to an actual file. -
getInputStream
Deprecated.This method has been replaced bygetInputStream(Repository).Returns a stream for reading the content of the corresponding data model. This method is not supported for embedded data models or data models located inside therepositorydirectory, since those must be resolved in the context of a repository.- Throws:
Exception
-
getInputStream
Returns a stream for reading the content of the corresponding data model. The specified repository is used for resolving the content of a data model contained in a repository. For instance, a repository is necessary for getting the content of an embedded data model or a data model located inside therepositorydirectory .- Throws:
Exception
-
getModuleName
Returns the name of the module that contains the resource or, if this instance is URI based, returns the default module name. The name of a module is defined in the document/WEB-INF/ebx/module.xml, by the element/module/name.- Throws:
IllegalStateException- if this method is called on an embedded data model. Embedded data models must be resolved in the context of a repository.
-
isReserved
public abstract boolean isReserved()Returnstruefor data models that are managed by EBX®. -
isPackagedInModule
public abstract boolean isPackagedInModule()Returnstrueif this instance is a module-based location. -
getPathInModule
Returns the location of the related data model inside its container module if it is packaged in a module.Returns
nullif this instance does not refer to packaged data model.- Since:
- 6.1.0
- See Also:
-
isURI
public abstract boolean isURI()Returnstrueif this instance is a URL-based location. -
isPublication
public abstract boolean isPublication()Returnstrueif this instance refers to a publication. A publication is a data model embedded in an EBX® repository.- Since:
- 6.1.0
- See Also:
-
getPublicationName
Returns the name of the publication if this instance is an embedded data model.Returns
nullif this instance does not refer to an embedded data model.- Since:
- 6.1.0
- See Also:
-
resolve
Returns the most accurate locator constituting the real target with this current instance as the base name.- Throws:
IllegalArgumentException- If the given string violates RFC 2396
-
format
Returns a string representation of the location of this data model.- See Also:
-
parse
Returns aSchemaLocationbased on the string specified.The specified string must have been generated by
format().- Throws:
IllegalArgumentException- if the specified URN does not correspond to a supported EBX® URN or if the specified URN correspond to a relative path.- See Also:
-
toStringInfo
Returns a string that identifies this location.- Parameters:
aLocale- ifnull, uses the default locale.
-
getInputStream(Repository).