implement DEV workspace and project automation authority
This commit is contained in:
@@ -101,18 +101,18 @@ public class StudioApplicationConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
AssetCatalog assetCatalog(PackerWorkspaceService packer) {
|
||||
return new PackerAssetCatalog(packer);
|
||||
AssetCatalog assetCatalog(PackerWorkspaceService packer, p.studio.api.automation.ProjectAccess access) {
|
||||
return new PackerAssetCatalog(packer, access);
|
||||
}
|
||||
|
||||
@Bean
|
||||
AssetCommands assetCommands(PackerWorkspaceService packer) {
|
||||
return new PackerAssetCommands(packer);
|
||||
AssetCommands assetCommands(PackerWorkspaceService packer, p.studio.api.automation.ProjectAccess access) {
|
||||
return new PackerAssetCommands(packer, access);
|
||||
}
|
||||
|
||||
@Bean
|
||||
AssetPacking assetPacking(PackerWorkspaceService packer, OperationExecutor operations) {
|
||||
return new PackerAssetPacking(packer, operations);
|
||||
AssetPacking assetPacking(PackerWorkspaceService packer, OperationExecutor operations, p.studio.api.automation.ProjectAccess access) {
|
||||
return new PackerAssetPacking(packer, operations, access);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -126,8 +126,8 @@ public class StudioApplicationConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
AssetWorkspaceStorage assetWorkspaceStorage() {
|
||||
return new FileSystemAssetWorkspaceStorage();
|
||||
AssetWorkspaceStorage assetWorkspaceStorage(p.studio.api.automation.ProjectAccess access) {
|
||||
return new FileSystemAssetWorkspaceStorage(access);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -146,18 +146,18 @@ public class StudioApplicationConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
AssetMetadataService assetMetadataService(ObjectMapper mapper) {
|
||||
return new AssetStudioMetadataService(mapper);
|
||||
AssetMetadataService assetMetadataService(ObjectMapper mapper, p.studio.api.automation.ProjectAccess access) {
|
||||
return new AssetStudioMetadataService(mapper, access);
|
||||
}
|
||||
|
||||
@Bean
|
||||
SceneBankWorkflow sceneBankWorkflow(AssetCatalog assetCatalog, ObjectMapper mapper) {
|
||||
return new SceneBankWorkflowService(assetCatalog, mapper);
|
||||
SceneBankWorkflow sceneBankWorkflow(AssetCatalog assetCatalog, ObjectMapper mapper, p.studio.api.automation.ProjectAccess access) {
|
||||
return new SceneBankWorkflowService(assetCatalog, mapper, access);
|
||||
}
|
||||
|
||||
@Bean
|
||||
TiledAssetService tiledAssetService(AssetMetadataService metadataService) {
|
||||
return new TiledAssetGenerationService(metadataService);
|
||||
TiledAssetService tiledAssetService(AssetMetadataService metadataService, p.studio.api.automation.ProjectAccess access) {
|
||||
return new TiledAssetGenerationService(metadataService, access);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -177,8 +177,8 @@ public class StudioApplicationConfiguration {
|
||||
|
||||
@Bean
|
||||
Shipper shipper(CompilerBuildGateway compiler, PackerWorkspaceService packer, ObjectMapper mapper,
|
||||
OperationExecutor operations) {
|
||||
return new StudioShipperService(compiler, packer, mapper, operations);
|
||||
OperationExecutor operations, p.studio.api.automation.ProjectAccess access) {
|
||||
return new StudioShipperService(compiler, packer, mapper, operations, access);
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
@@ -198,8 +198,8 @@ public class StudioApplicationConfiguration {
|
||||
|
||||
@Bean
|
||||
ExecutionControllerFactory executionControllerFactory(Shipper shipper, RuntimeGateway runtime,
|
||||
OperationExecutor operations) {
|
||||
return new DefaultExecutionControllerFactory(shipper, runtime, operations);
|
||||
OperationExecutor operations, p.studio.api.automation.ProjectAccess access) {
|
||||
return new DefaultExecutionControllerFactory(shipper, runtime, operations, access);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -222,10 +222,16 @@ public class StudioApplicationConfiguration {
|
||||
return new LspLifecycleAdapter(lifecycle);
|
||||
}
|
||||
|
||||
@Bean
|
||||
p.studio.core.project.ProjectAccessRegistry projectAccessRegistry() {
|
||||
return new p.studio.core.project.ProjectAccessRegistry();
|
||||
}
|
||||
|
||||
@Bean
|
||||
ProjectSessionFactory projectSessionFactory(ProjectLocalStudioStateStore stateStore,
|
||||
ProjectLocalStudioSetupStore setupStore, LspLifecyclePort lsp) {
|
||||
return new DefaultProjectSessionFactory(stateStore, setupStore, lsp);
|
||||
ProjectLocalStudioSetupStore setupStore, LspLifecyclePort lsp,
|
||||
p.studio.core.project.ProjectAccessRegistry access, OperationExecutor operations) {
|
||||
return new DefaultProjectSessionFactory(stateStore, setupStore, lsp, access, operations);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -39,6 +39,9 @@ public final class ExecutorOperationExecutor implements OperationExecutor {
|
||||
private final String summary;
|
||||
private final Callable<R> operation;
|
||||
private final CompletableFuture<R> completion = new CompletableFuture<>();
|
||||
private final CompletableFuture<Void> termination = new CompletableFuture<>();
|
||||
private final Object workerLifecycle = new Object();
|
||||
private boolean started;
|
||||
private final CopyOnWriteArrayList<Consumer<OperationSnapshot>> subscribers = new CopyOnWriteArrayList<>();
|
||||
private final AtomicReference<OperationSnapshot> snapshot;
|
||||
private volatile Future<?> task;
|
||||
@@ -62,12 +65,19 @@ public final class ExecutorOperationExecutor implements OperationExecutor {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}) {
|
||||
@Override public void run() {
|
||||
synchronized (workerLifecycle) { started = true; }
|
||||
try { super.run(); }
|
||||
finally { termination.complete(null); }
|
||||
}
|
||||
};
|
||||
task = submitted;
|
||||
try {
|
||||
transition(OperationState.RUNNING, summary);
|
||||
executor.execute(submitted);
|
||||
} catch (RuntimeException failure) {
|
||||
termination.complete(null);
|
||||
if (transitionTerminal(OperationState.FAILED, failureSummary(failure))) {
|
||||
completion.completeExceptionally(failure);
|
||||
}
|
||||
@@ -89,6 +99,8 @@ public final class ExecutorOperationExecutor implements OperationExecutor {
|
||||
return completion;
|
||||
}
|
||||
|
||||
@Override public CompletionStage<Void> termination() { return termination; }
|
||||
|
||||
@Override
|
||||
public boolean cancel() {
|
||||
while (true) {
|
||||
@@ -99,8 +111,9 @@ public final class ExecutorOperationExecutor implements OperationExecutor {
|
||||
final OperationSnapshot cancelled = new OperationSnapshot(id, OperationState.CANCELLED, Instant.now(), summary);
|
||||
if (snapshot.compareAndSet(current, cancelled)) {
|
||||
final Future<?> submitted = task;
|
||||
if (submitted != null) {
|
||||
submitted.cancel(true);
|
||||
synchronized (workerLifecycle) {
|
||||
if (submitted != null) submitted.cancel(true);
|
||||
if (!started) termination.complete(null);
|
||||
}
|
||||
completion.cancel(false);
|
||||
publish(cancelled);
|
||||
|
||||
Reference in New Issue
Block a user