2013-04-30 50 views
1

我一直在試圖獲取modeshape 3.2與MySQL數據庫的工作,我沒有得到很遠。默認情況下,所有內容都在我無法使用的內存中。請求簡單的modeshape 3.x/infinispan SQL數據庫配置

從我拼湊到目前爲止,它似乎我需要配置infinispan以堅持JCR。我嘗試過調整我用Google搜索的各種示例,但無濟於事。

這是一個工作/驗證配置的請求,而不是嘗試修復jboss.org網站上的一個損壞的配置。

+0

請注意,從infinispan 5.2.5.final這些錯誤中,不能聲明設置simpleConnection.connectionUrl。吉拉長大了。 – TedTrippin 2013-05-01 09:50:27

回答

1

從Modeshape 3.2開始,由於缺陷,您不能使用帶simpleConnection的infinispan xml配置。但這裏是如何以編程方式做到這一點...

振形配置

{ 
    "name" : "My Repository", 
    "jndiName" : "", 
    "monitoring" : { 
     "enabled" : true 
    }, 
    "workspaces" : { 
     "default" : "defaultWorkspace", 
     "allowCreation" : true 
    }, 
    "storage" : { 
     "cacheName" : "myCache", 
     "binaryStorage" : { 
      "type" : "database", 
      "driverClass" : "com.mysql.jdbc.Driver", 
      "username" : "modeshape", 
      "password" : "modeshape", 
      "url" : "jdbc:mysql://127.0.0.1:3306/modeshape?autoReconnect=true" 
     } 
    }, 
    "security" : { 
     "anonymous" : { 
      "roles" : ["readonly","readwrite","admin"], 
      "username" : "admin", 
      "useOnFailedLogin" : true 
     }, 
     "providers" : [] 
    }, 
} 

然後在你的代碼中配置的,包括Infinispan的是這樣的...

ConfigurationBuilder builder = new ConfigurationBuilder(); 
     Configuration cacheConfig = 
     builder 
      .transaction() 
       .transactionManagerLookup(new GenericTransactionManagerLookup()) 
       .transactionMode(TransactionMode.TRANSACTIONAL) 
       .lockingMode(LockingMode.OPTIMISTIC) 
      .loaders() 
       .addLoader(JdbcStringBasedCacheStoreConfigurationBuilder.class) 
       .fetchPersistentState(false) 
       .ignoreModifications(false) 
       .purgeOnStartup(false) 
       .table() 
        .dropOnExit(false) 
        .createOnStart(true) 
        .tableNamePrefix("ISPN_STRING_TABLE") 
        .idColumnName("ID_COLUMN").idColumnType("VARCHAR(255)") 
        .dataColumnName("DATA_COLUMN").dataColumnType("BLOB") 
        .timestampColumnName("TIMESTAMP_COLUMN").timestampColumnType("BIGINT") 
       .simpleConnection() 
        .connectionUrl("jdbc:mysql://127.0.0.1:3306/modeshape?autoReconnect=true") 
        .username("modeshape") 
        .password("modeshape") 
        .driverClass("com.mysql.jdbc.Driver").build(); 

     LocalEnvironment environment = new LocalEnvironment(); 
     environment.defineCache("myCache", cacheConfig); // Must match the cacheName property in your modeshape config 

     String confPath = "<path to modeshape config>"; 
     RepositoryConfiguration repositoryConfiguration = RepositoryConfiguration.read(new File(confPath)); 
     repositoryConfiguration = repositoryConfiguration.with(environment); 

     ModeShapeEngine engine = new ModeShapeEngine(); 
     engine.start(); 
     repository = engine.deploy(repositoryConfiguration); 

希望幫助別人。雖然它速度很慢,所以你可能不想這樣設置。

+0

您是否嘗試過使用作爲Infinispan XML配置的資源路徑的值添加「cacheConfiguration」字段(與「cacheName」處於同一級別)?如果需要,甚至可以在ModeShape配置中使用變量。有關詳細信息,請參閱我們的ModeShape文檔:https://docs.jboss.org/author/display/MODE/ModeShape+in+Java+applications#ModeShapeinJavaapplications-ModeShaperepositoryconfigurationfiles – 2013-05-02 16:35:16

+0

感謝Randall。我爲https://issues.jboss.org/browse/ISPN-3065發佈的問題提出了這張票 – TedTrippin 2013-05-02 22:11:23