WAS v8.5 > Reference > Administrator best practicesSample custom adapters for federated repositories examples
Out of the box adapters for federated repositories provide File, LDAP, and Database adapters for the 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.
Develop custom adapters for federated repositories
Out of the box adapters for federated repositories provide File, LDAP and Database adapters for the 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 WAS 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 we 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://www.ibm.com/developerworks/websphere/downloads/samples/vmmsampleadapter.html.
Contents of the vmmsampleadapter.jar file are as follows:
- 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
The sample files should not be used in the production environment. You should make a copy of these files, rename them, and update them based on your specific adapter implementation. Refer to the Javadoc in the source code for more information.
- 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. We 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.
Related
Establish custom adapters for federated repositories
Configure custom adapters for federated repositories using wsadmin
Use custom adapters for federated repositories
Related information: