Skip to content

Commit

Permalink
work around #42 problem -- i've got a talk to work on for the next fe…
Browse files Browse the repository at this point in the history
…w days and i want to keep it working rather than screw around with maven and spring... I added a unit test but it doesn't do any good because the problem has something to do with the super JAR packaging
  • Loading branch information
Paul Houle authored and Paul Houle committed Sep 26, 2013
1 parent 49efeda commit 9b6ccb8
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bakemono/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand Down
1 change: 1 addition & 0 deletions bakemono/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class Beans {

@Bean
public static Sieve3Configuration sieve3Default() {
public Sieve3Configuration sieve3Default() {
return new Sieve3Configuration(
new Rule("a", matchesA()),
new Rule("label", matchesLabel()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public void setup(Context context) throws IOException,
mos=new RealMultipleOutputs(context);
super.setup(context);
other=new PrimaryKeyValueAcceptor(context);
sieve3conf=applicationContext.getBean(Sieve3Configuration.SIEVE3DEFAULT,Sieve3Configuration.class);
sieve3conf = Sieve3Tool.createDefaultConfiguration();


for(Rule r:sieve3conf.getRules())
outputs.put(r.getOutputName(), new NamedKeyValueAcceptor(mos,r.getOutputName()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.ontology2.bakemono.Main;
import com.ontology2.bakemono.Main.IncorrectUsageException;
import com.ontology2.bakemono.abstractions.Spring;
import com.ontology2.bakemono.configuration.Beans;
import com.ontology2.bakemono.jena.SPOTripleOutputFormat;
import com.ontology2.bakemono.mapred.RealMultipleOutputs;
import com.ontology2.bakemono.mapred.RealMultipleOutputsMainOutputWrapper;
Expand Down Expand Up @@ -58,7 +59,7 @@ public void setConf(Configuration arg0) {

@Override
public int run(String[] arg0) throws Exception {
ApplicationContext context=Spring.getApplicationContext(conf);
// ApplicationContext context=Spring.getApplicationContext(conf);
try {
PeekingIterator<String> a=Iterators.peekingIterator(Iterators.forArray(arg0));
if (!a.hasNext())
Expand Down Expand Up @@ -87,7 +88,7 @@ public int run(String[] arg0) throws Exception {
FileOutputFormat.setCompressOutput(job, true);
FileOutputFormat.setOutputCompressorClass(job, GzipCodec.class);

Sieve3Configuration sieve3Config = context.getBean(Sieve3Configuration.SIEVE3DEFAULT,Sieve3Configuration.class);
Sieve3Configuration sieve3Config = createDefaultConfiguration();
for(Rule r:sieve3Config.getRules())
RealMultipleOutputs.addNamedOutput(job,
r.getOutputName(),
Expand All @@ -103,6 +104,11 @@ public int run(String[] arg0) throws Exception {
return 2;
}
}

static Sieve3Configuration createDefaultConfiguration() {
// return context.getBean(Sieve3Configuration.SIEVE3DEFAULT,Sieve3Configuration.class);
return new Beans().sieve3Default();
}

private static void usage() throws IncorrectUsageException {
throw new Main.IncorrectUsageException("incorrect arguments");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ontology2.bakemono.abstractions;

import static org.junit.Assert.*;

import org.junit.Test;
import org.springframework.context.ApplicationContext;

import com.ontology2.bakemono.sieve3.Sieve3Configuration;

public class SpringTest {

@Test
public void canGetSieve3Configuration() {
// right now we don't actually use the Hadoop Config, so null is OK
ApplicationContext c=Spring.getApplicationContext(null);
Sieve3Configuration sieve3Config = c.getBean(Sieve3Configuration.SIEVE3DEFAULT,Sieve3Configuration.class);
assertEquals(sieve3Config.getRules().size(),11);
}

}

0 comments on commit 9b6ccb8

Please sign in to comment.