Author: rhauch
Date: 2009-01-14 15:08:52 -0500 (Wed, 14 Jan 2009)
New Revision: 703
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
Log:
DNA-58 Create repository configuration and component
Added a static "create(RepositorySource,ExecutionContext)" method for creating a
Graph given a RepositorySource.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-01-09 23:06:15 UTC
(rev 702)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-01-14 20:08:52 UTC
(rev 703)
@@ -120,6 +120,27 @@
return new Graph(connectorSourceName, connectionFactory, context);
}
+ /**
+ * Create a graph instance that uses the supplied {@link RepositoryConnection} and
{@link ExecutionContext context}.
+ *
+ * @param source the source that should be used
+ * @param context the context in which all executions should be performed
+ * @return the new graph
+ * @throws IllegalArgumentException if the connection or context parameters are null
+ */
+ public static Graph create( final RepositorySource source,
+ ExecutionContext context ) {
+ CheckArg.isNotNull(source, "source");
+ final String connectorSourceName = source.getName();
+ RepositoryConnectionFactory connectionFactory = new RepositoryConnectionFactory()
{
+ public RepositoryConnection createConnection( String sourceName ) throws
RepositorySourceException {
+ if (connectorSourceName.equals(sourceName)) return
source.getConnection();
+ return null;
+ }
+ };
+ return new Graph(connectorSourceName, connectionFactory, context);
+ }
+
private final String sourceName;
private final RepositoryConnectionFactory connectionFactory;
private final ExecutionContext context;
Show replies by date