use of javax.annotation.PostConstruct in project che by eclipse.
the class WSocketEventBusClient method start.
@PostConstruct
void start() {
if (start.compareAndSet(false, true)) {
if (policy != null) {
eventService.subscribe(new EventSubscriber<Object>() {
@Override
public void onEvent(Object event) {
propagate(event);
}
});
}
if (eventSubscriptions != null) {
final Map<URI, Set<String>> cfg = new HashMap<>();
for (Pair<String, String> service : eventSubscriptions) {
try {
final URI key = new URI(service.first);
Set<String> values = cfg.get(key);
if (values == null) {
cfg.put(key, values = new LinkedHashSet<>());
}
if (service.second != null) {
values.add(service.second);
}
} catch (URISyntaxException e) {
LOG.error(e.getMessage(), e);
}
}
if (!cfg.isEmpty()) {
executor = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("WSocketEventBusClient-%d").setUncaughtExceptionHandler(LoggingUncaughtExceptionHandler.getInstance()).setDaemon(true).build());
for (Map.Entry<URI, Set<String>> entry : cfg.entrySet()) {
executor.execute(new ConnectTask(entry.getKey(), entry.getValue()));
}
}
}
}
}
use of javax.annotation.PostConstruct in project che by eclipse.
the class JavaPlugin method start.
@PostConstruct
public void start() {
// WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() {
// @Override
// public IBuffer createBuffer(ICompilationUnit workingCopy) {
// ICompilationUnit original = workingCopy.getPrimary();
// IResource resource = original.getResource();
// if (resource instanceof IFile)
// return new DocumentAdapter(workingCopy, (IFile)resource);
// return DocumentAdapter.NULL;
// }
// });
new JavaCore();
fMembersOrderPreferenceCache = new MembersOrderPreferenceCache();
PreferenceConstants.initializeDefaultValues(PreferenceConstants.getPreferenceStore());
new JavaCorePreferenceInitializer().initializeDefaultPreferences();
new CheCodeFormatterInitializer().initializeDefaultPreferences();
}
use of javax.annotation.PostConstruct in project che by eclipse.
the class ProjectRegistry method initProjects.
@PostConstruct
public void initProjects() throws ConflictException, NotFoundException, ServerException, ForbiddenException {
List<? extends ProjectConfig> projectConfigs = workspaceHolder.getProjects();
// take all the projects from ws's config
for (ProjectConfig projectConfig : projectConfigs) {
final String path = projectConfig.getPath();
final VirtualFile vf = vfs.getRoot().getChild(Path.of(path));
final FolderEntry projectFolder = ((vf == null) ? null : new FolderEntry(vf, this));
putProject(projectConfig, projectFolder, false, false);
}
initUnconfiguredFolders();
initialized = true;
for (RegisteredProject project : projects.values()) {
// only for projects with sources
if (project.getBaseFolder() != null) {
fireInitHandlers(project);
}
}
}
use of javax.annotation.PostConstruct in project che by eclipse.
the class DockerRegistryChecker method checkRegistryIsAvailable.
/**
* Checks that registry is available and if it is not - logs warning message.
*/
@PostConstruct
private void checkRegistryIsAvailable() throws IOException {
if (snapshotUseRegistry && !isNullOrEmpty(machineDockerRegistry)) {
String registryUrl = "http://" + machineDockerRegistry;
LOG.info("Probing registry '{}'", registryUrl);
final HttpURLConnection conn = (HttpURLConnection) new URL(registryUrl).openConnection();
conn.setConnectTimeout(30 * 1000);
try {
final int responseCode = conn.getResponseCode();
LOG.info("Probe of registry '{}' succeed with HTTP response code '{}'", registryUrl, responseCode);
} catch (IOException ioEx) {
LOG.warn("Docker registry {} is not available, " + "which means that you won't be able to save snapshots of your workspaces." + "\nHow to configure registry?" + "\n\tLocal registry -> https://docs.docker.com/registry/" + "\n\tRemote registry -> set up 'che.docker.registry.auth.*' properties", registryUrl);
} finally {
conn.disconnect();
}
}
}
use of javax.annotation.PostConstruct in project che by eclipse.
the class ApiEndpointAccessibilityChecker method start.
@PostConstruct
public void start() {
try {
final HttpJsonResponse pingResponse = httpJsonRequestFactory.fromUrl(apiEndpoint).setMethod(HttpMethod.GET).setTimeout(2000).request();
if (pingResponse.getResponseCode() == HttpURLConnection.HTTP_OK) {
return;
}
} catch (ApiException | IOException e) {
LOG.error(e.getLocalizedMessage(), e);
}
LOG.error("The workspace agent has attempted to start, but it is unable to ping the Che server at " + apiEndpoint);
LOG.error("The workspace agent has been forcefully stopped. " + "This error happens when the agent cannot resolve the location of the Che server. " + "This error can usually be fixed with additional configuration settings in /conf/che.properties. " + "The Che server will stop this workspace after a short timeout. " + "You can get help by posting your config, stacktrace and workspace /etc/hosts below as a GitHub issue.");
// content of /etc/hosts file may provide clues on why the connection failed, e.g. how che-host is resolved
try {
LOG.info("Workspace /etc/hosts: " + IoUtil.readAndCloseQuietly(new FileInputStream(new File("/etc/hosts"))));
} catch (Exception e) {
LOG.info(e.getLocalizedMessage(), e);
}
System.exit(0);
}
Aggregations