String name = getName();
if (name == null) {
I18n msg = GraphI18n.namePropertyIsRequiredForFederatedRepositorySource;
throw new RepositorySourceException(getName(), msg.text("name"));
}
RepositoryContext context = getRepositoryContext();
if (context == null) {
I18n msg = GraphI18n.federatedRepositorySourceMustBeInitialized;
throw new RepositorySourceException(getName(), msg.text("name", name));
}
// Now set up or get the existing components needed by the workspace ...
RepositoryConnectionFactory connectionFactory = null;
ExecutorService executor = null;
LinkedList<FederatedWorkspace> workspaces = new LinkedList<FederatedWorkspace>();
CachePolicy defaultCachePolicy = null;
if (this.configuration != null) {
connectionFactory = this.configuration.getConnectionFactory();
executor = this.configuration.getExecutor();
defaultCachePolicy = this.configuration.getDefaultCachePolicy();
for (String existingWorkspaceName : this.configuration.getWorkspaceNames()) {
if (existingWorkspaceName.equals(workspaceName)) continue;
workspaces.add(this.configuration.getWorkspace(existingWorkspaceName));
}
} else {
connectionFactory = context.getRepositoryConnectionFactory();
executor = Executors.newCachedThreadPool(new NamedThreadFactory(name));
}
// Add the new workspace ...
FederatedWorkspace newWorkspace = new FederatedWorkspace(context, name, workspaceName, projections, defaultCachePolicy);