blob: 085e2b039fbf969be57bf8f41d6aa15332ac8887 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/*******************************************************************************
* Copyright (c) 2006 - 2006 Mylar eclipse.org project and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Mylar project committers - initial API and implementation
*******************************************************************************/
package org.eclipse.mylar.internal.trac.core;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
import org.eclipse.mylar.provisional.tasklist.TaskRepository;
/**
* Caches {@link ITracClient} objects.
*
* @author Steffen Pingel
*/
public class TracClientManager {
Map<String, ITracClient> clientByUrl = new HashMap<String, ITracClient>();
public TracClientManager() {
}
public ITracClient getRepository(TaskRepository taskRepository) throws MalformedURLException {
ITracClient repository = clientByUrl.get(taskRepository.getUrl());
if (repository == null) {
repository = TracClientFactory.createClient(taskRepository.getUrl(), Version.fromVersion(taskRepository
.getVersion()), taskRepository.getUserName(), taskRepository.getPassword());
clientByUrl.put(taskRepository.getUrl(), repository);
}
return repository;
}
}
|