001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.hibernate.jmx;
023:
024: import org.jboss.system.ServiceMBean;
025: import org.hibernate.SessionFactory;
026:
027: import javax.management.MBeanRegistration;
028: import javax.management.ObjectName;
029: import java.net.URL;
030: import java.util.Date;
031:
032: /**
033: * Describes a Hibernate service MBean. Configures a
034: * {@link org.hibernate.SessionFactory} instance and exposes it through JNDI.
035: * The SessionFactory is built through either<ul>
036: * <li>auto-discovery : where the classpath of the top-level deployment
037: * containing this MBean is searched for jars and directories to add to the
038: * config
039: * <li>har-deployment : where the deployment containing this MBean description
040: * conforms to the har layout definition.
041: * </ul>
042: *
043: * @version <tt>$Revision: 57193 $</tt>
044: * @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
045: * @author <a href="mailto:gavin@hibernate.org">Gavin King</a>
046: * @author <a href="mailto:steve@hibernate.org">Steve Ebersole</a>
047: * @author <a href="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
048: */
049: public interface HibernateMBean extends ServiceMBean, MBeanRegistration {
050:
051: /**
052: * The url to the har deployment, if MBean is operating in har deployment mode.
053: *
054: * @return The url of the har containing this MBean, or null if not part of
055: * a har deployment.
056: */
057: public URL getHarUrl();
058:
059: /**
060: * Enables scanning of the entire deployment classpath for any potential mapping
061: * sources (jars or directories).
062: * <p/>
063: * Only used in the case of har deployments.
064: *
065: * @return
066: */
067: public boolean isScanForMappingsEnabled();
068:
069: /**
070: * Enables scanning of the entire deployment classpath for any potential mapping
071: * sources (jars or directories).
072: * <p/>
073: * Only used in the case of har deployments.
074: *
075: * @param scanForMappings
076: */
077: public void setScanForMappingsEnabled(boolean scanForMappings);
078:
079: /**
080: * The JNDI namespace where the managed {@link org.hibernate.SessionFactory} is to be bound.
081: *
082: * @return The current setting value.
083: */
084: public String getSessionFactoryName();
085:
086: /**
087: * The JNDI namespace where the managed {@link org.hibernate.SessionFactory} is to be bound.
088: *
089: * @param sessionFactoryName The new JNDI namespace to use.
090: */
091: public void setSessionFactoryName(String sessionFactoryName);
092:
093: /**
094: * The JMX name of a {@link org.jboss.cache.TreeCache} MBean to be used as the second level cache.
095: * <p/>
096: * Note : only used when {@link #getCacheProviderClass} == {@link org.jboss.hibernate.cache.DeployedTreeCacheProvider}
097: *
098: * @return The current setting
099: */
100: public ObjectName getDeployedTreeCacheObjectName();
101:
102: /**
103: * The JMX name of a {@link org.jboss.cache.TreeCache} MBean to be used as the second level cache.
104: *
105: * @param deployedTreeCacheObjectName The new mbean object name.
106: */
107: public void setDeployedTreeCacheObjectName(
108: ObjectName deployedTreeCacheObjectName);
109:
110: /**
111: * Retreive the service name of the managed stats mbean.
112: * <p/>
113: * When statistics are enabled on the managed session factory, the mbean
114: * automatically manages a stats mbean for stats exposure via jmx. This
115: * returns the name under which that stats mbean is available from the jmx
116: * server.
117: *
118: * @return The service name of the stats mbean, or null if stats not enabled.
119: */
120: public ObjectName getStatisticsServiceName();
121:
122: /**
123: * The name of the dialect class to use for communicating with the database.
124: *
125: * @return The current setting value.
126: *
127: * @see org.hibernate.cfg.Environment#DIALECT
128: */
129: public String getDialect();
130:
131: /**
132: * The name of the dialect class to use for communicating with the database.
133: *
134: * @param dialect The new dialect class name to use.
135: */
136: public void setDialect(String dialect);
137:
138: /**
139: * The form, if any, of schema generation which should be used.
140: *
141: * @return The current setting value.
142: *
143: * @see org.hibernate.cfg.Environment#HBM2DDL_AUTO
144: */
145: public String getHbm2ddlAuto();
146:
147: /**
148: * The form, if any, of schema generation which should be used.
149: *
150: * @param hbm2ddlAuto The new hbm2ddl setting; valid values are: update, create, create-drop
151: */
152: public void setHbm2ddlAuto(String hbm2ddlAuto);
153:
154: /**
155: * The JNDI namespace of the {@link javax.sql.DataSource} which should be used by the managed {@link
156: * org.hibernate.SessionFactory}.
157: *
158: * @return The current setting value.
159: *
160: * @see org.hibernate.cfg.Environment#DATASOURCE
161: */
162: public String getDatasourceName();
163:
164: /**
165: * The JNDI namespace of the {@link javax.sql.DataSource} which should be used by the managed {@link
166: * org.hibernate.SessionFactory}.
167: *
168: * @param datasourceName The new DataSource JNDI name to use.
169: */
170: public void setDatasourceName(String datasourceName);
171:
172: /**
173: * The username used to access the specified datasource.
174: *
175: * @return The current setting value.
176: *
177: * @see org.hibernate.cfg.Environment#USER
178: */
179: public String getUsername();
180:
181: /**
182: * The username used to access the specified datasource.
183: *
184: * @param username The new username value.
185: */
186: public void setUsername(String username);
187:
188: /**
189: * The password used to access the specified datasource.
190: *
191: * @param password The new password value.
192: */
193: public void setPassword(String password);
194:
195: /**
196: * Should sql comments be used?
197: *
198: * @return
199: *
200: * @see org.hibernate.cfg.Environment#USE_SQL_COMMENTS
201: */
202: public Boolean getSqlCommentsEnabled();
203:
204: /**
205: * Should sql comments be used?
206: *
207: * @param commentsEnabled
208: */
209: public void setSqlCommentsEnabled(Boolean commentsEnabled);
210:
211: /**
212: * The default database schema to use within the database being mapped.
213: * <p/>
214: * Used for databases which support the concept of schemas instead of catalogs.
215: *
216: * @return The current setting value.
217: *
218: * @see #getDefaultCatalog
219: * @see org.hibernate.cfg.Environment#DEFAULT_SCHEMA
220: */
221: public String getDefaultSchema();
222:
223: /**
224: * The default database schema to use within the database being mapped.
225: *
226: * @param defaultSchema The new default schema name to use.
227: */
228: public void setDefaultSchema(String defaultSchema);
229:
230: /**
231: * The default database catalog to use within the database being mapped.
232: * <p/>
233: * Used for databases which support the concept of catalogs instead of schemas.
234: *
235: * @return The current setting value.
236: *
237: * @see #getDefaultSchema
238: * @see org.hibernate.cfg.Environment#DEFAULT_CATALOG
239: */
240: public String getDefaultCatalog();
241:
242: /**
243: * The default database catalog to use within the database being mapped.
244: *
245: * @param defaultCatalog The new default catalog name.
246: */
247: public void setDefaultCatalog(String defaultCatalog);
248:
249: /**
250: * The maximum outer join fetch depth.
251: *
252: * @return The current setting value
253: *
254: * @see org.hibernate.cfg.Environment#MAX_FETCH_DEPTH
255: */
256: public Integer getMaxFetchDepth();
257:
258: /**
259: * The maximum outer join fetch depth.
260: *
261: * @param maxFetchDepth The new max fetch depth value
262: */
263: public void setMaxFetchDepth(Integer maxFetchDepth);
264:
265: /**
266: * The JDBC batch update batch size.
267: *
268: * @return The current setting value
269: *
270: * @see org.hibernate.cfg.Environment#STATEMENT_BATCH_SIZE
271: */
272: public Integer getJdbcBatchSize();
273:
274: /**
275: * The JDBC batch update batch size.
276: *
277: * @param jdbcBatchSize The new value for the number of statements to batch together.
278: */
279: public void setJdbcBatchSize(Integer jdbcBatchSize);
280:
281: /**
282: * The JDBC fetch size.
283: *
284: * @return The current setting value
285: *
286: * @see org.hibernate.cfg.Environment#STATEMENT_FETCH_SIZE
287: */
288: public Integer getJdbcFetchSize();
289:
290: /**
291: * The JDBC fetch size.
292: *
293: * @param jdbcFetchSize The new value for the number of rows to fetch from server at a time.
294: */
295: public void setJdbcFetchSize(Integer jdbcFetchSize);
296:
297: /**
298: * Are scrollable result sets enabled?
299: *
300: * @return The current setting value
301: *
302: * @see org.hibernate.cfg.Environment#USE_SCROLLABLE_RESULTSET
303: */
304: public Boolean getJdbcScrollableResultSetEnabled();
305:
306: /**
307: * Are scrollable result sets enabled?
308: *
309: * @param jdbcScrollableResultSetEnabled The new value.
310: */
311: public void setJdbcScrollableResultSetEnabled(
312: Boolean jdbcScrollableResultSetEnabled);
313:
314: /**
315: * Is the use of JDBC3 <tt>getGeneratedKeys()</tt> enabled?
316: *
317: * @return The current setting value
318: *
319: * @see org.hibernate.cfg.Environment#USE_GET_GENERATED_KEYS
320: */
321: public Boolean getGetGeneratedKeysEnabled();
322:
323: /**
324: * Is the use of JDBC3 <tt>getGeneratedKeys()</tt> enabled?
325: *
326: * @param getGeneratedKeysEnabled The new value.
327: */
328: public void setGetGeneratedKeysEnabled(
329: Boolean getGeneratedKeysEnabled);
330:
331: /**
332: * Should Hibernate allow JDBC batch-updating of versioned entities?
333: * <p/>
334: * Many drivers have bugs regarding the row counts returned in response to JDBC Batch API operations; in these cases,
335: * this should definitely be set to false.
336: *
337: * @return The current setting value
338: *
339: * @see org.hibernate.cfg.Environment#BATCH_VERSIONED_DATA
340: */
341: public Boolean getBatchVersionedDataEnabled();
342:
343: /**
344: * Should Hibernate allow JDBC batch-updating of versioned entities?
345: *
346: * @param batchVersionedDataEnabled
347: */
348: public void setBatchVersionedDataEnabled(
349: Boolean batchVersionedDataEnabled);
350:
351: /**
352: * Should Hibernate use I/O streaming for handling binary/LOB data?
353: *
354: * @return
355: *
356: * @see org.hibernate.cfg.Environment#USE_STREAMS_FOR_BINARY
357: */
358: public Boolean getStreamsForBinaryEnabled();
359:
360: /**
361: * Should Hibernate use I/O streaming for handling binary/LOB data?
362: *
363: * @param streamsForBinaryEnabled
364: */
365: public void setStreamsForBinaryEnabled(
366: Boolean streamsForBinaryEnabled);
367:
368: /**
369: * Query substitutions to use.
370: *
371: * @return The current setting value
372: *
373: * @see org.hibernate.cfg.Environment#QUERY_SUBSTITUTIONS
374: */
375: public String getQuerySubstitutions();
376:
377: /**
378: * Query substitutions to use.
379: *
380: * @param querySubstitutions The new query substitutions to use
381: */
382: public void setQuerySubstitutions(String querySubstitutions);
383:
384: /**
385: * The name of the {@link org.hibernate.cache.CacheProvider} implementation class to use for second level caching.
386: *
387: * @return The current setting value
388: *
389: * @see org.hibernate.cfg.Environment#CACHE_PROVIDER
390: */
391: public String getCacheProviderClass();
392:
393: /**
394: * The name of the {@link org.hibernate.cache.CacheProvider} implementation class to use for second level caching.
395: *
396: * @param cacheProviderClass The new provider impl class name.
397: */
398: public void setCacheProviderClass(String cacheProviderClass);
399:
400: /**
401: * The prefix to use for this session factory within the second level cache.
402: *
403: * @return The current setting value
404: *
405: * @see org.hibernate.cfg.Environment#CACHE_NAMESPACE
406: */
407: public String getCacheRegionPrefix();
408:
409: /**
410: * The prefix to use for this session factory within the second level cache.
411: *
412: * @param cacheRegionPrefix The new prefix value.
413: */
414: public void setCacheRegionPrefix(String cacheRegionPrefix);
415:
416: /**
417: * Should minimal puts be enabled against the given cache provider?
418: *
419: * @return The current setting value
420: *
421: * @see org.hibernate.cfg.Environment#USE_MINIMAL_PUTS
422: */
423: public Boolean getMinimalPutsEnabled();
424:
425: /**
426: * Should minimal puts be enabled against the given cache provider?
427: *
428: * @param minimalPutsEnabled
429: */
430: public void setMinimalPutsEnabled(Boolean minimalPutsEnabled);
431:
432: /**
433: * Should Hibernate use structured cache entries when putting stuff into the second level cache?
434: * <p/>
435: * Mainly useful if users wish to directly browse the second level caches as it is easier to see what the cache entries
436: * actually represent.
437: *
438: * @return
439: *
440: * @see org.hibernate.cfg.Environment#USE_STRUCTURED_CACHE
441: */
442: public Boolean getUseStructuredCacheEntriesEnabled();
443:
444: /**
445: * Should Hibernate use structured cache entries when putting stuff into the second level cache?
446: *
447: * @param structuredEntriesEnabled
448: */
449: public void setUseStructuredCacheEntriesEnabled(
450: Boolean structuredEntriesEnabled);
451:
452: public Boolean getSecondLevelCacheEnabled();
453:
454: public void setSecondLevelCacheEnabled(
455: Boolean secondLevelCacheEnabled);
456:
457: /**
458: * Is use of the query cache enabled?
459: *
460: * @return The current setting value
461: *
462: * @see org.hibernate.cfg.Environment#USE_QUERY_CACHE
463: */
464: public Boolean getQueryCacheEnabled();
465:
466: /**
467: * Is use of the query cache enabled?
468: *
469: * @param queryCacheEnabled The new value of whether or not to enable.
470: */
471: public void setQueryCacheEnabled(Boolean queryCacheEnabled);
472:
473: /**
474: * Should all SQL be shown (dumped to console and logged)?
475: *
476: * @return The current setting value
477: *
478: * @see org.hibernate.cfg.Environment#SHOW_SQL
479: */
480: public Boolean getShowSqlEnabled();
481:
482: /**
483: * Should all SQL be shown (dumped to console and logged)?
484: *
485: * @param showSqlEnabled
486: */
487: public void setShowSqlEnabled(Boolean showSqlEnabled);
488:
489: /**
490: * Should Hibernate use cglib-based reflection optimizations?
491: * <p/>
492: * Note : this may or may not improve performance based on the JVM you are using.
493: *
494: * @return
495: *
496: * @see org.hibernate.cfg.Environment#USE_REFLECTION_OPTIMIZER
497: */
498: public Boolean getReflectionOptimizationEnabled();
499:
500: /**
501: * Should Hibernate use cglib-based reflection optimizations?
502: *
503: * @param reflectionOptimizationEnabled
504: */
505: public void setReflectionOptimizationEnabled(
506: Boolean reflectionOptimizationEnabled);
507:
508: /**
509: * Should generation and collection of Hibernate3 statistics be enabled?
510: *
511: * @return
512: *
513: * @see org.hibernate.cfg.Environment#GENERATE_STATISTICS
514: */
515: public Boolean getStatGenerationEnabled();
516:
517: /**
518: * Should generation and collection of Hibernate3 statistics be enabled?
519: *
520: * @param statGenerationEnabled
521: */
522: public void setStatGenerationEnabled(Boolean statGenerationEnabled);
523:
524: /**
525: * The name of an {@link org.hibernate.Interceptor} impl class to be attached to the managed {@link
526: * org.hibernate.SessionFactory}.
527: *
528: * @return
529: */
530: public String getSessionFactoryInterceptor();
531:
532: /**
533: * The name of an {@link org.hibernate.Interceptor} impl class to be attached to the managed {@link
534: * org.hibernate.SessionFactory}.
535: *
536: * @param sessionFactoryInterceptor
537: */
538: public void setSessionFactoryInterceptor(
539: String sessionFactoryInterceptor);
540:
541: /**
542: * The {@link org.jboss.hibernate.ListenerInjector} implementor class to use.
543: *
544: * @return
545: */
546: public String getListenerInjector();
547:
548: /**
549: * The {@link org.jboss.hibernate.ListenerInjector} implementor class to use.
550: *
551: * @param listenerInjector
552: */
553: public void setListenerInjector(String listenerInjector);
554:
555: /**
556: * Is this MBean dirty? Meaning, have any changes been made to it that have not yet been propogated to the managed
557: * {@link org.hibernate.SessionFactory}?
558: * <p/>
559: * Note : the only way to propogate these changes to the SF is by calling the {@link #rebuildSessionFactory()} managed
560: * operation.
561: *
562: * @return
563: */
564: public boolean isDirty();
565:
566: /**
567: * Does this MBean instance have a currently running managed {@link org.hibernate.SessionFactory}?
568: *
569: * @return
570: */
571: public boolean isSessionFactoryRunning();
572:
573: /**
574: * The version Hibernate for the managed {@link org.hibernate.SessionFactory}.
575: *
576: * @return
577: */
578: public String getVersion();
579:
580: /**
581: * Exposes the internally managed session factory via a read-only JMX managed attribute.
582: *
583: * @return The managed session factory.
584: */
585: public SessionFactory getInstance();
586:
587: /**
588: * The date and time since which the currently managed {@link org.hibernate.SessionFactory} has been running.
589: *
590: * @return The date and time the current {@link org.hibernate.SessionFactory} was started.
591: */
592: public Date getRunningSince();
593:
594: /**
595: * Export the <tt>CREATE</tt> DDL to the database
596: * @throws Exception
597: */
598: public void createSchema() throws Exception;
599:
600: /**
601: * Export the <tt>DROP</tt> DDL to the database
602: * @throws Exception
603: */
604: public void dropSchema() throws Exception;
605:
606: /**
607: * A JMX managed operation to rebuild the managed {@link org.hibernate.SessionFactory} such that any setting changes
608: * made can take effect.
609: *
610: * @throws Exception
611: */
612: public void rebuildSessionFactory() throws Exception;
613:
614: }
|