Skip to content

Deploying an Extension

spmallette edited this page Jan 21, 2012 · 12 revisions

Deploying an extension is not difficult. To demonstrate the process involved, we will use the Sample Kibbles.

After building Sample Kibbles with Maven (mvn clean install), copy the sample-kibbles-*.jar file (where * refers to the version of kibbles you are building) to the REXSTER_HOME/ext directory.

The next step is to configure the extensions within rexster.xml. For purposes of this example, we will expose the sample extensions on the tinkergraph sample graph. The namespace for the samples is tp-sample. Therefore rexster.xml should be modified in the following manner:

<graph>
  <graph-name>tinkergraph</graph-name>
  <graph-type>tinkergraph</graph-type>
  <graph-file>data/graph-example-1.xml</graph-file>
  <extensions>
    <allows>
      <allow>tp:gremlin</allow>
      <allow>tp-sample:*</allow>
    </allows>
  </extensions>
</graph>

The addition of tp-sample:* means that all extensions within the tp-sample namespace are exposed on the tinkergraph sample graph.

We now need to consider the configuration of individual extensions. In this case, the MapConfigurationExtension requires some basic configuration in rexster.xml for it to work properly. Modify the configuration so that the <graph> element looks like this:

<graph>
  <graph-name>tinkergraph</graph-name>
  <graph-type>tinkergraph</graph-type>
  <graph-file>data/graph-example-1.xml</graph-file>
  <extensions>
    <allows>
      <allow>tp:gremlin</allow>
      <allow>tp-sample:*</allow>
    </allows>
    <extension>
      <namespace>tp-sample</namespace>
      <name>map-config</name>
      <configuration>
        <some-key>some-value</some-key>
        <other-key>other-value</other-key>
      </configuration>
    </extension>
  </extensions>
</graph>

At this point, Rexster is ready to start serving the Sample Kibbles. Start Rexster and access http://localhost:8182/graphs/tinkergraph being sure to set the Accept header with the application/vnd.rexster-v1+json Rexster Mime Type:

{
  "version":"*.*",
  "name":"tinkergraph",
  "graph":"tinkergraph[vertices:6 edges:6]",
  "read_only":false,
  "type":"com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraph",
  "query_time":2.57055,
  "up_time":"0[d]:00[h]:01[m]:30[s]",
  "extensions":[
    {"title":"evaluate an ad-hoc Gremlin script for a graph.","href":"tp\/gremlin"},
    {"title":"returns the results of the toString() method on the graph.","href":"tp-sample\/simple-root"},
    {"title":"returns the results of the toString() method on the graph.","href":"tp-sample\/simple-path\/some-work"},
    {"title":"returns the results of the toString() method on the edge.","href":"tp-sample\/simple-path\/other-work"},
    {"title":"a simple ping extension.","href":"tp-sample\/ping"},
    {"title":"returns the configuration as JSON.","href":"tp-sample\/map-config"}
  ]
}

As you can see, the list of extensions configured and available are listed. Note that only those extensions that are available for the GRAPH extension point are displayed here. As some extensions only work from the VERTEX or EDGE extension points they will not be visible here — however they are displayed on their respective endpoints such as http://localhost:8182/graphs/tinkergraph/vertices/1.

Service Loader

Rexster uses ServiceLoader to expose available extensions. When developing an extension to Rexster, it is necessary to include a com.tinkerpop.rexster.extension.RexsterExtension file in META-INF/services of the packaged extension to include the extensions to be exposed. In the case of the Sample Kibbles, the file lists each of the extensions to be made available through Rexster:

com.tinkerpop.rexster.kibbles.sample.MapConfigurationExtension
com.tinkerpop.rexster.kibbles.sample.PingExtension
com.tinkerpop.rexster.kibbles.sample.PingAddOnExtension
com.tinkerpop.rexster.kibbles.sample.ProducesXmlExtension
com.tinkerpop.rexster.kibbles.sample.SimplePathExtension
com.tinkerpop.rexster.kibbles.sample.SimpleRootExtension
Clone this wiki locally