Source:
<code>public CheEnvironmentEngine(SnapshotDao snapshotDao, MachineInstanceProviders machineInstanceProviders, @Named("che.workspace.logs") String machineLogsDir, @Named("che.workspace.default_memory_mb") int defaultMachineMemorySizeMB, EventService eventService, EnvironmentParser environmentParser, DefaultServicesStartStrategy startStrategy, MachineInstanceProvider machineProvider, InfrastructureProvisioner infrastructureProvisioner, @Named("che.api") String apiEndpoint, RecipeDownloader recipeDownloader, ContainerNameGenerator containerNameGenerator, AgentRegistry agentRegistry, WorkspaceSharedPool sharedPool) { this.snapshotDao = snapshotDao; this.eventService = eventService; this.environmentParser = environmentParser; this.startStrategy = startStrategy; this.machineProvider = machineProvider; this.infrastructureProvisioner = infrastructureProvisioner; this.recipeDownloader = recipeDownloader; this.agentRegistry = agentRegistry; this.environments = new ConcurrentHashMap<>(); this.machineInstanceProviders = machineInstanceProviders; this.machineLogsDir = new File(machineLogsDir); this.defaultMachineMemorySizeBytes = Size.parseSize(defaultMachineMemorySizeMB + "MB"); this.stripedLocks = new StripedLocks(16); this.recipeApiPattern = Pattern.compile("(^https?" + apiEndpoint.substring(apiEndpoint.indexOf(":")) + "/recipe/.*$)|(^/recipe/.*$)"); this.containerNameGenerator = containerNameGenerator; <START> eventService.subscribe(event -> { <END> if ((event.getType() == OOM) || (event.getType() == DIE)) { sharedPool.execute(() -> cleanupMachine(event.getWorkspaceId(), event.getMachineId(), event.getType())); } }, InstanceStateEvent.class); }</code><technical_language>please subscribe constructor e.g. java @PostConstruct private void subscribe() { eventSubscriber.subscribe(...) } implicitly expose instance fully constructed</technical_language>

Target:
public CheEnvironmentEngine(SnapshotDao snapshotDao, MachineInstanceProviders machineInstanceProviders, @Named("che.workspace.logs") String machineLogsDir, @Named("che.workspace.default_memory_mb") int defaultMachineMemorySizeMB, EventService eventService, EnvironmentParser environmentParser, DefaultServicesStartStrategy startStrategy, MachineInstanceProvider machineProvider, InfrastructureProvisioner infrastructureProvisioner, @Named("che.api") String apiEndpoint, RecipeDownloader recipeDownloader, ContainerNameGenerator containerNameGenerator, AgentRegistry agentRegistry, WorkspaceSharedPool sharedPool) { this.snapshotDao = snapshotDao; this.eventService = eventService; this.environmentParser = environmentParser; this.startStrategy = startStrategy; this.machineProvider = machineProvider; this.infrastructureProvisioner = infrastructureProvisioner; this.recipeDownloader = recipeDownloader; this.agentRegistry = agentRegistry; this.sharedPool = sharedPool; this.environments = new ConcurrentHashMap<>(); this.machineInstanceProviders = machineInstanceProviders; this.machineLogsDir = new File(machineLogsDir); this.defaultMachineMemorySizeBytes = Size.parseSize(defaultMachineMemorySizeMB + "MB"); this.stripedLocks = new StripedLocks(16); this.recipeApiPattern = Pattern.compile("(^https?" + apiEndpoint.substring(apiEndpoint.indexOf(":")) + "/recipe/.*$)|(^/recipe/.*$)"); this.containerNameGenerator = containerNameGenerator; }