Skip to content

Instantly share code, notes, and snippets.

@seanf
Created August 23, 2017 02:20
Show Gist options
  • Select an option

  • Save seanf/aebcc23f0634e3f9343e3f663f966bcc to your computer and use it in GitHub Desktop.

Select an option

Save seanf/aebcc23f0634e3f9343e3f663f966bcc to your computer and use it in GitHub Desktop.
Configuring wildfly for Zanata with Creaper
import org.slf4j.LoggerFactory
import org.wildfly.extras.creaper.commands.datasources.AddDataSource
import org.wildfly.extras.creaper.commands.logging.AddLogger
import org.wildfly.extras.creaper.commands.logging.ChangeConsoleLogHandler
import org.wildfly.extras.creaper.commands.logging.LogLevel
import org.wildfly.extras.creaper.commands.messaging.AddQueue
import org.wildfly.extras.creaper.commands.security.AddLoginModule
import org.wildfly.extras.creaper.commands.security.AddSecurityDomain
import org.wildfly.extras.creaper.core.ManagementClient
import org.wildfly.extras.creaper.core.offline.OfflineOptions
import java.io.File
object ArquillianRest {
private val log = LoggerFactory.getLogger(ArquillianRest::class.java)
@JvmStatic
fun main(args: Array<String>) {
log.info("beforeSetup")
val jbossHome = System.getProperty("jboss.home") ?: throw RuntimeException(
"System property jboss.home needs to be set")
// This code attempts to replicate (part of)
// and server/etc/scripts/zanata-config-test-common.cli
// and server/etc/scripts/zanata-config-arq-test.cli.
// Note that Creaper can't make all required changes, especially in offline mode.
// See also https://gist.github.com/seanf/5d8bd26516d27491ef78c801e11c1966
// for another approach which should be able to do everything a .cli script can do.
val client = ManagementClient.offline(OfflineOptions.standalone()
.rootDirectory(File(jbossHome))
.configurationFile("standalone-full.xml")
.build())
client.apply(
AddDataSource.Builder<AddDataSource.Builder<*>>("zanataDatasource")
.enableAfterCreate()
.jndiName("java:jboss/datasources/zanataDatasource")
.driverName("h2")
.connectionUrl("jdbc:h2:mem:zanata;DB_CLOSE_DELAY=-1")
.usernameAndPassword("sa", "sa")
.validateOnMatch(false)
.backgroundValidation(false)
.validConnectionCheckerClass("org.jboss.jca.adapters.jdbc.extensions.novendor.JDBC4ValidConnectionChecker")
.exceptionSorterClass("org.jboss.jca.adapters.jdbc.extensions.novendor.NullExceptionSorter")
.useCcm(true)
.replaceExisting()
.build(),
/* online only
new AddLocalCache.Builder("zanata")
.jndiName("java:jboss/infinispan/container/zanata")
.statisticsEnabled(true)
.cacheContainer("zanata")
// .replaceExisting()
.build(),
*/
ChangeConsoleLogHandler.Builder("CONSOLE")
.level(LogLevel.DEBUG)
.build(),
AddLogger.Builder("org.hibernate.SQL")
.replaceExisting()
.level(LogLevel.DEBUG)
.build(),
AddLogger.Builder("org.hibernate.tool.hbm2ddl")
.replaceExisting()
.level(LogLevel.DEBUG)
.build(),
AddQueue.Builder("MailsQueue")
.durable(true)
.jndiEntries(
listOf("java:/jms/queue/MailsQueue"))
.replaceExisting()
.build(),
AddSecurityDomain.Builder("zanata")
.replaceExisting()
.build(),
AddLoginModule.Builder<AddLoginModule.Builder<*>>("org.zanata.security.ZanataCentralLoginModule", "ZanataCentralLoginModule")
.securityDomainName("zanata")
.replaceExisting()
.flag("required")
.build(),
AddSecurityDomain.Builder("zanata.internal")
.replaceExisting()
.build(),
AddLoginModule.Builder<AddLoginModule.Builder<*>>("org.zanata.security.jaas.InternalLoginModule", "ZanataInternalLoginModule")
.securityDomainName("zanata.internal")
.replaceExisting()
.flag("required")
.build(),
AddSecurityDomain.Builder("zanata.openid")
.replaceExisting()
.build(),
AddLoginModule.Builder<AddLoginModule.Builder<*>>("org.zanata.security.OpenIdLoginModule", "ZanataOpenIdLoginModule")
.securityDomainName("zanata.openid")
.replaceExisting()
.flag("required")
.build()
)
}
}
@seanf
Copy link
Copy Markdown
Author

seanf commented Aug 23, 2017

Maven dependency:

    <dependency>
      <groupId>org.wildfly.extras.creaper</groupId>
      <artifactId>creaper-commands</artifactId>
      <version>1.6.1</version>
      <scope>test</scope>
    </dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment