commit e4ae1fe3ce44896cd828d2e837fea09023a52063
parent bfc2f6cf953dfa980579b15c1199effdac866254
Author: Dan Callaghan <djc@djc.id.au>
Date: Sun, 9 May 2010 20:24:03 +1000
use new ModelOperations interface for better testability
Diffstat:
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/main/java/au/com/miskinhill/rdftemplate/view/RDFTemplateView.java b/src/main/java/au/com/miskinhill/rdftemplate/view/RDFTemplateView.java
@@ -8,8 +8,8 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.deadlit.rdf.util.SdbTemplate;
-import org.deadlit.rdf.util.SdbTemplate.ModelExecutionCallbackWithoutResult;
+import org.deadlit.rdf.util.ModelOperations;
+import org.deadlit.rdf.util.ModelOperations.ModelExecutionCallbackWithoutResult;
import org.springframework.web.servlet.view.AbstractTemplateView;
import au.com.miskinhill.rdftemplate.TemplateInterpolator;
@@ -24,14 +24,14 @@ public class RDFTemplateView extends AbstractTemplateView {
private TemplateInterpolator templateInterpolator;
private SelectorFactory selectorFactory;
- private SdbTemplate sdbTemplate;
+ private ModelOperations modelOperations;
public void setSelectorFactory(SelectorFactory selectorFactory) {
this.selectorFactory = selectorFactory;
}
- public void setSdbTemplate(SdbTemplate sdbTemplate) {
- this.sdbTemplate = sdbTemplate;
+ public void setModelOperations(ModelOperations modelOperations) {
+ this.modelOperations = modelOperations;
}
@Override
@@ -40,7 +40,7 @@ public class RDFTemplateView extends AbstractTemplateView {
if (selectorFactory == null) {
throw new IllegalArgumentException("Property 'selectorFactory' is required");
}
- if (sdbTemplate == null) {
+ if (modelOperations == null) {
throw new IllegalArgumentException("Property 'sdbTemplate' is required");
}
this.templateInterpolator = new TemplateInterpolator(selectorFactory);
@@ -52,7 +52,7 @@ public class RDFTemplateView extends AbstractTemplateView {
throws Exception {
final InputStream inputStream = getApplicationContext().getResource(getUrl()).getInputStream();
try {
- sdbTemplate.withModel(new ModelExecutionCallbackWithoutResult() {
+ modelOperations.withModel(new ModelExecutionCallbackWithoutResult() {
@Override
protected void executeWithoutResult(Model rdfModel) {
Resource node = rdfModel.getResource((String) model.get(NODE_URI_KEY));
diff --git a/src/main/java/au/com/miskinhill/rdftemplate/view/RDFTemplateViewResolver.java b/src/main/java/au/com/miskinhill/rdftemplate/view/RDFTemplateViewResolver.java
@@ -1,6 +1,6 @@
package au.com.miskinhill.rdftemplate.view;
-import org.deadlit.rdf.util.SdbTemplate;
+import org.deadlit.rdf.util.ModelOperations;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.web.servlet.view.AbstractTemplateView;
import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
@@ -10,19 +10,22 @@ import au.com.miskinhill.rdftemplate.selector.SelectorFactory;
public class RDFTemplateViewResolver extends AbstractTemplateViewResolver implements InitializingBean {
private SelectorFactory selectorFactory;
- private SdbTemplate sdbTemplate;
+ private ModelOperations modelOperations;
public RDFTemplateViewResolver() {
super();
setViewClass(requiredViewClass());
+ setExposeRequestAttributes(false);
+ setExposeSessionAttributes(false);
+ setExposeSpringMacroHelpers(false);
}
public void setSelectorFactory(SelectorFactory selectorFactory) {
this.selectorFactory = selectorFactory;
}
-
- public void setSdbTemplate(SdbTemplate sdbTemplate) {
- this.sdbTemplate = sdbTemplate;
+
+ public void setModelOperations(ModelOperations modelOperations) {
+ this.modelOperations = modelOperations;
}
@Override
@@ -30,8 +33,8 @@ public class RDFTemplateViewResolver extends AbstractTemplateViewResolver implem
if (selectorFactory == null) {
throw new IllegalArgumentException("Property 'selectorFactory' is required");
}
- if (sdbTemplate == null) {
- throw new IllegalArgumentException("Property 'sdbTemplate' is required");
+ if (modelOperations == null) {
+ throw new IllegalArgumentException("Property 'modelOperations' is required");
}
}
@@ -44,7 +47,7 @@ public class RDFTemplateViewResolver extends AbstractTemplateViewResolver implem
protected RDFTemplateView buildView(String viewName) throws Exception {
RDFTemplateView view = (RDFTemplateView) super.buildView(viewName);
view.setSelectorFactory(selectorFactory);
- view.setSdbTemplate(sdbTemplate);
+ view.setModelOperations(modelOperations);
return view;
}