1 /* 2 * ModeShape (http://www.modeshape.org) 3 * See the COPYRIGHT.txt file distributed with this work for information 4 * regarding copyright ownership. Some portions may be licensed 5 * to Red Hat, Inc. under one or more contributor license agreements. 6 * See the AUTHORS.txt file in the distribution for a full listing of 7 * individual contributors. 8 * 9 * ModeShape is free software. Unless otherwise indicated, all code in ModeShape 10 * is licensed to you under the terms of the GNU Lesser General Public License as 11 * published by the Free Software Foundation; either version 2.1 of 12 * the License, or (at your option) any later version. 13 * 14 * ModeShape is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this software; if not, write to the Free 21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 22 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 23 */ 24 package org.modeshape.connector.infinispan; 25 26 import java.util.UUID; 27 import org.infinispan.Cache; 28 import org.modeshape.graph.connector.base.StandardMapWorkspace; 29 30 /** 31 * 32 */ 33 public class InfinispanWorkspace extends StandardMapWorkspace<InfinispanNode> { 34 35 private Cache<UUID, InfinispanNode> workspaceCache; 36 37 /** 38 * Create a new workspace instance. 39 * 40 * @param name the name of the workspace 41 * @param workspaceCache the Infinispan cache containing the workspace content 42 * @param rootNode the root node for the workspace 43 */ 44 public InfinispanWorkspace( String name, 45 Cache<UUID, InfinispanNode> workspaceCache, 46 InfinispanNode rootNode ) { 47 super(name, workspaceCache, rootNode); 48 this.workspaceCache = workspaceCache; 49 } 50 51 /** 52 * Create a new workspace instance. 53 * 54 * @param name the name of the workspace 55 * @param workspaceCache the Infinispan cache containing the workspace content 56 * @param originalToClone the workspace that is to be cloned 57 */ 58 public InfinispanWorkspace( String name, 59 Cache<UUID, InfinispanNode> workspaceCache, 60 InfinispanWorkspace originalToClone ) { 61 super(name, workspaceCache, originalToClone); 62 this.workspaceCache = workspaceCache; 63 } 64 65 public void destroy() { 66 this.workspaceCache.clear(); 67 } 68 69 /** 70 * This method shuts down the workspace and makes it no longer usable. This method should also only be called once. 71 */ 72 public void shutdown() { 73 this.workspaceCache.stop(); 74 } 75 76 }