Este conteúdo não está disponível no idioma selecionado.

16.43. Using Workspaces


ModeShape graphs have the notion of workspaces that provide different views of the content. Some graphs may have one workspace, while others may have multiple workspaces. Some graphs will allow a client to create new workspaces or destroy existing workspaces, while other graphs will not allow adding or removing workspaces. Some graphs may have workspaces that may show the same (or very similar) content, while other graphs may have workspaces that contain completely independent content.
The Graph object is always bound to a workspace, which initially is the default workspace. To find out what the name of the default workspace is, ask for the current workspace after creating the Graph:
Workspace current = graph.getCurrentWorkspace();
To obtain the list of workspaces available in a graph, ask for them:
Set<String> workspaceNames = graph.getWorkspaces();
Once you know the name of a particular workspace, you can specify that the graph should use it:
graph.useWorkspace("myWorkspace");
From this point forward, all requests will apply to the workspace named "myWorkspace". At any time, you can use a different workspace, which will affect all subsequent requests made using the graph. To go back to the default workspace, supply a null name:
graph.useWorkspace(null);
Of course, creating a new workspace is just as easy:
graph.createWorkspace().named("newWorkspace");
This will attempt to create a workspace named "newWorkspace", which will fail if that workspace already exists. You may want to create a new workspace with a name that should be altered if the name you supply is already used. The following code shows how you can do this:
graph.createWorkspace().namedSomethingLike("newWorkspace");
If there is no existing workspace named "newWorkspace", a new one will be created with this name. However, if "newWorkspace" already exists, this call will create a workspace with a name that is some alteration of the supplied name.
You can also clone workspaces, too:
graph.createWorkspace().clonedFrom("original").named("something");
or
graph.createWorkspace().clonedFrom("original").namedSomethingLike("something");
As you can see, it is very easy to specify which workspace you want to use or to create new workspaces. You can also find out which workspace the graph is currently using:
String current = graph.getCurrentWorkspaceName();
or, if you want, you can get more information about the workspace:
Workspace current = graph.getCurrentWorkspace();
String name = current.getName();
Location rootLocation = current.getRoot();
Red Hat logoGithubredditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

Theme

© 2026 Red Hat
Voltar ao topo