From hibernate-commits at lists.jboss.org Fri Aug 20 06:59:45 2010 Content-Type: multipart/mixed; boundary="===============4977855577617443908==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r20203 - in search/trunk/hibernate-search: src/main/java/org/hibernate/search and 6 other directories. Date: Fri, 20 Aug 2010 06:59:45 -0400 Message-ID: <201008201059.o7KAxj49027060@svn01.web.mwc.hst.phx2.redhat.com> --===============4977855577617443908== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: hardy.ferentschik Date: 2010-08-20 06:59:44 -0400 (Fri, 20 Aug 2010) New Revision: 20203 Added: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/Ind= exControl.java search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/Ind= exControlMBean.java search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jm= x/IndexControlMBeanTest.java Removed: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/Ind= exCtrl.java search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/Ind= exCtrlMBean.java search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jm= x/IndexCtrlMBeanTest.java Modified: search/trunk/hibernate-search/pom.xml search/trunk/hibernate-search/src/main/java/org/hibernate/search/Project= ionConstants.java search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend= /UpdatableBackendQueueProcessorFactory.java search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend= /impl/batchlucene/LuceneBatchBackend.java search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/Se= archFactoryBuilder.java search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/Sea= rchFactoryIntegrator.java search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jm= x/NoMBeansEnabledTest.java Log: HSEARCH-278 Renamed IndexCtrl to IndexControl and marked IndexControlMBean = as experimental. Introduced @experimental in order to have a more formal wa= y to mark something as such Modified: search/trunk/hibernate-search/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/pom.xml 2010-08-20 05:23:28 UTC (rev 2020= 2) +++ search/trunk/hibernate-search/pom.xml 2010-08-20 10:59:44 UTC (rev 2020= 3) @@ -226,6 +226,13 @@ org.apache.maven.plugins maven-javadoc-plugin + + + experimental + a + Experimental + + = true ${basedir}/src/main/javadoc/stylesheet= .css Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/= ProjectionConstants.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/main/java/org/hibernate/search/Projec= tionConstants.java 2010-08-20 05:23:28 UTC (rev 20202) +++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/Projec= tionConstants.java 2010-08-20 10:59:44 UTC (rev 20203) @@ -1,26 +1,25 @@ -/* $Id$ - * = +/* * Hibernate, Relational Persistence for Idiomatic Java - * = - * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party = contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat, Inc. - * = - * This copyrighted material is made available to anyone wishing to use, m= odify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Founda= tion. - * = - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT= ABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public= License - * for more details. - * = - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA + * + * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party= contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat, Inc. + * + * This copyrighted material is made available to anyone wishing to use, = modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Found= ation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN= TABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Publi= c License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public Licen= se + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA */ package org.hibernate.search; = @@ -58,10 +57,11 @@ public String ID =3D "__HSearch_id"; = /** - * Lucene Document id - * Experimental: If you use this feature, please speak up in the forum + * Lucene Document id. *

* Expert: Lucene document id can change overtime between 2 different Ind= exReader opening. + * + * @experimental If you use this constant/feature, please speak up in the= forum */ public String DOCUMENT_ID =3D "__HSearch_DocumentId"; = Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/= backend/UpdatableBackendQueueProcessorFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backen= d/UpdatableBackendQueueProcessorFactory.java 2010-08-20 05:23:28 UTC (rev 2= 0202) +++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backen= d/UpdatableBackendQueueProcessorFactory.java 2010-08-20 10:59:44 UTC (rev 2= 0203) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party= contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat, Inc. + * + * This copyrighted material is made available to anyone wishing to use, = modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Found= ation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN= TABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Publi= c License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public Licen= se + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.search.backend; = import java.util.Set; @@ -6,10 +29,10 @@ import org.hibernate.search.store.DirectoryProvider; = /** - * Experimental - * Allow a BackendQueueProcessorFactory to be notified of DiurectoryProvid= er changes + * Allow a BackendQueueProcessorFactory to be notified of {@code Directory= Provider} changes. * * @author Emmanuel Bernard + * @experimental This API is experimental */ public interface UpdatableBackendQueueProcessorFactory extends BackendQueu= eProcessorFactory { /** Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/= backend/impl/batchlucene/LuceneBatchBackend.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backen= d/impl/batchlucene/LuceneBatchBackend.java 2010-08-20 05:23:28 UTC (rev 202= 02) +++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backen= d/impl/batchlucene/LuceneBatchBackend.java 2010-08-20 10:59:44 UTC (rev 202= 03) @@ -43,11 +43,12 @@ import org.hibernate.search.store.IndexShardingStrategy; = /** - * First EXPERIMENTAL BatchBackend; this is not meant to be used as a regu= lar + * This is not meant to be used as a regular * backend, only to apply batch changes to the index. Several threads * are used to make changes to each index, so order of Work processing is = not guaranteed. * = * @author Sanne Grinovero + * @experimental First {@code BatchBackend} */ public class LuceneBatchBackend implements BatchBackend { = Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/= impl/SearchFactoryBuilder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/S= earchFactoryBuilder.java 2010-08-20 05:23:28 UTC (rev 20202) +++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/S= earchFactoryBuilder.java 2010-08-20 10:59:44 UTC (rev 20203) @@ -74,7 +74,7 @@ import org.hibernate.search.filter.FilterCachingStrategy; import org.hibernate.search.filter.MRUFilterCachingStrategy; import org.hibernate.search.filter.ShardSensitiveOnlyFilter; -import org.hibernate.search.jmx.IndexCtrl; +import org.hibernate.search.jmx.IndexControl; import org.hibernate.search.jmx.JMXRegistrar; import org.hibernate.search.reader.ReaderProvider; import org.hibernate.search.reader.ReaderProviderFactory; @@ -168,8 +168,8 @@ = // if we have a JNDI bound SessionFactory we can also enable the index c= ontrol bean if ( StringHelper.isNotEmpty( configurationProperties.getProperty( "hibe= rnate.session_factory_name" ) ) ) { - IndexCtrl indexCtrlBean =3D new IndexCtrl( configurationProperties ); - JMXRegistrar.registerMBean( indexCtrlBean, IndexCtrl.INDEX_CTRL_MBEAN_O= BJECT_NAME ); + IndexControl indexCtrlBean =3D new IndexControl( configurationPropertie= s ); + JMXRegistrar.registerMBean( indexCtrlBean, IndexControl.INDEX_CTRL_MBEA= N_OBJECT_NAME ); } } = Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jm= x/IndexControl.java (from rev 20181, search/trunk/hibernate-search/src/main= /java/org/hibernate/search/jmx/IndexCtrl.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/In= dexControl.java (rev 0) +++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/In= dexControl.java 2010-08-20 10:59:44 UTC (rev 20203) @@ -0,0 +1,155 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party= contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat, Inc. + * + * This copyrighted material is made available to anyone wishing to use, = modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Found= ation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN= TABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Publi= c License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public Licen= se + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.search.jmx; + +import java.util.Properties; +import javax.naming.Context; +import javax.naming.InitialContext; + +import org.hibernate.CacheMode; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.search.FullTextSession; +import org.hibernate.search.Search; +import org.hibernate.search.util.JNDIHelper; +import org.hibernate.util.ReflectHelper; + + +/** + * Implementation of the {@code IndexControlMBean} JMX attributes and oper= ations. + * + * @author Hardy Ferentschik + */ +public class IndexControl implements IndexControlMBean { + private static final String HIBERNATE_JNDI_PREFIX =3D "hibernate.jndi."; + + private final Properties jndiProperties; + private final String sessionFactoryJndiName; + + private int batchSize =3D 25; + private int numberOfObjectLoadingThreads =3D 2; + private int numberOfFetchingThreads =3D 4; + + public IndexControl(Properties props) { + this.sessionFactoryJndiName =3D props.getProperty( "hibernate.session_fa= ctory_name" ); + this.jndiProperties =3D JNDIHelper.getJndiProperties( props, HIBERNATE_J= NDI_PREFIX ); + } + + public void setBatchSize(int batchSize) { + this.batchSize =3D batchSize; + } + + public int getBatchSize() { + return batchSize; + } + + public void setNumberOfObjectLoadingThreads(int numberOfThreads) { + this.numberOfObjectLoadingThreads =3D numberOfThreads; + } + + public int getNumberOfObjectLoadingThreads() { + return numberOfObjectLoadingThreads; + } + + public void setNumberOfFetchingThreads(int numberOfThreads) { + this.numberOfFetchingThreads =3D numberOfThreads; + } + + public int getNumberOfFetchingThreads() { + return numberOfFetchingThreads; + } + + public void index(String entity) { + Class clazz =3D getEntityClass( entity ); + + SessionFactory factory =3D getSessionFactory(); + Session session =3D factory.openSession(); + FullTextSession fulltextSession =3D Search.getFullTextSession( session ); + try { + fulltextSession.createIndexer( clazz ) + .batchSizeToLoadObjects( batchSize ) + .cacheMode( CacheMode.NORMAL ) + .threadsToLoadObjects( numberOfObjectLoadingThreads ) + .threadsForSubsequentFetching( numberOfFetchingThreads ) + .startAndWait(); + } + catch ( InterruptedException e ) { + throw new RuntimeException( "Unable to complete indexing" ); + } + session.close(); + } + + public void optimize(String entity) { + Class clazz =3D getEntityClass( entity ); + + SessionFactory factory =3D getSessionFactory(); + Session session =3D factory.openSession(); + FullTextSession fullTextSession =3D Search.getFullTextSession( session ); + fullTextSession.beginTransaction(); + fullTextSession.getSearchFactory().optimize( clazz ); + fullTextSession.getTransaction().commit(); + session.close(); + } + + public void purge(String entity) { + Class clazz =3D getEntityClass( entity ); + + SessionFactory factory =3D getSessionFactory(); + Session session =3D factory.openSession(); + FullTextSession fullTextSession =3D Search.getFullTextSession( session ); + fullTextSession.beginTransaction(); + fullTextSession.purgeAll( clazz ); + fullTextSession.getTransaction().commit(); + session.close(); + } + + private Class getEntityClass(String entity) { + Class clazz; + try { + clazz =3D ReflectHelper.classForName( entity, IndexControl.class ); + } + catch ( ClassNotFoundException e ) { + throw new IllegalArgumentException( entity + "not a indexed entity" ); + } + return clazz; + } + + private SessionFactory getSessionFactory() { + try { + Context initialContext; + if ( jndiProperties.isEmpty() ) { + initialContext =3D new InitialContext(); + } + else { + initialContext =3D new InitialContext( jndiProperties ); + } + return ( SessionFactory ) initialContext.lookup( sessionFactoryJndiName= ); + } + catch ( Exception e ) { + throw new UnsupportedOperationException( + "In order for this operation to work the SessionFactory must be bound= to JNDI" + ); + } + } +} \ No newline at end of file Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jm= x/IndexControlMBean.java (from rev 20181, search/trunk/hibernate-search/src= /main/java/org/hibernate/search/jmx/IndexCtrlMBean.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/In= dexControlMBean.java (rev 0) +++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/In= dexControlMBean.java 2010-08-20 10:59:44 UTC (rev 20203) @@ -0,0 +1,109 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party= contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat, Inc. + * + * This copyrighted material is made available to anyone wishing to use, = modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Found= ation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN= TABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Publi= c License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public Licen= se + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.search.jmx; + +/** + * Defines the Hibernate Search exposed JMX attributes and operations for = index creation and purging. + * + * @experimental This MBean is experimental + * @author Hardy Ferentschik + */ +public interface IndexControlMBean { + + public static final String INDEX_CTRL_MBEAN_OBJECT_NAME =3D "org.hibernat= e.search.jmx:type=3DIndexControlMBean"; + + /** + * Sets the batch size for the mass indexer. + * + * @param batchSize the new batch size + */ + void setBatchSize(int batchSize); + + /** + * @return the current batch size for (mass) indexing + */ + int getBatchSize(); + + /** + * @param numberOfThreads the number of threads used for object loading = during mass indexing. + */ + void setNumberOfObjectLoadingThreads(int numberOfThreads); + + /** + * @return the current number of threads during mass indexing + */ + int getNumberOfObjectLoadingThreads(); + + /** + * @param numberOfThreads the number of threads used for collections fetc= hing during mass indexing + */ + void setNumberOfFetchingThreads(int numberOfThreads); + + /** + * @return the current number of threads used for collection fetching + */ + int getNumberOfFetchingThreads(); + + /** + * Index the specified entity using the mass indexer. + *

Note:
+ * This method is only available if the Hibernate {@code SessionFactory} + * is available via JNDI. + *

+ * + * @param entity The fqc of the entity to index + * + * @throws IllegalArgumentException in case the entity name is not valid + * @throws UnsupportedOperationException in case the Hibernate {@code Ses= sionFactory} is not bound via JNDI. + */ + void index(String entity); + + /** + * Optimizes the index for the specified entity. + *

Note:
+ * This method is only available if the Hibernate {@code SessionFactory} + * is available via JNDI. + *

+ * + * @param entity The fqc of the entity to index + * + * @throws IllegalArgumentException in case the entity name is not valid + * @throws UnsupportedOperationException in case the Hibernate {@code Ses= sionFactory} is not bound via JNDI. + */ + void optimize(String entity); + + /** + * Purge the index of the specified entity. + *

Note:
+ * This method is only available if the Hibernate {@code SessionFactory} + * is available via JNDI. + *

+ * + * @param entity The fqc of the entity to index + * + * @throws IllegalArgumentException in case the entity name is not valid + * @throws UnsupportedOperationException in case the Hibernate {@code Ses= sionFactory} is not bound via JNDI. + */ + void purge(String entity); +} \ No newline at end of file Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/j= mx/IndexCtrl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/In= dexCtrl.java 2010-08-20 05:23:28 UTC (rev 20202) +++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/In= dexCtrl.java 2010-08-20 10:59:44 UTC (rev 20203) @@ -1,155 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party= contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat, Inc. - * - * This copyrighted material is made available to anyone wishing to use, = modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Found= ation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN= TABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Publi= c License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public Licen= se - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.search.jmx; - -import java.util.Properties; -import javax.naming.Context; -import javax.naming.InitialContext; - -import org.hibernate.CacheMode; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.search.FullTextSession; -import org.hibernate.search.Search; -import org.hibernate.search.util.JNDIHelper; -import org.hibernate.util.ReflectHelper; - - -/** - * Implementation of the {@code IndexCtrlMBean} JMX attributes and operati= ons. - * - * @author Hardy Ferentschik - */ -public class IndexCtrl implements IndexCtrlMBean { - private static final String HIBERNATE_JNDI_PREFIX =3D "hibernate.jndi."; - - private final Properties jndiProperties; - private final String sessionFactoryJndiName; - - private int batchSize =3D 25; - private int numberOfObjectLoadingThreads =3D 2; - private int numberOfFetchingThreads =3D 4; - - public IndexCtrl(Properties props) { - this.sessionFactoryJndiName =3D props.getProperty( "hibernate.session_fa= ctory_name" ); - this.jndiProperties =3D JNDIHelper.getJndiProperties( props, HIBERNATE_J= NDI_PREFIX ); - } - - public void setBatchSize(int batchSize) { - this.batchSize =3D batchSize; - } - - public int getBatchSize() { - return batchSize; - } - - public void setNumberOfObjectLoadingThreads(int numberOfThreads) { - this.numberOfObjectLoadingThreads =3D numberOfThreads; - } - - public int getNumberOfObjectLoadingThreads() { - return numberOfObjectLoadingThreads; - } - - public void setNumberOfFetchingThreads(int numberOfThreads) { - this.numberOfFetchingThreads =3D numberOfThreads; - } - - public int getNumberOfFetchingThreads() { - return numberOfFetchingThreads; - } - - public void index(String entity) { - Class clazz =3D getEntityClass( entity ); - - SessionFactory factory =3D getSessionFactory(); - Session session =3D factory.openSession(); - FullTextSession fulltextSession =3D Search.getFullTextSession( session ); - try { - fulltextSession.createIndexer( clazz ) - .batchSizeToLoadObjects( batchSize ) - .cacheMode( CacheMode.NORMAL ) - .threadsToLoadObjects( numberOfObjectLoadingThreads ) - .threadsForSubsequentFetching( numberOfFetchingThreads ) - .startAndWait(); - } - catch ( InterruptedException e ) { - throw new RuntimeException( "Unable to complete indexing" ); - } - session.close(); - } - - public void optimize(String entity) { - Class clazz =3D getEntityClass( entity ); - - SessionFactory factory =3D getSessionFactory(); - Session session =3D factory.openSession(); - FullTextSession fullTextSession =3D Search.getFullTextSession( session ); - fullTextSession.beginTransaction(); - fullTextSession.getSearchFactory().optimize( clazz ); - fullTextSession.getTransaction().commit(); - session.close(); - } - - public void purge(String entity) { - Class clazz =3D getEntityClass( entity ); - - SessionFactory factory =3D getSessionFactory(); - Session session =3D factory.openSession(); - FullTextSession fullTextSession =3D Search.getFullTextSession( session ); - fullTextSession.beginTransaction(); - fullTextSession.purgeAll( clazz ); - fullTextSession.getTransaction().commit(); - session.close(); - } - - private Class getEntityClass(String entity) { - Class clazz; - try { - clazz =3D ReflectHelper.classForName( entity, IndexCtrl.class ); - } - catch ( ClassNotFoundException e ) { - throw new IllegalArgumentException( entity + "not a indexed entity" ); - } - return clazz; - } - - private SessionFactory getSessionFactory() { - try { - Context initialContext; - if ( jndiProperties.isEmpty() ) { - initialContext =3D new InitialContext(); - } - else { - initialContext =3D new InitialContext( jndiProperties ); - } - return ( SessionFactory ) initialContext.lookup( sessionFactoryJndiName= ); - } - catch ( Exception e ) { - throw new UnsupportedOperationException( - "In order for this operation to work the SessionFactory must be bound= to JNDI" - ); - } - } -} \ No newline at end of file Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/j= mx/IndexCtrlMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/In= dexCtrlMBean.java 2010-08-20 05:23:28 UTC (rev 20202) +++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/In= dexCtrlMBean.java 2010-08-20 10:59:44 UTC (rev 20203) @@ -1,108 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party= contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat, Inc. - * - * This copyrighted material is made available to anyone wishing to use, = modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Found= ation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN= TABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Publi= c License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public Licen= se - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.search.jmx; - -/** - * Defines the Hibernate Search exposed JMX attributes and operations for = index creation and purging. - * - * @author Hardy Ferentschik - */ -public interface IndexCtrlMBean { - - public static final String INDEX_CTRL_MBEAN_OBJECT_NAME =3D "org.hibernat= e.search.jmx:type=3DIndexCtrlMBean"; - - /** - * Sets the batch size for the mass indexer. - * - * @param batchSize the new batch size - */ - void setBatchSize(int batchSize); - - /** - * @return the current batch size for (mass) indexing - */ - int getBatchSize(); - - /** - * @param numberOfThreads the number of threads used for object loading = during mass indexing. - */ - void setNumberOfObjectLoadingThreads(int numberOfThreads); - - /** - * @return the current number of threads during mass indexing - */ - int getNumberOfObjectLoadingThreads(); - - /** - * @param numberOfThreads the number of threads used for collections fetc= hing during mass indexing - */ - void setNumberOfFetchingThreads(int numberOfThreads); - - /** - * @return the current number of threads used for collection fetching - */ - int getNumberOfFetchingThreads(); - - /** - * Index the specified entity using the mass indexer. - *

Note:
- * This method is only available if the Hibernate {@code SessionFactory} - * is available via JNDI. - *

- * - * @param entity The fqc of the entity to index - * - * @throws IllegalArgumentException in case the entity name is not valid - * @throws UnsupportedOperationException in case the Hibernate {@code Ses= sionFactory} is not bound via JNDI. - */ - void index(String entity); - - /** - * Optimizes the index for the specified entity. - *

Note:
- * This method is only available if the Hibernate {@code SessionFactory} - * is available via JNDI. - *

- * - * @param entity The fqc of the entity to index - * - * @throws IllegalArgumentException in case the entity name is not valid - * @throws UnsupportedOperationException in case the Hibernate {@code Ses= sionFactory} is not bound via JNDI. - */ - void optimize(String entity); - - /** - * Purge the index of the specified entity. - *

Note:
- * This method is only available if the Hibernate {@code SessionFactory} - * is available via JNDI. - *

- * - * @param entity The fqc of the entity to index - * - * @throws IllegalArgumentException in case the entity name is not valid - * @throws UnsupportedOperationException in case the Hibernate {@code Ses= sionFactory} is not bound via JNDI. - */ - void purge(String entity); -} \ No newline at end of file Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/= spi/SearchFactoryIntegrator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/Se= archFactoryIntegrator.java 2010-08-20 05:23:28 UTC (rev 20202) +++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/Se= archFactoryIntegrator.java 2010-08-20 10:59:44 UTC (rev 20203) @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party= contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat, Inc. + * + * This copyrighted material is made available to anyone wishing to use, = modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Found= ation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN= TABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Publi= c License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public Licen= se + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.search.spi; = import org.hibernate.search.SearchFactory; @@ -14,6 +37,7 @@ * It also allows modification of some of the search factory internals: * - today allow addition of new indexed classes. * + * @experimental * @author Emmanuel Bernard */ public interface SearchFactoryIntegrator extends SearchFactory { Copied: search/trunk/hibernate-search/src/test/java/org/hibernate/search/te= st/jmx/IndexControlMBeanTest.java (from rev 20181, search/trunk/hibernate-s= earch/src/test/java/org/hibernate/search/test/jmx/IndexCtrlMBeanTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/j= mx/IndexControlMBeanTest.java (rev 0) +++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/j= mx/IndexControlMBeanTest.java 2010-08-20 10:59:44 UTC (rev 20203) @@ -0,0 +1,165 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party= contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat, Inc. + * + * This copyrighted material is made available to anyone wishing to use, = modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Found= ation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN= TABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Publi= c License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public Licen= se + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.search.test.jmx; + +import java.io.File; +import java.lang.management.ManagementFactory; +import java.util.HashSet; +import java.util.Set; +import javax.management.InstanceNotFoundException; +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanException; +import javax.management.MBeanInfo; +import javax.management.MBeanOperationInfo; +import javax.management.MBeanServer; +import javax.management.ObjectName; +import javax.management.ReflectionException; + +import org.hibernate.Transaction; +import org.hibernate.cfg.Configuration; +import org.hibernate.search.Environment; +import org.hibernate.search.FullTextSession; +import org.hibernate.search.Search; +import org.hibernate.search.jmx.IndexControlMBean; +import org.hibernate.search.jmx.StatisticsInfoMBean; +import org.hibernate.search.test.SearchTestCase; + +/** + * @author Hardy Ferentschik + */ +public class IndexControlMBeanTest extends SearchTestCase { + MBeanServer mbeanServer; + ObjectName statisticsBeanObjectName; + ObjectName indexBeanObjectName; + + public void testIndexCtrlMBeanRegistered() throws Exception { + assertTrue( + "With the right property set the Search MBean should be registered", + mbeanServer.isRegistered( indexBeanObjectName ) + ); + } + + public void testAttributesAndOperations() throws Exception { + MBeanInfo info =3D mbeanServer.getMBeanInfo( indexBeanObjectName ); + MBeanAttributeInfo[] attributes =3D info.getAttributes(); + assertEquals( "Wrong number of attributes", 3, attributes.length ); + Set attributeNames =3D new HashSet(); + attributeNames.add( "NumberOfObjectLoadingThreads" ); + attributeNames.add( "NumberOfFetchingThreads" ); + attributeNames.add( "BatchSize" ); + for ( MBeanAttributeInfo attribute : attributes ) { + assertTrue( attributeNames.contains( attribute.getName() ) ); + } + + MBeanOperationInfo[] operations =3D info.getOperations(); + assertEquals( "Wrong number of operations", 3, operations.length ); + Set operationNames =3D new HashSet(); + operationNames.add( "index" ); + operationNames.add( "purge" ); + operationNames.add( "optimize" ); + for ( MBeanOperationInfo operation : operations ) { + assertTrue( operationNames.contains( operation.getName() ) ); + } + } + + public void testIndexAndPurge() throws Exception { + FullTextSession s =3D Search.getFullTextSession( openSession() ); + Transaction tx =3D s.beginTransaction(); + Counter counter =3D new Counter(); + s.save( counter ); + tx.commit(); + s.close(); + + assertNumberOfIndexedEntities( Counter.class.getName(), 0 ); // manual i= ndexing! + + mbeanServer.invoke( + indexBeanObjectName, + "index", + new String[] { Counter.class.getName() }, + new String[] { String.class.getName() } + ); + + assertNumberOfIndexedEntities( Counter.class.getName(), 1 ); + + mbeanServer.invoke( + indexBeanObjectName, + "purge", + new String[] { Counter.class.getName() }, + new String[] { String.class.getName() } + ); + + assertNumberOfIndexedEntities( Counter.class.getName(), 0 ); + } + + protected void setUp() throws Exception { + setCfg( null ); // force a rebuild of the configuration + super.setUp(); + mbeanServer =3D ManagementFactory.getPlatformMBeanServer(); + statisticsBeanObjectName =3D new ObjectName( StatisticsInfoMBean.STATIST= ICS_MBEAN_OBJECT_NAME ); + indexBeanObjectName =3D new ObjectName( IndexControlMBean.INDEX_CTRL_MBE= AN_OBJECT_NAME ); + } + + protected void tearDown() throws Exception { + super.tearDown(); + if ( mbeanServer.isRegistered( statisticsBeanObjectName ) ) { + mbeanServer.unregisterMBean( statisticsBeanObjectName ); + } + if ( mbeanServer.isRegistered( indexBeanObjectName ) ) { + mbeanServer.unregisterMBean( indexBeanObjectName ); + } + } + + protected void configure(Configuration cfg) { + super.configure( cfg ); + File targetDir =3D getTargetDir(); + File simpleJndiDir =3D new File( targetDir, "simpleJndi" ); + simpleJndiDir.mkdir(); + + cfg.setProperty( "hibernate.session_factory_name", "java:comp/SessionFac= tory" ); + cfg.setProperty( "hibernate.jndi.class", "org.osjava.sj.SimpleContextFac= tory" ); + cfg.setProperty( "hibernate.jndi.org.osjava.sj.root", simpleJndiDir.getA= bsolutePath() ); + cfg.setProperty( "hibernate.jndi.org.osjava.sj.jndi.shared", "true" ); + + cfg.setProperty( "hibernate.search.indexing_strategy", "manual" ); + cfg.setProperty( Environment.JMX_ENABLED, "true" ); + } + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { Counter.class }; + } + + private void assertNumberOfIndexedEntities(String entity, int count) + throws InstanceNotFoundException, MBeanException, ReflectionException { + assertEquals( + "wrong number of indexed entities", count, + mbeanServer.invoke( + statisticsBeanObjectName, + "getNumberOfIndexedEntities", + new String[] { entity }, + new String[] { String.class.getName() } + ) + ); + } +} \ No newline at end of file Deleted: search/trunk/hibernate-search/src/test/java/org/hibernate/search/t= est/jmx/IndexCtrlMBeanTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/j= mx/IndexCtrlMBeanTest.java 2010-08-20 05:23:28 UTC (rev 20202) +++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/j= mx/IndexCtrlMBeanTest.java 2010-08-20 10:59:44 UTC (rev 20203) @@ -1,165 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party= contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat, Inc. - * - * This copyrighted material is made available to anyone wishing to use, = modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Found= ation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN= TABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Publi= c License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public Licen= se - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.search.test.jmx; - -import java.io.File; -import java.lang.management.ManagementFactory; -import java.util.HashSet; -import java.util.Set; -import javax.management.InstanceNotFoundException; -import javax.management.MBeanAttributeInfo; -import javax.management.MBeanException; -import javax.management.MBeanInfo; -import javax.management.MBeanOperationInfo; -import javax.management.MBeanServer; -import javax.management.ObjectName; -import javax.management.ReflectionException; - -import org.hibernate.Transaction; -import org.hibernate.cfg.Configuration; -import org.hibernate.search.Environment; -import org.hibernate.search.FullTextSession; -import org.hibernate.search.Search; -import org.hibernate.search.jmx.IndexCtrlMBean; -import org.hibernate.search.jmx.StatisticsInfoMBean; -import org.hibernate.search.test.SearchTestCase; - -/** - * @author Hardy Ferentschik - */ -public class IndexCtrlMBeanTest extends SearchTestCase { - MBeanServer mbeanServer; - ObjectName statisticsBeanObjectName; - ObjectName indexBeanObjectName; - - public void testIndexCtrlMBeanRegistered() throws Exception { - assertTrue( - "With the right property set the Search MBean should be registered", - mbeanServer.isRegistered( indexBeanObjectName ) - ); - } - - public void testAttributesAndOperations() throws Exception { - MBeanInfo info =3D mbeanServer.getMBeanInfo( indexBeanObjectName ); - MBeanAttributeInfo[] attributes =3D info.getAttributes(); - assertEquals( "Wrong number of attributes", 3, attributes.length ); - Set attributeNames =3D new HashSet(); - attributeNames.add( "NumberOfObjectLoadingThreads" ); - attributeNames.add( "NumberOfFetchingThreads" ); - attributeNames.add( "BatchSize" ); - for ( MBeanAttributeInfo attribute : attributes ) { - assertTrue( attributeNames.contains( attribute.getName() ) ); - } - - MBeanOperationInfo[] operations =3D info.getOperations(); - assertEquals( "Wrong number of operations", 3, operations.length ); - Set operationNames =3D new HashSet(); - operationNames.add( "index" ); - operationNames.add( "purge" ); - operationNames.add( "optimize" ); - for ( MBeanOperationInfo operation : operations ) { - assertTrue( operationNames.contains( operation.getName() ) ); - } - } - - public void testIndexAndPurge() throws Exception { - FullTextSession s =3D Search.getFullTextSession( openSession() ); - Transaction tx =3D s.beginTransaction(); - Counter counter =3D new Counter(); - s.save( counter ); - tx.commit(); - s.close(); - - assertNumberOfIndexedEntities( Counter.class.getName(), 0 ); // manual i= ndexing! - - mbeanServer.invoke( - indexBeanObjectName, - "index", - new String[] { Counter.class.getName() }, - new String[] { String.class.getName() } - ); - - assertNumberOfIndexedEntities( Counter.class.getName(), 1 ); - - mbeanServer.invoke( - indexBeanObjectName, - "purge", - new String[] { Counter.class.getName() }, - new String[] { String.class.getName() } - ); - - assertNumberOfIndexedEntities( Counter.class.getName(), 0 ); - } - - protected void setUp() throws Exception { - setCfg( null ); // force a rebuild of the configuration - super.setUp(); - mbeanServer =3D ManagementFactory.getPlatformMBeanServer(); - statisticsBeanObjectName =3D new ObjectName( StatisticsInfoMBean.STATIST= ICS_MBEAN_OBJECT_NAME ); - indexBeanObjectName =3D new ObjectName( IndexCtrlMBean.INDEX_CTRL_MBEAN_= OBJECT_NAME ); - } - - protected void tearDown() throws Exception { - super.tearDown(); - if ( mbeanServer.isRegistered( statisticsBeanObjectName ) ) { - mbeanServer.unregisterMBean( statisticsBeanObjectName ); - } - if ( mbeanServer.isRegistered( indexBeanObjectName ) ) { - mbeanServer.unregisterMBean( indexBeanObjectName ); - } - } - - protected void configure(Configuration cfg) { - super.configure( cfg ); - File targetDir =3D getTargetDir(); - File simpleJndiDir =3D new File( targetDir, "simpleJndi" ); - simpleJndiDir.mkdir(); - - cfg.setProperty( "hibernate.session_factory_name", "java:comp/SessionFac= tory" ); - cfg.setProperty( "hibernate.jndi.class", "org.osjava.sj.SimpleContextFac= tory" ); - cfg.setProperty( "hibernate.jndi.org.osjava.sj.root", simpleJndiDir.getA= bsolutePath() ); - cfg.setProperty( "hibernate.jndi.org.osjava.sj.jndi.shared", "true" ); - - cfg.setProperty( "hibernate.search.indexing_strategy", "manual" ); - cfg.setProperty( Environment.JMX_ENABLED, "true" ); - } - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { Counter.class }; - } - - private void assertNumberOfIndexedEntities(String entity, int count) - throws InstanceNotFoundException, MBeanException, ReflectionException { - assertEquals( - "wrong number of indexed entities", count, - mbeanServer.invoke( - statisticsBeanObjectName, - "getNumberOfIndexedEntities", - new String[] { entity }, - new String[] { String.class.getName() } - ) - ); - } -} \ No newline at end of file Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/= test/jmx/NoMBeansEnabledTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/j= mx/NoMBeansEnabledTest.java 2010-08-20 05:23:28 UTC (rev 20202) +++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/j= mx/NoMBeansEnabledTest.java 2010-08-20 10:59:44 UTC (rev 20203) @@ -30,7 +30,7 @@ = import org.hibernate.cfg.Configuration; import org.hibernate.search.Environment; -import org.hibernate.search.jmx.IndexCtrlMBean; +import org.hibernate.search.jmx.IndexControlMBean; import org.hibernate.search.jmx.StatisticsInfoMBean; import org.hibernate.search.test.SearchTestCase; = @@ -49,7 +49,7 @@ mbeanServer.isRegistered( name ) ); = - name =3D new ObjectName( IndexCtrlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME ); + name =3D new ObjectName( IndexControlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME = ); assertFalse( "Without '" + Environment.JMX_ENABLED + "' set the index control MBean= should not be registered", mbeanServer.isRegistered( name ) @@ -77,7 +77,7 @@ if ( mbeanServer.isRegistered( statisticsBeanObjectName ) ) { mbeanServer.unregisterMBean( statisticsBeanObjectName ); } - ObjectName indexBeanObjectName =3D new ObjectName( IndexCtrlMBean.INDEX_= CTRL_MBEAN_OBJECT_NAME ); + ObjectName indexBeanObjectName =3D new ObjectName( IndexControlMBean.IND= EX_CTRL_MBEAN_OBJECT_NAME ); if ( mbeanServer.isRegistered( indexBeanObjectName ) ) { mbeanServer.unregisterMBean( indexBeanObjectName ); } --===============4977855577617443908==--