You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2012/05/24 20:04:16 UTC
svn commit: r1342360 - in /incubator/clerezza/trunk/parent: ./
platform.content.fsadaptor/src/main/resources/OSGI-INF/
platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/
Author: reto
Date: Thu May 24 18:04:16 2012
New Revision: 1342360
URL: http://svn.apache.org/viewvc?rev=1342360&view=rev
Log:
CLEREZZA-705: listeing to PathNode Services providing additional directory stuctures
Modified:
incubator/clerezza/trunk/parent/ (props changed)
incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/resources/OSGI-INF/serviceComponents.xml
incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/BundleFsLoader.scala
incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala
Propchange: incubator/clerezza/trunk/parent/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu May 24 18:04:16 2012
@@ -2,5 +2,6 @@
target
.pom.xml.swp
.idea
-
*.iml
+.project
+.settings
Modified: incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/resources/OSGI-INF/serviceComponents.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/resources/OSGI-INF/serviceComponents.xml?rev=1342360&r1=1342359&r2=1342360&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/resources/OSGI-INF/serviceComponents.xml (original)
+++ incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/resources/OSGI-INF/serviceComponents.xml Thu May 24 18:04:16 2012
@@ -32,6 +32,7 @@
cardinality="1..1" policy="static" bind="bindContentGraphProvider" unbind="unbindContentGraphProvider"/>
<reference name="startLevel" interface="org.osgi.service.startlevel.StartLevel"
cardinality="1..1" policy="static" bind="bindStartLevel" unbind="unbindStartLevel"/>
-
+ <reference name="pathNode" interface="org.wymiwyg.commons.util.dirbrowser.PathNode"
+ cardinality="0..n" policy="dynamic" bind="bindPathNode" unbind="unbindPathNode"/>
</scr:component>
</components>
Modified: incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/BundleFsLoader.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/BundleFsLoader.scala?rev=1342360&r1=1342359&r2=1342360&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/BundleFsLoader.scala (original)
+++ incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/BundleFsLoader.scala Thu May 24 18:04:16 2012
@@ -42,6 +42,8 @@ import org.osgi.framework.BundleListener
import org.osgi.service.component.ComponentContext
import org.osgi.service.startlevel.StartLevel
import org.slf4j.LoggerFactory
+import org.wymiwyg.commons.util.dirbrowser.MultiPathNode
+import org.wymiwyg.commons.util.dirbrowser.PathNode
import scala.util._
/**
@@ -60,8 +62,11 @@ class BundleFsLoader extends BundleListe
private var tcManager: TcManager = null
private var cgProvider: ContentGraphProvider = null
private var startLevel: StartLevel = null
+ private var pathNodes: List[PathNode] = Nil
private var bundleList = List[Bundle]()
private var currentCacheMGraph: MGraph = null
+
+ private var frequentUpdateDirectory: Option[PathNode] = None
private val virtualMGraph = new AbstractMGraph() {
override def performFilter(s: NonLiteral, p: UriRef,
@@ -178,7 +183,27 @@ class BundleFsLoader extends BundleListe
override def getMGraph(name: UriRef) = {
if (name.equals(RESOURCE_MGRAPH_URI)) {
- virtualMGraph
+ frequentUpdateDirectory match {
+ case Some(p) => val directoryOverlay =
+ new DirectoryOverlay(p, virtualMGraph)
+ new AbstractMGraph() {
+ override def performFilter(s: NonLiteral, p: UriRef,
+ o: Resource): java.util.Iterator[Triple] = {
+ val baseIter = directoryOverlay.filter(s,p,o)
+ new java.util.Iterator[Triple]() {
+ override def next = {
+ baseIter.next
+ }
+ override def hasNext = baseIter.hasNext
+ override def remove = throw new UnsupportedOperationException
+ }
+ }
+
+ override def size = directoryOverlay.size
+ }
+ case None => virtualMGraph
+ }
+
} else {
throw new NoSuchEntityException(name);
}
@@ -263,6 +288,19 @@ class BundleFsLoader extends BundleListe
this.startLevel = null;
}
+ def bindPathNode(pathNode: PathNode) {
+ this.pathNodes ::= pathNode;
+ frequentUpdateDirectory = Some(new MultiPathNode(pathNodes: _*))
+ }
+
+ def unbindPathNode(pathNode: PathNode) {
+ this.pathNodes -= pathNode;
+ frequentUpdateDirectory = pathNodes match {
+ case Nil => None
+ case _ => Some(new MultiPathNode(pathNodes: _*))
+ }
+ }
+
}
object BundleFsLoader {
private val log = LoggerFactory.getLogger(classOf[BundleFsLoader])
Modified: incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala?rev=1342360&r1=1342359&r2=1342360&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala (original)
+++ incubator/clerezza/trunk/parent/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala Thu May 24 18:04:16 2012
@@ -33,44 +33,54 @@ import java.util.Iterator
class DirectoryOverlay(pathNode: PathNode, base: TripleCollection)
extends AbstractTripleCollection {
- private val addedTriples = new SimpleMGraph()
-
- PathNode2MGraph.describeInGraph(pathNode, addedTriples)
+
import collection.JavaConversions._
- val subjects = (for (triple <- addedTriples; subject = triple.getSubject) yield {
- subject
- }).toSet
-
- class FilteringIterator(baseIter: Iterator[Triple]) extends Iterator[Triple] {
- var nextElem: Triple = null
- def prepareNext {
- nextElem = if (baseIter.hasNext) baseIter.next else null
- if ((nextElem != null) &&
- (subjects.contains(nextElem.getSubject))) {
- //println("skipping "+nextElem)
- prepareNext
- }
- }
- prepareNext
+
- override def next = {
- val result = nextElem
+ override def performFilter(s: NonLiteral, p: UriRef,
+ o: Resource): Iterator[Triple] = {
+ val addedTriples = new SimpleMGraph()
+
+ PathNode2MGraph.describeInGraph(pathNode, addedTriples)
+
+ val subjects = (for (triple <- addedTriples; subject = triple.getSubject) yield {
+ subject
+ }).toSet
+
+ class FilteringIterator(baseIter: Iterator[Triple]) extends Iterator[Triple] {
+ var nextElem: Triple = null
+ def prepareNext {
+ nextElem = if (baseIter.hasNext) baseIter.next else null
+ if ((nextElem != null) &&
+ (subjects.contains(nextElem.getSubject))) {
+ //println("skipping "+nextElem)
+ prepareNext
+ }
+ }
prepareNext
- result
+
+ override def next = {
+ val result = nextElem
+ prepareNext
+ result
+ }
+ override def hasNext = nextElem != null
+ override def remove = throw new UnsupportedOperationException
}
- override def hasNext = nextElem != null
- override def remove = throw new UnsupportedOperationException
- }
-
- override def performFilter(s: NonLiteral, p: UriRef,
- o: Resource): Iterator[Triple] = {
+
new IteratorMerger(new FilteringIterator(base.filter(s, p, o)), addedTriples.filter(s,p, o))
}
/**
* returns an upper bound of the size (removals in abse are not deducted)
*/
- override def size = base.size+addedTriples.size
+ override def size = {
+ val addedTriples = new SimpleMGraph()
+
+ PathNode2MGraph.describeInGraph(pathNode, addedTriples)
+
+ base.size+addedTriples.size
+ }
}