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 2011/07/21 16:58:54 UTC

svn commit: r1149208 [1/2] - in /incubator/stanbol/trunk: ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/ ontologymanag...

Author: alexdma
Date: Thu Jul 21 14:58:45 2011
New Revision: 1149208

URL: http://svn.apache.org/viewvc?rev=1149208&view=rev
Log:
STANBOL-285:
- Centralized registry population methods in RegistryManager
- Added exception and event model for loading registry resources (TODO actual loading not re-implemented yet, still using old RegistryLoader)
- ONManagerImpl now takes a RegistryManager as a constructor argument. This is probably temporary and might be removed once the old RegistryLoader is decommissioned.
- Adapted other Stanbol unit tests to invoke updated ONManager constructor

Added:
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/LibraryContentNotLoadedException.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentException.java
      - copied, changed from r1149065, incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryContentException.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentListener.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOntologyNotLoadedException.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/registry/TestOntologyRegistry.java
      - copied, changed from r1149065, incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/registry/TestRegistry.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/resources/ontologies/registry/onmtest_additions.owl
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/resources/ontologies/test1.owl
Removed:
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryContentException.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/registry/TestRegistry.java
Modified:
    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/registry/RegistryLoader.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryManager.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Library.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.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/registry/RegistryLoaderImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryManagerImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/cache/RegistryUtils.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/AbstractRegistryItem.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/LibraryImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryOntologyImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/Locations.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOntologyInputSources.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestIndexing.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/registry/TestOntologyLibrary.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/session/TestSessions.java
    incubator/stanbol/trunk/reengineer/db/src/test/java/org/apache/stanbol/reengineer/db/DBExtractorTest.java
    incubator/stanbol/trunk/reengineer/xml/src/test/java/org/apache/stanbol/reengineer/xml/XMLReengineerTest.java
    incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/AddRecipeTest.java
    incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/AddRuleTest.java
    incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/GetRecipeTest.java
    incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/GetRuleTest.java
    incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/LoadRuleFileTest.java
    incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/RemoveRecipeTest.java
    incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/RemoveRuleTest.java
    incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/RuleStoreTest.java
    incubator/stanbol/trunk/rules/refactor/src/test/java/org/apache/stanbol/rules/refactor/RefactoringTest.java

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=1149208&r1=1149207&r2=1149208&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 Thu Jul 21 14:58:45 2011
@@ -1,19 +1,19 @@
 /*
-* 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.
-*/
+ * 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;
 
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyIndex;
@@ -21,6 +21,7 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpaceFactory;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.ScopeRegistry;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryLoader;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryManager;
 import org.apache.stanbol.ontologymanager.ontonet.api.session.SessionManager;
 import org.apache.stanbol.ontologymanager.ontonet.impl.io.ClerezzaOntologyStorage;
 import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.OWLOntologyManagerFactoryImpl;
@@ -38,28 +39,35 @@ import org.semanticweb.owlapi.model.OWLO
  */
 public interface ONManager {
 
-    public OWLOntologyManagerFactoryImpl getOntologyManagerFactory();
+    /**
+     * Returns the String that represent the namespace used by KReS for its ontologies
+     * 
+     * @return the namespace of KReS.
+     */
+    String getKReSNamespace();
 
     /**
      * Returns the default object that automatically indexes ontologies as they are loaded within scopes.
      * 
      * @return the default ontology index.
      */
-    public OntologyIndex getOntologyIndex();
+    OntologyIndex getOntologyIndex();
+
+    OWLOntologyManagerFactoryImpl getOntologyManagerFactory();
 
     /**
      * Returns the ontology scope factory that was created along with the manager context.
      * 
      * @return the default ontology scope factory
      */
-    public OntologyScopeFactory getOntologyScopeFactory();
+    OntologyScopeFactory getOntologyScopeFactory();
 
     /**
      * Returns the ontology space factory that was created along with the manager context.
      * 
      * @return the default ontology space factory.
      */
-    public OntologySpaceFactory getOntologySpaceFactory();
+    OntologySpaceFactory getOntologySpaceFactory();
 
     /**
      * Returns the default ontology storage system for this KReS instance.
@@ -67,7 +75,7 @@ public interface ONManager {
      * @return the default ontology store.
      */
 
-    public ClerezzaOntologyStorage getOntologyStore();
+    ClerezzaOntologyStorage getOntologyStore();
 
     /**
      * Returns an OWL Ontology Manager that is never cleared of its ontologies, so it can be used for caching
@@ -76,35 +84,37 @@ public interface ONManager {
      * 
      * @return the OWL Ontology Manager used for caching ontologies.
      */
-    public OWLOntologyManager getOwlCacheManager();
+    OWLOntologyManager getOwlCacheManager();
 
     /**
      * Returns a factory object that can be used for obtaining OWL API objects.
      * 
      * @return the default OWL data factory
      */
-    public OWLDataFactory getOwlFactory();
+    OWLDataFactory getOwlFactory();
 
     /**
      * Returns the default ontology registry loader.
      * 
      * @return the default ontology registry loader.
      */
-    public RegistryLoader getRegistryLoader();
+    RegistryLoader getRegistryLoader();
+
+    RegistryManager getRegistryManager();
 
     /**
      * Returns the unique ontology scope registry for this context.
      * 
      * @return the ontology scope registry.
      */
-    public ScopeRegistry getScopeRegistry();
+    ScopeRegistry getScopeRegistry();
 
     /**
      * Returns the unique KReS session manager for this context.
      * 
      * @return the KreS session manager.
      */
-    public SessionManager getSessionManager();
+    SessionManager getSessionManager();
 
     /**
      * Returns the list of IRIs that identify scopes that should be activated on startup, <i>if they
@@ -112,12 +122,5 @@ public interface ONManager {
      * 
      * @return the list of scope IDs to activate.
      */
-    public String[] getUrisToActivate();
-
-    /**
-     * Returns the String that represent the namespace used by KReS for its ontologies
-     * 
-     * @return the namespace of KReS.
-     */
-    public String getKReSNamespace();
+    String[] getUrisToActivate();
 }

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/LibraryContentNotLoadedException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/LibraryContentNotLoadedException.java?rev=1149208&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/LibraryContentNotLoadedException.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/LibraryContentNotLoadedException.java Thu Jul 21 14:58:45 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.registry;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
+
+/**
+ * Thrown whenever there is a request for the contents of an ontology library which have not been loaded yet
+ * (e.g. due to lazy loading policies). Developers who catch this exception may, for example, decide to load
+ * the library contents.
+ */
+public class LibraryContentNotLoadedException extends RegistryContentException {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 4442769260608567120L;
+
+    /**
+     * Creates a new instance of {@link LibraryContentNotLoadedException}.
+     * 
+     * @param library
+     *            the ontology library that caused the exception.
+     */
+    public LibraryContentNotLoadedException(Library library) {
+        super(library.toString());
+        this.library = library;
+    }
+
+    private Library library;
+
+    /**
+     * Returns the library whose content was requested that is not loaded yet.
+     * 
+     * @return the ontology library that caused the exception.
+     */
+    public Library getLibrary() {
+        return library;
+    }
+
+}

Copied: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentException.java (from r1149065, incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryContentException.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentException.java?p2=incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentException.java&p1=incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryContentException.java&r1=1149065&r2=1149208&rev=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryContentException.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentException.java Thu Jul 21 14:58:45 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
+package org.apache.stanbol.ontologymanager.ontonet.api.registry;
 
 public class RegistryContentException extends Exception {
 

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentListener.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentListener.java?rev=1149208&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentListener.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentListener.java Thu Jul 21 14:58:45 2011
@@ -0,0 +1,25 @@
+/*
+ * 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.registry;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
+
+public interface RegistryContentListener {
+
+    void registryContentRequested(RegistryItem requestTarget);
+
+}

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java Thu Jul 21 14:58:45 2011
@@ -20,7 +20,6 @@ import java.util.Set;
 
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
-import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryContentException;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
 import org.semanticweb.owlapi.model.IRI;
 import org.semanticweb.owlapi.model.OWLOntology;

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryManager.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryManager.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryManager.java Thu Jul 21 14:58:45 2011
@@ -20,13 +20,16 @@ import java.util.Set;
 
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryOntology;
 import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLNamedIndividual;
+import org.semanticweb.owlapi.model.OWLOntology;
 
 /**
  * Replacement for {@link RegistryLoader}. Also indexes libraries (and ontologies?).
  */
 public interface RegistryManager {
-    
+
     public String CACHING_POLICY = "org.apache.stanbol.ontologymanager.ontonet.registryCaching";
 
     public String LAZY_LOADING = "org.apache.stanbol.ontologymanager.ontonet.registryLazy";
@@ -47,6 +50,12 @@ public interface RegistryManager {
 
     boolean isLazyLoading();
 
+    Library populateLibrary(OWLNamedIndividual ind, Set<OWLOntology> registries) throws RegistryContentException;
+
+    RegistryOntology populateOntology(OWLNamedIndividual ind, Set<OWLOntology> registries) throws RegistryContentException;
+
+    Registry populateRegistry(OWLOntology registry) throws RegistryContentException;
+
     void removeRegistry(IRI registryId);
 
     void setLazyLoading(boolean lazy);

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOntologyNotLoadedException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOntologyNotLoadedException.java?rev=1149208&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOntologyNotLoadedException.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOntologyNotLoadedException.java Thu Jul 21 14:58:45 2011
@@ -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.registry;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryOntology;
+
+public class RegistryOntologyNotLoadedException extends RegistryContentException {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 6336128674251128796L;
+
+    private RegistryOntology ontology;
+
+    public RegistryOntologyNotLoadedException(RegistryOntology ontology) {
+        super(ontology.getName());
+        this.ontology = ontology;
+    }
+
+    public RegistryOntology getOntology() {
+        return ontology;
+    }
+
+}

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Library.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Library.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Library.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Library.java Thu Jul 21 14:58:45 2011
@@ -16,6 +16,28 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
 
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentException;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
 public interface Library extends RegistryItem {
 
+    final Type type = Type.LIBRARY;
+
+    /**
+     * Upon invocation, this method immediately fires a registry content request event on itself. Note,
+     * however, that this method is in general not synchronized. Therefore, any listeners that react by
+     * invoking a load method may or may not cause the content to be available to this method.
+     * 
+     * @return
+     * @throws RegistryContentException
+     */
+    Set<OWLOntology> getOntologies() throws RegistryContentException;
+
+    boolean isLoaded();
+
+    void loadOntologies(OWLOntologyManager mgr);
+
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java Thu Jul 21 14:58:45 2011
@@ -16,9 +16,24 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
 
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
 /**
  * An ontology registry can reference zero or more ontology libraries.
  */
 public interface Registry extends RegistryItem {
 
+    final Type type = Type.REGISTRY;
+
+    /**
+     * 
+     * @return
+     */
+    OWLOntologyManager getCache();
+
+    /**
+     * 
+     * @param cache
+     */
+    void setCache(OWLOntologyManager cache);
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java Thu Jul 21 14:58:45 2011
@@ -18,6 +18,10 @@ package org.apache.stanbol.ontologymanag
 
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentException;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentListener;
 
 public interface RegistryItem {
 
@@ -32,13 +36,23 @@ public interface RegistryItem {
 
     void addChild(RegistryItem child) throws RegistryContentException;
 
+    void addContainer(RegistryItem container) throws RegistryContentException;
+
+    void addRegistryContentListener(RegistryContentListener listener);
+
     void clearChildren();
 
+    void clearRegistryContentListeners();
+
     RegistryItem[] getChildren();
 
+    RegistryItem[] getContainers();
+
     String getName();
 
-    RegistryItem[] getContainers();
+    Set<RegistryContentListener> getRegistryContentListeners();
+
+    Type getType();
 
     URL getURL();
 
@@ -49,12 +63,12 @@ public interface RegistryItem {
     boolean isOntology();
 
     void removeChild(RegistryItem child);
-    
+
     void removeContainer(RegistryItem container);
 
+    void removeRegistryContentListener(RegistryContentListener listener);
+
     void setName(String string);
-    
-    void addContainer(RegistryItem container) throws RegistryContentException;
 
     void setURL(URL url) throws URISyntaxException;
 

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java Thu Jul 21 14:58:45 2011
@@ -20,6 +20,10 @@ import org.semanticweb.owlapi.model.OWLO
 
 public interface RegistryOntology extends RegistryItem {
 
+    final Type type = Type.ONTOLOGY;
+    
     OWLOntology asOWLOntology();
+    
+    void setOWLOntology(OWLOntology owl);
 
 }

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=1149208&r1=1149207&r2=1149208&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 Thu Jul 21 14:58:45 2011
@@ -49,6 +49,7 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpaceFactory;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.ScopeRegistry;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.UnmodifiableOntologySpaceException;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryManager;
 import org.apache.stanbol.ontologymanager.ontonet.api.session.SessionManager;
 import org.apache.stanbol.ontologymanager.ontonet.conf.OntologyNetworkConfigurationUtils;
 import org.apache.stanbol.ontologymanager.ontonet.impl.io.ClerezzaOntologyStorage;
@@ -133,6 +134,9 @@ public class ONManagerImpl implements ON
 
     @Reference
     private ONManagerConfiguration config;
+    
+    @Reference
+    private RegistryManager regman;
 
     private Helper helper = null;
 
@@ -205,9 +209,9 @@ public class ONManagerImpl implements ON
      * @param configuration
      */
     @Deprecated
-    public ONManagerImpl(TcManager tcm, WeightedTcProvider wtcp, Dictionary<String,Object> configuration) {
+    public ONManagerImpl(TcManager tcm, WeightedTcProvider wtcp, RegistryManager registryManager, Dictionary<String,Object> configuration) {
         // Copy the same configuration to the ONManagerConfigurationImpl.
-        this(tcm, wtcp, new ONManagerConfigurationImpl(configuration), configuration);
+        this(tcm, wtcp, new ONManagerConfigurationImpl(configuration), registryManager, configuration);
     }
 
     /**
@@ -225,12 +229,14 @@ public class ONManagerImpl implements ON
     public ONManagerImpl(TcManager tcm,
                          WeightedTcProvider wtcp,
                          ONManagerConfiguration onmconfig,
+                         RegistryManager registryManager,
                          Dictionary<String,Object> configuration) {
         this();
         // Assume this.tcm this.wtcp and this.wtcp were not filled in by OSGi-DS.
         this.tcm = tcm;
         this.wtcp = wtcp;
         this.config = onmconfig;
+        this.regman = registryManager;
         try {
             activate(configuration);
         } catch (IOException e) {
@@ -576,4 +582,9 @@ public class ONManagerImpl implements ON
     protected final boolean isOfflineMode() {
         return offlineMode != null;
     }
+
+    @Override
+    public RegistryManager getRegistryManager() {
+        return regman;
+    }
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryLoaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryLoaderImpl.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryLoaderImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryLoaderImpl.java Thu Jul 21 14:58:45 2011
@@ -31,10 +31,11 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentException;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryLoader;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryManager;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
-import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryContentException;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
 import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.OWLOntologyManagerFactoryImpl;
 import org.apache.stanbol.ontologymanager.ontonet.impl.registry.cache.ODPRegistryCacheException;
@@ -397,7 +398,7 @@ public class RegistryLoaderImpl implemen
         OWLOntologyManager mgr = onm.getOwlCacheManager();
         try {
             OWLOntology ontology = mgr.loadOntology(registryPhysicalIRI);
-            registry = RegistryUtils.populateRegistry(ontology);
+            registry = onm.getRegistryManager().populateRegistry(ontology);
         } catch (OWLOntologyDocumentAlreadyExistsException e) {
             log.warn("Ontology document at " + e.getOntologyDocumentIRI()
                      + " exists and will not be reloaded.", e);
@@ -508,7 +509,7 @@ public class RegistryLoaderImpl implemen
         if (mgr == null) mgr = onm.getOwlCacheManager();
         try {
             OWLOntology ontology = mgr.loadOntology(registryPhysicalIRI);
-            registry = RegistryUtils.populateRegistry(ontology);
+            registry = onm.getRegistryManager().populateRegistry(ontology);
         } catch (OWLOntologyDocumentAlreadyExistsException e) {
             log.warn("Ontology document at " + e.getOntologyDocumentIRI()
                      + " exists and will not be reloaded.", e);

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryManagerImpl.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryManagerImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryManagerImpl.java Thu Jul 21 14:58:45 2011
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -30,12 +31,24 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.PropertyOption;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentException;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryItemFactory;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryManager;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem.Type;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryOntology;
+import org.apache.stanbol.ontologymanager.ontonet.impl.registry.cache.RegistryUtils;
+import org.apache.stanbol.ontologymanager.ontonet.xd.vocabulary.CODOVocabulary;
 import org.osgi.service.component.ComponentContext;
 import org.semanticweb.owlapi.apibinding.OWLManager;
 import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLClass;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLIndividual;
+import org.semanticweb.owlapi.model.OWLNamedIndividual;
+import org.semanticweb.owlapi.model.OWLObjectProperty;
 import org.semanticweb.owlapi.model.OWLOntology;
 import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException;
 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
@@ -49,6 +62,29 @@ public class RegistryManagerImpl impleme
 
     private static final boolean _LAZY_LOADING_DEFAULT = false;
 
+    private static final OWLClass cRegistryLibrary, cOntology;
+
+    private static final OWLObjectProperty hasPart, hasOntology, isPartOf, isOntologyOf;
+
+    static {
+        OWLDataFactory factory = OWLManager.getOWLDataFactory();
+        cOntology = factory.getOWLClass(IRI.create(CODOVocabulary.CODK_Ontology));
+        cRegistryLibrary = factory.getOWLClass(IRI.create(CODOVocabulary.CODD_OntologyLibrary));
+        isPartOf = factory.getOWLObjectProperty(IRI.create(CODOVocabulary.PARTOF_IsPartOf));
+        isOntologyOf = factory.getOWLObjectProperty(IRI.create(CODOVocabulary.ODPM_IsOntologyOf));
+        hasPart = factory.getOWLObjectProperty(IRI.create(CODOVocabulary.PARTOF_HasPart));
+        hasOntology = factory.getOWLObjectProperty(IRI.create(CODOVocabulary.ODPM_HasOntology));
+    }
+
+    @Property(name = RegistryManager.CACHING_POLICY, options = {
+                                                                @PropertyOption(value = '%'
+                                                                                        + RegistryManager.CACHING_POLICY
+                                                                                        + ".option.registry", name = "registry"),
+                                                                @PropertyOption(value = '%'
+                                                                                        + RegistryManager.CACHING_POLICY
+                                                                                        + ".option.all", name = "all")}, value = "all")
+    private String cachingPolicyString;
+
     @Property(name = RegistryManager.LAZY_LOADING, boolValue = _LAZY_LOADING_DEFAULT)
     private boolean lazyLoading = _LAZY_LOADING_DEFAULT;
 
@@ -61,16 +97,11 @@ public class RegistryManagerImpl impleme
 
     private Map<IRI,Set<IRI>> ontologyIndex = new HashMap<IRI,Set<IRI>>();
 
+    private Map<IRI,RegistryItem> population = new TreeMap<IRI,RegistryItem>();
+
     private Map<IRI,Registry> registries = new HashMap<IRI,Registry>();
 
-    @Property(name = RegistryManager.CACHING_POLICY, options = {
-                                                                @PropertyOption(value = '%'
-                                                                                        + RegistryManager.CACHING_POLICY
-                                                                                        + ".option.registry", name = "registry"),
-                                                                @PropertyOption(value = '%'
-                                                                                        + RegistryManager.CACHING_POLICY
-                                                                                        + ".option.all", name = "all")}, value = "all")
-    private String cachingPolicyString;
+    private RegistryItemFactory riFactory;
 
     /**
      * This default constructor is <b>only</b> intended to be used by the OSGI environment with Service
@@ -80,7 +111,9 @@ public class RegistryManagerImpl impleme
      * YOU NEED TO USE {@link #RegistryManagerImpl(Dictionary)} or its overloads, to parse the configuration
      * and then initialise the rule store if running outside an OSGI environment.
      */
-    public RegistryManagerImpl() {}
+    public RegistryManagerImpl() {
+        riFactory = new RegistryItemFactoryImpl();
+    }
 
     /**
      * To be invoked by non-OSGi environments.
@@ -112,7 +145,7 @@ public class RegistryManagerImpl impleme
         locations = (String[]) configuration.get(RegistryManager.REGISTRY_LOCATIONS);
         if (locations == null) locations = new String[] {};
         // TODO manage enum constants for caching policy.
-        
+
         OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
         // Load registries
         for (String loc : locations) {
@@ -179,6 +212,96 @@ public class RegistryManagerImpl impleme
         return lazyLoading;
     }
 
+    public Library populateLibrary(OWLNamedIndividual ind, Set<OWLOntology> registries) throws RegistryContentException {
+        IRI id = ind.getIRI();
+        RegistryItem lib = null;
+        if (population.containsKey(id)) {
+            // We are not allowing multityping either.
+            lib = population.get(id);
+            if (!(lib instanceof Library)) throw new RegistryContentException(
+                    "Inconsistent multityping: for item " + id + " : {" + Library.class + ", "
+                            + lib.getClass() + "}");
+        } else {
+            lib = riFactory.createLibrary(ind.asOWLNamedIndividual());
+            try {
+                population.put(IRI.create(lib.getURL()), lib);
+            } catch (URISyntaxException e) {
+                log.error("Invalid identifier for library item " + lib, e);
+                return null;
+            }
+        }
+        // EXIT nodes.
+        Set<OWLIndividual> ronts = new HashSet<OWLIndividual>();
+        for (OWLOntology o : registries)
+            ronts.addAll(ind.getObjectPropertyValues(hasOntology, o));
+        for (OWLIndividual iont : ronts) {
+            if (iont.isNamed()) lib.addChild(populateOntology(iont.asOWLNamedIndividual(), registries));
+        }
+        return (Library) lib;
+    }
+
+    public RegistryOntology populateOntology(OWLNamedIndividual ind, Set<OWLOntology> registries) throws RegistryContentException {
+        IRI id = ind.getIRI();
+        RegistryItem ront = null;
+        if (population.containsKey(id)) {
+            // We are not allowing multityping either.
+            ront = population.get(id);
+            if (!(ront instanceof RegistryOntology)) throw new RegistryContentException(
+                    "Inconsistent multityping: for item " + id + " : {" + RegistryOntology.class + ", "
+                            + ront.getClass() + "}");
+        } else {
+            ront = riFactory.createRegistryOntology(ind);
+            try {
+                population.put(IRI.create(ront.getURL()), ront);
+            } catch (URISyntaxException e) {
+                log.error("Invalid identifier for library item " + ront, e);
+                return null;
+            }
+        }
+        // EXIT nodes.
+        Set<OWLIndividual> libs = new HashSet<OWLIndividual>();
+        for (OWLOntology o : registries)
+            libs.addAll(ind.getObjectPropertyValues(isOntologyOf, o));
+        for (OWLIndividual ilib : libs) {
+            if (ilib.isNamed()) ront.addContainer(populateLibrary(ilib.asOWLNamedIndividual(), registries));
+        }
+        return (RegistryOntology) ront;
+    }
+
+    public Registry populateRegistry(OWLOntology registry) throws RegistryContentException {
+
+        Registry reg = riFactory.createRegistry(registry);
+        Set<OWLOntology> closure = registry.getOWLOntologyManager().getImportsClosure(registry);
+
+        // Just scan all individuals. Recurse in case the registry imports more registries.
+        for (OWLIndividual ind : registry.getIndividualsInSignature(true)) {
+            // We do not allow anonymous registry items.
+            if (ind.isAnonymous()) continue;
+            RegistryItem item = null;
+            // IRI id = ind.asOWLNamedIndividual().getIRI();
+            Type t = RegistryUtils.getType(ind, closure);
+            if (t == null) {
+                log.warn("Undetermined type for registry ontology individual {}", ind);
+                continue;
+            }
+            switch (t) {
+                case LIBRARY:
+                    // // Create the library and attach to parent and children
+                    item = populateLibrary(ind.asOWLNamedIndividual(), closure);
+                    reg.addChild(item);
+                    break;
+                case ONTOLOGY:
+                    // Create the ontology and attach to parent
+                    item = populateOntology(ind.asOWLNamedIndividual(), closure);
+                    // We don't know where to attach it to in this method.
+                    break;
+                default:
+                    break;
+            }
+        }
+        return reg;
+    }
+
     @Override
     public void removeRegistry(IRI registryId) {
         registries.remove(registryId);

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/cache/RegistryUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/cache/RegistryUtils.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/cache/RegistryUtils.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/cache/RegistryUtils.java Thu Jul 21 14:58:45 2011
@@ -22,10 +22,10 @@ import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
 
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentException;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryItemFactory;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
-import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryContentException;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem.Type;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryOntology;
@@ -47,10 +47,14 @@ public class RegistryUtils {
 
     private static final OWLClass cRegistryLibrary, cOntology;
 
-    private static RegistryItemFactory riFactory;
-
     private static final OWLObjectProperty hasPart, hasOntology, isPartOf, isOntologyOf;
 
+    private static Logger log = LoggerFactory.getLogger(RegistryUtils.class);
+
+    private static Map<IRI,RegistryItem> population = new TreeMap<IRI,RegistryItem>();
+
+    private static RegistryItemFactory riFactory;
+
     static {
         riFactory = new RegistryItemFactoryImpl();
         OWLDataFactory factory = OWLManager.getOWLDataFactory();
@@ -62,102 +66,34 @@ public class RegistryUtils {
         hasOntology = factory.getOWLObjectProperty(IRI.create(CODOVocabulary.ODPM_HasOntology));
     }
 
-    private static Logger log = LoggerFactory.getLogger(RegistryUtils.class);
-
-    private static Map<IRI,RegistryItem> population = new TreeMap<IRI,RegistryItem>();
-
-    public static Registry populateRegistry(OWLOntology registry) throws RegistryContentException {
-
-        Registry reg = riFactory.createRegistry(registry);
-        Set<OWLOntology> closure = registry.getOWLOntologyManager().getImportsClosure(registry);
-
-        // Just scan all individuals. Recurse in case the registry imports more registries.
-        for (OWLIndividual ind : registry.getIndividualsInSignature(true)) {
-            // We do not allow anonymous registry items.
-            if (ind.isAnonymous()) continue;
-            RegistryItem item = null;
-            // IRI id = ind.asOWLNamedIndividual().getIRI();
-            Type t = getType(ind, closure);
-            if (t==null) {
-                log.warn("Undetermined type for registry ontology individual {}",ind);
-                continue;
-            }
-            switch (getType(ind, closure)) {
-                case LIBRARY:
-                    // // Create the library and attach to parent and children
-                    item = populateLibrary(ind.asOWLNamedIndividual(), closure);
-                    reg.addChild(item);
-                    break;
-                case ONTOLOGY:
-                    // Create the ontology and attach to parent
-                    item = populateOntology(ind.asOWLNamedIndividual(), closure);
-                    // We don't know where to attach it to in this method.
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        population = new TreeMap<IRI,RegistryItem>();
-        return reg;
-    }
+    /**
+     * Utility method to recurse into registry items.
+     * 
+     * TODO: move this to main?
+     * 
+     * @param item
+     * @param ontologyId
+     * @return
+     */
+    public static boolean containsOntologyRecursive(RegistryItem item, IRI ontologyId) {
 
-    public static Library populateLibrary(OWLNamedIndividual ind, Set<OWLOntology> registries) throws RegistryContentException {
-        IRI id = ind.getIRI();
-        RegistryItem lib = null;
-        if (population.containsKey(id)) {
-            // We are not allowing multityping either.
-            lib = population.get(id);
-            if (!(lib instanceof Library)) throw new RegistryContentException(
-                    "Inconsistent multityping: for item " + id + " : {" + Library.class + ", "
-                            + lib.getClass() + "}");
-        } else {
-            lib = riFactory.createLibrary(ind.asOWLNamedIndividual());
+        boolean result = false;
+        if (item instanceof RegistryOntology) {
+            // An Ontology MUST have a non-null URI.
             try {
-                population.put(IRI.create(lib.getURL()), lib);
-            } catch (URISyntaxException e) {
-                log.error("Invalid identifier for library item " + lib, e);
-                return null;
+                IRI iri = IRI.create(item.getURL());
+                result |= iri.equals(ontologyId);
+            } catch (Exception e) {
+                return false;
             }
+        } else if (item instanceof Library || item instanceof Registry)
+        // Inspect children
+        for (RegistryItem child : ((RegistryItem) item).getChildren()) {
+            result |= containsOntologyRecursive(child, ontologyId);
+            if (result) break;
         }
-        // EXIT nodes.
-        Set<OWLIndividual> ronts = new HashSet<OWLIndividual>();
-        for (OWLOntology o : registries)
-            ronts.addAll(ind.getObjectPropertyValues(hasOntology, o));
-        for (OWLIndividual iont : ronts) {
-            if (iont.isNamed())
-                lib.addChild(populateOntology(iont.asOWLNamedIndividual(), registries));
-        }
-        return (Library) lib;
-    }
-    
-    public static RegistryOntology populateOntology(OWLNamedIndividual ind, Set<OWLOntology> registries) throws RegistryContentException {
-        IRI id = ind.getIRI();
-        RegistryItem ront = null;
-        if (population.containsKey(id)) {
-            // We are not allowing multityping either.
-            ront = population.get(id);
-            if (!(ront instanceof RegistryOntology)) throw new RegistryContentException(
-                    "Inconsistent multityping: for item " + id + " : {" + RegistryOntology.class + ", "
-                            + ront.getClass() + "}");
-        } else {
-            ront = riFactory.createRegistryOntology(ind);
-            try {
-                population.put(IRI.create(ront.getURL()), ront);
-            } catch (URISyntaxException e) {
-                log.error("Invalid identifier for library item " + ront, e);
-                return null;
-            }
-        }
-        // EXIT nodes.
-        Set<OWLIndividual> libs = new HashSet<OWLIndividual>();
-        for (OWLOntology o : registries)
-            libs.addAll(ind.getObjectPropertyValues(isOntologyOf, o));
-        for (OWLIndividual ilib : libs) {
-            if (ilib.isNamed())
-                ront.addContainer(populateLibrary(ilib.asOWLNamedIndividual(), registries));
-        }
-        return (RegistryOntology) ront;
+        return result;
+
     }
 
     /**
@@ -167,7 +103,7 @@ public class RegistryUtils {
      * @param o
      * @return
      */
-    private static Type getType(OWLIndividual ind, Set<OWLOntology> ontologies) {
+    public static Type getType(OWLIndividual ind, Set<OWLOntology> ontologies) {
         // TODO also use property values
         Set<OWLClassExpression> types = ind.getTypes(ontologies);
         if (types.contains(cOntology) && !types.contains(cRegistryLibrary))
@@ -176,5 +112,99 @@ public class RegistryUtils {
             return Type.LIBRARY;
         return null;
     }
+   
+//    public static Library populateLibrary(OWLNamedIndividual ind, Set<OWLOntology> registries) throws RegistryContentException {
+//        IRI id = ind.getIRI();
+//        RegistryItem lib = null;
+//        if (population.containsKey(id)) {
+//            // We are not allowing multityping either.
+//            lib = population.get(id);
+//            if (!(lib instanceof Library)) throw new RegistryContentException(
+//                    "Inconsistent multityping: for item " + id + " : {" + Library.class + ", "
+//                            + lib.getClass() + "}");
+//        } else {
+//            lib = riFactory.createLibrary(ind.asOWLNamedIndividual());
+//            try {
+//                population.put(IRI.create(lib.getURL()), lib);
+//            } catch (URISyntaxException e) {
+//                log.error("Invalid identifier for library item " + lib, e);
+//                return null;
+//            }
+//        }
+//        // EXIT nodes.
+//        Set<OWLIndividual> ronts = new HashSet<OWLIndividual>();
+//        for (OWLOntology o : registries)
+//            ronts.addAll(ind.getObjectPropertyValues(hasOntology, o));
+//        for (OWLIndividual iont : ronts) {
+//            if (iont.isNamed())
+//                lib.addChild(populateOntology(iont.asOWLNamedIndividual(), registries));
+//        }
+//        return (Library) lib;
+//    }
+//    
+//    public static RegistryOntology populateOntology(OWLNamedIndividual ind, Set<OWLOntology> registries) throws RegistryContentException {
+//        IRI id = ind.getIRI();
+//        RegistryItem ront = null;
+//        if (population.containsKey(id)) {
+//            // We are not allowing multityping either.
+//            ront = population.get(id);
+//            if (!(ront instanceof RegistryOntology)) throw new RegistryContentException(
+//                    "Inconsistent multityping: for item " + id + " : {" + RegistryOntology.class + ", "
+//                            + ront.getClass() + "}");
+//        } else {
+//            ront = riFactory.createRegistryOntology(ind);
+//            try {
+//                population.put(IRI.create(ront.getURL()), ront);
+//            } catch (URISyntaxException e) {
+//                log.error("Invalid identifier for library item " + ront, e);
+//                return null;
+//            }
+//        }
+//        // EXIT nodes.
+//        Set<OWLIndividual> libs = new HashSet<OWLIndividual>();
+//        for (OWLOntology o : registries)
+//            libs.addAll(ind.getObjectPropertyValues(isOntologyOf, o));
+//        for (OWLIndividual ilib : libs) {
+//            if (ilib.isNamed())
+//                ront.addContainer(populateLibrary(ilib.asOWLNamedIndividual(), registries));
+//        }
+//        return (RegistryOntology) ront;
+//    }
+//
+//    public static Registry populateRegistry(OWLOntology registry) throws RegistryContentException {
+//
+//        Registry reg = riFactory.createRegistry(registry);
+//        Set<OWLOntology> closure = registry.getOWLOntologyManager().getImportsClosure(registry);
+//
+//        // Just scan all individuals. Recurse in case the registry imports more registries.
+//        for (OWLIndividual ind : registry.getIndividualsInSignature(true)) {
+//            // We do not allow anonymous registry items.
+//            if (ind.isAnonymous()) continue;
+//            RegistryItem item = null;
+//            // IRI id = ind.asOWLNamedIndividual().getIRI();
+//            Type t = getType(ind, closure);
+//            if (t==null) {
+//                log.warn("Undetermined type for registry ontology individual {}",ind);
+//                continue;
+//            }
+//            switch (getType(ind, closure)) {
+//                case LIBRARY:
+//                    // // Create the library and attach to parent and children
+//                    item = populateLibrary(ind.asOWLNamedIndividual(), closure);
+//                    reg.addChild(item);
+//                    break;
+//                case ONTOLOGY:
+//                    // Create the ontology and attach to parent
+//                    item = populateOntology(ind.asOWLNamedIndividual(), closure);
+//                    // We don't know where to attach it to in this method.
+//                    break;
+//                default:
+//                    break;
+//            }
+//        }
+//
+//        population = new TreeMap<IRI,RegistryItem>();
+//        return reg;
+//    }
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/AbstractRegistryItem.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/AbstractRegistryItem.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/AbstractRegistryItem.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/AbstractRegistryItem.java Thu Jul 21 14:58:45 2011
@@ -22,21 +22,22 @@ import java.net.URL;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryContentException;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentException;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentListener;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
 import org.semanticweb.owlapi.model.IRI;
 
 public abstract class AbstractRegistryItem implements RegistryItem {
 
-    // Two-way adjacency TODO use maps instead?
-    protected Set<RegistryItem> children = new HashSet<RegistryItem>();
-    private IRI iri;
+    /* Two-way adjacency TODO use maps instead? */
+    protected Set<RegistryItem> children = new HashSet<RegistryItem>(),
+            parents = new HashSet<RegistryItem>();
 
-    private String name;
+    private IRI iri;
 
-    protected Set<RegistryItem> parents = new HashSet<RegistryItem>();
+    protected Set<RegistryContentListener> listeners = new HashSet<RegistryContentListener>();
 
-    // private RegistryItem parent;
+    private String name;
 
     public AbstractRegistryItem(String name) {
         setName(name);
@@ -47,6 +48,11 @@ public abstract class AbstractRegistryIt
         setURL(url);
     }
 
+    protected void fireContentRequested(RegistryItem item) {
+        for (RegistryContentListener listener : getRegistryContentListeners())
+            listener.registryContentRequested(item);
+    }
+
     @Override
     public void addChild(RegistryItem child) throws RegistryContentException {
         if (parents.contains(child)) throw new RegistryContentException("Cannot add parent item " + child
@@ -71,6 +77,13 @@ public abstract class AbstractRegistryIt
         }
     }
 
+    // private RegistryItem parent;
+
+    @Override
+    public void addRegistryContentListener(RegistryContentListener listener) {
+        listeners.add(listener);
+    }
+
     @Override
     public void clearChildren() {
         for (RegistryItem child : children)
@@ -78,6 +91,11 @@ public abstract class AbstractRegistryIt
     }
 
     @Override
+    public void clearRegistryContentListeners() {
+        listeners.clear();
+    }
+
+    @Override
     public RegistryItem[] getChildren() {
         return children.toArray(new RegistryItem[children.size()]);
     }
@@ -91,6 +109,11 @@ public abstract class AbstractRegistryIt
         return this.name;
     }
 
+    @Override
+    public Set<RegistryContentListener> getRegistryContentListeners() {
+        return listeners;
+    }
+
     public URL getURL() {
         try {
             return iri.toURI().toURL();
@@ -106,6 +129,16 @@ public abstract class AbstractRegistryIt
     }
 
     @Override
+    public boolean isLibrary() {
+        return Type.LIBRARY.equals(getType());
+    }
+
+    @Override
+    public boolean isOntology() {
+        return Type.ONTOLOGY.equals(getType());
+    }
+
+    @Override
     public void removeChild(RegistryItem child) {
         if (children.contains(child)) {
             children.remove(child);
@@ -122,6 +155,11 @@ public abstract class AbstractRegistryIt
     }
 
     @Override
+    public void removeRegistryContentListener(RegistryContentListener listener) {
+        listeners.remove(listener);
+    }
+
+    @Override
     public void setName(String string) {
         this.name = string;
     }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/LibraryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/LibraryImpl.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/LibraryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/LibraryImpl.java Thu Jul 21 14:58:45 2011
@@ -18,11 +18,25 @@ package org.apache.stanbol.ontologymanag
 
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
 
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.LibraryContentNotLoadedException;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentException;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryOntologyNotLoadedException;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
-
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryOntology;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
+/**
+ * Default implementation of the ontology library model.
+ */
 public class LibraryImpl extends AbstractRegistryItem implements Library {
 
+    private boolean loaded = false;
+
     public LibraryImpl(String name) {
         super(name);
     }
@@ -32,13 +46,42 @@ public class LibraryImpl extends Abstrac
     }
 
     @Override
-    public boolean isLibrary() {
-        return true;
+    public Set<OWLOntology> getOntologies() throws RegistryContentException {
+        /*
+         * Note that this implementation is not synchronized. Listeners may indefinitely be notified before or
+         * after the rest of this method is executed. If listeners call loadOntologies(), they could still get
+         * a RegistryContentException, which however they can catch by calling loadOntologies() and
+         * getOntologies() in sequence.
+         */
+        fireContentRequested(this);
+        if (!loaded) throw new LibraryContentNotLoadedException(this);
+        Set<OWLOntology> ontologies = new HashSet<OWLOntology>();
+        for (RegistryItem child : getChildren()) {
+            if (child instanceof RegistryOntology) {
+                OWLOntology o = ((RegistryOntology) child).asOWLOntology();
+                // Should never be null if the library was loaded correctly (an error should have already been
+                // thrown when loading it), but just in case.
+                if (o != null) ontologies.add(o);
+                else throw new RegistryOntologyNotLoadedException((RegistryOntology) child);
+            }
+        }
+        return ontologies;
+    }
+
+    @Override
+    public Type getType() {
+        return type;
+    }
+
+    @Override
+    public boolean isLoaded() {
+        return loaded;
     }
 
     @Override
-    public boolean isOntology() {
-        return false;
+    public void loadOntologies(OWLOntologyManager mgr) {
+        // TODO Auto-generated method stub
+        loaded = true;
     }
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryImpl.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryImpl.java Thu Jul 21 14:58:45 2011
@@ -20,17 +20,36 @@ import java.net.URISyntaxException;
 import java.net.URL;
 
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
 
 public class RegistryImpl extends AbstractRegistryItem implements Registry {
 
+    private OWLOntologyManager cache;
+
     private String message = "";
 
     public RegistryImpl(String name) {
+        this(name, OWLManager.createOWLOntologyManager());
+    }
+
+    public RegistryImpl(String name, OWLOntologyManager cache) {
         super(name);
+        setCache(cache);
     }
 
     public RegistryImpl(String name, URL url) throws URISyntaxException {
+        this(name, url, OWLManager.createOWLOntologyManager());
+    }
+
+    public RegistryImpl(String name, URL url, OWLOntologyManager cache) throws URISyntaxException {
         super(name, url);
+        setCache(cache);
+    }
+
+    @Override
+    public OWLOntologyManager getCache() {
+        return cache;
     }
 
     public String getError() {
@@ -41,13 +60,13 @@ public class RegistryImpl extends Abstra
         return super.getName() + getError();
     }
 
-    public boolean isError() {
-        return !isOK();
+    @Override
+    public Type getType() {
+        return type;
     }
 
-    @Override
-    public boolean isLibrary() {
-        return false;
+    public boolean isError() {
+        return !isOK();
     }
 
     public boolean isOK() {
@@ -55,8 +74,8 @@ public class RegistryImpl extends Abstra
     }
 
     @Override
-    public boolean isOntology() {
-        return false;
+    public void setCache(OWLOntologyManager cache) {
+        this.cache = cache;
     }
 
     public void setError(String message) {

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryOntologyImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryOntologyImpl.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryOntologyImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryOntologyImpl.java Thu Jul 21 14:58:45 2011
@@ -24,6 +24,8 @@ import org.semanticweb.owlapi.model.OWLO
 
 public class RegistryOntologyImpl extends AbstractRegistryItem implements RegistryOntology {
 
+    private OWLOntology owl;
+
     public RegistryOntologyImpl(String name) {
         super(name);
     }
@@ -33,18 +35,19 @@ public class RegistryOntologyImpl extend
     }
 
     @Override
-    public boolean isLibrary() {
-        return false;
+    public OWLOntology asOWLOntology() {
+        fireContentRequested(this);
+        return owl;
     }
 
     @Override
-    public boolean isOntology() {
-        return true;
+    public Type getType() {
+        return type;
     }
 
     @Override
-    public OWLOntology asOWLOntology() {
-        // TODO Implement me!
-        return null;
+    public void setOWLOntology(OWLOntology owl) {
+        this.owl = owl;
     }
+
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/Locations.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/Locations.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/Locations.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/Locations.java Thu Jul 21 14:58:45 2011
@@ -24,39 +24,45 @@ import org.semanticweb.owlapi.model.IRI;
 public class Locations {
 
     /**
+     * Default namespace of Stanbol ontologies.
+     */
+    public static final IRI __STANBOL_ONT_NAMESPACE = IRI.create("http://stanbol.apache.org/ontologies/");
+
+    /**
      * Default physical location of the ontology registry for testing.
      */
-    public static final IRI _STANBOL_ONT_NAMESPACE = IRI.create("http://stanbol.apache.org/ontologies/");
+    public static final IRI _REGISTRY_TEST = IRI.create(__STANBOL_ONT_NAMESPACE + "registries/onmtest.owl");
 
     /**
      * Default physical location of the ontology registry for testing.
      */
-    public static final IRI _REGISTRY_TEST = IRI.create(_STANBOL_ONT_NAMESPACE + "registries/onmtest.owl");
+    public static final IRI _REGISTRY_TEST_ADDITIONS = IRI.create(__STANBOL_ONT_NAMESPACE
+                                                                  + "registries/onmtest_additions.owl");
 
     /**
-     * Identifier of test ontology library 1.
+     * An ontology in test library 1 but not in test library 2.
      */
-    public static final IRI LIBRARY_TEST1 = IRI.create(_REGISTRY_TEST + "#Library1");
+    public static final IRI CHAR_ACTIVE = IRI.create(__STANBOL_ONT_NAMESPACE + "pcomics/characters_all.owl");
 
     /**
-     * Identifier of test ontology library 2.
+     * An ontology in test library 2 but not in test library 1.
      */
-    public static final IRI LIBRARY_TEST2 = IRI.create(_REGISTRY_TEST + "#Library2");
+    public static final IRI CHAR_DROPPED = IRI.create(__STANBOL_ONT_NAMESPACE
+                                                      + "pcomics/droppedcharacters.owl");
 
     /**
      * An ontology in test libraries 1 and 2.
      */
-    public static final IRI CHAR_MAIN = IRI.create(_STANBOL_ONT_NAMESPACE + "pcomics/maincharacters.owl");
+    public static final IRI CHAR_MAIN = IRI.create(__STANBOL_ONT_NAMESPACE + "pcomics/maincharacters.owl");
 
     /**
-     * An ontology in test library 2 but not in test library 1.
+     * Identifier of test ontology library 1.
      */
-    public static final IRI CHAR_DROPPED = IRI.create(_STANBOL_ONT_NAMESPACE
-                                                      + "pcomics/droppedcharacters.owl");
+    public static final IRI LIBRARY_TEST1 = IRI.create(_REGISTRY_TEST + "#Library1");
 
     /**
-     * An ontology in test library 1 but not in test library 2.
+     * Identifier of test ontology library 2.
      */
-    public static final IRI CHAR_ACTIVE = IRI.create(_STANBOL_ONT_NAMESPACE + "pcomics/characters_all.owl");
+    public static final IRI LIBRARY_TEST2 = IRI.create(_REGISTRY_TEST + "#Library2");
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOntologyInputSources.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOntologyInputSources.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOntologyInputSources.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOntologyInputSources.java Thu Jul 21 14:58:45 2011
@@ -52,7 +52,7 @@ public class TestOntologyInputSources {
 
     @BeforeClass
     public static void setUp() {
-        onm = new ONManagerImpl(null, null, new Hashtable<String,Object>());
+        onm = new ONManagerImpl(null, null, null, new Hashtable<String,Object>());
         df = onm.getOwlFactory();
     }
 

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestIndexing.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestIndexing.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestIndexing.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestIndexing.java Thu Jul 21 14:58:45 2011
@@ -16,23 +16,28 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.ontology;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.net.URL;
+import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.apache.stanbol.ontologymanager.ontonet.api.DuplicateIDException;
 import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
-import org.apache.stanbol.ontologymanager.ontonet.api.ONManagerConfiguration;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.ParentPathInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyIndex;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyScope;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpace;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryManager;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.io.OntologyRegistryIRISource;
 import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerConfigurationImpl;
 import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
+import org.apache.stanbol.ontologymanager.ontonet.impl.registry.RegistryManagerImpl;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.semanticweb.owlapi.model.IRI;
@@ -56,9 +61,10 @@ public class TestIndexing {
 
     @BeforeClass
     public static void setup() {
+        final Dictionary<String,Object> emptyConfig = new Hashtable<String,Object>();
+        RegistryManager regman = new RegistryManagerImpl(emptyConfig);
         // An ONManagerImpl with no store and default settings
-        ONManagerConfiguration conf = new ONManagerConfigurationImpl(new Hashtable<String,Object>());
-        onm = new ONManagerImpl(null, null, conf, new Hashtable<String,Object>());
+        onm = new ONManagerImpl(null, null, new ONManagerConfigurationImpl(emptyConfig), regman, emptyConfig);
         mgr = onm.getOntologyManagerFactory().createOntologyManager(true);
 
         // Since it is registered, this scope must be unique, or subsequent

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologyScope.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologyScope.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologyScope.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologyScope.java Thu Jul 21 14:58:45 2011
@@ -66,7 +66,7 @@ public class TestOntologyScope {
     @BeforeClass
     public static void setup() {
         // An ONManagerImpl with no store and default settings
-        onm = new ONManagerImpl(null, null, new Hashtable<String,Object>());
+        onm = new ONManagerImpl(null, null, null, new Hashtable<String,Object>());
         factory = onm.getOntologyScopeFactory();
         if (factory == null) fail("Could not instantiate ontology space factory");
         OWLOntologyManager mgr = onm.getOntologyManagerFactory().createOntologyManager(true);

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java Thu Jul 21 14:58:45 2011
@@ -75,7 +75,7 @@ public class TestOntologySpaces {
     public static void setup() throws Exception {
 
         // An ONManagerImpl with no store and default settings
-        onm = new ONManagerImpl(null, null, new Hashtable<String,Object>());
+        onm = new ONManagerImpl(null, null, null, new Hashtable<String,Object>());
         spaceFactory = onm.getOntologySpaceFactory();
         if (spaceFactory == null) fail("Could not instantiate ontology space factory");
 

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/registry/TestOntologyLibrary.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/registry/TestOntologyLibrary.java?rev=1149208&r1=1149207&r2=1149208&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/registry/TestOntologyLibrary.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/registry/TestOntologyLibrary.java Thu Jul 21 14:58:45 2011
@@ -16,25 +16,29 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.registry;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.net.URL;
+import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.apache.stanbol.ontologymanager.ontonet.Locations;
 import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
-import org.apache.stanbol.ontologymanager.ontonet.api.ONManagerConfiguration;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryLoader;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryManager;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.io.LibrarySource;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
 import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
-import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryOntology;
 import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerConfigurationImpl;
 import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
 import org.apache.stanbol.ontologymanager.ontonet.impl.registry.RegistryLoaderImpl;
+import org.apache.stanbol.ontologymanager.ontonet.impl.registry.RegistryManagerImpl;
+import org.apache.stanbol.ontologymanager.ontonet.impl.registry.cache.RegistryUtils;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -64,9 +68,10 @@ public class TestOntologyLibrary {
      */
     @BeforeClass
     public static void setupTest() throws Exception {
+        final Dictionary<String,Object> emptyConfig = new Hashtable<String,Object>();
+        RegistryManager regman = new RegistryManagerImpl(emptyConfig);
         // An ONManagerImpl with no store and default settings
-        ONManagerConfiguration configuration = new ONManagerConfigurationImpl(new Hashtable<String,Object>());
-        onm = new ONManagerImpl(null, null, configuration, new Hashtable<String,Object>());
+        onm = new ONManagerImpl(null, null, new ONManagerConfigurationImpl(emptyConfig), regman, emptyConfig);
         loader = new RegistryLoaderImpl(onm);
     }
 
@@ -92,36 +97,6 @@ public class TestOntologyLibrary {
     }
 
     /**
-     * Utility method to recurse into registry items.
-     * 
-     * TODO: move this to main?
-     * 
-     * @param item
-     * @param ontologyId
-     * @return
-     */
-    private boolean containsOntologyRecursive(RegistryItem item, IRI ontologyId) {
-
-        boolean result = false;
-        if (item instanceof RegistryOntology) {
-            // An Ontology MUST have a non-null URI.
-            try {
-                IRI iri = IRI.create(item.getURL());
-                result |= iri.equals(ontologyId);
-            } catch (Exception e) {
-                return false;
-            }
-        } else if (item instanceof Library || item instanceof Registry)
-        // Inspect children
-        for (RegistryItem child : ((RegistryItem) item).getChildren()) {
-            result |= containsOntologyRecursive(child, ontologyId);
-            if (result) break;
-        }
-        return result;
-
-    }
-
-    /**
      * Uses a plain {@link RegistryLoader} to load a single ontology library and checks for its expected hits
      * and misses.
      * 
@@ -142,16 +117,16 @@ public class TestOntologyLibrary {
         }
         assertNotNull(lib);
         // Should be in the library.
-        boolean hasShould = containsOntologyRecursive(lib, Locations.CHAR_DROPPED);
+        boolean hasShould = RegistryUtils.containsOntologyRecursive(lib, Locations.CHAR_DROPPED);
         // Should NOT be in the library (belongs to another library in the same registry).
-        boolean hasShouldNot = containsOntologyRecursive(lib, Locations.CHAR_ACTIVE);
+        boolean hasShouldNot = RegistryUtils.containsOntologyRecursive(lib, Locations.CHAR_ACTIVE);
         assertTrue(hasShould);
         assertFalse(hasShouldNot);
     }
 
     /**
      * Tests the creation of an ontology input source from a single library. Because the test is run offline,
-     * import statements might be file URIs, so tests will not fail on this.
+     * import statements might be file URIs, so tests should not fail on this.
      * 
      * @throws Exception
      */
@@ -164,7 +139,7 @@ public class TestOntologyLibrary {
         boolean hasImporting = false, hasImported = false;
         for (OWLImportsDeclaration ax : o.getImportsDeclarations()) {
             // Since we added a local IRI mapping, import statements might be using file: IRIs instead of
-            // HTTP, in which case IRI equality would fail.
+            // HTTP, in which case IRI equality would fail. So it is enough here to just check the filename.
             String tmpstr = ax.getIRI().toString();
             if (!hasImporting && tmpstr.endsWith("characters_all.owl")) hasImporting = true;
             else if (!hasImported && tmpstr.endsWith("maincharacters.owl")) hasImported = true;