...
Camel makes use of "components" to integrate various services using a terse, domain specific language (DSL) that can be expressed in JAVA, XML, Scala or Groovy. There exists one such component designed to work specifically with a Fedora4 repository. This makes it possible to model Solr indexing in only a few lines of code like so:
Code Block |
---|
language | java |
---|
title | Camel Route using the JAVA DSL |
---|
linenumbers | true |
---|
|
XPathBuilder xpath = new XPathBuilder("/rdf:RDF/rdf:Description/rdf:type[@rdf:resource='http://fedora.info/definitions/v4/rest-api#indexableindexing#indexable']")
xpath.namespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
from("activemq:topic:fedora")
.to("fcrepo:localhost:8080/fedora/rest")
.filter(xpath)
.to("fcrepo:localhost:8080/fedora/rest?accept=application/json&transform=default")
.to("http4:localhost:8080/solr/core/update"); |
...
Code Block |
---|
language | xml |
---|
title | Camel Route using the Spring DSL |
---|
linenumbers | true |
---|
|
<route>
<from uri="activemq:topic:fedora"/>
<to uri="fcrepo:localhost:8080/fedora/rest"/>
<filter>
<xpath>/rdf:RDF/rdf:Description/rdf:type[@rdf:resource='http://fedora.info/definitions/v4/rest-api#indexableindexing#indexable']</xpath>
<to uri="fcrepo:localhost:8080/fedora/rest?accept=application/json&transform=default"/>
<to uri="http4:localhost:8080/solr/core/update"/>
</filter>
</route> |
...
Code Block |
---|
language | scala |
---|
title | Camel Route using the Scala DSL |
---|
linenumbers | true |
---|
|
val xpath = new XPathBuilder("/rdf:RDF/rdf:Description/rdf:type[@rdf:resource='http://fedora.info/definitions/v4/rest-api#indexableindexing#indexable']")
xpath.namespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
"activemq:topic:fedora" ==> {
to("fcrepo:localhost:8080/fedora/rest")
filter(xpath) {
to("fcrepo:localhost:8080/fedora/rest?accept=application/json&transform=default")
to("http4:localhost:8080/solr/core/update")
}
} |
...