-
Language:
English
-
Language:
English
Red Hat Training
A Red Hat training course is available for Red Hat JBoss Data Virtualization
16.61. Create a Custom Connector
Creating a custom connector involves the following steps:
- Implement the RepositorySource interface, using JavaBean properties for each bit of information the implementation will need to establish a connection to the source system. Then, implement the RepositoryConnection interface with a class that represents a connection to the source. The
execute(
method should process any and all requests that may come down the pike, and the results of each request can be put directly on that request. This approach is pretty straightforward, and gives you ultimate freedom in terms of your class structure.ExecutionContext
,Request
)Alternatively, an easier way to get a complete read-write connector would be to extend one of our two abstract RepositorySource implementations. If the content your connector exposes has unique keys (such as a unique string, UUID or other identifier), consider implementingMapRepositorySource
, subclassingMapRepository
, and using the existingMapRepositoryConnection
implementation. ThisMapRepositoryConnection
does most of the work already, relying upon yourMapRepository
subclass for anything that might be source-specific. (See the JavaDoc for details.) Or, if the content your connector exposes is path-based, consider implementingPathRepositorySource
, subclassingPathRepository
, and using the existingPathRepositoryConnection
implementation. Again,PathRepositoryConnection
class does almost all of the work and delegates to yourPathRepository
subclass for anything that might be source-specific. (See the JavaDoc for details.)Don't forget unit tests that verify the connector is doing what it is expected to do. (If you'll be committing the connector code to the ModeShape project, please ensure that the unit tests can be run by others that may not have access to the source system. In this case, consider writing integration tests that can be easily configured to use different sources in different environments, and try to make the failure messages clear when the tests can't connect to the underlying source.) - Configure ModeShape to use your connector. This may involve just registering the source with the
RepositoryService
, or it may involve adding a source to a configuration repository used by the federated repository. - Deploy the JAR file with your connector (as well as any dependencies), and make them available to ModeShape in your application.