350fec62a97715a7a7cefa2254afd70d2c7fe328
[idea/community.git] / platform / external-system-impl / src / com / intellij / openapi / externalSystem / service / RemoteExternalSystemFacade.java
1 package com.intellij.openapi.externalSystem.service;
2
3 import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
4 import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
5 import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
6 import com.intellij.openapi.externalSystem.service.internal.ExternalSystemTaskAware;
7 import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager;
8 import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver;
9 import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemTaskManager;
10 import org.jetbrains.annotations.NotNull;
11
12 import java.rmi.Remote;
13 import java.rmi.RemoteException;
14 import java.util.Collections;
15 import java.util.Map;
16 import java.util.Set;
17
18 /**
19  * Serves as a facade for working with external system which might be located at an external (non-ide) process.
20  * <p/>
21  * The main idea is that we don't want to use it directly from an ide process (to avoid unnecessary heap/perm gen pollution, 
22  * memory leaks etc). So, we use it at external process and current class works as a facade to it from ide process.
23  * 
24  * @author Denis Zhdanov
25  * @since 8/8/11 10:52 AM
26  */
27 public interface RemoteExternalSystemFacade<S extends ExternalSystemExecutionSettings> extends Remote, ExternalSystemTaskAware {
28
29   /** <a href="http://en.wikipedia.org/wiki/Null_Object_pattern">Null object</a> for {@link RemoteExternalSystemFacade}. */
30   RemoteExternalSystemFacade<?> NULL_OBJECT = new RemoteExternalSystemFacade<ExternalSystemExecutionSettings>() {
31     @NotNull
32     @Override
33     public RemoteExternalSystemProjectResolver<ExternalSystemExecutionSettings> getResolver()
34       throws RemoteException, IllegalStateException
35     {
36       return RemoteExternalSystemProjectResolver.NULL_OBJECT;
37     }
38
39
40     @NotNull
41     @Override
42     public RemoteExternalSystemTaskManager<ExternalSystemExecutionSettings> getTaskManager() throws RemoteException {
43       return RemoteExternalSystemTaskManager.NULL_OBJECT;
44     }
45
46     @Override
47     public void applySettings(@NotNull ExternalSystemExecutionSettings settings) throws RemoteException {
48     }
49
50     @Override
51     public void applyProgressManager(@NotNull RemoteExternalSystemProgressNotificationManager progressManager) throws RemoteException {
52     }
53
54     @Override
55     public boolean isTaskInProgress(@NotNull ExternalSystemTaskId id) throws RemoteException {
56       return false;
57     }
58
59     @Override
60     public boolean cancelTask(@NotNull ExternalSystemTaskId id) throws RemoteException {
61       return false;
62     }
63
64     @NotNull
65     @Override
66     public Map<ExternalSystemTaskType, Set<ExternalSystemTaskId>> getTasksInProgress() throws RemoteException {
67       return Collections.emptyMap();
68     }
69   };
70
71   /**
72    * Exposes <code>'resolve external system project'</code> service that works at another process.
73    *
74    * @return                        <code>'resolve external system project'</code> service
75    * @throws RemoteException        in case of unexpected I/O exception during processing
76    * @throws IllegalStateException  in case of inability to create the service
77    */
78   @NotNull
79   RemoteExternalSystemProjectResolver<S> getResolver() throws RemoteException, IllegalStateException;
80
81   /**
82    * Exposes <code>'run external system task'</code> service which works at another process.
83    *
84    * @return external system build manager
85    * @throws RemoteException  in case of inability to create the service
86    */
87   @NotNull
88   RemoteExternalSystemTaskManager<S> getTaskManager() throws RemoteException;
89
90   /**
91    * Asks remote external system process to apply given settings.
92    *
93    * @param settings            settings to apply
94    * @throws RemoteException    in case of unexpected I/O exception during processing
95    */
96   void applySettings(@NotNull S settings) throws RemoteException;
97
98   /**
99    * Asks remote external system process to use given progress manager.
100    *
101    * @param progressManager  progress manager to use
102    * @throws RemoteException    in case of unexpected I/O exception during processing
103    */
104   void applyProgressManager(@NotNull RemoteExternalSystemProgressNotificationManager progressManager) throws RemoteException;
105 }