不做浮躁的人
          正在行走的人...
          posts - 171,  comments - 51,  trackbacks - 0

          GPS通過2個(gè)概念提供了整合不同的可索引的數(shù)據(jù)源:CompassGps和CompassGpsDevice。Device可以結(jié)合任何類型的可索引數(shù)據(jù)來源,它提供索引數(shù)據(jù)、搜索數(shù)據(jù)、敏感數(shù)據(jù)變化的能力。?GPS建立在Compass基礎(chǔ)之上。利用Compass的特征,如:事務(wù)、OSEM以及API等。

          CompassGps是GPS的主要接口,它擁有一系列的CompassGpsDevices,并且管理他們的生命周期。

          Compass提供了兩個(gè)Gps的實(shí)現(xiàn):
          SingleCompassGps:擁有一個(gè)compass實(shí)例。這個(gè)compass實(shí)例用來做索引和鏡像操作。
          DualCompassGps:擁有兩個(gè)Compass實(shí)例。indexCompass和mirrorCompass。主要處理兩個(gè)事務(wù)級(jí)別。indexCompass一般采用batch_insert隔離級(jí)別,而mirrorCompass采用read_committed事務(wù)級(jí)別。

          hibernate Gps Device

          hb3新的基于時(shí)間的機(jī)制提供了實(shí)時(shí)數(shù)據(jù)改變的鏡像。數(shù)據(jù)的傳送順序?yàn)椋篋atabase -- Hibernate -- Objects -- Compass::Gps --Compass::Core (Search Engine).
          在hb3中,程序配置:
          Compass compass = ... // set compass instance
          CompassGps gps = new SingleCompassGps(compass);
          CompassGpsDevice hibernateDevice =
          new Hibernate3GpsDevice("hibernate", sessionFactory);
          gps.addDevice(hibernateDevice);
          .... // configure other devices
          gps.start();

          hibernate device提供了一個(gè)fetchCount參數(shù),這個(gè)參數(shù)控制索引一個(gè)類的分頁進(jìn)程。

          實(shí)時(shí)數(shù)據(jù)鏡像:在hb3中是基于新的時(shí)間機(jī)制。數(shù)據(jù)改變將會(huì)反射給compass index。配置時(shí)要注意的是系統(tǒng)和compass必須使用相同的SessionFactory。如果使用hb3和spring,請(qǐng)使用SpringHibernate3GpsDevice。

          Compass與spring結(jié)合:
          1:支持compass級(jí)別的工廠bean。采用Spring ioc的配置選項(xiàng)。
          2:提供Compass DAO級(jí)別的支持。采用事務(wù)整合和DAO支持類。
          3:擴(kuò)展GPS Hiberante3 device。
          4:提供OJB的整合支持。
          5:提供Spring MVC的搜索控制器和索引控制器。

          spring中配置compass bean:
          <bean id="compass"
          class="org.compass.spring.LocalCompassBean">
          <property name="resourceLocations">
          <list>
          <value>classpath:org/compass/spring/test/A.cpm.xml</value>
          </list>
          </property>
          <property name="compassSettings">
          <props>
          <prop key="compass.engine.connection">
          target/testindex
          </prop>
          <!-- This is the default transaction handling
          (just explicitly setting it) -->
          <prop key="compass.transaction.factory">
          org.compass.core.transaction.LocalTransactionFactory
          </prop>
          </props>
          </property>
          </bean>

          compass提供CompassDaoSupport類來執(zhí)行Dao操作。

          public class LibraryCompassDao extends CompassDaoSupport {
          public int getNumberOfHits(final String query) {
          Integer numberOfHits = (Integer)getCompassTemplate().execute(
          new CompassCallback() {
          public Object doInCompass(CompassSession session) {
          CompassHits hits = session.find(query);
          return new Integer(hits.getLength());
          }
          }
          );
          }
          return numberOfHits.intValue();
          }

          然后配置該DAO類使用的Compass實(shí)例:
          <beans>
          <bean id="libraryCompass" class="LibraryCompassDao">
          <property name="compass">
          <ref local="compass" />
          </property>
          </bean>
          </beans>

          SpringSyncTransaction:compass將同步spring本身的事務(wù).
          SpringHibernate3GpsDevice:對(duì)Hibernate3GpsDevice的擴(kuò)展,能夠處理spring帶來的sessionFactory以便使用時(shí)間機(jī)制監(jiān)聽實(shí)時(shí)數(shù)據(jù)改變。

          posted on 2006-12-02 15:46 不做浮躁的人 閱讀(3313) 評(píng)論(1)  編輯  收藏

          FeedBack:
          # re: compass學(xué)習(xí)筆記4
          2008-11-20 10:15 | 老丁
          遇到 clob和blob 會(huì)報(bào)錯(cuò)怎么解決???

          Exception in thread "main" org.compass.core.mapping.MappingException: No converter defined for type [java.sql.Clob]

            回復(fù)  更多評(píng)論
            

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          <2006年12月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          常用鏈接

          留言簿(9)

          隨筆分類(31)

          隨筆檔案(75)

          文章分類(1)

          文章檔案(3)

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 上饶市| 晋州市| 克拉玛依市| 沁源县| 敖汉旗| 南宫市| 遂宁市| 满城县| 什邡市| 洛浦县| 海丰县| 拜城县| 吉木乃县| 瓦房店市| 岳西县| 夏邑县| 河南省| 丘北县| 旬邑县| 广平县| 平安县| 黑水县| 南平市| 葫芦岛市| 桓仁| 凯里市| 保康县| 涿州市| 蕲春县| 寿阳县| 颍上县| 墨玉县| 嘉荫县| 阿瓦提县| 精河县| 云霄县| 会同县| 水城县| 珲春市| 綦江县| 交口县|