Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » kaha » [javadoc | source]
    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.activemq.kaha;
   18   
   19   import java.io.File;
   20   import java.io.IOException;
   21   import java.util.concurrent.atomic.AtomicLong;
   22   
   23   import org.apache.activemq.kaha.impl.KahaStore;
   24   
   25   /**
   26    * Factory for creating stores
   27    * 
   28    * @version $Revision: 1.2 $
   29    */
   30   public final class StoreFactory {
   31   
   32       private StoreFactory() {
   33       }
   34   
   35       /**
   36        * open or create a Store
   37        * 
   38        * @param name
   39        * @param mode
   40        * @return the opened/created store
   41        * @throws IOException
   42        */
   43       public static Store open(String name, String mode) throws IOException {
   44           return new KahaStore(name, mode,new AtomicLong());
   45       }
   46       
   47       /**
   48        * Open or create a Store
   49        * 
   50        * @param directory
   51        * @param mode
   52        * @return
   53        * @throws IOException
   54        */
   55       public static Store open(File directory, String mode) throws IOException {
   56           return new KahaStore(directory, mode, new AtomicLong());
   57       }
   58       
   59       /**
   60        * open or create a Store
   61        * @param name
   62        * @param mode
   63        * @param size
   64        * @return the opened/created store
   65        * @throws IOException
   66        */
   67       public static Store open(String name, String mode, AtomicLong size) throws IOException {
   68           return new KahaStore(name, mode,size);
   69       }
   70       
   71   
   72       /**
   73        * Open or create a Store
   74        * 
   75        * @param directory
   76        * @param mode
   77        * @param size
   78        * @return
   79        * @throws IOException
   80        */
   81       public static Store open(File directory, String mode, AtomicLong size) throws IOException {
   82           return new KahaStore(directory, mode, size);
   83       }
   84       
   85   
   86       /**
   87        * Delete a database
   88        * 
   89        * @param name of the database
   90        * @return true if successful
   91        * @throws IOException
   92        */
   93       public static boolean delete(String name) throws IOException {
   94           KahaStore store = new KahaStore(name, "rw");
   95           return store.delete();
   96       }
   97       
   98       /**
   99        * Delete a database
  100        * 
  101        * @param directory
  102        * @return true if successful
  103        * @throws IOException
  104        */
  105       public static boolean delete(File directory) throws IOException {
  106           KahaStore store = new KahaStore(directory, "rw");
  107           return store.delete();
  108       }
  109   }

Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » kaha » [javadoc | source]