You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by al...@apache.org on 2012/04/04 15:48:14 UTC

svn commit: r1309382 [1/3] - in /incubator/stanbol/trunk: enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/ ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ ontologymanager/ontone...

Author: alexdma
Date: Wed Apr  4 13:48:12 2012
New Revision: 1309382

URL: http://svn.apache.org/viewvc?rev=1309382&view=rev
Log:
* Major simplification of the OntoNet Scope management API as per (STANBOL-467). Ticket will be closed once remaining deprecated methods in ONManager can be safely removed (TODO check with Stanbol adopters)
* First sketch of a vocabulary for representing ontology network structures in a Graph (STANBOL-571)
* Removed old iksnetwork registries from ontologymanager/registry resources (the default registry is provided in the data/registries/default bundle) (STANBOL-410)

Added:
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/Vocabulary.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/ScopeResource/
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/ScopeResource/index.ftl
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/ScopeResource/ontology.ftl
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/SessionResource/
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/SessionResource/index.ftl
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/SessionResource/ontology.ftl
Removed:
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/SessionOntologySpace.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeFactoryImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/owlapi/SessionOntologySpaceImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/renderers/SessionRenderer.java
    incubator/stanbol/trunk/ontologymanager/registry/src/main/resources/ontologies/registry/iksnetwork-noimports.owl
    incubator/stanbol/trunk/ontologymanager/registry/src/main/resources/ontologies/registry/iksnetwork.owl
    incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeOntologyResource.java
Modified:
    incubator/stanbol/trunk/enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/RefactorEnhancementEngine.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManager.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLExportable.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScope.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScopeFactory.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpace.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpaceFactory.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionManager.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/OntologySpaceFactoryImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/ScopeRegistryImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/owlapi/AbstractOntologySpaceImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/owlapi/OWLAPIOntologyProvider.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/owlapi/OntologySpaceFactoryImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOWLAPIInputSources.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestStorage.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestClerezzaSpaces.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologyScope.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/session/TestSessions.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/OntologyManagerWebFragment.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/OntologyNetworkResource.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeResource.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/SessionResource.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntologyNetworkResource/index.ftl
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/SessionManagerResource/index.ftl
    incubator/stanbol/trunk/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/input/provider/impl/OntonetInputProvider.java
    incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DBDataTransformer.java
    incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DBExtractor.java
    incubator/stanbol/trunk/reengineer/db/src/test/java/org/apache/stanbol/reengineer/db/DBExtractorTest.java
    incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java
    incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XSDExtractor.java

Modified: incubator/stanbol/trunk/enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/RefactorEnhancementEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/RefactorEnhancementEngine.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/RefactorEnhancementEngine.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/RefactorEnhancementEngine.java Wed Apr  4 13:48:12 2012
@@ -68,7 +68,6 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScope;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpace;
-import org.apache.stanbol.ontologymanager.ontonet.api.scope.ScopeRegistry;
 import org.apache.stanbol.ontologymanager.ontonet.api.session.Session;
 import org.apache.stanbol.ontologymanager.ontonet.api.session.SessionLimitException;
 import org.apache.stanbol.ontologymanager.ontonet.api.session.SessionManager;
@@ -305,15 +304,13 @@ public class RefactorEnhancementEngine e
             log.debug("Recipe {} contains {} rules.", recipe, recipe.getRuleList().size());
             log.debug("The ontology to be refactor is {}", ontology);
 
-            TripleCollection tc = refactorer
-            	.graphRefactoring(OWLAPIToClerezzaConverter.owlOntologyToClerezzaMGraph(ontology), recipe);
-            
-            
-            /*
-            ontology = refactorer
-                    .ontologyRefactoring(ontology, IRI.create(engineConfiguration.getRecipeId()));
+            TripleCollection tc = refactorer.graphRefactoring(
+                OWLAPIToClerezzaConverter.owlOntologyToClerezzaMGraph(ontology), recipe);
 
-			*/
+            /*
+             * ontology = refactorer .ontologyRefactoring(ontology,
+             * IRI.create(engineConfiguration.getRecipeId()));
+             */
             /*
              * The newly generated ontology is converted to Clarezza format and then added os substitued to
              * the old mGraph.
@@ -380,24 +377,24 @@ public class RefactorEnhancementEngine e
             // step 1: get all the rules
             log.debug("Recipe {} and its associated rules will be removed from the rule store.", recipeId);
             Recipe recipe = null;
-			try {
-				recipe = ruleStore.getRecipe(recipeId);
-			} catch (RecipeConstructionException e) {
-				log.error(e.getMessage());
-			}
-			if(recipe != null){
-	            
-				// step 2: remove the recipe
-	            try {
-					if (ruleStore.removeRecipe(recipeId)) {
-					    log.debug(
-					        "Recipe {} has been removed correctly. Note that its rules will be removed separately.",
-					        recipeId);
-					} else log.error("Recipe {} cannot be removed.", recipeId);
-				} catch (RecipeEliminationException e) {
-					log.error(e.getMessage());
-				}
-			}
+            try {
+                recipe = ruleStore.getRecipe(recipeId);
+            } catch (RecipeConstructionException e) {
+                log.error(e.getMessage());
+            }
+            if (recipe != null) {
+
+                // step 2: remove the recipe
+                try {
+                    if (ruleStore.removeRecipe(recipeId)) {
+                        log.debug(
+                            "Recipe {} has been removed correctly. Note that its rules will be removed separately.",
+                            recipeId);
+                    } else log.error("Recipe {} cannot be removed.", recipeId);
+                } catch (RecipeEliminationException e) {
+                    log.error(e.getMessage());
+                }
+            }
 
         } catch (NoSuchRecipeException ex) {
             log.error("The recipe " + engineConfiguration.getRecipeId() + " doesn't exist", ex);
@@ -406,7 +403,7 @@ public class RefactorEnhancementEngine e
         // step 3: clear OntoNet resources
         scope.getCoreSpace().tearDown();
         scope.tearDown();
-        onManager.getScopeRegistry().deregisterScope(scope);
+        onManager.deregisterScope(scope);
         log.debug("OntoNet resources released : scope {}", scope);
 
         log.info("in " + RefactorEnhancementEngine.class + " deactivate with context " + context);
@@ -456,13 +453,12 @@ public class RefactorEnhancementEngine e
         String scopeId = engineConfiguration.getScope();
 
         // Create or get the scope with the configured ID
-        ScopeRegistry scopeRegistry = onManager.getScopeRegistry();
         try {
-            scope = onManager.getOntologyScopeFactory().createOntologyScope(scopeId);
+            scope = onManager.createOntologyScope(scopeId);
             // No need to deactivate a newly created scope.
         } catch (DuplicateIDException e) {
-            scope = scopeRegistry.getScope(scopeId);
-            scopeRegistry.setScopeActive(scopeId, false);
+            scope = onManager.getScope(scopeId);
+            onManager.setScopeActive(scopeId, false);
         }
         // All resolvable ontologies stated in the configuration are loaded into the core space.
         OntologySpace ontologySpace = scope.getCoreSpace();
@@ -498,8 +494,8 @@ public class RefactorEnhancementEngine e
         for (String s : failed)
             log.info(" >> {} : FAILED", s);
         ontologySpace.setUp();
-        if (!scopeRegistry.containsScope(scopeId)) scopeRegistry.registerScope(scope);
-        scopeRegistry.setScopeActive(scopeId, true);
+        if (!onManager.containsScope(scopeId)) onManager.registerScope(scope);
+        onManager.setScopeActive(scopeId, true);
 
         /*
          * The first thing to do is to create a recipe in the rule store that can be used by the engine to
@@ -507,58 +503,58 @@ public class RefactorEnhancementEngine e
          */
         String recipeId = engineConfiguration.getRecipeId();
         Recipe recipe = null;
-		try {
-			recipe = ruleStore.createRecipe(new UriRef(recipeId), null);
-		} catch (AlreadyExistingRecipeException e1) {
-			log.error("A recipe with ID {} already exists in the store.", recipeId);
-		}
-		
-		if(recipe != null){
-		    log.debug("Initialised blank recipe with ID {}", recipeId);
-		
-		    /*
-		     * The set of rule to put in the recipe can be provided by the user. A default set of rules is
-		     * provided in /META-INF/default/seo_rules.sem. Use the property engine.refactor in the felix console
-		     * to pass to the engine your set of rules.
-		     */
-		    String recipeLocation = engineConfiguration.getRecipeLocation();
-		
-		    InputStream recipeStream = null;
-		    String recipeString = null;
-		
-		    if (recipeLocation != null && !recipeLocation.isEmpty()) {
-		        Dereferencer dereferencer = new DereferencerImpl();
-		        try {
-		            recipeStream = dereferencer.resolve(recipeLocation);
-		            log.debug("Loaded recipe from external source {}", recipeLocation);
-		        } catch (FileNotFoundException e) {
-		            log.error("Recipe Stream is null.", e);
-		        }
-		    } else {
-		        // TODO remove this part (or manage it better in the @Activate method).
-		        String loc = "/META-INF/default/seo_rules.sem";
-		        recipeStream = getClass().getResourceAsStream(loc);
-		        log.debug("Loaded default recipe in {}.", loc);
-		    }
-		
-		    if (recipeStream != null) {
-		        BufferedReader reader = new BufferedReader(new InputStreamReader(recipeStream));
-		        recipeString = "";
-		        String line = null;
-		        try {
-		            while ((line = reader.readLine()) != null)
-		                recipeString += line;
-		        } catch (IOException e) {
-		            log.error("Failed to load Refactor Engine recipe from stream. Aborting read. ", e);
-		            recipeString = null;
-		        }
-		    }
-		    log.debug("Recipe content follows :\n{}", recipeString);
-		    if (recipeString != null){ 
-		    	ruleStore.addRulesToRecipe(recipe, recipeString, null);
-		        log.debug("Added rules to recipe {}", recipeId);
-		    }
-		}
+        try {
+            recipe = ruleStore.createRecipe(new UriRef(recipeId), null);
+        } catch (AlreadyExistingRecipeException e1) {
+            log.error("A recipe with ID {} already exists in the store.", recipeId);
+        }
+
+        if (recipe != null) {
+            log.debug("Initialised blank recipe with ID {}", recipeId);
+
+            /*
+             * The set of rule to put in the recipe can be provided by the user. A default set of rules is
+             * provided in /META-INF/default/seo_rules.sem. Use the property engine.refactor in the felix
+             * console to pass to the engine your set of rules.
+             */
+            String recipeLocation = engineConfiguration.getRecipeLocation();
+
+            InputStream recipeStream = null;
+            String recipeString = null;
+
+            if (recipeLocation != null && !recipeLocation.isEmpty()) {
+                Dereferencer dereferencer = new DereferencerImpl();
+                try {
+                    recipeStream = dereferencer.resolve(recipeLocation);
+                    log.debug("Loaded recipe from external source {}", recipeLocation);
+                } catch (FileNotFoundException e) {
+                    log.error("Recipe Stream is null.", e);
+                }
+            } else {
+                // TODO remove this part (or manage it better in the @Activate method).
+                String loc = "/META-INF/default/seo_rules.sem";
+                recipeStream = getClass().getResourceAsStream(loc);
+                log.debug("Loaded default recipe in {}.", loc);
+            }
+
+            if (recipeStream != null) {
+                BufferedReader reader = new BufferedReader(new InputStreamReader(recipeStream));
+                recipeString = "";
+                String line = null;
+                try {
+                    while ((line = reader.readLine()) != null)
+                        recipeString += line;
+                } catch (IOException e) {
+                    log.error("Failed to load Refactor Engine recipe from stream. Aborting read. ", e);
+                    recipeString = null;
+                }
+            }
+            log.debug("Recipe content follows :\n{}", recipeString);
+            if (recipeString != null) {
+                ruleStore.addRulesToRecipe(recipe, recipeString, null);
+                log.debug("Added rules to recipe {}", recipeId);
+            }
+        }
     }
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManager.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManager.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManager.java Wed Apr  4 13:48:12 2012
@@ -18,26 +18,26 @@ package org.apache.stanbol.ontologymanag
 
 import java.io.File;
 
-import org.apache.stanbol.commons.owl.OWLOntologyManagerFactory;
-import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
+import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScope;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScopeFactory;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpaceFactory;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.ScopeRegistry;
-import org.apache.stanbol.ontologymanager.ontonet.api.session.SessionManager;
-import org.apache.stanbol.ontologymanager.ontonet.impl.session.SessionManagerImpl;
-import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException;
-import org.semanticweb.owlapi.model.OWLOntologyManager;
 
 /**
  * An Ontology Network Manager holds all references and tools for creating, modifying and deleting the logical
  * realms that store Web Ontologies, as well as offer facilities for handling the ontologies contained
- * therein.
+ * therein.<br>
+ * <br>
+ * Note that since this object is both a {@link ScopeRegistry} and an {@link OntologyScopeFactory}, the call
+ * to {@link ScopeRegistry#registerScope(OntologyScope)} or its overloads after
+ * {@link OntologyScopeFactory#createOntologyScope(String, OntologyInputSource...)} is unnecessary, as the
+ * ONManager automatically registers newly created scopes.
  * 
  * @author alexdma, anuzzolese
  * 
  */
-public interface ONManager {
+public interface ONManager extends ScopeRegistry, OntologyScopeFactory {
 
     /**
      * The key used to configure the path of the ontology network configuration.
@@ -85,54 +85,34 @@ public interface ONManager {
     /**
      * Returns the ontology scope factory that was created along with the manager context.
      * 
+     * @deprecated returns this object, which is also an {@link OntologyScopeFactory}.
      * @return the default ontology scope factory
      */
     OntologyScopeFactory getOntologyScopeFactory();
 
     /**
-     * Returns the ontology space factory that was created along with the manager context.
+     * Returns the ontology space factory that was created along with the manager context. <br>
+     * <br>
+     * Note: Because this can be backend-dependent, this method is not deprecated yet.
      * 
      * @return the default ontology space factory.
      */
     OntologySpaceFactory getOntologySpaceFactory();
 
     /**
-     * Returns an OWL Ontology Manager that is never cleared of its ontologies, so it can be used for caching
-     * ontologies without having to reload them using other managers. It is sufficient to catch
-     * {@link OWLOntologyAlreadyExistsException}s and obtain the ontology with that same ID from this manager.
-     * 
-     * @deprecated the ONManager will soon stop providing a cache manager, as it will gradually be replaced by
-     *             {@link OntologyProvider}. Implementations that need to use an OWLOntologyManager which
-     *             avoids reloading stored ontologies can either call {@link OntologyProvider#getStore()} on
-     *             an {@link OWLOntologyManager}-based implementation, or create a new one by calling
-     *             {@link OWLOntologyManagerFactory#createOWLOntologyManager(IRI[])} or OWL API methods.
-     * @return the OWL Ontology Manager used for caching ontologies.
-     */
-    OWLOntologyManager getOwlCacheManager();
-
-    /**
      * Returns the unique ontology scope registry for this context.
      * 
+     * @deprecated returns this object, which is also a {@link ScopeRegistry}.
      * @return the ontology scope registry.
      */
     ScopeRegistry getScopeRegistry();
 
     /**
-     * Returns the unique session manager for this context.
-     * 
-     * @deprecated {@link SessionManager} is now a standalone component and should be accessed independently
-     *             from the ONManager (e.g. by instantiating a new {@link SessionManagerImpl} or by
-     *             referencing {@link SessionManager} in OSGi components).
-     * 
-     * @return the session manager.
-     */
-    SessionManager getSessionManager();
-
-    /**
-     * Returns the list of IRIs that identify scopes that should be activated on startup, <i>if they
-     * exist</i>.
+     * Sets the IRI that will be the base namespace for all ontology scopes and collectors created by this
+     * object.
      * 
-     * @return the list of scope IDs to activate.
+     * @param namespace
+     *            the base namespace.
      */
-    String[] getUrisToActivate();
+    void setOntologyNetworkNamespace(String namespace);
 }

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/Vocabulary.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/Vocabulary.java?rev=1309382&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/Vocabulary.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/Vocabulary.java Wed Apr  4 13:48:12 2012
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api;
+
+public class Vocabulary {
+
+    public static final String _NS_ONTONET = "http://stanbol.apache.org/ontology/meta/ontonet#";
+
+    public static final String IS_MANAGED_BY = _NS_ONTONET + "isManagedBy";
+
+    public static final String MANAGES = _NS_ONTONET + "manages";
+    
+    public static final String HAS_STATUS = _NS_ONTONET + "hasStatus";
+    
+    public static final String STATUS = _NS_ONTONET + "Status";
+    
+    public static final String STATUS_ACTIVE = _NS_ONTONET + "Status.ACTIVE";
+
+    public static final String STATUS_INACTIVE = _NS_ONTONET + "Status.INACTIVE";
+    
+    public static final String SCOPE = _NS_ONTONET + "Scope";
+
+    public static final String SESSION = _NS_ONTONET + "Session";
+
+}

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java Wed Apr  4 13:48:12 2012
@@ -23,7 +23,6 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSourceHandler;
 import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLOntology;
 
 /**
  * It is not literally an ontology <i>collection</i>, in that it only collects references to ontologies, not
@@ -69,7 +68,8 @@ public interface OntologyCollector exten
     Collection<OntologyCollectorListener> getListeners();
 
     /**
-     * Returns the ontologies managed by this ontology space.
+     * Returns the ontologies managed by this ontology space. This is a shortcut method for iterating
+     * {@link #getOntology(IRI, Class)} calls over {@link #listManagedOntologies()}.
      * 
      * @param withClosure
      *            if true, also the ontologies imported by those directly managed by this space will be
@@ -79,45 +79,11 @@ public interface OntologyCollector exten
     <O> Set<O> getManagedOntologies(Class<O> returnType, boolean withClosure);
 
     /**
-     * Returns the ontologies managed by this ontology space.
-     * 
-     * @deprecated to obtain the set as {@link OWLOntology} objects, please use
-     *             <code>#getManagedOntologies(OWLOntology.class, boolean)</code>.
-     * 
-     * @param withClosure
-     *            if true, also the ontologies imported by those directly managed by this space will be
-     *            included.
-     * @return the set of ontologies in the ontology space
-     */
-    Set<OWLOntology> getOntologies(boolean withClosure);
-
-    /**
-     * Equivalent to calling <code>getOntology(IRI, false)</code>;
-     * 
-     * @deprecated to obtain the {@link OWLOntology} object, cast the result of <code>#getOntology(IRI,
-     *             OWLOntology.class)</code> to OWLOntology.
+     * TODO replace with Ontology IDs
      * 
-     * @param ontologyIri
      * @return
      */
-    OWLOntology getOntology(IRI ontologyIri);
-
-    /**
-     * Returns the ontology identified by the supplied <i>logical</i> IRI, if such an ontology has been loaded
-     * in this space.<br>
-     * <br>
-     * Note that ontologies are not identified by physical IRI here. There's no need to ask KReS for
-     * ontologies by physical IRI, use a browser or some other program instead!
-     * 
-     * @deprecated to obtain the {@link OWLOntology} object, please use <code>#getOntology(IRI,
-     *             OWLOntology.class, boolean)</code>.
-     * 
-     * @param ontologyIri
-     *            the <i>logical</i> identifier of the ontology to query for.
-     * 
-     * @return the requested ontology, or null if no ontology with this ID has been loaded.
-     */
-    OWLOntology getOntology(IRI ontologyIri, boolean merge);
+    Set<IRI> listManagedOntologies();
 
     <O> O getOntology(IRI ontologyIri, Class<O> returnType);
 
@@ -131,18 +97,6 @@ public interface OntologyCollector exten
      */
     <O> O getOntology(IRI ontologyIri, Class<O> returnType, boolean merge);
 
-    int getOntologyCount();
-
-    /**
-     * A shortcut method to avoid computing the ontologies themselves before counting them.
-     * 
-     * TODO deprecate once support for closure is added to {@link #listManagedOntologies()}.
-     * 
-     * @param withClosure
-     * @return
-     */
-    int getOntologyCount(boolean withClosure);
-
     /**
      * Determines if the ontology identified by the supplied <i>logical</i> IRI has been loaded in this space.<br>
      * <br>
@@ -157,13 +111,6 @@ public interface OntologyCollector exten
     boolean hasOntology(IRI ontologyIri);
 
     /**
-     * TODO replace with Ontology IDs
-     * 
-     * @return
-     */
-    Set<IRI> listManagedOntologies();
-
-    /**
      * Unregisters the supplied for changes in this ontology space. Has no effect if the same listener was not
      * registered with this ontology space.
      * 
@@ -187,12 +134,16 @@ public interface OntologyCollector exten
     /**
      * Bootstraps the ontology space. In some cases (such as with core and custom spaces) this also implies
      * write-locking its ontologies.
+     * 
+     * XXX make it a protected, non-interface method ?
      */
     void setUp();
 
     /**
      * Performs all required operations for disposing of an ontology space and releasing its resources (e.g.
      * removing the writelock).
+     * 
+     * XXX make it a protected, non-interface method ?
      */
     void tearDown();
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java Wed Apr  4 13:48:12 2012
@@ -44,7 +44,7 @@ public class OntologySpaceSource extends
                 "Could not add subtrees to unmodifiable ontology space {}. Input source will have no additions.",
                 e.getOntologyCollector());
         }
-        bindRootOntology(space.asOWLOntology(false));
+        bindRootOntology(space.export(OWLOntology.class, false));
     }
 
     protected void appendSubtree(OntologyInputSource<?,?> subtree) throws UnmodifiableOntologyCollectorException {
@@ -57,7 +57,7 @@ public class OntologySpaceSource extends
 
     @Override
     public Set<OWLOntology> getImports(boolean recursive) {
-        return space.getOntologies(recursive);
+        return space.getManagedOntologies(OWLOntology.class, recursive);
     }
 
     @Override

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLExportable.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLExportable.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLExportable.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLExportable.java Wed Apr  4 13:48:12 2012
@@ -17,10 +17,9 @@
 package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
 
 import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLOntology;
 
 /**
- * An object that can be represented as an {@link OWLOntology} instance.
+ * An object that can be represented as an ontology instance.
  * 
  * @author alexdma
  * 
@@ -28,19 +27,6 @@ import org.semanticweb.owlapi.model.OWLO
 public interface OWLExportable {
 
     /**
-     * Returns the OWL ontology form of this object.
-     * 
-     * @deprecated use the method {@link #export(Class, boolean)} instead, with the first argument set as
-     *             {@link OWLOntology.class}.
-     * 
-     * @param merge
-     *            if true, all imported ontologies will be merged and no import statements will appear.
-     * @return the OWL ontology that represents this object.
-     * 
-     */
-    OWLOntology asOWLOntology(boolean merge);
-
-    /**
      * Returns an ontological form of this object of the specified return type, if supported. If the supplied
      * class is not a supported return type, an {@link UnsupportedOperationException} is thrown. <br>
      * <br>

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java Wed Apr  4 13:48:12 2012
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Set;
 
+import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.access.TcProvider;
 import org.apache.clerezza.rdf.core.serializedform.UnsupportedFormatException;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.ImportManagementPolicy;
@@ -50,6 +51,11 @@ public interface OntologyProvider<S> {
     public String IMPORT_POLICY = "org.apache.stanbol.ontologymanager.ontonet.importPolicy";
 
     /**
+     * The key used to configure the identifier of the meta-level graph
+     */
+    public String META_GRAPH_ID = "org.apache.stanbol.ontologymanager.ontonet.metaGraphId";
+
+    /**
      * The key used to configure the default import resolution policy for this provider.
      */
     public String RESOLVE_IMPORTS = "org.apache.stanbol.ontologymanager.ontonet.resolveImports";
@@ -74,6 +80,14 @@ public interface OntologyProvider<S> {
     String getKey(IRI ontologyIRI);
 
     /**
+     * Returns the graph that stores all the information on stored ontologies
+     * 
+     * @param returnType
+     * @return
+     */
+    <O extends TripleCollection> O getMetaGraph(Class<O> returnType);
+
+    /**
      * Gets the set of all the strings that can be used to access the ontologies stored by this provider.
      * 
      * @return the ontology key set.
@@ -172,6 +186,14 @@ public interface OntologyProvider<S> {
      */
     Class<?>[] getSupportedReturnTypes();
 
+    /**
+     * A convenience method for checking the availability of an ontology given its (physical or logical) IRI.
+     * It is typically more efficient than calling {@link #getStoredOntology(IRI, Class)} and null-checking
+     * the result.
+     * 
+     * @param ontologyIri
+     * @return
+     */
     boolean hasOntology(IRI ontologyIri);
 
     /**

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScope.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScope.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScope.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScope.java Wed Apr  4 13:48:12 2012
@@ -16,13 +16,10 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.api.scope;
 
-import java.util.Set;
-
 import org.apache.stanbol.ontologymanager.ontonet.api.NamedResource;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.Lockable;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.UnmodifiableOntologyCollectorException;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OWLExportable;
-import org.apache.stanbol.ontologymanager.ontonet.api.session.Session;
 
 /**
  * Represents an ontology network that is used for modelling a given knowledge component or domain, e.g.
@@ -44,18 +41,6 @@ import org.apache.stanbol.ontologymanage
 public interface OntologyScope extends NamedResource, Lockable, ScopeOntologyListenable, OWLExportable {
 
     /**
-     * Adds a new ontology space to the list of user session spaces for this scope.
-     * 
-     * @deprecated as session ontology spaces are obsolete, so is this method. Please refer directly to the
-     *             session identified by <code>sessionID</code>.
-     * 
-     * @param sessionSpace
-     *            the ontology space to be added.
-     * @throws UnmodifiableOntologyCollectorException
-     */
-    void addSessionSpace(OntologySpace sessionSpace, String sessionID) throws UnmodifiableOntologyCollectorException;
-
-    /**
      * Returns the core ontology space for this ontology scope. The core space should never be null for any
      * scope.
      * 
@@ -71,29 +56,6 @@ public interface OntologyScope extends N
     OntologySpace getCustomSpace();
 
     /**
-     * Returns the ontology space for this scope that is identified by the supplied IRI.
-     * 
-     * @deprecated as session ontology spaces are obsolete, so is this method. Please refer directly to the
-     *             session identified by <code>sessionID</code>.
-     * 
-     * @param sessionID
-     *            the unique identifier of the KReS session.
-     * @return the ontology space identified by <code>sessionID</code>, or null if no such space is registered
-     *         for this scope and session.
-     */
-    SessionOntologySpace getSessionSpace(String sessionID);
-
-    /**
-     * Returns all the active ontology spaces for this scope.
-     * 
-     * @deprecated as session ontology spaces are obsolete, so is this method. Please reroute all
-     *             session-related queries to {@link Session} objects directly.
-     * 
-     * @return a set of active ontology spaces for this scope.
-     */
-    Set<OntologySpace> getSessionSpaces();
-
-    /**
      * Sets an ontology space as the custom space for this scope.
      * 
      * @param customSpace
@@ -113,21 +75,6 @@ public interface OntologyScope extends N
     void setUp();
 
     /**
-     * Performs whatever operations are required for making sure the custom space of this scope is aware of
-     * changes occurring in its core space, that all session spaces are aware of changes in the custom space,
-     * and so on. Typically, this includes updating all import statements in the top ontologies for each
-     * space.<br>
-     * <br>
-     * This method is not intended for usage by ontology managers. Since its invocation is supposed to be
-     * automatic, it should be invoked by whatever classes are responsible for listening to changes in an
-     * ontology scope/space. In the default implementation, it is the scope itself, yet the method is left
-     * public in order to allow for external controllers.
-     * 
-     * @deprecated synchronization is managed internally, therefore this method has no effect.
-     */
-    void synchronizeSpaces();
-
-    /**
      * Performs the operations required for deactivating the ontology scope. In general, this is not
      * equivalent to finalizing the object for garbage collection. It should be possible to activate the same
      * ontology scope again if need be.

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScopeFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScopeFactory.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScopeFactory.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScopeFactory.java Wed Apr  4 13:48:12 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.api.scope;
 
-import org.apache.stanbol.ontologymanager.ontonet.api.NamedResource;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.DuplicateIDException;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
 
@@ -30,7 +29,7 @@ import org.apache.stanbol.ontologymanage
  * @author alexdma
  * 
  */
-public interface OntologyScopeFactory extends NamedResource, ScopeEventListenable {
+public interface OntologyScopeFactory extends ScopeEventListenable {
 
     /**
      * Creates and returns a new ontology scope with the core space ontologies obtained from

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpace.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpace.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpace.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpace.java Wed Apr  4 13:48:12 2012
@@ -42,14 +42,7 @@ public interface OntologySpace extends O
         /**
          * Denotes a custom space (0..1).
          */
-        CUSTOM("custom"),
-
-        /**
-         * Denotes a session space (0..n).
-         * 
-         * @deprecated no session spaces should created anymore.
-         */
-        SESSION("session");
+        CUSTOM("custom");
 
         private String suffix;
 

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpaceFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpaceFactory.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpaceFactory.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpaceFactory.java Wed Apr  4 13:48:12 2012
@@ -19,7 +19,6 @@ package org.apache.stanbol.ontologymanag
 import org.apache.stanbol.ontologymanager.ontonet.api.NamedResource;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpace.SpaceType;
-import org.apache.stanbol.ontologymanager.ontonet.api.session.Session;
 
 /**
  * An ontology space factory is responsible for the creation of new, readily specialized ontology spaces from
@@ -74,22 +73,4 @@ public interface OntologySpaceFactory ex
                                       SpaceType type,
                                       OntologyInputSource<?,?>... ontologySources);
 
-    /**
-     * Creates and sets up a default session ontology space. Equivalent to calling
-     * <code>createOntologySpace(IRI, SpaceTypes.SESSION, OntologyInputSource...)</code>.
-     * 
-     * @deprecated session spaces should no longer exist, as session data should be loaded in {@link Session}
-     *             objects. Therefore, implementations of this method are expected to throw an
-     *             {@link UnsupportedOperationException}.
-     * 
-     * @param scopeId
-     *            the unique identifier of the ontology scope that will reference this space. It can be used
-     *            for generating the identifier for this ontology space.
-     * @param sessionSources
-     *            the sources of the optional ontologies to be immediately loaded upon space creation.
-     * @return the generated ontology space.
-     */
-    SessionOntologySpace createSessionOntologySpace(String scopeId,
-                                                    OntologyInputSource<?,?>... sessionSources);
-
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionManager.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionManager.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionManager.java Wed Apr  4 13:48:12 2012
@@ -20,7 +20,6 @@ import java.io.OutputStream;
 import java.util.Set;
 
 import org.apache.stanbol.ontologymanager.ontonet.api.NamedResource;
-import org.apache.stanbol.ontologymanager.ontonet.api.scope.SessionOntologySpace;
 import org.semanticweb.owlapi.model.OWLOntologyStorageException;
 
 /**
@@ -103,15 +102,6 @@ public interface SessionManager extends 
     Session getSession(String sessionID);
 
     /**
-     * Returns the ontology spaces associated with this session.
-     * 
-     * @deprecated as session spaces are obsolete, so is this method. Do no use session spaces.
-     * 
-     * @return the session spaces
-     */
-    Set<SessionOntologySpace> getSessionSpaces(String sessionID) throws NonReferenceableSessionException;
-
-    /**
      * Sets the maximum allowed number of active sessions managed by this manager simultaneously. A negative
      * value denotes no limit.
      * 

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java Wed Apr  4 13:48:12 2012
@@ -20,13 +20,14 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Dictionary;
+import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.List;
+import java.util.Set;
 
-import org.apache.clerezza.rdf.core.access.TcManager;
 import org.apache.clerezza.rdf.core.access.TcProvider;
-import org.apache.clerezza.rdf.core.access.WeightedTcProvider;
-import org.apache.clerezza.rdf.core.serializedform.Parser;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -40,6 +41,7 @@ import org.apache.stanbol.commons.owl.OW
 import org.apache.stanbol.commons.stanboltools.offline.OfflineMode;
 import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
 import org.apache.stanbol.ontologymanager.ontonet.api.OfflineConfiguration;
+import org.apache.stanbol.ontologymanager.ontonet.api.collector.DuplicateIDException;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.UnmodifiableOntologyCollectorException;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.BlankOntologySource;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
@@ -50,12 +52,11 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScopeFactory;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpace;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpaceFactory;
+import org.apache.stanbol.ontologymanager.ontonet.api.scope.ScopeEventListener;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.ScopeRegistry;
-import org.apache.stanbol.ontologymanager.ontonet.api.session.SessionManager;
 import org.apache.stanbol.ontologymanager.ontonet.conf.OntologyNetworkConfigurationUtils;
-import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.ClerezzaOntologyProvider;
 import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.OntologySpaceFactoryImpl;
-import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.OntologyScopeFactoryImpl;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.OntologyScopeImpl;
 import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.ScopeRegistryImpl;
 import org.osgi.service.component.ComponentContext;
 import org.semanticweb.owlapi.io.FileDocumentSource;
@@ -78,7 +79,7 @@ import org.slf4j.LoggerFactory;
  */
 @Component(immediate = true, metatype = true)
 @Service(ONManager.class)
-public class ONManagerImpl implements ONManager {
+public class ONManagerImpl extends ScopeRegistryImpl implements ONManager {
 
     /**
      * Utility class to speed up ontology network startup. <br>
@@ -96,7 +97,7 @@ public class ONManagerImpl implements ON
          * @param locationIri
          */
         public synchronized void addToCustomSpace(String scopeID, String[] locationIris) {
-            OntologyScope scope = getScopeRegistry().getScope(scopeID);
+            OntologyScope scope = ONManagerImpl.this.getScope(scopeID);
 
             scope.getCustomSpace().tearDown();
             for (String locationIri : locationIris) {
@@ -135,6 +136,8 @@ public class ONManagerImpl implements ON
 
     private Helper helper = null;
 
+    private Set<ScopeEventListener> listeners = new HashSet<ScopeEventListener>();
+
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Reference
@@ -154,8 +157,7 @@ public class ONManagerImpl implements ON
     @Reference
     private OntologyProvider<?> ontologyProvider;
 
-    private OntologyScopeFactory ontologyScopeFactory;
-
+    @Reference
     private OntologySpaceFactory ontologySpaceFactory;
 
     @Property(name = ONManager.ID, value = _ID_DEFAULT)
@@ -164,10 +166,6 @@ public class ONManagerImpl implements ON
     @Property(name = ONManager.ONTOLOGY_NETWORK_NS, value = _ONTOLOGY_NETWORK_NS_DEFAULT)
     private String ontonetNS;
 
-    private OWLOntologyManager owlCacheManager;
-
-    private ScopeRegistry scopeRegistry;
-
     @Property(name = ONManager.ID_SCOPE_REGISTRY, value = _ID_SCOPE_REGISTRY_DEFAULT)
     private String scopeRegistryId;
 
@@ -190,9 +188,17 @@ public class ONManagerImpl implements ON
         // All bindings are deferred to the activator
     }
 
+    @Deprecated
     public ONManagerImpl(OntologyProvider<?> ontologyProvider,
                          OfflineConfiguration offline,
                          Dictionary<String,Object> configuration) {
+        this(ontologyProvider, offline, null, configuration);
+    }
+
+    public ONManagerImpl(OntologyProvider<?> ontologyProvider,
+                         OfflineConfiguration offline,
+                         OntologySpaceFactory spaceFactory,
+                         Dictionary<String,Object> configuration) {
         this();
         this.ontologyProvider = ontologyProvider;
         this.offline = offline;
@@ -204,47 +210,6 @@ public class ONManagerImpl implements ON
     }
 
     /**
-     * @deprecated use {@link #ONManagerImpl(TcManager, WeightedTcProvider, OfflineConfiguration, Dictionary)}
-     *             instead. Note that if the deprecated method is used instead, its effect will be to copy the
-     *             Dictionary context to a new {@link OfflineConfiguration} object.
-     * @param tcm
-     * @param wtcp
-     * @param configuration
-     */
-    @Deprecated
-    public ONManagerImpl(TcManager tcm, WeightedTcProvider wtcp, Dictionary<String,Object> configuration) {
-        // Copy the same configuration to the ONManagerConfigurationImpl.
-        this(tcm, wtcp, new OfflineConfigurationImpl(configuration), configuration);
-    }
-
-    /**
-     * Constructor to be invoked by non-OSGi environments.
-     * 
-     * @deprecated tcm and wctp are no longer to be supplied directly to the ONManager object. Use
-     *             {@link #ONManagerImpl(OntologyProvider, OfflineConfiguration, Dictionary)} instead.
-     * 
-     * @param tcm
-     *            the triple collection manager to be used for storing ontologies.
-     * @param wtcp
-     *            the triple collection provider to be used for storing ontologies.
-     * @param onmconfig
-     *            the configuration of this ontology network manager.
-     * @param configuration
-     *            additional parameters for the ONManager not included in {@link OfflineConfiguration}.
-     */
-    @Deprecated
-    public ONManagerImpl(TcManager tcm,
-                         WeightedTcProvider wtcp,
-                         OfflineConfiguration offline,
-                         Dictionary<String,Object> configuration) {
-        /*
-         * Assume this.tcm this.wtcp and this.wtcp were not filled in by OSGi-DS. As a matter of fact,
-         * WeightedTcProvider is now ignored as we assume to use those bound with the TcManager.
-         */
-        this(new ClerezzaOntologyProvider(tcm, offline, new Parser()), offline, configuration);
-    }
-
-    /**
      * Used to configure an instance within an OSGi container.
      * 
      * @throws IOException
@@ -290,13 +255,6 @@ public class ONManagerImpl implements ON
             // Ok, go empty
         }
 
-        owlCacheManager = OWLOntologyManagerFactory.createOWLOntologyManager(offline
-                .getOntologySourceLocations().toArray(new IRI[0]));
-
-        // These depend on one another
-        scopeRegistry = new ScopeRegistryImpl();
-        // oIndex = new OntologyIndexImpl(this);
-
         bindResources();
 
         // String tfile = (String) configuration.get(CONFIG_FILE_PATH);
@@ -361,15 +319,21 @@ public class ONManagerImpl implements ON
 
     }
 
+    @Override
+    public void addScopeEventListener(ScopeEventListener listener) {
+        listeners.add(listener);
+    }
+
     protected void bindResources() {
-        IRI ns = IRI.create(getOntologyNetworkNamespace());
-        if (ontologyProvider.getStore() instanceof TcProvider) ontologySpaceFactory = new OntologySpaceFactoryImpl(
-                scopeRegistry, (OntologyProvider<TcProvider>) ontologyProvider, offline,
-                IRI.create(ns + scopeRegistryId + "/"));
-        else ontologySpaceFactory = new org.apache.stanbol.ontologymanager.ontonet.impl.owlapi.OntologySpaceFactoryImpl(
-                scopeRegistry, offline, ns);
-        IRI iri = IRI.create(ns + scopeRegistryId + "/");
-        ontologyScopeFactory = new OntologyScopeFactoryImpl(scopeRegistry, iri, ontologySpaceFactory);
+        if (ontologySpaceFactory == null) {
+            IRI ns = IRI.create(getOntologyNetworkNamespace());
+            if (ontologyProvider.getStore() instanceof TcProvider) ontologySpaceFactory = new OntologySpaceFactoryImpl(
+                    (OntologyProvider<TcProvider>) ontologyProvider, new Hashtable<String,Object>());
+            else ontologySpaceFactory = new org.apache.stanbol.ontologymanager.ontonet.impl.owlapi.OntologySpaceFactoryImpl(
+                    this, offline, ns);
+        }
+        IRI iri = IRI.create(getOntologyNetworkNamespace() + scopeRegistryId + "/");
+        ontologySpaceFactory.setNamespace(iri);
     }
 
     private void bootstrapOntologyNetwork(OWLOntology configOntology) {
@@ -400,7 +364,7 @@ public class ONManagerImpl implements ON
 
                 // Create the scope
                 OntologyScope sc = null;
-                sc = ontologyScopeFactory.createOntologyScope(scopeIRI, new BlankOntologySource());
+                sc = createOntologyScope(scopeIRI, new BlankOntologySource());
 
                 // Populate the core space
                 if (cores.length > 0) {
@@ -416,7 +380,7 @@ public class ONManagerImpl implements ON
                 }
 
                 sc.setUp();
-                scopeRegistry.registerScope(sc);
+                registerScope(sc);
 
                 // getScopeHelper().createScope(scopeIRI);
                 // getScopeHelper().addToCoreSpace(scopeIRI, cores);
@@ -431,7 +395,7 @@ public class ONManagerImpl implements ON
             for (String scopeID : toActivate) {
                 try {
                     scopeID = scopeID.trim();
-                    scopeRegistry.setScopeActive(scopeID, true);
+                    setScopeActive(scopeID, true);
                     log.info("Ontology scope " + scopeID + " activated.");
                 } catch (NoSuchScopeException ex) {
                     log.warn("Tried to activate unavailable scope " + scopeID + ".");
@@ -447,6 +411,38 @@ public class ONManagerImpl implements ON
 
     }
 
+    @Override
+    public void clearScopeEventListeners() {
+        listeners.clear();
+    }
+
+    @Override
+    public OntologyScope createOntologyScope(String scopeID, OntologyInputSource<?,?>... coreSources) throws DuplicateIDException {
+        if (this.containsScope(scopeID)) throw new DuplicateIDException(scopeID,
+                "Scope registry already contains ontology scope with ID " + scopeID);
+        OntologyScope scope = new OntologyScopeImpl(scopeID, IRI.create(getOntologyNetworkNamespace()
+                                                                        + scopeRegistryId + "/"),
+                getOntologySpaceFactory(), coreSources);
+        if (scope != null) {
+            this.registerScope(scope);
+            fireScopeCreated(scope);
+        }
+        return scope;
+    }
+
+    @Override
+    public synchronized void registerScope(OntologyScope scope) {
+        if (scope == null) throw new IllegalArgumentException("scope cannot be null.");
+        String id = scope.getID();
+        if (this.containsScope(id)) {
+            if (scope != getScope(id)) {
+                log.warn("Overriding different scope with same ID {}", id);
+                super.registerScope(scope);
+            } else log.warn("Ignoring unnecessary call to already registered scope {}", id);
+        } else super.registerScope(scope);
+
+    }
+
     /**
      * Deactivation of the ONManagerImpl resets all its resources.
      */
@@ -476,6 +472,11 @@ public class ONManagerImpl implements ON
         this.offlineMode = mode;
     }
 
+    protected void fireScopeCreated(OntologyScope scope) {
+        for (ScopeEventListener l : listeners)
+            l.scopeCreated(scope);
+    }
+
     @Override
     public OfflineConfiguration getOfflineConfiguration() {
         return offline;
@@ -496,8 +497,9 @@ public class ONManagerImpl implements ON
      * 
      * @return the ontology scope factory
      */
+    @Override
     public OntologyScopeFactory getOntologyScopeFactory() {
-        return ontologyScopeFactory;
+        return this;
     }
 
     /**
@@ -505,12 +507,14 @@ public class ONManagerImpl implements ON
      * 
      * @return the ontology space factory
      */
+    @Override
     public OntologySpaceFactory getOntologySpaceFactory() {
         return ontologySpaceFactory;
     }
 
-    public OWLOntologyManager getOwlCacheManager() {
-        return owlCacheManager;
+    @Override
+    public Collection<ScopeEventListener> getScopeEventListeners() {
+        return listeners;
     }
 
     public Helper getScopeHelper() {
@@ -520,23 +524,9 @@ public class ONManagerImpl implements ON
         return helper;
     }
 
-    /**
-     * Returns the unique ontology scope registry for this context.
-     * 
-     * @return the ontology scope registry
-     */
+    @Override
     public ScopeRegistry getScopeRegistry() {
-        return scopeRegistry;
-    }
-
-    public SessionManager getSessionManager() {
-        throw new UnsupportedOperationException(
-                "ONManager no longer accesses session managers directly. Please create/reference SessionManager objects independently.");
-        // return sessionManager;
-    }
-
-    public String[] getUrisToActivate() {
-        return toActivate;
+        return this;
     }
 
     /**
@@ -548,4 +538,20 @@ public class ONManagerImpl implements ON
         return offlineMode != null;
     }
 
+    @Override
+    public void removeScopeEventListener(ScopeEventListener listener) {
+        listeners.remove(listener);
+    }
+
+    @Override
+    public void setOntologyNetworkNamespace(String namespace) {
+        if (namespace == null || namespace.isEmpty()) throw new IllegalArgumentException(
+                "namespace must be a non-null and non-empty string.");
+        if (!namespace.endsWith("/")) {
+            log.warn("OntoNet namespaces must be slash URIs, adding '/'.");
+            namespace += "/";
+        }
+        this.ontonetNS = namespace;
+    }
+
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java Wed Apr  4 13:48:12 2012
@@ -220,11 +220,6 @@ public abstract class AbstractOntologyCo
     }
 
     @Override
-    public OWLOntology asOWLOntology(boolean merge) {
-        return export(OWLOntology.class, merge);
-    }
-
-    @Override
     public void clearListeners() {
         listeners.clear();
     }
@@ -362,7 +357,7 @@ public abstract class AbstractOntologyCo
 
                 for (IRI ontologyIri : managedOntologies) {
                     log.debug("Merging {} with {}.", ontologyIri, root);
-                    set.add(getOntology(ontologyIri, true));
+                    set.add(getOntology(ontologyIri, OWLOntology.class, true));
                 }
 
                 OWLOntologySetProvider provider = new OWLOntologySetProvider() {
@@ -470,26 +465,6 @@ public abstract class AbstractOntologyCo
         return namespace;
     }
 
-    /**
-     * FIXME not including closure yet.
-     * 
-     * @see OntologySpace#getOntologies(boolean)
-     */
-    @Override
-    public Set<OWLOntology> getOntologies(boolean withClosure) {
-        return getManagedOntologies(OWLOntology.class, withClosure);
-    }
-
-    @Override
-    public OWLOntology getOntology(IRI ontologyIri) {
-        return getOntology(ontologyIri, false);
-    }
-
-    @Override
-    public OWLOntology getOntology(IRI ontologyIri, boolean merge) {
-        return getOntology(ontologyIri, OWLOntology.class, merge);
-    }
-
     @Override
     public <O> O getOntology(IRI ontologyIri, Class<O> returnType) {
         return getOntology(ontologyIri, returnType, false);
@@ -623,18 +598,6 @@ public abstract class AbstractOntologyCo
     }
 
     @Override
-    public int getOntologyCount() {
-        return getOntologyCount(false);
-    }
-
-    @Override
-    public int getOntologyCount(boolean withClosure) {
-        if (withClosure) throw new UnsupportedOperationException(
-                "Closure support not implemented efficiently yet. Please call getOntologyCount(false).");
-        return managedOntologies.size();
-    }
-
-    @Override
     public Set<Class<?>> getSupportedOntologyTypes() {
         return Collections.unmodifiableSet(supportedTypes);
     }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java Wed Apr  4 13:48:12 2012
@@ -122,7 +122,7 @@ public class ClerezzaOntologyProvider im
 
         private MGraph graph;
 
-        private UriRef graphId = new UriRef(OntologyToTcMapper.class.getCanonicalName());
+        private UriRef graphId = new UriRef(metaGraphId);
 
         OntologyToTcMapper() {
             if (store == null) throw new IllegalArgumentException("TcProvider cannot be null");
@@ -153,22 +153,6 @@ public class ClerezzaOntologyProvider im
         }
 
         /**
-         * Creates an {@link UriRef} out of an {@link OWLOntologyID}, so it can be used as a storage key for
-         * the graph.
-         * 
-         * @param ontologyReference
-         * @return
-         */
-        private UriRef buildResource(OWLOntologyID ontologyReference) {
-            // The UriRef is of the form ontologyIRI[/versionIRI] (TODO use something less conventional?)
-            IRI ontologyIRI = ontologyReference.getOntologyIRI(), versionIri = ontologyReference
-                    .getVersionIRI();
-            UriRef entry = new UriRef(ontologyIRI.toString()
-                                      + ((versionIri == null) ? "" : ("/" + versionIri.toString())));
-            return entry;
-        }
-
-        /**
          * Creates an {@link OWLOntologyID} object by combining the ontologyIRI and the versionIRI, where
          * applicable, of the stored graph.
          * 
@@ -192,6 +176,22 @@ public class ClerezzaOntologyProvider im
             else return new OWLOntologyID(oiri, viri);
         }
 
+        /**
+         * Creates an {@link UriRef} out of an {@link OWLOntologyID}, so it can be used as a storage key for
+         * the graph.
+         * 
+         * @param ontologyReference
+         * @return
+         */
+        private UriRef buildResource(OWLOntologyID ontologyReference) {
+            // The UriRef is of the form ontologyIRI[/versionIRI] (TODO use something less conventional?)
+            IRI ontologyIRI = ontologyReference.getOntologyIRI(), versionIri = ontologyReference
+                    .getVersionIRI();
+            UriRef entry = new UriRef(ontologyIRI.toString()
+                                      + ((versionIri == null) ? "" : ("/" + versionIri.toString())));
+            return entry;
+        }
+
         void clearMappings() {
             graph.clear();
         }
@@ -244,6 +244,8 @@ public class ClerezzaOntologyProvider im
 
     private static final ImportManagementPolicy _IMPORT_POLICY_DEFAULT = ImportManagementPolicy.PRESERVE;
 
+    private static final String _META_GRAPH_ID_DEFAULT = "org.apache.stanbol.ontologymanager.ontonet";
+
     private static final boolean _RESOLVE_IMPORTS_DEFAULT = true;
 
     @Property(name = OntologyProvider.IMPORT_POLICY, options = {
@@ -268,6 +270,9 @@ public class ClerezzaOntologyProvider im
 
     private List<OWLOntologyIRIMapper> mappers = new ArrayList<OWLOntologyIRIMapper>();
 
+    @Property(name = OntologyProvider.META_GRAPH_ID, value = _META_GRAPH_ID_DEFAULT)
+    protected String metaGraphId = _META_GRAPH_ID_DEFAULT;
+
     @Reference
     private OfflineConfiguration offlineConfig;
 
@@ -344,6 +349,11 @@ public class ClerezzaOntologyProvider im
         // Check if the TcManager should be set as the store
         if (store == null) store = tcManager;
 
+        // Parse configuration.
+        metaGraphId = (String) (configuration.get(OntologyProvider.META_GRAPH_ID));
+        if (metaGraphId == null) metaGraphId = _META_GRAPH_ID_DEFAULT; // Should be already assigned though
+
+        // This call will also create the metadata graph.
         keymap = new OntologyToTcMapper();
 
         // Parse configuration.
@@ -463,6 +473,14 @@ public class ClerezzaOntologyProvider im
         return keymap.stringValues();
     }
 
+    @SuppressWarnings("unchecked")
+    @Override
+    public <O extends TripleCollection> O getMetaGraph(Class<O> returnType) {
+        if (!TripleCollection.class.isAssignableFrom(returnType)) throw new IllegalArgumentException(
+                "Only subtypes of " + TripleCollection.class + " are allowed.");
+        return (O) store.getTriples(new UriRef(metaGraphId));
+    }
+
     @Override
     public TcProvider getStore() {
         return store;
@@ -535,6 +553,11 @@ public class ClerezzaOntologyProvider im
     }
 
     @Override
+    public boolean hasOntology(IRI ontologyIri) {
+        return hasOntology(new OWLOntologyID(ontologyIri));
+    }
+
+    @Override
     public boolean hasOntology(OWLOntologyID id) {
         if (id == null || id.isAnonymous()) throw new IllegalArgumentException(
                 "Cannot check for an anonymous ontology.");
@@ -879,8 +902,4 @@ public class ClerezzaOntologyProvider im
         }
     }
 
-    @Override
-    public boolean hasOntology(IRI ontologyIri) {
-        return hasOntology(new OWLOntologyID(ontologyIri));
-    }
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/OntologySpaceFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/OntologySpaceFactoryImpl.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/OntologySpaceFactoryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/OntologySpaceFactoryImpl.java Wed Apr  4 13:48:12 2012
@@ -16,20 +16,24 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.impl.clerezza;
 
+import java.io.IOException;
+import java.util.Dictionary;
+
 import org.apache.clerezza.rdf.core.access.TcProvider;
-import org.apache.stanbol.ontologymanager.ontonet.api.OfflineConfiguration;
-import org.apache.stanbol.ontologymanager.ontonet.api.collector.OntologyCollectorListener;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.UnmodifiableOntologyCollectorException;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.CoreOntologySpace;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.CustomOntologySpace;
-import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScope;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpace;
-import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpaceFactory;
-import org.apache.stanbol.ontologymanager.ontonet.api.scope.ScopeRegistry;
-import org.apache.stanbol.ontologymanager.ontonet.api.scope.SessionOntologySpace;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpace.SpaceType;
+import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpaceFactory;
+import org.osgi.service.component.ComponentContext;
 import org.semanticweb.owlapi.model.IRI;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -40,26 +44,54 @@ import org.slf4j.LoggerFactory;
  * @author alexdma
  * 
  */
+@Component(immediate = true, metatype = false)
+@Service(OntologySpaceFactory.class)
 public class OntologySpaceFactoryImpl implements OntologySpaceFactory {
 
     protected Logger log = LoggerFactory.getLogger(getClass());
 
     protected IRI namespace;
 
-    protected OfflineConfiguration offline;
+    @Reference
+    private OntologyProvider<TcProvider> ontologyProvider;
 
-    protected ScopeRegistry registry;
+    public OntologySpaceFactoryImpl() {
+        super();
+    };
+
+    public OntologySpaceFactoryImpl(OntologyProvider<TcProvider> provider,
+                                    Dictionary<String,Object> configuration) {
+        this.ontologyProvider = provider;
+        try {
+            activate(configuration);
+        } catch (IOException e) {
+            log.error("Unable to access servlet context.", e);
+        }
+    }
 
-    protected OntologyProvider<TcProvider> provider;
+    /**
+     * Used to configure an instance within an OSGi container.
+     * 
+     * @throws IOException
+     */
+    @SuppressWarnings("unchecked")
+    @Activate
+    protected void activate(ComponentContext context) throws IOException {
+        log.info("in " + OntologySpaceFactoryImpl.class + " activate with context " + context);
+        if (context == null) {
+            throw new IllegalStateException("No valid" + ComponentContext.class + " parsed in activate!");
+        }
+        activate((Dictionary<String,Object>) context.getProperties());
+    }
 
-    public OntologySpaceFactoryImpl(ScopeRegistry registry,
-                                    OntologyProvider<TcProvider> provider,
-                                    OfflineConfiguration offline,
-                                    IRI namespace) {
-        this.registry = registry;
-        this.provider = provider;
-        this.offline = offline;
-        this.namespace = namespace;
+    /**
+     * Called within both OSGi and non-OSGi environments.
+     * 
+     * @param configuration
+     * @throws IOException
+     */
+    protected void activate(Dictionary<String,Object> configuration) throws IOException {
+        log.debug(OntologySpaceFactoryImpl.class + " activated.");
     }
 
     /**
@@ -70,11 +102,11 @@ public class OntologySpaceFactoryImpl im
      * @param rootSource
      */
     private void configureSpace(OntologySpace s, String scopeID, OntologyInputSource<?,?>... ontologySources) {
-        // FIXME: ensure that this is not null AND convert to using Strings for scope IDs
-        OntologyScope parentScope = registry.getScope(scopeID);
-
-        if (parentScope != null && parentScope instanceof OntologyCollectorListener) s
-                .addListener((OntologyCollectorListener) parentScope);
+        // // FIXME: ensure that this is not null AND convert to using Strings for scope IDs
+        // OntologyScope parentScope = registry.getScope(scopeID);
+        //
+        // if (parentScope != null && parentScope instanceof OntologyCollectorListener) s
+        // .addListener((OntologyCollectorListener) parentScope);
         // Set the supplied ontology's parent as the root for this space.
         if (ontologySources != null) try {
             for (OntologyInputSource<?,?> src : ontologySources)
@@ -87,7 +119,7 @@ public class OntologySpaceFactoryImpl im
 
     @Override
     public CoreOntologySpace createCoreOntologySpace(String scopeId, OntologyInputSource<?,?>... coreSources) {
-        CoreOntologySpace s = new CoreOntologySpaceImpl(scopeId, namespace, provider);
+        CoreOntologySpace s = new CoreOntologySpaceImpl(scopeId, namespace, ontologyProvider);
         configureSpace(s, scopeId, coreSources);
         return s;
     }
@@ -95,7 +127,7 @@ public class OntologySpaceFactoryImpl im
     @Override
     public CustomOntologySpace createCustomOntologySpace(String scopeId,
                                                          OntologyInputSource<?,?>... customSources) {
-        CustomOntologySpace s = new CustomOntologySpaceImpl(scopeId, namespace, provider);
+        CustomOntologySpace s = new CustomOntologySpaceImpl(scopeId, namespace, ontologyProvider);
         configureSpace(s, scopeId, customSources);
         return s;
     }
@@ -109,21 +141,23 @@ public class OntologySpaceFactoryImpl im
                 return createCoreOntologySpace(scopeId, ontologySources);
             case CUSTOM:
                 return createCustomOntologySpace(scopeId, ontologySources);
-            case SESSION:
-                // return createSessionOntologySpace(scopeId, ontologySources);
-                throw new IllegalArgumentException("Factory " + getClass()
-                                                   + "cannot create obsolete session spaces.");
             default:
                 return null;
         }
     }
 
+    /**
+     * Deactivation of the ONManagerImpl resets all its resources.
+     */
+    @Deactivate
+    protected void deactivate(ComponentContext context) {
+        namespace = null;
+        log.info("in " + OntologySpaceFactoryImpl.class + " deactivate with context " + context);
+    }
+
     @Override
-    public SessionOntologySpace createSessionOntologySpace(String scopeId,
-                                                           OntologyInputSource<?,?>... sessionSources) {
-        throw new UnsupportedOperationException(
-                "Newer ontology space factory implementations such as " + getClass()
-                        + " no longer allow the creation of session spaces. Please store data in sessions");
+    public String getID() {
+        return this.toString();
     }
 
     @Override
@@ -136,9 +170,4 @@ public class OntologySpaceFactoryImpl im
         this.namespace = namespace;
     }
 
-    @Override
-    public String getID() {
-        return this.toString();
-    }
-
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java Wed Apr  4 13:48:12 2012
@@ -17,12 +17,10 @@
 package org.apache.stanbol.ontologymanager.ontonet.impl.ontology;
 
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import org.apache.clerezza.rdf.core.Graph;
@@ -45,7 +43,6 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpace;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpaceFactory;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.ScopeOntologyListener;
-import org.apache.stanbol.ontologymanager.ontonet.api.scope.SessionOntologySpace;
 import org.semanticweb.owlapi.apibinding.OWLManager;
 import org.semanticweb.owlapi.model.AddImport;
 import org.semanticweb.owlapi.model.IRI;
@@ -94,11 +91,6 @@ public class OntologyScopeImpl implement
 
     protected IRI namespace = null;
 
-    /**
-     * Maps session IDs to ontology space. A single scope has at most one space per session.
-     */
-    protected Map<String,SessionOntologySpace> sessionSpaces;
-
     public OntologyScopeImpl(String id,
                              IRI namespace,
                              OntologySpaceFactory factory,
@@ -123,8 +115,6 @@ public class OntologyScopeImpl implement
                 e);
         }
         this.customSpace.addListener(this);
-
-        sessionSpaces = new HashMap<String,SessionOntologySpace>();
     }
 
     @Override
@@ -133,24 +123,6 @@ public class OntologyScopeImpl implement
     }
 
     @Override
-    public synchronized void addSessionSpace(OntologySpace sessionSpace, String sessionId) throws UnmodifiableOntologyCollectorException {
-        if (sessionSpace instanceof SessionOntologySpace) {
-            sessionSpaces.put(sessionId, (SessionOntologySpace) sessionSpace);
-            sessionSpace.addListener(this);
-
-            if (this.getCustomSpace() != null) ((SessionOntologySpace) sessionSpace).attachSpace(
-                this.getCustomSpace(), true);
-            else ((SessionOntologySpace) sessionSpace).attachSpace(this.getCoreSpace(), true);
-
-        }
-    }
-
-    @Override
-    public OWLOntology asOWLOntology(boolean merge) {
-        return export(OWLOntology.class, merge);
-    }
-
-    @Override
     public void clearOntologyScopeListeners() {
         listeners.clear();
     }
@@ -293,13 +265,13 @@ public class OntologyScopeImpl implement
                 List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
                 // Add the import statement for the custom space, if existing and not empty
                 OntologySpace spc = getCustomSpace();
-                if (spc != null && spc.getOntologyCount(false) > 0) {
+                if (spc != null && spc.listManagedOntologies().size() > 0) {
                     IRI spaceIri = IRI.create(getNamespace() + spc.getID());
                     additions.add(new AddImport(ont, df.getOWLImportsDeclaration(spaceIri)));
                 }
                 // Add the import statement for the core space, if existing and not empty
                 spc = getCoreSpace();
-                if (spc != null && spc.getOntologyCount(false) > 0) {
+                if (spc != null && spc.listManagedOntologies().size() > 0) {
                     IRI spaceIri = IRI.create(getNamespace() + spc.getID());
                     additions.add(new AddImport(ont, df.getOWLImportsDeclaration(spaceIri)));
                 }
@@ -353,16 +325,6 @@ public class OntologyScopeImpl implement
     }
 
     @Override
-    public SessionOntologySpace getSessionSpace(String sessionID) {
-        return sessionSpaces.get(sessionID);
-    }
-
-    @Override
-    public Set<OntologySpace> getSessionSpaces() {
-        return new HashSet<OntologySpace>(sessionSpaces.values());
-    }
-
-    @Override
     public boolean isLocked() {
         return locked;
     }
@@ -445,11 +407,6 @@ public class OntologyScopeImpl implement
     }
 
     @Override
-    public void synchronizeSpaces() {
-        // TODO Auto-generated method stub
-    }
-
-    @Override
     public synchronized void tearDown() {
         // this.coreSpace.addOntologySpaceListener(this);
         this.coreSpace.tearDown();

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/ScopeRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/ScopeRegistryImpl.java?rev=1309382&r1=1309381&r2=1309382&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/ScopeRegistryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/ScopeRegistryImpl.java Wed Apr  4 13:48:12 2012
@@ -46,49 +46,24 @@ public class ScopeRegistryImpl implement
         scopeListeners = new HashSet<ScopeEventListener>();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * eu.iksproject.kres.api.manager.ontology.ScopeRegistry#addScopeRegistrationListener(eu.iksproject.kres
-     * .api.manager.ontology.ScopeEventListener)
-     */
     @Override
     public void addScopeRegistrationListener(ScopeEventListener listener) {
         scopeListeners.add(listener);
 
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.ScopeRegistry#clearScopeRegistrationListeners()
-     */
     @Override
     public void clearScopeRegistrationListeners() {
         scopeListeners.clear();
 
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * eu.iksproject.kres.api.manager.ontology.ScopeRegistry#containsScope(org.semanticweb.owlapi.model.IRI)
-     */
     @Override
     public boolean containsScope(String scopeID) {
         // containsKey() is not reliable enough
         return scopeMap.get(scopeID) != null;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * eu.iksproject.kres.api.manager.ontology.ScopeRegistry#deregisterScope(eu.iksproject.kres.api.manager
-     * .ontology.OntologyScope)
-     */
     @Override
     public synchronized void deregisterScope(OntologyScope scope) {
         String id = scope.getID();