+

Search Tips   |   Advanced Search

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.

  1. Create the custom advisor code.
  2. Custom advisors are written in the Java language. A custom advisor extends the com.ibm.wsspi.advisor.AbstractCustomAdvisor class in the proxy.jar file included with WebSphere Application Server. 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>                                                      <description>Webbsphere Proxy Demo HTTP Advisor Context</description>  <display-name>Webbsphere Proxy Demo HTTP Advisor Context</display-name>
    ?                                                                       <advisor>                                                              <advisor-name>WebsphereProxyDemoHttpAdvisor</advisor-name>             ?                                                                       <advisor-class>                                                        com.ibm.ws.proxy.demo.customadvisor.http.HttpProxyCustomAdvisor        </advisor-class>                                                       <description>Demo Websphere Proxy Http Advisor                         Implementation</description>                                           <display-name>Demo Websphere Proxy Http Advisor</display-name>         </advisor>                                                             </advisor-context> 

  3. Compile the custom advisor code. After we have created the Java source code for the custom advisor, you must compile it using the AbstractCustomAdvisor code included with WebSphere Application Server. To access the abstract custom advisor classes in the com.ibm.wsspi.advisor package, add the proxy.jar file to the Java class path. The proxy.jar file is located in the ${WAS_INSTALL_ROOT|/plugins directory.

  4. 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>

  5. 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

  6. Configure the deployed custom advisor. See Administer custom advisors for the proxy server for additional details.


Related concepts

Custom advisor policies


Related tasks

  • Administer custom advisors for the proxy server

    Custom advisors collection

    Custom advisor policy settings

  • Business-level application configuration scripts
  • Set up business-level applications