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

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

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

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

          hibernate Gps Device

          hb3新的基于時間的機制提供了實時數據改變的鏡像。數據的傳送順序為:Database -- 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提供了一個fetchCount參數,這個參數控制索引一個類的分頁進程。

          實時數據鏡像:在hb3中是基于新的時間機制。數據改變將會反射給compass index。配置時要注意的是系統和compass必須使用相同的SessionFactory。如果使用hb3和spring,請使用SpringHibernate3GpsDevice。

          Compass與spring結合:
          1:支持compass級別的工廠bean。采用Spring ioc的配置選項。
          2:提供Compass DAO級別的支持。采用事務整合和DAO支持類。
          3:擴展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類來執行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實例:
          <beans>
          <bean id="libraryCompass" class="LibraryCompassDao">
          <property name="compass">
          <ref local="compass" />
          </property>
          </bean>
          </beans>

          SpringSyncTransaction:compass將同步spring本身的事務.
          SpringHibernate3GpsDevice:對Hibernate3GpsDevice的擴展,能夠處理spring帶來的sessionFactory以便使用時間機制監聽實時數據改變。

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

          FeedBack:
          # re: compass學習筆記4
          2008-11-20 10:15 | 老丁
          遇到 clob和blob 會報錯怎么解決啊?

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

            回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

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

          常用鏈接

          留言簿(9)

          隨筆分類(31)

          隨筆檔案(75)

          文章分類(1)

          文章檔案(3)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 平邑县| 娄烦县| 正阳县| 阿拉善左旗| 响水县| 六枝特区| 龙岩市| 韶山市| 岳普湖县| 枣强县| 平潭县| 海丰县| 潮安县| 大足县| 鲁甸县| 榕江县| 德阳市| 舞钢市| 宁国市| 镶黄旗| 麦盖提县| 安乡县| 宁都县| 烟台市| 津南区| 定安县| 固阳县| 剑河县| 图们市| 合作市| 大丰市| 佛山市| 清苑县| 清新县| 广汉市| 醴陵市| 连山| 彰化县| 明溪县| 沈阳市| 龙井市|