Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Indexer core fully loaded in OSGi framework
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Feb 4, 2014
1 parent dbca165 commit 0b650db
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 19 deletions.
4 changes: 2 additions & 2 deletions fcrepo-jms-indexer-core/pom.xml
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>fcrepo-jms-indexer-core</artifactId>
<name>${project.artifactId}</name>
<name>Fedora JMS Indexer Core Module</name>
<description>Fedora JMS Indexer Core</description>
<packaging>bundle</packaging>

Expand Down Expand Up @@ -48,7 +48,7 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-osgi</artifactId>
<type>bundle</type>
<version>4.3.1</version>
<version>4.2.3</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-jms-indexer-elasticsearch/pom.xml
Expand Up @@ -6,7 +6,7 @@
<version>4.0.0-alpha-4-SNAPSHOT</version>
</parent>
<artifactId>fcrepo-jms-indexer-elasticsearch</artifactId>
<name>${project.artifactId}</name>
<name>ElasticSearch Indexer Module</name>
<description>Fedora JMS-driven indexer for Elasticsearch</description>

<packaging>bundle</packaging>
Expand Down
122 changes: 118 additions & 4 deletions fcrepo-jms-indexer-runtime/pom.xml
Expand Up @@ -15,10 +15,6 @@
</properties>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
Expand All @@ -28,14 +24,132 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-jms-indexer-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-osgi</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-cache</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.jena</groupId>
<artifactId>jena-iri</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>4.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-osgi</artifactId>
<version>4.2.3</version>
<type>bundle</type>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-cache</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-osgi</artifactId>
<version>4.2.3</version>
<type>bundle</type>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-cache</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-cache</artifactId>
<version>4.2.3</version>
<type>bundle</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.clerezza.ext</groupId>
<artifactId>org.apache.jena</artifactId>
<scope>provided</scope>
<version>0.7-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.clerezza.ext</groupId>
<artifactId>javax.mail</artifactId>
<scope>provided</scope>
<version>0.5-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.jms</artifactId>
<scope>provided</scope>
<version>10.0-b28</version>
</dependency>
</dependencies>

<repositories>
<repository>
<id>Apache</id>
<url>https://repository.apache.org/content/repositories/public</url>
</repository>
</repositories>

<build>
<plugins>
Expand Down
Expand Up @@ -48,10 +48,10 @@ public class Main {

private static final int SHUTDOWN_TIMEOUT = 20000;

private static final String INDEXER_HOME_PROP_NAME =
public static final String INDEXER_HOME_PROP_NAME =
"org.fcrepo.indexer.home";

private static final String AUTODEPLOY_DIR_PROP_NAME =
public static final String AUTODEPLOY_DIR_PROP_NAME =
"felix.auto.deploy.dir";

// take the first available
Expand All @@ -69,7 +69,10 @@ public Main() {
framework = frameworkFactory.newFramework(getConfig());
}

private static Map<String, String> getConfig() {
/**
* @return Parsed conf from System properties
*/
public static Map<String, String> getConfig() {
return of(FRAMEWORK_STORAGE, getProperty(INDEXER_HOME_PROP_NAME,
"indexer"), AUTO_DEPLOY_DIR_PROPERY, getProperty(
AUTODEPLOY_DIR_PROP_NAME, "bundle"),
Expand Down Expand Up @@ -128,6 +131,13 @@ public void stop() throws Throwable {

}

/**
* @return the {@link Framework} in use
*/
public Framework framework() {
return framework;
}

/**
* @param args
*/
Expand All @@ -137,7 +147,7 @@ public static void main(final String[] args) {

try {
m.init();
process(getConfig(), m.framework.getBundleContext());
process(getConfig(), m.framework().getBundleContext());
m.start();
System.in.read();
m.stop();
Expand Down
Expand Up @@ -16,20 +16,48 @@

package org.fcrepo.indexer.runtime;

import static java.lang.System.setProperty;
import static java.util.Collections.list;
import static org.apache.felix.main.AutoProcessor.process;
import static org.fcrepo.indexer.runtime.Main.AUTODEPLOY_DIR_PROP_NAME;
import static org.fcrepo.indexer.runtime.Main.INDEXER_HOME_PROP_NAME;
import static org.fcrepo.indexer.runtime.Main.getConfig;
import static org.junit.Assert.fail;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;
import java.util.Dictionary;

import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.slf4j.Logger;

public class SanityTest {

private static final Logger LOGGER = getLogger(SanityTest.class);

@Before
public void setDirectories() {
setProperty(AUTODEPLOY_DIR_PROP_NAME, "target/bundle");
setProperty(INDEXER_HOME_PROP_NAME, "target/indexer");
}

@Test
public void runOnce() throws IOException, BundleException,
InterruptedException {
public void runOnce() throws BundleException {
final Main m = new Main();
m.init();
process(getConfig(), m.framework().getBundleContext());
m.start();
for (final Bundle b : m.framework().getBundleContext().getBundles()) {
LOGGER.debug("Found bundle: {} at: {} in state: {}", b
.getSymbolicName(), b.getLocation(), b.getState());
final Dictionary<String, String> d = b.getHeaders();

for (final String key : list(d.keys())) {
LOGGER.debug("with header: {} = {}", key, d.get(key));
}
}
try {
m.stop();
} catch (final Throwable e) {
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-jms-indexer-solr/pom.xml
Expand Up @@ -7,7 +7,7 @@
<version>4.0.0-alpha-4-SNAPSHOT</version>
</parent>
<artifactId>fcrepo-jms-indexer-solr</artifactId>
<name>Solr indexer</name>
<name>Solr Indexer Module</name>
<packaging>bundle</packaging>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-jms-indexer-sparql/pom.xml
Expand Up @@ -6,7 +6,7 @@
<version>4.0.0-alpha-4-SNAPSHOT</version>
</parent>
<artifactId>fcrepo-jms-indexer-sparql</artifactId>
<name>SPARQL indexer</name>
<name>SPARQL Indexer Module</name>
<description>Indexes into services that are equipped with a SPARQL Update interface</description>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-jms-indexer-webapp/pom.xml
Expand Up @@ -7,7 +7,7 @@
</parent>

<artifactId>fcrepo-jms-indexer-webapp</artifactId>
<name>${project.artifactId}</name>
<name>Indexer Deployable Web Application</name>
<description>Fedora JMS Indexer Web Application</description>
<packaging>war</packaging>

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -9,8 +9,8 @@
</parent>

<artifactId>fcrepo-jms-indexer-pluggable</artifactId>
<name>${project.artifactId}</name>
<description>Fedora JMS Indexer</description>
<name>Fedora JMS-driven Indexer</name>
<description>Indexer application accepting JMS messages from a Fedora repository</description>
<packaging>pom</packaging>

<properties>
Expand Down

0 comments on commit 0b650db

Please sign in to comment.