Skip to content

Commit

Permalink
chore: move StorageAccessible out of StorageServiceImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
D-D-H committed Oct 17, 2023
1 parent ec1eb51 commit 463967a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.PositiveOrZero;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/********************************************************************************
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
package org.eclipse.jifa.server.condition;

import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;

public class StorageAccessible extends AnyNestedCondition {

public StorageAccessible() {
super(ConfigurationPhase.REGISTER_BEAN);
}

@SuppressWarnings("unused")
@Master
@ElasticSchedulingStrategy
static class MasterWithElasticSchedulingStrategy {
}

@SuppressWarnings("unused")
@org.eclipse.jifa.server.condition.Worker
static class Worker {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class ElasticWorkerController {

private final WorkerService workerService;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public ElasticWorkerController(WorkerService workerService) {
this.workerService = workerService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@
import org.eclipse.jifa.common.util.ExecutorFactory;
import org.eclipse.jifa.common.util.Validate;
import org.eclipse.jifa.server.ConfigurationAccessor;
import org.eclipse.jifa.server.condition.ElasticSchedulingStrategy;
import org.eclipse.jifa.server.condition.Master;
import org.eclipse.jifa.server.condition.StorageAccessible;
import org.eclipse.jifa.server.domain.dto.FileTransferRequest;
import org.eclipse.jifa.server.enums.FileType;
import org.eclipse.jifa.server.service.StorageService;
import org.eclipse.jifa.server.support.FileTransferListener;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
Expand All @@ -70,28 +68,10 @@
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicLong;

@Conditional(StorageServiceImpl.Accessible.class)
@Conditional(StorageAccessible.class)
@Service
public class StorageServiceImpl extends ConfigurationAccessor implements StorageService {

static class Accessible extends AnyNestedCondition {

public Accessible() {
super(ConfigurationPhase.REGISTER_BEAN);
}

@SuppressWarnings("unused")
@Master
@ElasticSchedulingStrategy
static class MasterWithElasticSchedulingStrategy {
}

@SuppressWarnings("unused")
@org.eclipse.jifa.server.condition.Worker
static class Worker {
}
}

private Executor executor;

private Path basePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class ElasticWorkerRelatedTasks extends ConfigurationAccessor {

private final WorkerService workerService;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public ElasticWorkerRelatedTasks(LockSupport lockSupport, ElasticWorkerRepo elasticWorkerRepo,
ElasticWorkerScheduler elasticWorkerScheduler,
WorkerService workerService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@

import lombok.extern.slf4j.Slf4j;
import org.eclipse.jifa.server.ConfigurationAccessor;
import org.eclipse.jifa.server.condition.StorageAccessible;
import org.eclipse.jifa.server.enums.FileType;
import org.eclipse.jifa.server.repository.FileRepo;
import org.eclipse.jifa.server.repository.TransferringFileRepo;
import org.eclipse.jifa.server.service.FileService;
import org.eclipse.jifa.server.service.StorageService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Conditional;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

Expand All @@ -28,7 +29,7 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;

@ConditionalOnBean(StorageService.class)
@Conditional(StorageAccessible.class)
@Component
@Slf4j
public class StorageRelatedTasks extends ConfigurationAccessor {
Expand Down

0 comments on commit 463967a

Please sign in to comment.