-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
ClasspathServiceClientImpl.java
62 lines (52 loc) · 2.5 KB
/
ClasspathServiceClientImpl.java
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*******************************************************************************
* Copyright (c) 2012-2016 Codenvy, S.A.
* 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:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.ide.ext.java.client.project.classpath.service;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto;
import org.eclipse.che.ide.rest.AsyncRequestFactory;
import org.eclipse.che.ide.rest.DtoUnmarshallerFactory;
import org.eclipse.che.ide.ui.loaders.request.LoaderFactory;
import org.eclipse.che.ide.ui.loaders.request.MessageLoader;
import java.util.List;
/**
* The implementation of {@link ClasspathServiceClient}.
*
* @author Valeriy Svydenko
*/
@Singleton
public class ClasspathServiceClientImpl implements ClasspathServiceClient {
private final String pathToService;
private final MessageLoader loader;
private final AsyncRequestFactory asyncRequestFactory;
private final DtoUnmarshallerFactory unmarshallerFactory;
private final AppContext appContext;
@Inject
public ClasspathServiceClientImpl(AsyncRequestFactory asyncRequestFactory,
DtoUnmarshallerFactory unmarshallerFactory,
AppContext appContext,
LoaderFactory loaderFactory) {
this.asyncRequestFactory = asyncRequestFactory;
this.unmarshallerFactory = unmarshallerFactory;
this.appContext = appContext;
this.loader = loaderFactory.newLoader();
this.pathToService = "/java/classpath";
}
@Override
public Promise<List<ClasspathEntryDto>> getClasspath(String projectPath) {
final String url = appContext.getDevMachine().getWsAgentBaseUrl() + pathToService + "?projectpath=" + projectPath;
return asyncRequestFactory.createGetRequest(url)
.loader(loader)
.send(unmarshallerFactory.newListUnmarshaller(ClasspathEntryDto.class));
}
}