KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > factories > CacheFactory


1 /*
2  * JBoss, Home of Professional Open Source
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.factories;
8
9 import org.jboss.cache.Cache;
10 import org.jboss.cache.config.Configuration;
11 import org.jboss.cache.config.ConfigurationException;
12
13 /**
14  * This factory constructs a cache from a given configuration set, and is also responsible for managing the lifecycle
15  * of the cache.
16  * <p/>
17  * Typical usage would be:
18  * <p/>
19  * <pre>
20  * CacheFactory factory = DefaultCacheFactory.getInstance();
21  * Cache cache = factory.createCache("replSync-service.xml"); // expects this file to be in classpath
22  * <p/>
23  * ...
24  * ...
25  * <p/>
26  * factory.stopCache( cache );
27  * </pre>
28  *
29  * @author <a HREF="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
30  * @see org.jboss.cache.Cache
31  * @since 2.0.0
32  */

33 public interface CacheFactory
34 {
35    /**
36     * Creates and starts a {@link Cache} instance using default configuration settings. See {@link Configuration} for default values.
37     *
38     * @return a cache
39     * @throws ConfigurationException if there are problems with the default configuration
40     */

41    Cache createCache() throws ConfigurationException;
42
43    /**
44     * Creates and starts a {@link org.jboss.cache.Cache} instance
45     *
46     * @param configFileName the named XML file should exist in the classpath.
47     * @return a running {@link org.jboss.cache.Cache} instance
48     * @throws org.jboss.cache.config.ConfigurationException
49     * if there are problems with the configuration
50     */

51    Cache createCache(String JavaDoc configFileName) throws ConfigurationException;
52
53    /**
54     * Creates {@link Cache} instance, and optionally starts it.
55     *
56     * @param configFileName the named XML file should exist in the classpath.
57     * @param start if true, the cache is started before returning.
58     * @return an optionally running {@link Cache} instance
59     * @throws org.jboss.cache.config.ConfigurationException
60     * if there are problems with the configuration
61     */

62    Cache createCache(String JavaDoc configFileName, boolean start) throws ConfigurationException;
63
64    /**
65     * Creates a {@link Cache} instance based on a {@link org.jboss.cache.config.Configuration} passed in.
66     * Implementations should clone the configuration passed in before using it, to ensure the reference is not
67     * shared and cannot be affected by the configuration changing unexpectedly.
68     *
69     * @param configuration the {@link Configuration} object that is passed in to configure the {@link Cache}.
70     * @return a running {@link Cache} instance
71     * @throws org.jboss.cache.config.ConfigurationException
72     * if there are problems with the configuration
73     */

74    Cache createCache(Configuration configuration) throws ConfigurationException;
75
76    /**
77     * Creates {@link Cache} instance, and optionally starts it, based on a {@link org.jboss.cache.config.Configuration} passed in.
78     * Implementations should clone the configuration passed in before using it, to ensure the reference is not
79     * shared and cannot be affected by the configuration changing unexpectedly.
80     *
81     * @param configuration the {@link Configuration} object that is passed in to configure the {@link Cache}.
82     * @param start if true, the cache is started before returning.
83     * @return an optionally running {@link Cache} instance
84     * @throws org.jboss.cache.config.ConfigurationException
85     * if there are problems with the configuration
86     */

87    Cache createCache(Configuration configuration, boolean start) throws ConfigurationException;
88 }
89
Popular Tags