[Mulgara-svn] r971 - in trunk/src/jar: resolver/java/org/mulgara/resolver resolver-spi/java/org/mulgara/resolver/spi
ronald at mulgara.org
ronald at mulgara.org
Mon Jun 2 02:50:44 UTC 2008
Author: ronald
Date: 2008-06-01 19:50:43 -0700 (Sun, 01 Jun 2008)
New Revision: 971
Modified:
trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverFactoryInitializer.java
trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseResolverFactoryInitializer.java
Log:
Added getSessionFactory() to ResolverFactoryInitializer so resolver can get
additional sessions if they need to. The implementation returns a wrapper so
that resolvers can't cast to Database and do more than they should, and so
that close() and delete() can't be invoked either.
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseResolverFactoryInitializer.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseResolverFactoryInitializer.java 2008-05-31 01:38:39 UTC (rev 970)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseResolverFactoryInitializer.java 2008-06-02 02:50:43 UTC (rev 971)
@@ -41,6 +41,8 @@
import org.mulgara.query.Constraint;
import org.mulgara.query.QueryException;
import org.mulgara.resolver.spi.*;
+import org.mulgara.server.Session;
+import org.mulgara.server.SessionFactory;
import org.mulgara.util.NVPair;
// Local packages
@@ -63,6 +65,7 @@
private final DatabaseMetadata metadata;
private final ContentHandlerManager contentHandlerManager;
private final ResolverFactory systemResolverFactory;
+ private final SessionFactory restrictedSessionFactory;
/**
* Sole constructor.
@@ -73,7 +76,7 @@
*/
public DatabaseResolverFactoryInitializer(
Set<ResolverFactory> cachedResolverFactorySet,
- Database database,
+ final Database database,
DatabaseMetadata metadata,
File persistenceDirectory,
ContentHandlerManager contentHandlerManager,
@@ -94,6 +97,14 @@
this.metadata = metadata;
this.contentHandlerManager = contentHandlerManager;
this.systemResolverFactory = systemResolverFactory;
+
+ this.restrictedSessionFactory = new SessionFactory() {
+ public URI getSecurityDomain() throws QueryException { return database.getSecurityDomain(); }
+ public Session newSession() throws QueryException { return database.newSession(); }
+ public Session newJRDFSession() throws QueryException { return database.newJRDFSession(); }
+ public void close() throws QueryException { throw new UnsupportedOperationException(); }
+ public void delete() throws QueryException { throw new UnsupportedOperationException(); }
+ };
}
@@ -198,4 +209,8 @@
logger.warn("Attempted to register " + constraintClass + " twice");
}
}
+
+ public SessionFactory getSessionFactory() {
+ return restrictedSessionFactory;
+ }
}
Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverFactoryInitializer.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverFactoryInitializer.java 2008-05-31 01:38:39 UTC (rev 970)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverFactoryInitializer.java 2008-06-02 02:50:43 UTC (rev 971)
@@ -37,6 +37,7 @@
import org.mulgara.content.ContentHandler;
import org.mulgara.content.ContentHandlerManager;
import org.mulgara.server.Session;
+import org.mulgara.server.SessionFactory;
import org.mulgara.store.stringpool.StringPool;
/**
@@ -166,4 +167,18 @@
* @throws InitializerException if the constraint class specified has already been registered
*/
public void registerNewConstraint(ConstraintDescriptor descriptor) throws InitializerException;
+
+ /**
+ * Obtain the session-factory the resolver-factory is being loaded by.
+ *
+ * There are a couple restrictions on the returned session-factory. For one, the methods
+ * {@link SessionFactory#close close()} and {@link SessionFactory#delete delete()} may not
+ * be used and will throw an exception. The second restriction is that operations on different
+ * session's may not be nested, which means that if a resolver or resolver-factory creates any
+ * sessions using this session-factory then it must use a separate thread for operations on
+ * those sessions.
+ *
+ * @return the owning session-factory
+ */
+ public SessionFactory getSessionFactory();
}
More information about the Mulgara-svn
mailing list