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/25 23:07:01 UTC
svn commit: r1150908 - in /incubator/stanbol/trunk/ontologymanager:
ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/
ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/
registry/src/main/java/or...
Author: alexdma
Date: Mon Jul 25 21:06:59 2011
New Revision: 1150908
URL: http://svn.apache.org/viewvc?rev=1150908&view=rev
Log:
STANBOL-285:
- Implemented lazy/eager loading and centralised/distributed caching (TODO load balancing for distributed caches)
- Deprecated old OWLOntologyManagerFactory in ontonet
Modified:
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLOntologyManagerFactory.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OWLOntologyManagerFactoryImpl.java
incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/RegistryItemFactory.java
incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryLoaderImpl.java
incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java
incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java
incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java
incubator/stanbol/trunk/ontologymanager/registry/src/test/resources/ontologies/registry/onmtest.owl
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLOntologyManagerFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLOntologyManagerFactory.java?rev=1150908&r1=1150907&r2=1150908&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLOntologyManagerFactory.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLOntologyManagerFactory.java Mon Jul 25 21:06:59 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.ontology;
import java.util.List;
@@ -26,7 +26,7 @@ import org.semanticweb.owlapi.model.OWLO
* each of them.
*
* @author alessandro
- *
+ * @deprecated use the static methods of {@link org.apache.stanbol.owl.OWLOntologyManagerFactory} instead.
*/
public interface OWLOntologyManagerFactory {
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OWLOntologyManagerFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OWLOntologyManagerFactoryImpl.java?rev=1150908&r1=1150907&r2=1150908&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OWLOntologyManagerFactoryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OWLOntologyManagerFactoryImpl.java Mon Jul 25 21:06:59 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.impl.ontology;
import java.io.File;
@@ -30,10 +30,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * FIXME: decide on this class either implementing an interface or providing static methods.
*
* @author alessandro
- *
+ * @deprecated use the static methods of {@link org.apache.stanbol.owl.OWLOntologyManagerFactory} instead.
*/
public class OWLOntologyManagerFactoryImpl implements OWLOntologyManagerFactory {
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/RegistryItemFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/RegistryItemFactory.java?rev=1150908&r1=1150907&r2=1150908&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/RegistryItemFactory.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/RegistryItemFactory.java Mon Jul 25 21:06:59 2011
@@ -30,7 +30,7 @@ import org.semanticweb.owlapi.model.OWLO
* <br/>
* <b>Note that implementations should not be aggressive</b>, in that they should <b>not</b> recursively
* create and/or append the parents and children of any generated object. Refer to
- * {@link RegistryManager#createModel(Set)} to recursively populate registry item starting from a set of
+ * {@link RegistryManager#createModel(Set)} to recursively populate a registry item starting from a set of
* registries.
*/
public interface RegistryItemFactory {
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryLoaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryLoaderImpl.java?rev=1150908&r1=1150907&r2=1150908&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryLoaderImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryLoaderImpl.java Mon Jul 25 21:06:59 2011
@@ -449,6 +449,7 @@ public class RegistryLoaderImpl implemen
// return registry;
// }
+ @Override
public void loadLocations() throws RegistryContentException {
try {
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java?rev=1150908&r1=1150907&r2=1150908&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java Mon Jul 25 21:06:59 2011
@@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -107,9 +108,6 @@ public class RegistryManagerImpl impleme
+ ".option.centralised", name = "CENTRALISED")}, value = "CENTRALISED")
private String cachingPolicyString;
- @Reference
- private OfflineConfiguration offline;
-
@Property(name = RegistryManager.LAZY_LOADING, boolValue = _LAZY_LOADING_DEFAULT)
private boolean lazyLoading = _LAZY_LOADING_DEFAULT;
@@ -121,6 +119,9 @@ public class RegistryManagerImpl impleme
private Logger log = LoggerFactory.getLogger(getClass());
+ @Reference
+ private OfflineConfiguration offline;
+
/* Maps libraries to ontologies */
private Map<IRI,Set<IRI>> ontologyIndex = new HashMap<IRI,Set<IRI>>();
@@ -228,7 +229,7 @@ public class RegistryManagerImpl impleme
// Build the model.
createModel(regOnts);
- // Set the cache.
+ // Create and set the cache.
if (cachingPolicyString.equals(CachingPolicy.CENTRALISED.name())) {
this.cache = OWLOntologyManagerFactory.createOWLOntologyManager(offlineResources);
for (Registry reg : getRegistries())
@@ -238,6 +239,12 @@ public class RegistryManagerImpl impleme
reg.setCache(OWLOntologyManagerFactory.createOWLOntologyManager(offlineResources));
this.cache = null;
}
+
+ if (isLazyLoading()) {
+ // Nothing to do about it at the moment.
+ } else {
+ loadEager();
+ }
}
@Override
@@ -258,6 +265,11 @@ public class RegistryManagerImpl impleme
updateLocations();
}
+ protected Map<Library,Float> computeLoadFactors() {
+ Map<Library,Float> loadFactors = new HashMap<Library,Float>();
+ return loadFactors;
+ }
+
@Override
public Set<Registry> createModel(Set<OWLOntology> registryOntologies) {
@@ -417,8 +429,14 @@ public class RegistryManagerImpl impleme
@Override
public Set<Registry> getRegistries(IRI libraryID) {
- // TODO Auto-generated method stub
- return null;
+ Set<Registry> results = new HashSet<Registry>();
+ try {
+ for (RegistryItem item : population.get(libraryID).getParents())
+ if (item instanceof Registry) results.add((Registry) item);
+ } catch (NullPointerException ex) {
+ return results;
+ }
+ return results;
}
@Override
@@ -531,10 +549,39 @@ public class RegistryManagerImpl impleme
return reg;
}
+ private void loadEager() {
+ for (RegistryItem item : population.values()) {
+ if (item instanceof Library && !((Library) item).isLoaded()) {
+ // TODO: implement ontology request targets.
+ if (CachingPolicy.CENTRALISED.equals(getCachingPolicy()) && this.cache != null) {
+ ((Library) item).loadOntologies(this.cache);
+ } else if (CachingPolicy.DISTRIBUTED.equals(getCachingPolicy())) {
+ // TODO implement load balancing.
+ Iterator<Registry> it = getRegistries(item.getIRI()).iterator();
+ if (it.hasNext()) ((Library) item).loadOntologies(it.next().getCache());
+ } else {
+ log.error("Tried to load ontology resource {} using a null cache.", item);
+ }
+ }
+ }
+ }
+
@Override
public void registryContentRequested(RegistryItem requestTarget) {
- // TODO Auto-generated method stub
-
+ log.debug("In {} registry content was requested on {}.", getClass(), requestTarget);
+ // TODO: implement ontology request targets.
+ if (CachingPolicy.CENTRALISED.equals(getCachingPolicy()) && this.cache != null) {
+ if (requestTarget instanceof Library && !((Library) requestTarget).isLoaded()) ((Library) requestTarget)
+ .loadOntologies(this.cache);
+ } else if (CachingPolicy.DISTRIBUTED.equals(getCachingPolicy())) {
+ if (requestTarget instanceof Library && !((Library) requestTarget).isLoaded()) {
+ // TODO implement load balancing.
+ Iterator<Registry> it = getRegistries(requestTarget.getIRI()).iterator();
+ if (it.hasNext()) ((Library) requestTarget).loadOntologies(it.next().getCache());
+ }
+ } else {
+ log.error("Tried to load ontology resource {} using a null cache.", requestTarget);
+ }
}
@Override
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java?rev=1150908&r1=1150907&r2=1150908&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java Mon Jul 25 21:06:59 2011
@@ -27,8 +27,12 @@ import org.apache.stanbol.ontologymanage
import org.apache.stanbol.ontologymanager.registry.api.model.RegistryOntology;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyDocumentAlreadyExistsException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Default implementation of the ontology library model.
@@ -37,6 +41,8 @@ public class LibraryImpl extends Abstrac
private boolean loaded = false;
+ private Logger log = LoggerFactory.getLogger(getClass());
+
public LibraryImpl(IRI iri) {
super(iri);
}
@@ -54,6 +60,7 @@ public class LibraryImpl extends Abstrac
* getOntologies() in sequence.
*/
fireContentRequested(this);
+ // If no listener has saved the day by loading the ontologies by now, an exception will be thrown.
if (!loaded) throw new LibraryContentNotLoadedException(this);
Set<OWLOntology> ontologies = new HashSet<OWLOntology>();
for (RegistryItem child : getChildren()) {
@@ -79,9 +86,23 @@ public class LibraryImpl extends Abstrac
}
@Override
- public void loadOntologies(OWLOntologyManager mgr) {
+ public synchronized void loadOntologies(OWLOntologyManager mgr) {
if (mgr == null) throw new IllegalArgumentException("A null ontology manager is not allowed.");
- // TODO Auto-generated method stub
+ for (RegistryItem item : getChildren()) {
+ if (item instanceof RegistryOntology) {
+ RegistryOntology o = (RegistryOntology) item;
+ IRI id = o.getIRI();
+ try {
+ o.setOWLOntology(mgr.loadOntology(id));
+ } catch (OWLOntologyAlreadyExistsException e) {
+ o.setOWLOntology(mgr.getOntology(e.getOntologyID()));
+ } catch (OWLOntologyDocumentAlreadyExistsException e) {
+ o.setOWLOntology(mgr.getOntology(e.getOntologyDocumentIRI()));
+ } catch (OWLOntologyCreationException e) {
+ log.error("Failed to load ontology " + id, e);
+ }
+ }
+ }
loaded = true;
}
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java?rev=1150908&r1=1150907&r2=1150908&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java Mon Jul 25 21:06:59 2011
@@ -26,17 +26,20 @@ import org.apache.stanbol.ontologymanage
import org.apache.stanbol.ontologymanager.ontonet.impl.OfflineConfigurationImpl;
import org.apache.stanbol.ontologymanager.registry.api.RegistryManager;
import org.apache.stanbol.ontologymanager.registry.api.model.CachingPolicy;
+import org.apache.stanbol.ontologymanager.registry.api.model.Library;
import org.apache.stanbol.ontologymanager.registry.api.model.Registry;
+import org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem;
import org.apache.stanbol.ontologymanager.registry.impl.RegistryManagerImpl;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.semanticweb.owlapi.model.OWLOntologyManager;
+/**
+ * Test the correct creation and setup of {@link RegistryManager} implementations.
+ */
public class TestRegistryManager {
- private RegistryManager regman;
-
/*
* This is the registry manager configuration (which varies across tests).
*/
@@ -50,6 +53,7 @@ public class TestRegistryManager {
@BeforeClass
public static void setup() throws Exception {
configuration = new Hashtable<String,Object>();
+ // We need this to make sure the local meta.owl (which does not import codolight) is loaded.
configuration.put(OfflineConfiguration.ONTOLOGY_PATHS, new String[] {"/ontologies",
"/ontologies/registry"});
configuration.put(
@@ -62,11 +66,19 @@ public class TestRegistryManager {
offline = new OfflineConfigurationImpl(configuration);
}
+ private RegistryManager regman;
+
@Before
public void setupTests() throws Exception {}
+ /**
+ * Verifies that by instantiating a new {@link RegistryManager} with a centralised caching policy and
+ * loading two registries, they share the same cache ontology manager.
+ *
+ * @throws Exception
+ */
@Test
- public void testCentralisedCaching() throws Exception {
+ public void testCachingCentralised() throws Exception {
// Change the caching policy and setup a new registry manager.
configuration.put(RegistryManager.CACHING_POLICY, CachingPolicy.CENTRALISED);
regman = new RegistryManagerImpl(offline, configuration);
@@ -78,10 +90,33 @@ public class TestRegistryManager {
OWLOntologyManager cache = it.next().getCache();
while (it.hasNext())
assertSame(cache, it.next().getCache());
+
+ // Now "touch" a library.
+ Registry reg;
+ do
+ reg = regman.getRegistries().iterator().next();
+ while (!reg.hasChildren());
+ assertNotNull(reg);
+
+ // There has to be at least one non-empty lib from the test ontologies.
+ Library lib = null;
+ RegistryItem[] children = reg.getChildren();
+ for (int i = 0; i < children.length && lib == null; i++)
+ if (children[i] instanceof Library) lib = (Library) (children[i]);
+ assertNotNull(lib);
+
+ // Touch the library. Also test that the listener system works.
+ assertFalse(lib.getOntologies().isEmpty());
}
+ /**
+ * Verifies that by instantiating a new {@link RegistryManager} with a distributed caching policy and
+ * loading two registries, they have different ontology managers.
+ *
+ * @throws Exception
+ */
@Test
- public void testDistributedCaching() throws Exception {
+ public void testCachingDistributed() throws Exception {
// Change the caching policy and setup a new registry manager.
configuration.put(RegistryManager.CACHING_POLICY, CachingPolicy.DISTRIBUTED);
regman = new RegistryManagerImpl(offline, configuration);
@@ -91,8 +126,64 @@ public class TestRegistryManager {
// Each registry must have its own distinct cache.
Iterator<Registry> it = regman.getRegistries().iterator();
OWLOntologyManager cache = it.next().getCache();
- while (it.hasNext())
+ // Just checking against the first in the list.
+ while (it.hasNext()) {
assertNotSame(cache, it.next().getCache());
+ }
+ }
+
+ @Test
+ public void testLoadingEager() throws Exception {
+ // Change the caching policy and setup a new registry manager.
+ configuration.put(RegistryManager.CACHING_POLICY, CachingPolicy.CENTRALISED);
+ configuration.put(RegistryManager.LAZY_LOADING, false);
+ regman = new RegistryManagerImpl(offline, configuration);
+ // Check that the configuration was set.
+ assertNotNull(regman);
+
+ // Now pick a library.
+ Registry reg;
+ do
+ reg = regman.getRegistries().iterator().next();
+ while (!reg.hasChildren());
+ assertNotNull(reg);
+
+ // There has to be at least one non-empty lib from the test ontologies.
+ Library lib = null;
+ RegistryItem[] children = reg.getChildren();
+ for (int i = 0; i < children.length && lib == null; i++)
+ if (children[i] instanceof Library) lib = (Library) (children[i]);
+ assertNotNull(lib);
+ assertTrue(lib.isLoaded());
+ }
+
+ @Test
+ public void testLoadingLazy() throws Exception {
+ // Change the caching policy and setup a new registry manager.
+ configuration.put(RegistryManager.CACHING_POLICY, CachingPolicy.CENTRALISED);
+ configuration.put(RegistryManager.LAZY_LOADING, true);
+ regman = new RegistryManagerImpl(offline, configuration);
+ // Check that the configuration was set.
+ assertNotNull(regman);
+
+ // Now pick a library.
+ Registry reg;
+ do
+ reg = regman.getRegistries().iterator().next();
+ while (!reg.hasChildren());
+ assertNotNull(reg);
+
+ // There has to be at least one non-empty lib from the test ontologies.
+ Library lib = null;
+ RegistryItem[] children = reg.getChildren();
+ for (int i = 0; i < children.length && lib == null; i++)
+ if (children[i] instanceof Library) lib = (Library) (children[i]);
+ assertNotNull(lib);
+ assertFalse(lib.isLoaded());
+
+ // Touch the library. Also test that the listener system works.
+ assertFalse(lib.getOntologies().isEmpty());
+ assertTrue(lib.isLoaded());
}
}
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/test/resources/ontologies/registry/onmtest.owl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/test/resources/ontologies/registry/onmtest.owl?rev=1150908&r1=1150907&r2=1150908&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/test/resources/ontologies/registry/onmtest.owl (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/test/resources/ontologies/registry/onmtest.owl Mon Jul 25 21:06:59 2011
@@ -40,6 +40,7 @@ Unless required by applicable law or agr
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ONM Test Library 1</rdfs:label>
<rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/coddata.owl#OntologyLibrary"/>
<owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.1</owl:versionInfo>
+ <meta:hasOntology rdf:resource="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl"/>
</rdf:Description>
<rdf:Description rdf:ID="Library2">
@@ -70,7 +71,6 @@ Unless required by applicable law or agr
<!-- For testing already loaded ontologies -->
<rdf:Description rdf:about="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl">
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Main Characters</rdfs:label>
- <meta:isOntologyOf rdf:resource="#Library1"/>
<meta:isOntologyOf rdf:resource="#Library2"/>
<rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
</rdf:Description>