Search in sources :

Example 1 with PostConstruct

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()));
                }
            }
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PostConstruct(javax.annotation.PostConstruct)

Example 2 with PostConstruct

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();
}
Also used : MembersOrderPreferenceCache(org.eclipse.jdt.internal.ui.preferences.MembersOrderPreferenceCache) JavaCorePreferenceInitializer(org.eclipse.jdt.internal.core.JavaCorePreferenceInitializer) JavaCore(org.eclipse.jdt.core.JavaCore) CheCodeFormatterInitializer(org.eclipse.jdt.internal.corext.format.CheCodeFormatterInitializer) PostConstruct(javax.annotation.PostConstruct)

Example 3 with PostConstruct

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);
        }
    }
}
Also used : NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig) ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) VirtualFile(org.eclipse.che.api.vfs.VirtualFile) PostConstruct(javax.annotation.PostConstruct)

Example 4 with PostConstruct

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();
        }
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) IOException(java.io.IOException) URL(java.net.URL) PostConstruct(javax.annotation.PostConstruct)

Example 5 with PostConstruct

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);
}
Also used : IOException(java.io.IOException) HttpJsonResponse(org.eclipse.che.api.core.rest.HttpJsonResponse) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) ApiException(org.eclipse.che.api.core.ApiException) ApiException(org.eclipse.che.api.core.ApiException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)194 IOException (java.io.IOException)24 File (java.io.File)16 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)16 Map (java.util.Map)13 ExternalResource (com.vaadin.server.ExternalResource)11 ArrayList (java.util.ArrayList)11 Label (com.vaadin.ui.Label)8 VerticalLayout (com.vaadin.ui.VerticalLayout)8 HashMap (java.util.HashMap)8 Request (com.nabalive.framework.web.Request)7 Response (com.nabalive.framework.web.Response)7 Route (com.nabalive.framework.web.Route)7 Link (com.vaadin.ui.Link)7 Properties (java.util.Properties)6 InitialContext (javax.naming.InitialContext)6 IStatus (org.eclipse.core.runtime.IStatus)5 URISyntaxException (java.net.URISyntaxException)4 Logger (org.slf4j.Logger)4 StatusLineWriter (alma.acs.eventbrowser.status.StatusLineWriter)3