KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.File JavaDoc;
10 import java.net.URL JavaDoc;
11 import java.net.URLClassLoader JavaDoc;
12 import java.util.Properties JavaDoc;
13 import java.util.HashSet JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.Date JavaDoc;
16 import java.util.jar.JarFile JavaDoc;
17 import javax.management.Notification JavaDoc;
18 import javax.management.ObjectName JavaDoc;
19 import javax.naming.InitialContext JavaDoc;
20 import javax.naming.NamingException JavaDoc;
21
22 import org.hibernate.HibernateException;
23 import org.hibernate.Interceptor;
24 import org.hibernate.SessionFactory;
25 import org.hibernate.jmx.StatisticsService;
26 import org.hibernate.cfg.Configuration;
27 import org.hibernate.cfg.Environment;
28 import org.hibernate.transaction.JBossTransactionManagerLookup;
29 import org.hibernate.transaction.JTATransactionFactory;
30
31 import org.jboss.hibernate.cache.DeployedTreeCacheProvider;
32 import org.jboss.hibernate.ListenerInjector;
33 import org.jboss.logging.Logger;
34 import org.jboss.naming.Util;
35 import org.jboss.system.ServiceMBeanSupport;
36 import org.jboss.deployment.DeploymentException;
37 import org.jboss.deployment.DeploymentInfo;
38 import org.jboss.mx.loading.RepositoryClassLoader;
39
40 /**
41  * The {@link HibernateMBean} implementation.
42  *
43  * @author <a HREF="mailto:alex@jboss.org">Alexey Loubyansky</a>
44  * @author <a HREF="mailto:gavin@hibernate.org">Gavin King</a>
45  * @author <a HREF="mailto:steve@hibernate.org">Steve Ebersole</a>
46  * @author <a HREF="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
47  * @version <tt>$Revision: 42717 $</tt>
48  */

49 public class Hibernate extends ServiceMBeanSupport implements HibernateMBean
50 {
51
52    private static final Logger log = Logger.getLogger( Hibernate.class );
53
54    public static final String JavaDoc SESSION_FACTORY_CREATE = "hibernate.sessionfactory.create";
55    public static final String JavaDoc SESSION_FACTORY_DESTROY = "hibernate.sessionfactory.destroy";
56
57    // Configuration attributes "passed through" to Hibernate
58
private String JavaDoc datasourceName;
59    private String JavaDoc dialect;
60    private String JavaDoc defaultSchema;
61    private String JavaDoc defaultCatalog;
62    private Boolean JavaDoc sqlCommentsEnabled;
63    private Integer JavaDoc maxFetchDepth;
64    private Integer JavaDoc jdbcFetchSize;
65    private Integer JavaDoc jdbcBatchSize;
66    private Boolean JavaDoc batchVersionedDataEnabled;
67    private Boolean JavaDoc jdbcScrollableResultSetEnabled;
68    private Boolean JavaDoc getGeneratedKeysEnabled;
69    private Boolean JavaDoc streamsForBinaryEnabled;
70    private String JavaDoc hbm2ddlAuto;
71    private String JavaDoc querySubstitutions;
72    private Boolean JavaDoc showSqlEnabled;
73    private String JavaDoc username;
74    private String JavaDoc password;
75    private Boolean JavaDoc secondLevelCacheEnabled = Boolean.TRUE;
76    private Boolean JavaDoc queryCacheEnabled;
77    private String JavaDoc cacheProviderClass;
78    private ObjectName JavaDoc deployedTreeCacheObjectName;
79    private Boolean JavaDoc minimalPutsEnabled;
80    private String JavaDoc cacheRegionPrefix;
81    private Boolean JavaDoc structuredCacheEntriesEnabled;
82    private Boolean JavaDoc statGenerationEnabled;
83    private Boolean JavaDoc reflectionOptimizationEnabled;
84
85    // Configuration attributes used by the MBean
86
private String JavaDoc sessionFactoryName;
87    private String JavaDoc sessionFactoryInterceptor;
88    private String JavaDoc listenerInjector;
89    private URL JavaDoc harUrl;
90    private boolean scanForMappingsEnabled = false;
91    private HashSet JavaDoc archiveClasspathUrls = new HashSet JavaDoc();
92    private HashSet JavaDoc directoryClasspathUrls = new HashSet JavaDoc();
93
94    // Internal state
95
private boolean dirty = false;
96    private Date JavaDoc runningSince;
97    private SessionFactory sessionFactory;
98    private ObjectName JavaDoc hibernateStatisticsServiceName;
99
100    /**
101     * Configure Hibernate and bind the <tt>SessionFactory</tt> to JNDI.
102     */

103    public void startService() throws Exception JavaDoc
104    {
105       log.debug( "Hibernate MBean starting; " + this );
106
107       // be defensive...
108
if ( sessionFactory != null )
109       {
110          destroySessionFactory();
111       }
112
113       harUrl = determineHarUrl();
114
115       if ( harUrl != null )
116       {
117          log.trace( "starting in har deployment mode" );
118          // we are part of a har deployment...
119
if ( scanForMappingsEnabled )
120          {
121             log.trace( "scan for mappings was enabled" );
122             scanForMappings();
123          }
124       }
125       else
126       {
127          // we are not contained within a har deployment...
128
log.trace( "starting in non-har deployment mode" );
129          scanForMappings();
130       }
131
132       buildSessionFactory();
133    }
134
135    /**
136     * Close the <tt>SessionFactory</tt>.
137     */

138    public void stopService() throws Exception JavaDoc
139    {
140       destroySessionFactory();
141       archiveClasspathUrls.clear();
142       directoryClasspathUrls.clear();
143    }
144
145    private URL JavaDoc determineHarUrl() throws Exception JavaDoc
146    {
147       log.trace( "Attempting to determine HarUrl..." );
148       DeploymentInfo deploymentInfo = getDeploymentInfo();
149       if ( deploymentInfo == null )
150       {
151          log.warn( "Unable to locate deployment info [" + getServiceName() + "]" );
152          return null;
153       }
154
155       String JavaDoc urlStr = deploymentInfo.url.getFile();
156       log.trace( "checking our deployment unit [" + urlStr + "]" );
157       if ( urlStr.endsWith( ".har" ) || urlStr.endsWith( ".har/" ) )
158       {
159          return deploymentInfo.url;
160       }
161       else
162       {
163          return null;
164       }
165    }
166
167    /**
168     * Centralize the logic needed for starting/binding the SessionFactory.
169     *
170     * @throws Exception
171     */

172    private void buildSessionFactory() throws Exception JavaDoc
173    {
174       log.debug( "Building SessionFactory; " + this );
175
176       Configuration cfg = new Configuration();
177       cfg.getProperties().clear(); // avoid reading hibernate.properties and Sys-props
178

179       // Handle custom listeners....
180
ListenerInjector listenerInjector = generateListenerInjectorInstance();
181       if ( listenerInjector != null )
182       {
183          listenerInjector.injectListeners( getServiceName(), cfg );
184       }
185
186       // Handle config settings....
187
transferSettings( cfg.getProperties() );
188
189       // Handle mappings....
190
handleMappings( cfg );
191
192       // Handle interceptor....
193
Interceptor interceptorInstance = generateInterceptorInstance();
194       if ( interceptorInstance != null )
195       {
196          cfg.setInterceptor( interceptorInstance );
197       }
198
199       // Generate sf....
200
sessionFactory = cfg.buildSessionFactory();
201
202       try
203       {
204          // Handle stat-mbean creation/registration....
205
if ( sessionFactory.getStatistics() != null && sessionFactory.getStatistics().isStatisticsEnabled() )
206          {
207             String JavaDoc serviceName = getServiceName().toString();
208             if( serviceName.indexOf("type=service") != -1 )
209             {
210                 serviceName = serviceName.replaceAll("type=service","type=stats");
211             }
212             else
213             {
214                 serviceName = serviceName + ",type=stats";
215             }
216             hibernateStatisticsServiceName = new ObjectName JavaDoc( serviceName );
217             StatisticsService hibernateStatisticsService = new StatisticsService();
218             hibernateStatisticsService.setSessionFactory( sessionFactory );
219             getServer().registerMBean( hibernateStatisticsService, hibernateStatisticsServiceName );
220          }
221
222          // Handle JNDI binding....
223
bind();
224       }
225       catch ( Exception JavaDoc e )
226       {
227          forceCleanup();
228          throw e;
229       }
230
231       dirty = false;
232
233       sendNotification(
234             new Notification JavaDoc( SESSION_FACTORY_CREATE, getServiceName(), getNextNotificationSequenceNumber() )
235       );
236
237       runningSince = new Date JavaDoc();
238
239       log.info( "SessionFactory successfully built and bound into JNDI [" + sessionFactoryName + "]" );
240    }
241
242    /**
243     * Centralize the logic needed to unbind/close a SessionFactory.
244     *
245     * @throws Exception
246     */

247    private void destroySessionFactory() throws Exception JavaDoc
248    {
249       if ( sessionFactory != null )
250       {
251          // TODO : exact situations where we need to clear the 2nd-lvl cache?
252
// (to allow clean release of the classloaders)
253
// Most likely, if custom classes are directly cached (UserTypes); anything else?
254
unbind();
255          sessionFactory.close();
256          sessionFactory = null;
257          runningSince = null;
258
259          if ( hibernateStatisticsServiceName != null )
260          {
261             try
262             {
263                getServer().unregisterMBean( hibernateStatisticsServiceName );
264             }
265             catch ( Throwable JavaDoc t )
266             {
267                // just log it
268
log.warn( "unable to cleanup statistics mbean", t );
269             }
270          }
271
272          sendNotification(
273                new Notification JavaDoc( SESSION_FACTORY_DESTROY, getServiceName(), getNextNotificationSequenceNumber() )
274          );
275       }
276    }
277
278    private void handleMappings(Configuration cfg)
279    {
280       if ( harUrl != null )
281       {
282          final File JavaDoc file = new File JavaDoc( harUrl.getFile() );
283          if ( file.isDirectory() )
284          {
285             cfg.addDirectory( file );
286          }
287          else
288          {
289             cfg.addJar( file );
290          }
291       }
292
293       Iterator JavaDoc itr = archiveClasspathUrls.iterator();
294       while ( itr.hasNext() )
295       {
296          final File JavaDoc archive = ( File JavaDoc ) itr.next();
297          log.debug( "Passing archive [" + archive + "] to Hibernate Configration" );
298          cfg.addJar( archive );
299       }
300
301       itr = directoryClasspathUrls.iterator();
302       while ( itr.hasNext() )
303       {
304          final File JavaDoc directory = ( File JavaDoc ) itr.next();
305          log.debug( "Passing directory [" + directory + "] to Hibernate Configration" );
306          cfg.addDirectory( directory );
307       }
308    }
309
310    /**
311     * Scan the current context's classloader to locate any potential sources of Hibernate mapping files.
312     *
313     * @throws DeploymentException
314     */

315    private void scanForMappings() throws DeploymentException
316    {
317       // Won't this cause problems if start() is called from say the console?
318
// a way around is to locate our DeploymentInfo and grab its ucl attribute
319
// for use here.
320
URL JavaDoc[] urls = null;
321       ClassLoader JavaDoc cl = Thread.currentThread().getContextClassLoader();
322       if ( cl instanceof RepositoryClassLoader )
323       {
324          urls = ( ( RepositoryClassLoader ) cl ).getClasspath();
325       }
326       else if ( cl instanceof URLClassLoader JavaDoc )
327       {
328          urls = ( ( URLClassLoader JavaDoc ) cl ).getURLs();
329       }
330       else
331       {
332          throw new DeploymentException( "Unable to determine urls from classloader [" + cl + "]" );
333       }
334
335       // Search the urls for each of the classpath entries for any containing
336
// hibernate mapping files or archives
337
for ( int i = 0; i < urls.length; i++ )
338       {
339          final File JavaDoc entry = new File JavaDoc( urls[i].getFile() );
340          log.trace( "checking classpath entry [" + entry + "]" );
341          if ( !entry.exists() )
342          {
343             continue;
344          }
345
346          if ( !entry.isDirectory() )
347          {
348             // This entry is not a directory, meaning it is a file of
349
// some sort. If it is an archive, we are interested in it...
350
if ( isArchive( entry ) )
351             {
352                log.trace( "classpath entry was an archive file..." );
353                archiveClasspathUrls.add( entry );
354             }
355             else
356             {
357                log.trace( "classpath entry was a non-archive file..." );
358             }
359          }
360          else
361          {
362             log.trace( "classpath entry was a directory..." );
363
364             // we have a directory, add it to the list of directory classpath urls
365
directoryClasspathUrls.add( entry );
366          }
367       }
368    }
369
370    /**
371     * Simple helper method to determine whether a given File instance represents an archive which complies with the JAR
372     * specification.
373     *
374     * @param file The file to test.
375     * @return True if the incoming file for certain represents an archive; false otherwise.
376     */

377    private boolean isArchive(File JavaDoc file)
378    {
379       try
380       {
381          new JarFile JavaDoc( file );
382          return true;
383       }
384       catch ( Throwable JavaDoc t )
385       {
386          return false;
387       }
388    }
389
390    /**
391     * Transfer the state represented by our current attribute values into the given Properties instance, translating our
392     * attributes into the appropriate Hibernate settings.
393     *
394     * @param settings The Properties instance to which to add our state.
395     */

396    private void transferSettings(Properties JavaDoc settings)
397    {
398       if ( cacheProviderClass == null )
399       {
400          cacheProviderClass = "org.hibernate.cache.HashtableCacheProvider";
401       }
402
403       log.debug( "Using JDBC batch size : " + jdbcBatchSize );
404
405       setUnlessNull( settings, Environment.DATASOURCE, datasourceName );
406       setUnlessNull( settings, Environment.DIALECT, dialect );
407       setUnlessNull( settings, Environment.CACHE_PROVIDER, cacheProviderClass );
408       setUnlessNull( settings, Environment.CACHE_REGION_PREFIX, cacheRegionPrefix );
409       setUnlessNull( settings, Environment.USE_MINIMAL_PUTS, minimalPutsEnabled );
410       setUnlessNull( settings, Environment.HBM2DDL_AUTO, hbm2ddlAuto );
411       setUnlessNull( settings, Environment.DEFAULT_SCHEMA, defaultSchema );
412       setUnlessNull( settings, Environment.STATEMENT_BATCH_SIZE, jdbcBatchSize );
413       setUnlessNull( settings, Environment.USE_SQL_COMMENTS, sqlCommentsEnabled );
414
415       setUnlessNull( settings, Environment.STATEMENT_FETCH_SIZE, jdbcFetchSize );
416       setUnlessNull( settings, Environment.USE_SCROLLABLE_RESULTSET, jdbcScrollableResultSetEnabled );
417       setUnlessNull( settings, Environment.USE_QUERY_CACHE, queryCacheEnabled );
418       setUnlessNull( settings, Environment.USE_STRUCTURED_CACHE, structuredCacheEntriesEnabled );
419       setUnlessNull( settings, Environment.QUERY_SUBSTITUTIONS, querySubstitutions );
420       setUnlessNull( settings, Environment.MAX_FETCH_DEPTH, maxFetchDepth );
421       setUnlessNull( settings, Environment.SHOW_SQL, showSqlEnabled );
422       setUnlessNull( settings, Environment.USE_GET_GENERATED_KEYS, getGeneratedKeysEnabled );
423       setUnlessNull( settings, Environment.USER, username );
424       setUnlessNull( settings, Environment.PASS, password );
425       setUnlessNull( settings, Environment.BATCH_VERSIONED_DATA, batchVersionedDataEnabled );
426       setUnlessNull( settings, Environment.USE_STREAMS_FOR_BINARY, streamsForBinaryEnabled );
427       setUnlessNull( settings, Environment.USE_REFLECTION_OPTIMIZER, reflectionOptimizationEnabled );
428       setUnlessNull( settings, Environment.GENERATE_STATISTICS, statGenerationEnabled );
429
430       setUnlessNull(
431             settings, Environment.TRANSACTION_MANAGER_STRATEGY, JBossTransactionManagerLookup.class.getName()
432       );
433       setUnlessNull( settings, Environment.TRANSACTION_STRATEGY, JTATransactionFactory.class.getName() );
434
435       if ( deployedTreeCacheObjectName != null )
436       {
437          String JavaDoc objNameString = deployedTreeCacheObjectName.toString();
438          if ( objNameString != null && !"".equals( objNameString ) )
439          {
440             settings.setProperty( DeployedTreeCacheProvider.OBJECT_NAME_PROP, objNameString );
441          }
442       }
443
444       settings.setProperty( Environment.FLUSH_BEFORE_COMPLETION, "true" );
445       settings.setProperty( Environment.AUTO_CLOSE_SESSION, "true" );
446
447       // This is really H3-version-specific:
448
// in 3.0.3 and later, this should be the ConnectionReleaseMode enum;
449
// in 3.0.2, this is a true/false setting;
450
// in 3.0 -> 3.0.1, there is no such setting
451
//
452
// so we just set them both :)
453
settings.setProperty( "hibernate.connection.agressive_release", "true" );
454       settings.setProperty( "hibernate.connection.release_mode", "after_statement" );
455    }
456
457    /**
458     * Simple helper method for transferring individual settings to a properties
459     * instance only if the setting's value is not null.
460     *
461     * @param props The properties instance into which to transfer the setting
462     * @param key The key under which to transfer the setting
463     * @param value The value of the setting.
464     */

465    private void setUnlessNull(Properties JavaDoc props, String JavaDoc key, Object JavaDoc value)
466    {
467       if ( value != null )
468       {
469          props.setProperty( key, value.toString() );
470       }
471    }
472
473    private ListenerInjector generateListenerInjectorInstance()
474    {
475       if ( listenerInjector == null )
476       {
477          return null;
478       }
479
480       log.info( "attempting to use listener injector [" + listenerInjector + "]" );
481       try
482       {
483          return ( ListenerInjector ) Thread.currentThread()
484                .getContextClassLoader()
485                .loadClass( listenerInjector )
486                .newInstance();
487       }
488       catch ( Throwable JavaDoc t )
489       {
490          log.warn( "Unable to generate specified listener injector", t );
491       }
492
493       return null;
494    }
495
496    private Interceptor generateInterceptorInstance()
497    {
498       if ( sessionFactoryInterceptor == null )
499       {
500          return null;
501       }
502
503       log.info( "Generating session factory interceptor instance [" + sessionFactoryInterceptor + "]" );
504       try
505       {
506          return ( Interceptor ) Thread.currentThread()
507                .getContextClassLoader()
508                .loadClass( sessionFactoryInterceptor )
509                .newInstance();
510       }
511       catch ( Throwable JavaDoc t )
512       {
513          log.warn( "Unable to generate session factory interceptor instance", t );
514       }
515
516       return null;
517    }
518
519    /**
520     * Perform the steps necessary to bind the managed SessionFactory into JNDI.
521     *
522     * @throws HibernateException
523     */

524    private void bind() throws HibernateException
525    {
526       InitialContext JavaDoc ctx = null;
527       try
528       {
529          ctx = new InitialContext JavaDoc();
530          Util.bind( ctx, sessionFactoryName, sessionFactory );
531       }
532       catch ( NamingException JavaDoc e )
533       {
534          throw new HibernateException( "Unable to bind SessionFactory into JNDI", e );
535       }
536       finally
537       {
538          if ( ctx != null )
539          {
540             try
541             {
542                ctx.close();
543             }
544             catch ( Throwable JavaDoc ignore )
545             {
546                // ignore
547
}
548          }
549       }
550    }
551
552    /**
553     * Perform the steps necessary to unbind the managed SessionFactory from JNDI.
554     *
555     * @throws HibernateException
556     */

557    private void unbind() throws HibernateException
558    {
559       InitialContext JavaDoc ctx = null;
560       try
561       {
562          ctx = new InitialContext JavaDoc();
563          Util.unbind( ctx, sessionFactoryName );
564       }
565       catch ( NamingException JavaDoc e )
566       {
567          throw new HibernateException( "Unable to unbind SessionFactory from JNDI", e );
568       }
569       finally
570       {
571          if ( ctx != null )
572          {
573             try
574             {
575                ctx.close();
576             }
577             catch ( Throwable JavaDoc ignore )
578             {
579                // ignore
580
}
581          }
582       }
583    }
584
585    private void forceCleanup()
586    {
587       try
588       {
589          sessionFactory.close();
590          sessionFactory = null;
591       }
592       catch ( Throwable JavaDoc ignore )
593       {
594          // ignore
595
}
596    }
597
598    public String JavaDoc toString()
599    {
600       return super.toString() + " [ServiceName=" + serviceName + ", JNDI=" + sessionFactoryName + "]";
601    }
602
603
604    // Managed operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
605

606    public void rebuildSessionFactory() throws Exception JavaDoc
607    {
608       destroySessionFactory();
609       buildSessionFactory();
610    }
611
612
613    // RO managed attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
614

615    public boolean isDirty()
616    {
617       return dirty;
618    }
619
620    public boolean isSessionFactoryRunning()
621    {
622       return sessionFactory != null;
623    }
624
625    public String JavaDoc getVersion()
626    {
627       return Environment.VERSION;
628    }
629
630    public SessionFactory getInstance()
631    {
632       return sessionFactory;
633    }
634
635    public ObjectName JavaDoc getStatisticsServiceName()
636    {
637       return hibernateStatisticsServiceName;
638    }
639
640    public Date JavaDoc getRunningSince()
641    {
642       return runningSince;
643    }
644
645    // R/W managed attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
646

647    public String JavaDoc getSessionFactoryName()
648    {
649       return sessionFactoryName;
650    }
651
652    public void setSessionFactoryName(String JavaDoc sessionFactoryName)
653    {
654       this.sessionFactoryName = sessionFactoryName;
655       dirty = true;
656    }
657
658    public String JavaDoc getDatasourceName()
659    {
660       return datasourceName;
661    }
662
663    public void setDatasourceName(String JavaDoc datasourceName)
664    {
665       this.datasourceName = datasourceName;
666       dirty = true;
667    }
668
669    public String JavaDoc getUsername()
670    {
671       return username;
672    }
673
674    public void setUsername(String JavaDoc username)
675    {
676       this.username = username;
677       dirty = true;
678    }
679
680    public void setPassword(String JavaDoc password)
681    {
682       this.password = password;
683       dirty = true;
684    }
685
686    public String JavaDoc getDefaultSchema()
687    {
688       return defaultSchema;
689    }
690
691    public void setDefaultSchema(String JavaDoc defaultSchema)
692    {
693       this.defaultSchema = defaultSchema;
694       dirty = true;
695    }
696
697    public String JavaDoc getDefaultCatalog()
698    {
699       return defaultCatalog;
700    }
701
702    public void setDefaultCatalog(String JavaDoc defaultCatalog)
703    {
704       this.defaultCatalog = defaultCatalog;
705    }
706
707    public String JavaDoc getHbm2ddlAuto()
708    {
709       return hbm2ddlAuto;
710    }
711
712    public void setHbm2ddlAuto(String JavaDoc hbm2ddlAuto)
713    {
714       this.hbm2ddlAuto = hbm2ddlAuto;
715       dirty = true;
716    }
717
718    public String JavaDoc getDialect()
719    {
720       return dialect;
721    }
722
723    public void setDialect(String JavaDoc dialect)
724    {
725       this.dialect = dialect;
726       dirty = true;
727    }
728
729    public Integer JavaDoc getMaxFetchDepth()
730    {
731       return maxFetchDepth;
732    }
733
734    public void setMaxFetchDepth(Integer JavaDoc maxFetchDepth)
735    {
736       this.maxFetchDepth = maxFetchDepth;
737       dirty = true;
738    }
739
740    public Integer JavaDoc getJdbcBatchSize()
741    {
742       return jdbcBatchSize;
743    }
744
745    public void setJdbcBatchSize(Integer JavaDoc jdbcBatchSize)
746    {
747       this.jdbcBatchSize = jdbcBatchSize;
748       dirty = true;
749    }
750
751    public Integer JavaDoc getJdbcFetchSize()
752    {
753       return jdbcFetchSize;
754    }
755
756    public void setJdbcFetchSize(Integer JavaDoc jdbcFetchSize)
757    {
758       this.jdbcFetchSize = jdbcFetchSize;
759       dirty = true;
760    }
761
762    public Boolean JavaDoc getJdbcScrollableResultSetEnabled()
763    {
764       return jdbcScrollableResultSetEnabled;
765    }
766
767    public void setJdbcScrollableResultSetEnabled(Boolean JavaDoc jdbcScrollableResultSetEnabled)
768    {
769       this.jdbcScrollableResultSetEnabled = jdbcScrollableResultSetEnabled;
770       dirty = true;
771    }
772
773    public Boolean JavaDoc getGetGeneratedKeysEnabled()
774    {
775       return getGeneratedKeysEnabled;
776    }
777
778    public void setGetGeneratedKeysEnabled(Boolean JavaDoc getGeneratedKeysEnabled)
779    {
780       this.getGeneratedKeysEnabled = getGeneratedKeysEnabled;
781       dirty = true;
782    }
783
784    public String JavaDoc getQuerySubstitutions()
785    {
786       return querySubstitutions;
787    }
788
789    public void setQuerySubstitutions(String JavaDoc querySubstitutions)
790    {
791       this.querySubstitutions = querySubstitutions;
792       dirty = true;
793    }
794
795    public Boolean JavaDoc getSecondLevelCacheEnabled()
796    {
797       return secondLevelCacheEnabled;
798    }
799
800    public void setSecondLevelCacheEnabled(Boolean JavaDoc secondLevelCacheEnabled)
801    {
802       this.secondLevelCacheEnabled = secondLevelCacheEnabled;
803       dirty = true;
804    }
805
806    public Boolean JavaDoc getQueryCacheEnabled()
807    {
808       return queryCacheEnabled;
809    }
810
811    public void setQueryCacheEnabled(Boolean JavaDoc queryCacheEnabled)
812    {
813       this.queryCacheEnabled = queryCacheEnabled;
814       dirty = true;
815    }
816
817    public String JavaDoc getCacheProviderClass()
818    {
819       return cacheProviderClass;
820    }
821
822    public void setCacheProviderClass(String JavaDoc cacheProviderClass)
823    {
824       this.cacheProviderClass = cacheProviderClass;
825       dirty = true;
826    }
827
828    public String JavaDoc getCacheRegionPrefix()
829    {
830       return cacheRegionPrefix;
831    }
832
833    public void setCacheRegionPrefix(String JavaDoc cacheRegionPrefix)
834    {
835       this.cacheRegionPrefix = cacheRegionPrefix;
836       dirty = true;
837    }
838
839    public Boolean JavaDoc getMinimalPutsEnabled()
840    {
841       return minimalPutsEnabled;
842    }
843
844    public void setMinimalPutsEnabled(Boolean JavaDoc minimalPutsEnabled)
845    {
846       this.minimalPutsEnabled = minimalPutsEnabled;
847       dirty = true;
848    }
849
850    public Boolean JavaDoc getUseStructuredCacheEntriesEnabled()
851    {
852       return structuredCacheEntriesEnabled;
853    }
854
855    public void setUseStructuredCacheEntriesEnabled(Boolean JavaDoc structuredCacheEntriesEnabled)
856    {
857       this.structuredCacheEntriesEnabled = structuredCacheEntriesEnabled;
858    }
859
860    public Boolean JavaDoc getShowSqlEnabled()
861    {
862       return showSqlEnabled;
863    }
864
865    public void setShowSqlEnabled(Boolean JavaDoc showSqlEnabled)
866    {
867       this.showSqlEnabled = showSqlEnabled;
868       dirty = true;
869    }
870
871    public Boolean JavaDoc getSqlCommentsEnabled()
872    {
873       return sqlCommentsEnabled;
874    }
875
876    public void setSqlCommentsEnabled(Boolean JavaDoc commentsEnabled)
877    {
878       this.sqlCommentsEnabled = commentsEnabled;
879    }
880
881    public String JavaDoc getSessionFactoryInterceptor()
882    {
883       return sessionFactoryInterceptor;
884    }
885
886    public void setSessionFactoryInterceptor(String JavaDoc sessionFactoryInterceptor)
887    {
888       this.sessionFactoryInterceptor = sessionFactoryInterceptor;
889       dirty = true;
890    }
891
892    public String JavaDoc getListenerInjector()
893    {
894       return listenerInjector;
895    }
896
897    public void setListenerInjector(String JavaDoc listenerInjector)
898    {
899       this.listenerInjector = listenerInjector;
900    }
901
902    public ObjectName JavaDoc getDeployedTreeCacheObjectName()
903    {
904       return deployedTreeCacheObjectName;
905    }
906
907    public void setDeployedTreeCacheObjectName(ObjectName JavaDoc deployedTreeCacheObjectName)
908    {
909       this.deployedTreeCacheObjectName = deployedTreeCacheObjectName;
910    }
911
912    public Boolean JavaDoc getBatchVersionedDataEnabled()
913    {
914       return batchVersionedDataEnabled;
915    }
916
917    public void setBatchVersionedDataEnabled(Boolean JavaDoc batchVersionedDataEnabled)
918    {
919       this.batchVersionedDataEnabled = batchVersionedDataEnabled;
920       this.dirty = true;
921    }
922
923    public Boolean JavaDoc getStreamsForBinaryEnabled()
924    {
925       return streamsForBinaryEnabled;
926    }
927
928    public void setStreamsForBinaryEnabled(Boolean JavaDoc streamsForBinaryEnabled)
929    {
930       this.streamsForBinaryEnabled = streamsForBinaryEnabled;
931       this.dirty = true;
932    }
933
934    public Boolean JavaDoc getReflectionOptimizationEnabled()
935    {
936       return reflectionOptimizationEnabled;
937    }
938
939    public void setReflectionOptimizationEnabled(Boolean JavaDoc reflectionOptimizationEnabled)
940    {
941       this.reflectionOptimizationEnabled = reflectionOptimizationEnabled;
942       this.dirty = true;
943    }
944
945    public Boolean JavaDoc getStatGenerationEnabled()
946    {
947       return statGenerationEnabled;
948    }
949
950    public void setStatGenerationEnabled(Boolean JavaDoc statGenerationEnabled)
951    {
952       this.statGenerationEnabled = statGenerationEnabled;
953    }
954
955    public URL JavaDoc getHarUrl()
956    {
957       return harUrl;
958    }
959
960    public void setHarUrl(URL JavaDoc harUrl)
961    {
962       this.harUrl = harUrl;
963       dirty = true;
964    }
965
966    public boolean isScanForMappingsEnabled()
967    {
968       return scanForMappingsEnabled;
969    }
970
971    public void setScanForMappingsEnabled(boolean scanForMappingsEnabled)
972    {
973       this.scanForMappingsEnabled = scanForMappingsEnabled;
974    }
975
976    /**
977     * Retrieve MBean's current deployment status.
978     *
979     * @return the current status.
980     */

981    public DeploymentInfo getDeploymentInfo()
982    {
983       try
984       {
985          return super.getDeploymentInfo();
986       }
987       catch ( Throwable JavaDoc t )
988       {
989          return null;
990       }
991    }
992 }
993
Popular Tags