The Assembler logs information to the Platform Services Log Server component.

In order to implement this logging feature in an application, you must instantiate a LogServerAdapter and pass it in to the AssemblerFactory, along with any other Event Listeners. To log front-end information, you must also register a ContentItemAugmentAdapter. The LogServerAdapter and ContentItemAugmentAdapter require a RequestEventInitializer and a MdexQueryInfoInitializer to log request event information to the Dgraph request log, so these should also be configured. Registering a MdexQueryInfoInitializer lets you establish the relationship between the Assembler request and its corresponding MDEX Engine queries in the Dgraph request logs. This helps you to identify and troubleshoot problems.

The RequestEventIntiailizer is used to initialize the RequestEvent thread local variable. Similarly, MdexQueryInfoInitializer is used to initialize the MdexQueryInfo thread local variable in the assembly process. If the MdexQueryInfoInitializer is not included in the assembler configuration, then the additional request information will not be included in the Dgraph request log.

In the following example of an assembler-context.xml file in a Spring implementation, note that the RequestEventIntiailizer is configured before the LogServerAdapter and ContentItemAugmentAdapter so that the request event is logged. The MdexQueryInfoInitializer is also configured so that query information such as the request id, and the session id is added to the Dgraph request log.

                  <bean class="com.endeca.infront.assembler.event.request.RequestEventInitializer">
    <property name="sessionIdProvider" ref="springUtility"/>
    <property name="requestIdProvider" ref="springUtility"/>
</bean>
<bean class="com.endeca.infront.navigation.event.MdexQueryInfoInitializer">
</bean>
<bean class="com.endeca.infront.assembler.event.request.ContentItemAugmentAdapter">
</bean>
<!-- Remove the following lines to disable logging to an Oracle Endeca Log Server -->
<bean class="com.endeca.infront.navigation.event.LogServerAdapter">
    <property name="logServerHost" value="${logserver.host}"/>
    <property name="logServerPort" value="${logserver.port}"/>
    <property name="isSslEnabled" value="${logserver.sslEnabled}"/>
</bean>

The RequestEventInitializer specifies a SessionIdProvider and a RequestIdProvider so you can associate Assembler requests with MDEX query entries in the Dgraph request log. You specify the following properties:

The referenced bean is configured as follows:

<bean id="springUtility" class="com.endeca.infront.web.spring.SpringUtility" scope="singleton"/>

You can create custom cartridge handlers to collect and act on any information that is important to your application.

Request event adapter classes perform some action based on information included with a request event.

A request event adapter class implements the handleAssemblerRequest() method in the abstract RequestEventListener class. This method is invoked at the end of the Assembler's assemble() method.

The following is an example of a simple request event adapter:

/**
 * Add log information to root content item
 */
public class SampleRequestEventAdapter extends RequestEventListener {

    /**
     * Constructor
     * @param sessionIdProvider provides an ID for the current user session
     */
    public SampleRequestEventAdapter() {
        super();
    }

    /**
     * Prints the request event's session id, request id, and search term (if present) to the console
     * @param assemblerRequestEvent the event containing all of the
     * information about the Assembler request
     * @param rootContentItem the Assembler output
     */
    public void handleAssemblerRequestEvent(RequestEvent event, ContentItem rootContentItem) {
        NavigationEventWrapper navigationEvent = new NavigationEventWrapper(assemblerRequestEvent);
        // Print Session ID - Note that the session Id has already been determined and set in the event object
        System.out.println("The current session is: "+event.getSessionId());
        // Print Request ID - Note that the request Id has already been determined and set in the event object
        System.out.println("The request ID is: "+event.getRequestId());
        // Print Search Term
        if (navigationEvent.getSearchTerms() != null && !navigationEvent.getSearchTerms().trim().isEmpty()) {
            System.out.println("The current search terms are: "+navigationEvent.getSearchTerms());
        } else {
            System.out.println("There were no search terms in the current request");
        }
    }
}

To use a request event adapter, you must register it with your AssemblerFactory.

You can disable request event adapters by removing them from the AssemblerFactory configuration.

In the reference application, the AssemblerFactory interface is implemented as SpringAssemblerFactory, and the AssemblerEventListener objects are specified as constructor arguments in the Assembler context file:

<!--
  ########################################################################
  # ASSEMBLER FACTORY
  #
  # Required.
  #
-->
<bean id="assemblerFactory" class="com.endeca.infront.assembler.spring.SpringAssemblerFactory"
      scope="singleton">
    <constructor-arg>
        <bean class="com.endeca.infront.assembler.AssemblerSettings">
            <property name="previewEnabled" value="${preview.enabled}" />
            <property name="previewModuleUrl" value="http://${workbench.host}:${workbench.port}/ifcr" />
        </bean>
    </constructor-arg>
    <constructor-arg>
        <list>
            <bean class="com.endeca.infront.logger.SLF4JAssemblerEventLogger" />
            <bean class="com.endeca.infront.assembler.event.request.RequestEventInitializer">
                    <property name="sessionIdProvider" ref="springUtility"/>
                    <property name="requestIdProvider" ref="springUtility"/>
             </bean>
             <bean class="com.endeca.infront.navigation.event.MdexQueryInfoInitializer">
             </bean>
             <bean class="com.endeca.infront.assembler.event.request.ContentItemAugmentAdapter">
             </bean>
             <!-- Remove the following lines to disable logging to an Oracle Endeca Log Server -->
             <bean class="com.endeca.infront.navigation.event.LogServerAdapter">
                 <property name="logServerHost" value="${logserver.host}"/>
                 <property name="logServerPort" value="${logserver.port}"/>
                 <property name="isSslEnabled" value="${logserver.sslEnabled}"/>
             </bean>
        </list>
    </constructor-arg>
</bean>


Copyright © Legal Notices