Skip to main content
Jump to: navigation, search

SMILA/Documentation/HowTo/How to implement a crawler

< SMILA‎ | Documentation‎ | HowTo
Revision as of 09:31, 6 October 2008 by (Talk | contribs) (Typo)

This page explains how to implement a crawler and add its functionality to SMILA.

Java implementations

  • Launch Eclipse, create a new project using the Plug-in Project wizard, and select "Equinox" as the OSGi framework.
  • Name the project using the prefix org.eclipse.smila.connectivity.framework.crawler.
  • Edit the manifest file and add the following packages to the Import-Package section.
    • org.eclipse.smila.connectivity.framework
    • org.eclipse.smila.connectivity.framework.utils
    • org.eclipse.smila.datamodel.record
    • com.sun.xml.bind.v2;version="2.1.6"
    • javax.xml.bind;version="2.1.0"
    • javax.xml.bind.annotation;version="2.1.0"
    • javax.xml.bind.annotation.adapters;version="2.1.0"
    • org.apache.commons.logging;version="1.1.1"
  • Edit the manifest file and add the following to the Require-Bundle section: (Please note that it is a MUST to import this package using Require-Bundle instead of Import-Package.)
    • org.eclipse.smila.connectivity.framework.indexorder
  • The manifest should now look like this:
Require-Bundle: org.eclipse.smila.connectivity.framework.indexorder
Import-Package: com.sun.xml.bind.v2;version="2.1.6",
  • Compile schema into JAXB classes (see main section on the top).
  • Add the code/gen folder to the source folders ( : source.. = code/src/,code/gen/):
    • Right-click your bundle and click New > Source Folder.
    • Enter "code/gen" as the folder name.
  • Copy the content of the folder schema-compile-runtime\schema-pattern\ into your crawler bundle folder.
  • Compile schema into JAXB classes by running schema.cmd (The schema-compile-runtime folder should be located on the projects level - it will be used for compilation.)
    • Launch the file schema.cmd from a cmd console to see the result or error messages.
  • Implement XSD schema for the crawler configuration using the template schemas\TemplateIndexOrder.xsd.
    • Index Order Configaration based on XSD schema redefinition of abstract "RootIndexOrderConfiguration" schema
    • Developer should define redefinition of "Process" and "Attribute" nodes for crawler specific information.
<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="">
  <xs:redefine schemaLocation="RootIndexOrderConfiguration.xsd">
    <xs:complexType name="Process">
        <xs:documentation>Process Specification</xs:documentation>
        <xs:extension base="Process">
	  <\!--define process here -->
    <xs:complexType name="Attribute">
        <xs:extension base="Attribute">
	  <\!--define attribute here -->
  • Add schema location reference in plug-in implementation (return "schemas/TemplateIndexOrder.xsd")
    • create a new class (IndexOrderSchemaImpl) which implements interface IndexOrderSchema
    • use method String getSchemaLocation() to return "schemas/TemplateIndexOrder.xsd"
package org.eclipse.smila.connectivity.framework.crawler.filesystem;
import org.eclipse.smila.connectivity.framework.indexorder.IndexOrderSchema;
 * The Class IndexOrderSchemaImpl.
public class IndexOrderSchemaImpl implements IndexOrderSchema {
   * {@inheritDoc}
   * @see org.eclipse.smila.connectivity.framework.indexorder.IndexOrderSchema#getSchemaLocation()
  public String getSchemaLocation() {
    return "schemas/filesystemIndexOrder.xsd";
  • Implement extension for "org.eclipse.smila.connectivity.framework.indexorder.schema" with the bundle name used as ID and NAME
    • in plugin.xml check schema class and change if it is necessary
  • Note: If you rename the schema file name, make sure to update the following locations:
    • plug-in implementation
    • TemplateIndexOrder.jxb (it also should be also renamed with the same name as schema)
    • schema.cmd

OSGi and Declarative Service requirements

  • It is not required to implement a BundleActivator (this may change if SCA Nodes are used, then it may be required to register the Crawler)
  • create a top level folder OSGI-INF
  • create a Component Description file in OSGI-INF. You can name the file as you like, but it is good practice to name it like the Crawler. Therein you have to provide a unique component name, it should be the same as the Crawler's name followed by DS (for DeclarativeService). Then you have to provide your implementation class and the service interface class, which is always org.eclipse.smila.connectivity.framework.Crawler.


<?xml version="1.0" encoding="UTF-8"?>
<component name="FileSystemCrawlerDS" immediate="true">
    <implementation class="org.eclipse.smila.connectivity.framework.crawler.filesystem.FileSystemCrawler" />
         <provide interface="org.eclipse.smila.connectivity.framework.Crawler"/>
    <property name="org.eclipse.smila.connectivity.framework.crawler.type" value="filesystemcrawler"/>
  • Add a Service-Component entry to your manifest file, e.g.
Service-Component: OSGI-INF/filesystemcrawler.xml
  • Open and change binary build: select folders OSGI-INF, schemas and file plugin.xml
source.. = code/src/,\
output.. = code/bin/
bin.includes = META-INF/,\

SCA requirements

Most requirements for SCA are already handled by the base class org.eclipse.smila.connectivity.framework.AbstractCrawler. You should annotate your implementation with @AllowsPassByReference, to allow SCA to pass service parameters by reference when service interactions are within the same adress space. Here is an example:

public class FileSystemCrawler extends AbstractCrawler {
// implementation goes here ...

For SCA, make sure to set attribute "immediate" of tag "component" to false and attribute "servicefactory" of tag "service " to true in your xml-file. This is required to let SCA dynamically create ServiceReferences. Finally you have to provide a value for the property org.eclipse.smila.connectivity.framework.crawler.type. This is used by SCA to find the correct OSGi Declarative Service during runtime. The value has to be unique (it is used in SCA contribution files) and should be named like the Crawler. Here is an example:


<?xml version="1.0" encoding="UTF-8"?>
<component name="FileSystemCrawlerDS" immediate="false">
    <implementation class="org.eclipse.smila.connectivity.framework.crawler.filesystem.FileSystemCrawler" />
    <service servicefactory="true">
         <provide interface="org.eclipse.smila.connectivity.framework.Crawler"/>
    <property name="org.eclipse.smila.connectivity.framework.crawler.type" value="filesystemcrawler"/>

Develop your crawler

  • Implement your crawler in a new class extending org.eclipse.smila.connectivity.framework.AbstractCrawler.
  • Create a JUnit test bundle for this crawler e.g. org.eclipse.smila.connectivity.framework.crawler.filesystem.test.
  • Integrate your new crawler bundle into the build process: Refer to the page How to integrate new bundle into build process for further instructions.
  • Integrate your test bundle into the build process: Refer to the page How to integrate test bundle into build process) for further instructions.
  • Start your crawler with launch
    • by SMILA.exe
    • Insert org.eclipse.smila.connectivity.framework.crawler.filesystem@4:start, \ to the config.ini file.
    • by SMILA.launch
    • Open the Run dialog, switch to the configuration page of your bundle, set the parameter Default Start level to 4, and the parameter Default Auto-Start to true.
  • Enjoy

Back to the top