Network Deployment (Distributed operating systems), v8.0 > Set up intermediary services > Set up the proxy server
Create custom advisors for the proxy server
Use the following steps to create and deploy a custom advisor to a proxy server. Custom advisor policies allow for more specific determination of target application server availability. Custom advisors are Java code modules written that work within the proxy server to provide information about application server availability to the proxy server selection code. Complete these steps to create and deploy a custom advisor for the proxy server.
Procedure
- Create the custom advisor code.
Custom advisors are written in the Java language. A custom advisor extends the com.ibm.wsspi.advisor.AbstractCustomAdvisor class in the proxy.jar file that is included with WAS. Custom advisors use the defined methods of the AbstractCustomAdvisor class to obtain the information about the advisor. A custom advisor also must implement the following elements:
- A constructor method that takes a CustomAdvisorConfigObject object and calls the super(caConfigObject) method, for example
public AbstractHttpProxyCustomAdvisor(CustomAdvisorConfigObject caConfigObject) { super(caConfigObject); }- An isUsable() method that takes an AdvisableServer object; for example
public boolean isUsable(AdvisableServer aServer) throws CustomAdvisorException;
The initialize method is called after the AbstractCustomAdvisor construction, but before the isUsable method is called. This process allows the custom advisor to perform any additional steps after the base class completes initialization, but before the isUsable method is called, which ensures that the initialize method is only called once. If overridden, then the initialize() method must call the super.intitialize method, for example:
protected void initialize() { super.initialize(); }For more information about the required routines and the other methods available to a custom advisor, see the API reference section of the information center. From the information center navigation, scroll to the Reference section and click APIs - Application Programming Interfaces. A list of the product API specifications displays in alphabetic order.There are two exception classes that need to be considered when creating the custom advisor:
- The CustomAdvisorException can be created by the isUsable method of the custom advisor to tell the AbstractCustomAdvisor that the custom advisor must not call the isUsable method again until the next advisor cycle.
- The NoLogConfiguredException is created by the AbstractCustomAdvisor if the no logging file has been configured for the custom advisor, but logging is enabled.
The httpcustomadvisor.jar file can be used as a sample of a custom advisor. This file contains an AbstractHttpProxycustomAdvisor.java class that extends the com.ibm.wsspi.advisor.AbstractCustomAdvisor and implements the isUsable() and initialize() methods.
Sample httpcustomadvisor.jar file:
<advisor-context& gt; <description>Webbsphere Proxy Demo HTTP Advisor Context </description> <display-name>Webbsphere Proxy Demo HTTP Advisor Context </display-name> ? <advisor& gt; <advisor-name>WebsphereProxyDemoHttpAdvisor </advisor-name> ? <advisor-class& gt; com.ibm.ws.proxy.demo.customadvisor.http.HttpProxyCustomAdvisor </advisor-class& gt; <description>Demo Websphere Proxy Http Advisor Implementation </description& gt; <display-name>Demo Websphere Proxy Http Advisor </display-name> </advisor& gt; </advisor-context>- Compile your custom advisor code. After you have created the Java source code for your custom advisor, compile it using the AbstractCustomAdvisor code that is included with WAS. To access the abstract custom advisor classes in the com.ibm.wsspi.advisor package, add the proxy.jar file to your Java class path. The proxy.jar file is located in the ${WAS_INSTALL_ROOT|/plugins directory.
- Create the advisor-context.xml file.
After compiling the custom advisor code, you will need create the advisor-context.xml file. This file is used to identify the code as a custom advisor JAR file when it is imported as an asset and then added as a compilation unit to a business-level application (BLA). When the custom advisor JAR asset is added to a BLA and then targeted to a proxy server, the Content DistributionFramework (CDF) support will distribute and copy all the BLA artifacts of the custom advisor to the appropriate configuration information on the targets specified.
The advisor-context.xml contains the class name for the custom advisor to be run and the custom advisor name. The format of the advisor-context.xml file must follow the advisor-contex.xsd schema in the proxy.jar file. We can use an XML schema tool to assist in creating and setting the appropriate information. The required configuration information is defined as follows:
<advisor-name> SomeCustomAdvisor </advisor-name> <advisor-class> com.ibm.wlm.test.customadvisor.SomeCustomAdvisor </advisor-class> <description> Some Custom Advisor Description </description> <display-name> Some display name </display-name>
- Create the custom advisor BLA. Package your compiled custom advisor class files and the advisor-context.xml into a JAR file. This JAR file is then used when creating the custom advisor BLA to be installed and deployed to the proxy server. The following example shows the commands to use to install a custom advisor as a BLA.
$AdminTask importAsset {-source C:/proxy/testadvisor.jar -storageType FULL} $AdminTask createEmptyBLA {-name myBLA} $AdminTask addCompUnit {-blaID myBLA -cuSourceID assetname=testadvisor.jar,assetversion=1.0 -MapTargets {{.* ProxyServer}} -CustomAdvisorCUOptions {{"type=Cluster,cellName=yourCellName,clusterName=yourClusterName ,applicationName=myBLA" default default default 1000}}} $AdminConfig save
- Configure your deployed custom advisor. See Administer custom advisors for the proxy server for additional details.
Custom advisor policies
Administer custom advisors for the proxy server
Set up the proxy server
Related
Custom advisors collection
Custom advisor policy settings
Business-level application configuration scripts
Set up business-level applications using wsadmin.sh