1

我一直在尝试让 modeshape 3.2 与 MySQL 数据库一起使用,但我并没有走得太远。默认情况下,所有内容都在内存中,这对我来说毫无用处。

从到目前为止我拼凑的内容来看,我似乎需要配置 infinispan 以保留 JCR。我尝试过调整我在谷歌上搜索过的各种示例,但无济于事。

这是对工作/经过验证的配置的请求,而不是尝试修复 jboss.org 站点上的损坏配置之一。

4

1 回答 1

1

从 Modeshape 3.2 开始,由于存在错误,您不能将 infinispan xml 配置与 simpleConnection 一起使用。但是,您可以通过以下方式以编程方式进行操作...

模态配置

{
    "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);

虽然,它比较慢。

于 2013-05-01T14:06:23.293 回答