01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.storagemanager;
12:
13: import com.versant.core.metadata.ModelMetaData;
14: import com.versant.core.server.DataStoreInfo;
15: import com.versant.core.server.CompiledQueryCache;
16:
17: import java.util.Set;
18:
19: /**
20: * Factory for StorageManager instances. There is a separate return method
21: * so that a StorageManager pool does not have to create proxies for them.
22: * Implementations must have a public constructor that accepts a
23: * StorageManagerFactoryBuilder argument.
24: */
25: public interface StorageManagerFactory {
26:
27: /**
28: * Perform factory initialization that requires connecting to the
29: * datastore. If the full flag is set then the factory will be fully
30: * initialized e.g. keygen tables populated for the JDBC store. If this
31: * flag is not set then the factory may connect to the datastore (e.g. to
32: * check the server version) but will not do anything that depends on the
33: * existence of tables and so on. The full == false option is useful
34: * for tools that define the schema or do migrations etc.
35: *
36: * All dynamically generated classes will have been compiled at this
37: * point. They can be loaded using loader.
38: */
39: public void init(boolean full, ClassLoader loader);
40:
41: /**
42: * Get a StorageManager instance.
43: */
44: public StorageManager getStorageManager();
45:
46: /**
47: * Return a StorageManager instance. The caller should hold no references
48: * to the returned StorageManager.
49: */
50: public void returnStorageManager(StorageManager sm);
51:
52: /**
53: * Free any resources held by this factory. None of the factory methods
54: * should be called after this but the factory is not required to throw
55: * exceptions if this happens.
56: */
57: public void destroy();
58:
59: /**
60: * Get a native connection to the datastore. This must be wrapped so it
61: * is returned when "closed" by the caller. If native connection access
62: * is not supported then a user exception must be thrown.
63: */
64: public Object getDatastoreConnection();
65:
66: /**
67: * If this factory maintains a connection pool for its StorageManager's
68: * then close all idle connections in the pool. If the factory does
69: * not maintain a pool then this is a NOP.
70: */
71: public void closeIdleDatastoreConnections();
72:
73: /**
74: * Get the meta data being used by the factory.
75: */
76: public ModelMetaData getModelMetaData();
77:
78: /**
79: * Get information about the factories datastore.
80: */
81: public DataStoreInfo getDataStoreInfo();
82:
83: /**
84: * If we are decorating another SMF then return it. Otherwise return null.
85: */
86: public StorageManagerFactory getInnerStorageManagerFactory();
87:
88: /**
89: * Make sure the options match our capabilities.
90: */
91: public void supportedOptions(Set options);
92:
93: /**
94: * Get our CompiledQueryCache.
95: */
96: public CompiledQueryCache getCompiledQueryCache();
97: }
|