|
18 | 18 | import org.seasar.doma.jdbc.statistic.DefaultStatisticManager; |
19 | 19 | import org.seasar.doma.jdbc.statistic.StatisticManager; |
20 | 20 |
|
21 | | -/** Default values for {@link Config} objects. */ |
| 21 | +/** |
| 22 | + * Provides default implementations for the {@link Config} interface. |
| 23 | + * |
| 24 | + * <p>This class serves as a central repository of default implementations for various components |
| 25 | + * used by the Doma framework. These default implementations are used when a custom {@link Config} |
| 26 | + * implementation does not override the corresponding methods. |
| 27 | + * |
| 28 | + * <p>Each field in this class represents a default implementation of a specific interface or |
| 29 | + * component that can be used by {@link Config} implementations. The default implementations provide |
| 30 | + * reasonable behavior for most applications, but can be replaced with custom implementations when |
| 31 | + * needed. |
| 32 | + * |
| 33 | + * <p>For example, the {@link Config#getSqlFileRepository()} method returns {@link |
| 34 | + * #defaultSqlFileRepository} by default, but a custom {@link Config} implementation can override |
| 35 | + * this method to provide a different {@link SqlFileRepository} implementation. |
| 36 | + * |
| 37 | + * <p>This design allows applications to customize only the components they need while using the |
| 38 | + * default implementations for everything else, promoting a flexible and modular architecture. |
| 39 | + * |
| 40 | + * <p>All fields in this class are public, static, and final, making them effectively constants that |
| 41 | + * can be referenced directly if needed, though they are typically accessed through the default |
| 42 | + * methods of the {@link Config} interface. |
| 43 | + */ |
22 | 44 | public final class ConfigSupport { |
23 | 45 |
|
| 46 | + /** |
| 47 | + * Default implementation of {@link SqlFileRepository} that caches SQL files aggressively. |
| 48 | + * |
| 49 | + * <p>This implementation uses a {@link GreedyCacheSqlFileRepository} which loads and caches SQL |
| 50 | + * files when they are first accessed. The cached SQL files are kept in memory for the lifetime of |
| 51 | + * the application, which improves performance but increases memory usage. |
| 52 | + * |
| 53 | + * <p>Used by {@link Config#getSqlFileRepository()} as the default return value. |
| 54 | + */ |
24 | 55 | public static final SqlFileRepository defaultSqlFileRepository = |
25 | 56 | new GreedyCacheSqlFileRepository(); |
26 | 57 |
|
| 58 | + /** |
| 59 | + * Default implementation of {@link ScriptFileLoader} that provides basic script loading |
| 60 | + * capabilities. |
| 61 | + * |
| 62 | + * <p>This implementation uses an anonymous inner class of {@link ScriptFileLoader} with default |
| 63 | + * behavior for loading SQL script files. |
| 64 | + * |
| 65 | + * <p>Used by {@link Config#getScriptFileLoader()} as the default return value. |
| 66 | + */ |
27 | 67 | public static final ScriptFileLoader defaultScriptFileLoader = new ScriptFileLoader() {}; |
28 | 68 |
|
| 69 | + /** |
| 70 | + * Default implementation of {@link JdbcLogger} that logs using java.util.logging. |
| 71 | + * |
| 72 | + * <p>This implementation uses {@link UtilLoggingJdbcLogger} which delegates to the standard Java |
| 73 | + * logging framework (java.util.logging) for logging SQL statements, parameters, and execution |
| 74 | + * times. |
| 75 | + * |
| 76 | + * <p>Used by {@link Config#getJdbcLogger()} as the default return value. |
| 77 | + */ |
29 | 78 | public static final JdbcLogger defaultJdbcLogger = new UtilLoggingJdbcLogger(); |
30 | 79 |
|
| 80 | + /** |
| 81 | + * Default implementation of {@link RequiresNewController} for transaction control. |
| 82 | + * |
| 83 | + * <p>This implementation uses an anonymous inner class of {@link RequiresNewController} with |
| 84 | + * default behavior for managing transactions with the REQUIRES_NEW attribute. |
| 85 | + * |
| 86 | + * <p>Used by {@link Config#getRequiresNewController()} as the default return value. |
| 87 | + */ |
31 | 88 | public static final RequiresNewController defaultRequiresNewController = |
32 | 89 | new RequiresNewController() {}; |
33 | 90 |
|
| 91 | + /** |
| 92 | + * Default implementation of {@link ClassHelper} for class loading and instantiation. |
| 93 | + * |
| 94 | + * <p>This implementation uses an anonymous inner class of {@link ClassHelper} with default |
| 95 | + * behavior for loading classes and creating instances. |
| 96 | + * |
| 97 | + * <p>Used by {@link Config#getClassHelper()} as the default return value. |
| 98 | + */ |
34 | 99 | public static final ClassHelper defaultClassHelper = new ClassHelper() {}; |
35 | 100 |
|
| 101 | + /** |
| 102 | + * Default implementation of {@link CommandImplementors} for creating command objects. |
| 103 | + * |
| 104 | + * <p>This implementation uses an anonymous inner class of {@link CommandImplementors} with |
| 105 | + * default behavior for creating implementations of the {@link |
| 106 | + * org.seasar.doma.jdbc.command.Command} interface. |
| 107 | + * |
| 108 | + * <p>Used by {@link Config#getCommandImplementors()} as the default return value. |
| 109 | + */ |
36 | 110 | public static final CommandImplementors defaultCommandImplementors = new CommandImplementors() {}; |
37 | 111 |
|
| 112 | + /** |
| 113 | + * Default implementation of {@link QueryImplementors} for creating query objects. |
| 114 | + * |
| 115 | + * <p>This implementation uses an anonymous inner class of {@link QueryImplementors} with default |
| 116 | + * behavior for creating implementations of the {@link org.seasar.doma.jdbc.query.Query} |
| 117 | + * interface. |
| 118 | + * |
| 119 | + * <p>Used by {@link Config#getQueryImplementors()} as the default return value. |
| 120 | + */ |
38 | 121 | public static final QueryImplementors defaultQueryImplementors = new QueryImplementors() {}; |
39 | 122 |
|
| 123 | + /** |
| 124 | + * Default implementation of {@link UnknownColumnHandler} that throws an exception. |
| 125 | + * |
| 126 | + * <p>This implementation uses an anonymous inner class of {@link UnknownColumnHandler} which |
| 127 | + * throws an {@link UnknownColumnException} when it encounters a column in a result set that |
| 128 | + * doesn't match any property in the corresponding entity class. |
| 129 | + * |
| 130 | + * <p>Used by {@link Config#getUnknownColumnHandler()} as the default return value. |
| 131 | + */ |
40 | 132 | public static final UnknownColumnHandler defaultUnknownColumnHandler = |
41 | 133 | new UnknownColumnHandler() {}; |
42 | 134 |
|
| 135 | + /** |
| 136 | + * Default implementation of {@link DuplicateColumnHandler} that uses the last occurrence. |
| 137 | + * |
| 138 | + * <p>This implementation uses an anonymous inner class of {@link DuplicateColumnHandler} which |
| 139 | + * silently accepts duplicate columns in a result set and uses the last occurrence of each |
| 140 | + * duplicate column when mapping to entity properties. |
| 141 | + * |
| 142 | + * <p>Used by {@link Config#getDuplicateColumnHandler()} as the default return value. |
| 143 | + */ |
43 | 144 | public static final DuplicateColumnHandler defaultDuplicateColumnHandler = |
44 | 145 | new DuplicateColumnHandler() {}; |
45 | 146 |
|
| 147 | + /** |
| 148 | + * Default implementation of {@link Naming} for name conversion between Java and databases. |
| 149 | + * |
| 150 | + * <p>This implementation uses {@link Naming#DEFAULT} which provides the default naming convention |
| 151 | + * for converting between Java property names and database column names. |
| 152 | + * |
| 153 | + * <p>Used by {@link Config#getNaming()} as the default return value. |
| 154 | + */ |
46 | 155 | public static final Naming defaultNaming = Naming.DEFAULT; |
47 | 156 |
|
| 157 | + /** |
| 158 | + * Default implementation of {@link MapKeyNaming} for map key naming conventions. |
| 159 | + * |
| 160 | + * <p>This implementation uses an anonymous inner class of {@link MapKeyNaming} with default |
| 161 | + * behavior for converting between database column names and keys in Map objects. |
| 162 | + * |
| 163 | + * <p>Used by {@link Config#getMapKeyNaming()} as the default return value. |
| 164 | + */ |
48 | 165 | public static final MapKeyNaming defaultMapKeyNaming = new MapKeyNaming() {}; |
49 | 166 |
|
| 167 | + /** |
| 168 | + * Default implementation of {@link Commenter} for adding comments to SQL statements. |
| 169 | + * |
| 170 | + * <p>This implementation uses an anonymous inner class of {@link Commenter} which adds no |
| 171 | + * comments to SQL statements by default. |
| 172 | + * |
| 173 | + * <p>Used by {@link Config#getCommenter()} as the default return value. |
| 174 | + */ |
50 | 175 | public static final Commenter defaultCommenter = new Commenter() {}; |
51 | 176 |
|
| 177 | + /** |
| 178 | + * Default implementation of {@link EntityListenerProvider} for entity listeners. |
| 179 | + * |
| 180 | + * <p>This implementation uses an anonymous inner class of {@link EntityListenerProvider} which |
| 181 | + * creates one instance of each listener class per entity class. This means that the same listener |
| 182 | + * instance is reused for all operations on entities of the same class. |
| 183 | + * |
| 184 | + * <p>Used by {@link Config#getEntityListenerProvider()} as the default return value. |
| 185 | + */ |
52 | 186 | public static final EntityListenerProvider defaultEntityListenerProvider = |
53 | 187 | new EntityListenerProvider() {}; |
54 | 188 |
|
| 189 | + /** |
| 190 | + * Default implementation of {@link SqlBuilderSettings} for SQL generation. |
| 191 | + * |
| 192 | + * <p>This implementation uses a new instance of {@link SqlBuilderSettings} with default settings |
| 193 | + * for SQL generation. |
| 194 | + * |
| 195 | + * <p>Used by {@link Config#getSqlBuilderSettings()} as the default return value. |
| 196 | + */ |
55 | 197 | public static final SqlBuilderSettings defaultSqlBuilderSettings = new SqlBuilderSettings() {}; |
56 | 198 |
|
| 199 | + /** |
| 200 | + * Default implementation of {@link StatisticManager} for collecting SQL execution statistics. |
| 201 | + * |
| 202 | + * <p>This implementation uses {@link DefaultStatisticManager} which provides basic functionality |
| 203 | + * for collecting and managing statistics about SQL execution. |
| 204 | + * |
| 205 | + * <p>Used by {@link Config#getStatisticManager()} as the default return value. |
| 206 | + */ |
57 | 207 | public static final StatisticManager defaultStatisticManager = new DefaultStatisticManager() {}; |
58 | 208 | } |
0 commit comments