org.eclipse.emf.emfstore.internal.client.model
Class ESWorkspaceProviderImpl

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.client.model.ESWorkspaceProviderImpl
All Implemented Interfaces:
ESWorkspaceProvider, ESCheckoutObserver, ESCommitObserver, ESShareObserver, ESUpdateObserver, ESObserver, ESDisposable

public final class ESWorkspaceProviderImpl
extends Object
implements ESWorkspaceProvider, ESCommitObserver, ESUpdateObserver, ESShareObserver, ESCheckoutObserver, ESDisposable

Controller for workspaces. Different threads can have a different instances associated with them. This is useful in the situation common where the client is a webserver, and different user sessions have different threads associated with them.

Author:
mkoegel, emueller, jfaltermeier

Field Summary
 
Fields inherited from interface org.eclipse.emf.emfstore.client.ESWorkspaceProvider
INSTANCE
 
Constructor Summary
ESWorkspaceProviderImpl()
          Default constructor.
ESWorkspaceProviderImpl(String id)
          Constructor that creates an instance with a specific ID.
 
Method Summary
 void checkoutDone(ESLocalProject project)
          Called on checkout.
 void commitCompleted(ESLocalProject project, ESPrimaryVersionSpec newRevision, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called after the commit is completed.
 void dispose()
          Marker method for classes that need to perform clean-up tasks.
 void flushCommandStack()
          Flushes the command stack.
 AdminConnectionManager getAdminConnectionManager()
          Get the admin connection manager.
 ConnectionManager getConnectionManager()
          Get the connection manager.
 org.eclipse.emf.edit.domain.EditingDomain getEditingDomain()
          Retrieve the editing domain.
static ESWorkspaceProviderImpl getInstance()
          This method retrieves the instance of ESWorkspaceProviderImpl associated with this thread.
static ESWorkspaceProviderImpl getInstance(String workspaceProviderId)
          This method retrieves the workspace provider instance associated with the given ID.
 Workspace getInternalWorkspace()
          Returns the internal workspace.
 String getName()
           
static ObserverBus getObserverBus()
          Returns the ObserverBus.
static ProjectSpace getProjectSpace(org.eclipse.emf.ecore.EObject modelElement)
          Retrieve the project space for a model element.
static ProjectSpace getProjectSpace(Project project)
          Retrieve the project space for a project.
 SessionManager getSessionManager()
          Returns the SessionManager.
 ESWorkspaceImpl getWorkspace()
          Get the current workspace.
static void init()
          Initialize the Workspace Manager.
static Runnable initRunnable(Runnable runnable)
          This method is used by ScopedWorkspaceThreadPoolExecutor which acts as a customized threadpool.
 boolean inspectChanges(ESLocalProject project, ESChangePackage changePackage, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called before the commit proceeds.
 boolean inspectChanges(ESLocalProject project, List<ESChangePackage> changePackages, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called to notify the observer about the changes that will be merged into the project space.
 boolean isDisposed()
          Whether the current workspace is disposed.
 void load()
          (Re-)Initializes the workspace.
 void setAdminConnectionManager(AdminConnectionManager adminConnectionManager)
          Set the admin connection manager.
 void setConnectionManager(ConnectionManager manager)
          Set the connectionmanager.
 void setEditingDomain(org.eclipse.emf.edit.domain.EditingDomain editingDomain)
          Sets the EditingDomain.
 void setName(String name)
           
 void setSessionProvider(ESAbstractSessionProvider sessionProvider)
          Allows the user to set the ESAbstractSessionProvider to use.
 void shareDone(ESLocalProject localProject)
          Called when the share of the passed ESLocalProject completed successfully.
 void updateCompleted(ESLocalProject project, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called after the changes have been applied to the project and the update is completed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ESWorkspaceProviderImpl

public ESWorkspaceProviderImpl()
Default constructor.


ESWorkspaceProviderImpl

public ESWorkspaceProviderImpl(String id)
Constructor that creates an instance with a specific ID.

Parameters:
id - the workspace identifier for the instance
Method Detail

initRunnable

public static Runnable initRunnable(Runnable runnable)
This method is used by ScopedWorkspaceThreadPoolExecutor which acts as a customized threadpool. When behavior is run in a ScopedWorkspaceThreadPoolExecutor, the pool first ensures that the thread local ESWorkspaceProviderImpl is taken from the thread that called for behavior to be run in the threadpool, and then set as the threadlocal instance for the thread running in the behavior in the threadpool.

Parameters:
runnable - the Runnable to be executed in the context of the current workspace
Returns:
the updated Runnable that accordingly sets the workspace

getName

public String getName()
Returns:
the name

setName

public void setName(String name)
Parameters:
name - the name to set

getInstance

public static ESWorkspaceProviderImpl getInstance()
This method retrieves the instance of ESWorkspaceProviderImpl associated with this thread. If there is not yet an associated instance, and no default instance then an instance is created and associated with the calling thread.

Returns:
the WorkspaceProvider for this thread

getInstance

public static ESWorkspaceProviderImpl getInstance(String workspaceProviderId)
This method retrieves the workspace provider instance associated with the given ID. If there is not yet an associated workspace with the given ID, then an instance is created and associated with the calling thread.

Parameters:
workspaceProviderId - the workspace identifier, usually a session id
Returns:
the WorkspaceProvider associated this workspaceIdentifier

init

public static void init()
Initialize the Workspace Manager.


getEditingDomain

public org.eclipse.emf.edit.domain.EditingDomain getEditingDomain()
Retrieve the editing domain.

Returns:
the workspace editing domain

setEditingDomain

public void setEditingDomain(org.eclipse.emf.edit.domain.EditingDomain editingDomain)
Sets the EditingDomain.

Parameters:
editingDomain - new domain.

dispose

public void dispose()
Marker method for classes that need to perform clean-up tasks.

Specified by:
dispose in interface ESDisposable
See Also:
ESDisposable.dispose()

isDisposed

public boolean isDisposed()
Whether the current workspace is disposed.

Returns:
true if the current workspace is disposed, false otherwise

load

public void load()
(Re-)Initializes the workspace. Loads workspace from persistent storage if present. There is always one current Workspace.


flushCommandStack

public void flushCommandStack()
Flushes the command stack.


getAdminConnectionManager

public AdminConnectionManager getAdminConnectionManager()
Get the admin connection manager. Return the admin connection manager for this workspace.

Returns:
the connectionManager

setAdminConnectionManager

public void setAdminConnectionManager(AdminConnectionManager adminConnectionManager)
Set the admin connection manager.

Parameters:
adminConnectionManager - the new AdminConnectionManager to be set

getProjectSpace

public static ProjectSpace getProjectSpace(org.eclipse.emf.ecore.EObject modelElement)
Retrieve the project space for a model element.

Parameters:
modelElement - the model element
Returns:
the project space

getProjectSpace

public static ProjectSpace getProjectSpace(Project project)
Retrieve the project space for a project.

Parameters:
project - the project
Returns:
the project space

getObserverBus

public static ObserverBus getObserverBus()
Returns the ObserverBus.

Returns:
observer bus

getSessionManager

public SessionManager getSessionManager()
Returns the SessionManager.

Returns:
session manager

getWorkspace

public ESWorkspaceImpl getWorkspace()
Get the current workspace. There is always one current workspace.

Specified by:
getWorkspace in interface ESWorkspaceProvider
Returns:
the workspace

getInternalWorkspace

public Workspace getInternalWorkspace()
Returns the internal workspace.

Returns:
the workspace

getConnectionManager

public ConnectionManager getConnectionManager()
Get the connection manager. Return the connection manager for this workspace.

Returns:
the connectionManager

setConnectionManager

public void setConnectionManager(ConnectionManager manager)
Set the connectionmanager.

Parameters:
manager - connection manager.

setSessionProvider

public void setSessionProvider(ESAbstractSessionProvider sessionProvider)
Allows the user to set the ESAbstractSessionProvider to use.

Specified by:
setSessionProvider in interface ESWorkspaceProvider
Parameters:
sessionProvider - the ESAbstractSessionProvider to use
See Also:
ESWorkspaceProvider.setSessionProvider(ESAbstractSessionProvider)

checkoutDone

public void checkoutDone(ESLocalProject project)
Called on checkout.

Specified by:
checkoutDone in interface ESCheckoutObserver
Parameters:
project - the checked out project
See Also:
ESCheckoutObserver.checkoutDone(org.eclipse.emf.emfstore.client.ESLocalProject)

shareDone

public void shareDone(ESLocalProject localProject)
Called when the share of the passed ESLocalProject completed successfully.

Specified by:
shareDone in interface ESShareObserver
Parameters:
localProject - the local project that has been shared
See Also:
ESShareObserver.shareDone(org.eclipse.emf.emfstore.client.ESLocalProject)

inspectChanges

public boolean inspectChanges(ESLocalProject project,
                              List<ESChangePackage> changePackages,
                              org.eclipse.core.runtime.IProgressMonitor monitor)
Called to notify the observer about the changes that will be merged into the project space.

Specified by:
inspectChanges in interface ESUpdateObserver
Parameters:
project - the ESLocalProject that should be updated
changePackages - a list of ESChangePackages containing the update changes
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
Returns:
false if the observer wants to cancel the update, true otherwise
See Also:
ESUpdateObserver.inspectChanges(org.eclipse.emf.emfstore.client.ESLocalProject, java.util.List, org.eclipse.core.runtime.IProgressMonitor)

updateCompleted

public void updateCompleted(ESLocalProject project,
                            org.eclipse.core.runtime.IProgressMonitor monitor)
Called after the changes have been applied to the project and the update is completed.

Specified by:
updateCompleted in interface ESUpdateObserver
Parameters:
project - the ESLocalProject whose update has been completed
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
See Also:
ESUpdateObserver.updateCompleted(org.eclipse.emf.emfstore.client.ESLocalProject, org.eclipse.core.runtime.IProgressMonitor)

inspectChanges

public boolean inspectChanges(ESLocalProject project,
                              ESChangePackage changePackage,
                              org.eclipse.core.runtime.IProgressMonitor monitor)
Called before the commit proceeds. A callback method to initiate the commit dialog and allow the user to confirm the changes.

Specified by:
inspectChanges in interface ESCommitObserver
Parameters:
project - the project the commit occurs on
changePackage - the ESChangePackage
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
Returns:
true if the changes have been confirmed, false - otherwise.
See Also:
ESCommitObserver.inspectChanges(org.eclipse.emf.emfstore.client.ESLocalProject, org.eclipse.emf.emfstore.server.model.ESChangePackage, org.eclipse.core.runtime.IProgressMonitor)

commitCompleted

public void commitCompleted(ESLocalProject project,
                            ESPrimaryVersionSpec newRevision,
                            org.eclipse.core.runtime.IProgressMonitor monitor)
Called after the commit is completed.

Specified by:
commitCompleted in interface ESCommitObserver
Parameters:
project - the project on which the commit has completed
newRevision - the new revision that was created by the commit
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
See Also:
ESCommitObserver.commitCompleted(org.eclipse.emf.emfstore.client.ESLocalProject, org.eclipse.emf.emfstore.server.model.versionspec.ESPrimaryVersionSpec, org.eclipse.core.runtime.IProgressMonitor)


Copyright © 2015. All Rights Reserved.