Creating a Handler Class
A query handler is a Java class that retrieves items from the Content Engine using search criteria entered into a Data Source query form. A query handler must:
-
Extend com.escenic.framework.datasource.fetcher.impl.AbstractFetcher
-
Override its
fetch()
method
The following example shows a skeleton handler class definition:
package com.mycompany.datasource.query.handler; import com.escenic.framework.datasource.fetcher.impl.AbstractFetcher; import com.escenic.framework.datasource.ContextInfo; import com.escenic.framework.datasource.model.SourceDefinition; import com.escenic.framework.datasource.model.SourceSettings; import java.util.List; public class MyQueryHandler extends AbstractFetcher { @Override public List<ResultItem> fetch(final SourceDefinition pSourceDefinition, final SourceSettings pSettings, final ContextInfo pContextInfo) { // your code here } }
The fetch()
method's first parameter is a
com.escenic.framework.datasource.model.SourceDefinition
object. This object is a bean containing all the values set by the user
in the query tab. It has a set of
get
Xxx()
methods for recovering various predefined standard query parameters
(getSection()
and
getContentTypes()
, for example), plus a
getFields()
method that returns a map containing all
other custom parameters that you may have defined for your query form.
The query form (and therefore the contents of the
SourceDefinition
bean) are determined by the query
type definition (see
Creating a Query Type Definition).
Once you have a created a query handler class, you need to:
-
Create
.properties
files to register the handler class in the system -
Package the handler in a JAR file
-
Deploy the JAR file in your publication