KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > hibernate > jmx > HibernateMBean


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.hibernate.jmx;
8
9 import org.jboss.system.ServiceMBean;
10 import org.jboss.deployment.DeploymentInfo;
11
12 import org.hibernate.SessionFactory;
13
14 import javax.management.MBeanRegistration JavaDoc;
15 import javax.management.ObjectName JavaDoc;
16 import java.net.URL JavaDoc;
17 import java.util.Date JavaDoc;
18
19 /**
20  * Describes a Hibernate service MBean. Configures a
21  * {@link org.hibernate.SessionFactory} instance and exposes it through JNDI.
22  * The SessionFactory is built through either<ul>
23  * <li>auto-discovery : where the classpath of the top-level deployment
24  * containing this MBean is searched for jars and directories to add to the
25  * config
26  * <li>har-deployment : where the deployment containing this MBean description
27  * conforms to the har layout definition.
28  * </ul>
29  *
30  * @version <tt>$Revision: 35017 $</tt>
31  * @author <a HREF="mailto:alex@jboss.org">Alexey Loubyansky</a>
32  * @author <a HREF="mailto:gavin@hibernate.org">Gavin King</a>
33  * @author <a HREF="mailto:steve@hibernate.org">Steve Ebersole</a>
34  * @author <a HREF="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
35  */

36 public interface HibernateMBean extends ServiceMBean, MBeanRegistration JavaDoc
37 {
38
39     /**
40     * The url to the har deployment, if MBean is operating in har deployment mode.
41      *
42      * @return The url of the har containing this MBean, or null if not part of
43      * a har deployment.
44      */

45     public URL JavaDoc getHarUrl();
46
47     /**
48      * Enables scanning of the entire deployment classpath for any potential mapping
49      * sources (jars or directories).
50      * <p/>
51      * Only used in the case of har deployments.
52      *
53      * @return
54      */

55     public boolean isScanForMappingsEnabled();
56
57     /**
58      * Enables scanning of the entire deployment classpath for any potential mapping
59      * sources (jars or directories).
60      * <p/>
61      * Only used in the case of har deployments.
62      *
63      * @param scanForMappings
64      */

65     public void setScanForMappingsEnabled(boolean scanForMappings);
66
67    /**
68     * Retrieve MBean's current deployment info.
69     *
70     * @return the deployment info.
71     */

72    public DeploymentInfo getDeploymentInfo();
73
74     /**
75      * The JNDI namespace where the managed {@link org.hibernate.SessionFactory} is to be bound.
76      *
77      * @return The current setting value.
78      */

79     public String JavaDoc getSessionFactoryName();
80
81     /**
82      * The JNDI namespace where the managed {@link org.hibernate.SessionFactory} is to be bound.
83      *
84      * @param sessionFactoryName The new JNDI namespace to use.
85      */

86     public void setSessionFactoryName(String JavaDoc sessionFactoryName);
87
88     /**
89      * The JMX name of a {@link org.jboss.cache.TreeCache} MBean to be used as the second level cache.
90      * <p/>
91      * Note : only used when {@link #getCacheProviderClass} == {@link org.jboss.hibernate.cache.DeployedTreeCacheProvider}
92      *
93      * @return The current setting
94      */

95     public ObjectName JavaDoc getDeployedTreeCacheObjectName();
96
97     /**
98      * The JMX name of a {@link org.jboss.cache.TreeCache} MBean to be used as the second level cache.
99      *
100      * @param deployedTreeCacheObjectName The new mbean object name.
101      */

102     public void setDeployedTreeCacheObjectName(ObjectName JavaDoc deployedTreeCacheObjectName);
103
104     /**
105      * Retreive the service name of the managed stats mbean.
106      * <p/>
107      * When statistics are enabled on the managed session factory, the mbean
108      * automatically manages a stats mbean for stats exposure via jmx. This
109      * returns the name under which that stats mbean is available from the jmx
110      * server.
111      *
112      * @return The service name of the stats mbean, or null if stats not enabled.
113      */

114     public ObjectName JavaDoc getStatisticsServiceName();
115
116     /**
117      * The name of the dialect class to use for communicating with the database.
118      *
119      * @return The current setting value.
120      *
121      * @see org.hibernate.cfg.Environment#DIALECT
122      */

123     public String JavaDoc getDialect();
124
125     /**
126      * The name of the dialect class to use for communicating with the database.
127      *
128      * @param dialect The new dialect class name to use.
129      */

130     public void setDialect(String JavaDoc dialect);
131
132     /**
133      * The form, if any, of schema generation which should be used.
134      *
135      * @return The current setting value.
136      *
137      * @see org.hibernate.cfg.Environment#HBM2DDL_AUTO
138      */

139     public String JavaDoc getHbm2ddlAuto();
140
141     /**
142      * The form, if any, of schema generation which should be used.
143      *
144      * @param hbm2ddlAuto The new hbm2ddl setting; valid values are: update, create, create-drop
145      */

146     public void setHbm2ddlAuto(String JavaDoc hbm2ddlAuto);
147
148     /**
149      * The JNDI namespace of the {@link javax.sql.DataSource} which should be used by the managed {@link
150      * org.hibernate.SessionFactory}.
151      *
152      * @return The current setting value.
153      *
154      * @see org.hibernate.cfg.Environment#DATASOURCE
155      */

156     public String JavaDoc getDatasourceName();
157
158     /**
159      * The JNDI namespace of the {@link javax.sql.DataSource} which should be used by the managed {@link
160      * org.hibernate.SessionFactory}.
161      *
162      * @param datasourceName The new DataSource JNDI name to use.
163      */

164     public void setDatasourceName(String JavaDoc datasourceName);
165
166     /**
167      * The username used to access the specified datasource.
168      *
169      * @return The current setting value.
170      *
171      * @see org.hibernate.cfg.Environment#USER
172      */

173     public String JavaDoc getUsername();
174
175     /**
176      * The username used to access the specified datasource.
177      *
178      * @param username The new username value.
179      */

180     public void setUsername(String JavaDoc username);
181
182     /**
183      * The password used to access the specified datasource.
184      *
185      * @param password The new password value.
186      */

187     public void setPassword(String JavaDoc password);
188
189     /**
190      * Should sql comments be used?
191      *
192      * @return
193      *
194      * @see org.hibernate.cfg.Environment#USE_SQL_COMMENTS
195      */

196     public Boolean JavaDoc getSqlCommentsEnabled();
197
198     /**
199      * Should sql comments be used?
200      *
201      * @param commentsEnabled
202      */

203     public void setSqlCommentsEnabled(Boolean JavaDoc commentsEnabled);
204
205     /**
206      * The default database schema to use within the database being mapped.
207      * <p/>
208      * Used for databases which support the concept of schemas instead of catalogs.
209      *
210      * @return The current setting value.
211      *
212      * @see #getDefaultCatalog
213      * @see org.hibernate.cfg.Environment#DEFAULT_SCHEMA
214      */

215     public String JavaDoc getDefaultSchema();
216
217     /**
218      * The default database schema to use within the database being mapped.
219      *
220      * @param defaultSchema The new default schema name to use.
221      */

222     public void setDefaultSchema(String JavaDoc defaultSchema);
223
224     /**
225      * The default database catalog to use within the database being mapped.
226      * <p/>
227      * Used for databases which support the concept of catalogs instead of schemas.
228      *
229      * @return The current setting value.
230      *
231      * @see #getDefaultSchema
232      * @see org.hibernate.cfg.Environment#DEFAULT_CATALOG
233      */

234     public String JavaDoc getDefaultCatalog();
235
236     /**
237      * The default database catalog to use within the database being mapped.
238      *
239      * @param defaultCatalog The new default catalog name.
240      */

241     public void setDefaultCatalog(String JavaDoc defaultCatalog);
242
243     /**
244      * The maximum outer join fetch depth.
245      *
246      * @return The current setting value
247      *
248      * @see org.hibernate.cfg.Environment#MAX_FETCH_DEPTH
249      */

250     public Integer JavaDoc getMaxFetchDepth();
251
252     /**
253      * The maximum outer join fetch depth.
254      *
255      * @param maxFetchDepth The new max fetch depth value
256      */

257     public void setMaxFetchDepth(Integer JavaDoc maxFetchDepth);
258
259     /**
260      * The JDBC batch update batch size.
261      *
262      * @return The current setting value
263      *
264      * @see org.hibernate.cfg.Environment#STATEMENT_BATCH_SIZE
265      */

266     public Integer JavaDoc getJdbcBatchSize();
267
268     /**
269      * The JDBC batch update batch size.
270      *
271      * @param jdbcBatchSize The new value for the number of statements to batch together.
272      */

273     public void setJdbcBatchSize(Integer JavaDoc jdbcBatchSize);
274
275     /**
276      * The JDBC fetch size.
277      *
278      * @return The current setting value
279      *
280      * @see org.hibernate.cfg.Environment#STATEMENT_FETCH_SIZE
281      */

282     public Integer JavaDoc getJdbcFetchSize();
283
284     /**
285      * The JDBC fetch size.
286      *
287      * @param jdbcFetchSize The new value for the number of rows to fetch from server at a time.
288      */

289     public void setJdbcFetchSize(Integer JavaDoc jdbcFetchSize);
290
291     /**
292      * Are scrollable result sets enabled?
293      *
294      * @return The current setting value
295      *
296      * @see org.hibernate.cfg.Environment#USE_SCROLLABLE_RESULTSET
297      */

298     public Boolean JavaDoc getJdbcScrollableResultSetEnabled();
299
300     /**
301      * Are scrollable result sets enabled?
302      *
303      * @param jdbcScrollableResultSetEnabled The new value.
304      */

305     public void setJdbcScrollableResultSetEnabled(Boolean JavaDoc jdbcScrollableResultSetEnabled);
306
307     /**
308      * Is the use of JDBC3 <tt>getGeneratedKeys()</tt> enabled?
309      *
310      * @return The current setting value
311      *
312      * @see org.hibernate.cfg.Environment#USE_GET_GENERATED_KEYS
313      */

314     public Boolean JavaDoc getGetGeneratedKeysEnabled();
315
316     /**
317      * Is the use of JDBC3 <tt>getGeneratedKeys()</tt> enabled?
318      *
319      * @param getGeneratedKeysEnabled The new value.
320      */

321     public void setGetGeneratedKeysEnabled(Boolean JavaDoc getGeneratedKeysEnabled);
322
323     /**
324      * Should Hibernate allow JDBC batch-updating of versioned entities?
325      * <p/>
326      * Many drivers have bugs regarding the row counts returned in response to JDBC Batch API operations; in these cases,
327      * this should definitely be set to false.
328      *
329      * @return The current setting value
330      *
331      * @see org.hibernate.cfg.Environment#BATCH_VERSIONED_DATA
332      */

333     public Boolean JavaDoc getBatchVersionedDataEnabled();
334
335     /**
336      * Should Hibernate allow JDBC batch-updating of versioned entities?
337      *
338      * @param batchVersionedDataEnabled
339      */

340     public void setBatchVersionedDataEnabled(Boolean JavaDoc batchVersionedDataEnabled);
341
342     /**
343      * Should Hibernate use I/O streaming for handling binary/LOB data?
344      *
345      * @return
346      *
347      * @see org.hibernate.cfg.Environment#USE_STREAMS_FOR_BINARY
348      */

349     public Boolean JavaDoc getStreamsForBinaryEnabled();
350
351     /**
352      * Should Hibernate use I/O streaming for handling binary/LOB data?
353      *
354      * @param streamsForBinaryEnabled
355      */

356     public void setStreamsForBinaryEnabled(Boolean JavaDoc streamsForBinaryEnabled);
357
358     /**
359      * Query substitutions to use.
360      *
361      * @return The current setting value
362      *
363      * @see org.hibernate.cfg.Environment#QUERY_SUBSTITUTIONS
364      */

365     public String JavaDoc getQuerySubstitutions();
366
367     /**
368      * Query substitutions to use.
369      *
370      * @param querySubstitutions The new query substitutions to use
371      */

372     public void setQuerySubstitutions(String JavaDoc querySubstitutions);
373
374     /**
375      * The name of the {@link org.hibernate.cache.CacheProvider} implementation class to use for second level caching.
376      *
377      * @return The current setting value
378      *
379      * @see org.hibernate.cfg.Environment#CACHE_PROVIDER
380      */

381     public String JavaDoc getCacheProviderClass();
382
383     /**
384      * The name of the {@link org.hibernate.cache.CacheProvider} implementation class to use for second level caching.
385      *
386      * @param cacheProviderClass The new provider impl class name.
387      */

388     public void setCacheProviderClass(String JavaDoc cacheProviderClass);
389
390     /**
391      * The prefix to use for this session factory within the second level cache.
392      *
393      * @return The current setting value
394      *
395      * @see org.hibernate.cfg.Environment#CACHE_NAMESPACE
396      */

397     public String JavaDoc getCacheRegionPrefix();
398
399     /**
400      * The prefix to use for this session factory within the second level cache.
401      *
402      * @param cacheRegionPrefix The new prefix value.
403      */

404     public void setCacheRegionPrefix(String JavaDoc cacheRegionPrefix);
405
406     /**
407      * Should minimal puts be enabled against the given cache provider?
408      *
409      * @return The current setting value
410      *
411      * @see org.hibernate.cfg.Environment#USE_MINIMAL_PUTS
412      */

413     public Boolean JavaDoc getMinimalPutsEnabled();
414
415     /**
416      * Should minimal puts be enabled against the given cache provider?
417      *
418      * @param minimalPutsEnabled
419      */

420     public void setMinimalPutsEnabled(Boolean JavaDoc minimalPutsEnabled);
421
422     /**
423      * Should Hibernate use structured cache entries when putting stuff into the second level cache?
424      * <p/>
425      * Mainly useful if users wish to directly browse the second level caches as it is easier to see what the cache entries
426      * actually represent.
427      *
428      * @return
429      *
430      * @see org.hibernate.cfg.Environment#USE_STRUCTURED_CACHE
431      */

432     public Boolean JavaDoc getUseStructuredCacheEntriesEnabled();
433
434     /**
435      * Should Hibernate use structured cache entries when putting stuff into the second level cache?
436      *
437      * @param structuredEntriesEnabled
438      */

439     public void setUseStructuredCacheEntriesEnabled(Boolean JavaDoc structuredEntriesEnabled);
440
441     public Boolean JavaDoc getSecondLevelCacheEnabled();
442
443     public void setSecondLevelCacheEnabled(Boolean JavaDoc secondLevelCacheEnabled);
444
445     /**
446      * Is use of the query cache enabled?
447      *
448      * @return The current setting value
449      *
450      * @see org.hibernate.cfg.Environment#USE_QUERY_CACHE
451      */

452     public Boolean JavaDoc getQueryCacheEnabled();
453
454     /**
455      * Is use of the query cache enabled?
456      *
457      * @param queryCacheEnabled The new value of whether or not to enable.
458      */

459     public void setQueryCacheEnabled(Boolean JavaDoc queryCacheEnabled);
460
461     /**
462      * Should all SQL be shown (dumped to console and logged)?
463      *
464      * @return The current setting value
465      *
466      * @see org.hibernate.cfg.Environment#SHOW_SQL
467      */

468     public Boolean JavaDoc getShowSqlEnabled();
469
470     /**
471      * Should all SQL be shown (dumped to console and logged)?
472      *
473      * @param showSqlEnabled
474      */

475     public void setShowSqlEnabled(Boolean JavaDoc showSqlEnabled);
476
477     /**
478      * Should Hibernate use cglib-based reflection optimizations?
479      * <p/>
480      * Note : this may or may not improve performance based on the JVM you are using.
481      *
482      * @return
483      *
484      * @see org.hibernate.cfg.Environment#USE_REFLECTION_OPTIMIZER
485      */

486     public Boolean JavaDoc getReflectionOptimizationEnabled();
487
488     /**
489      * Should Hibernate use cglib-based reflection optimizations?
490      *
491      * @param reflectionOptimizationEnabled
492      */

493     public void setReflectionOptimizationEnabled(Boolean JavaDoc reflectionOptimizationEnabled);
494
495     /**
496      * Should generation and collection of Hibernate3 statistics be enabled?
497      *
498      * @return
499      *
500      * @see org.hibernate.cfg.Environment#GENERATE_STATISTICS
501      */

502     public Boolean JavaDoc getStatGenerationEnabled();
503
504     /**
505      * Should generation and collection of Hibernate3 statistics be enabled?
506      *
507      * @param statGenerationEnabled
508      */

509     public void setStatGenerationEnabled(Boolean JavaDoc statGenerationEnabled);
510
511     /**
512      * The name of an {@link org.hibernate.Interceptor} impl class to be attached to the managed {@link
513      * org.hibernate.SessionFactory}.
514      *
515      * @return
516      */

517     public String JavaDoc getSessionFactoryInterceptor();
518
519     /**
520      * The name of an {@link org.hibernate.Interceptor} impl class to be attached to the managed {@link
521      * org.hibernate.SessionFactory}.
522      *
523      * @param sessionFactoryInterceptor
524      */

525     public void setSessionFactoryInterceptor(String JavaDoc sessionFactoryInterceptor);
526
527     /**
528      * The {@link org.jboss.hibernate.ListenerInjector} implementor class to use.
529      *
530      * @return
531      */

532     public String JavaDoc getListenerInjector();
533
534     /**
535      * The {@link org.jboss.hibernate.ListenerInjector} implementor class to use.
536      *
537      * @param listenerInjector
538      */

539     public void setListenerInjector(String JavaDoc listenerInjector);
540
541     /**
542      * Is this MBean dirty? Meaning, have any changes been made to it that have not yet been propogated to the managed
543      * {@link org.hibernate.SessionFactory}?
544      * <p/>
545      * Note : the only way to propogate these changes to the SF is by calling the {@link #rebuildSessionFactory()} managed
546      * operation.
547      *
548      * @return
549      */

550     public boolean isDirty();
551
552     /**
553      * Does this MBean instance have a currently running managed {@link org.hibernate.SessionFactory}?
554      *
555      * @return
556      */

557     public boolean isSessionFactoryRunning();
558
559     /**
560      * The version Hibernate for the managed {@link org.hibernate.SessionFactory}.
561      *
562      * @return
563      */

564     public String JavaDoc getVersion();
565
566     /**
567      * Exposes the internally managed session factory via a read-only JMX managed attribute.
568      *
569      * @return The managed session factory.
570      */

571     public SessionFactory getInstance();
572
573    /**
574     * The date and time since which the currently managed {@link org.hibernate.SessionFactory} has been running.
575     *
576     * @return The date and time the current {@link org.hibernate.SessionFactory} was started.
577     */

578    public Date JavaDoc getRunningSince();
579
580     /**
581      * A JMX managed operation to rebuild the managed {@link org.hibernate.SessionFactory} such that any setting changes
582      * made can take effect.
583      *
584      * @throws Exception
585      */

586     public void rebuildSessionFactory() throws Exception JavaDoc;
587
588 }
589
Popular Tags