Sample custom adapters for federated repositories examples
Out of the box adapters for federated repositories provide File, LDAP, and Database adapters for your use. These adapters implement the com.ibm.wsspi.wim.Repository software programming interface (SPI). A virtual member manager custom adapter needs to implement the same SPI, irrespective of the type of repositories the adapter is interacting with. There is no restriction on the type of repositories that the custom adapter can interact with.
Developing custom adapters for federated repositories
Out
of the box adapters for federated repositories provide File, LDAP
and Database adapters for your use. All these adapters implement the com.ibm.wsspi.wim.Repository
SPI.
See the com.ibm.wsspi.wim.Repository
SPI for more
information. As you develop a virtual member manager custom adapter,
you need to implement the same SPI.
Custom adapters for federated repositories must not depend on any WebSphere® Application Server components, such as data sources and enterprise beans. These WebSphere Application Server components require that security is initialized and enabled prior to startup. If your implementation of custom adapters for federated repositories needs to use data sources to connect to a database, you need to use Java™ database connectivity (JDBC) to make the connection during server startup. Then, at a later time, switch to using the data sources when the data source is available.
There are examples of suggested behavior and requirements of custom adapters for federated repositories that you can find in the sample code.
A sample custom adapter for federated repositories
A sample custom adapter implementation has been provided as an example. The custom adapter is based on file repository. The sample source code and class files are bundled in vmmsampleadapter.jar. The vmmsampleadapter.jar can be downloaded at this location: http://public.dhe.ibm.com/software/dw/wes/WASV61/vmmsampleadapter.jar.
- Class files for the sample adapter:
com/ibm/ws/wim/adapter/sample/AbstractAdapterImpl.class
com/ibm/ws/wim/adapter/sample/SampleFileAdapter.class
com/ibm/ws/wim/adapter/sample/XPathHelper.class
- Source code for the sample adapter:
src/com/ibm/ws/wim/adapter/sample/AbstractAdapterImpl.java
src/com/ibm/ws/wim/adapter/sample/SampleFileAdapter.java
src/com/ibm/ws/wim/adapter/sample/XPathHelper.java
- com/ibm/ws/wim/sample/adapter/AbstractAdapterImpl.java
- Provides an abstract implementation class which handles most of the repository independent internal operations for the adapter and defines some simple abstract methods that should be implemented by the custom adapter. For most cases, you may not need to change this file.
- com/ibm/ws/wim/sample/adapter/SampleFileAdapter.java
- Extends from the AbstractAdapterImpl class and implements the abstracts method. This class implements the abstract methods using file as the repository. Adapter providers can use this class as a reference to implement these methods specific to their adapters.
- com/ibm/ws/wim/sample/adapter/XPathHelper.java
- Defines a helper class to parse the XPath search expression and build the search tree. This
helper class also contains the method to evaluate the search expression. If your repository supports
a search expression, then you need to convert XPath expression to an expression that your repository
can process and let your repository evaluate the expression. This helper class evaluates the search
expression based on the use of dataobjects. You can overwrite the
evaluate()
method to perform the evaluation using other objects, such as java.util.Map.
Some utility classes have been provided to help adapter providers. Most of these utility methods are used in the sample adapter. Refer to the Javadoc information for more details.