Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
Adjust to slightly better config-api.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobmcwhirter committed Nov 2, 2015
1 parent a98f9a2 commit 6bfb0b6
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 149 deletions.
Expand Up @@ -17,7 +17,7 @@

import org.wildfly.swarm.config.Datasources;
import org.wildfly.swarm.config.datasources.DataSource;
import org.wildfly.swarm.config.datasources.JDBCDriverConfigurator;
import org.wildfly.swarm.config.datasources.JDBCDriverConsumer;
import org.wildfly.swarm.container.Fraction;

/**
Expand All @@ -30,14 +30,13 @@ public DatasourcesFraction dataSource(DataSource value) {
return super.dataSource(value);
}

public DatasourcesFraction jdbcDriver(String childKey, EnhancedJDBCDriverConfigurator config) {
JDBCDriver driver = new JDBCDriver(childKey);
config.configure(driver);
jdbcDriver( driver );
return this;
public DatasourcesFraction jdbcDriver(String childKey, JDBCDriverConsumer consumer) {
return super.jdbcDriver( childKey, (driver)->{
driver.driverName( childKey );
if ( consumer != null ) {
consumer.accept(driver);
}
});
}

public interface EnhancedJDBCDriverConfigurator extends JDBCDriverConfigurator {

}
}

This file was deleted.

4 changes: 2 additions & 2 deletions ee/api/src/main/java/org/wildfly/swarm/ee/EEFraction.java
Expand Up @@ -64,10 +64,10 @@ public static EEFraction createDefaultFraction() {
@Override
public void postInitialize(Container.PostInitContext initContext) {
if ( initContext.hasFraction( "Messaging" )) {
if ( this.defaultBindingsService() == null ) {
if ( this.subresources().defaultBindingsService() == null ) {
this.defaultBindingsService( new DefaultBindingsService() );
}
this.defaultBindingsService()
this.subresources().defaultBindingsService()
.jmsConnectionFactory( "java:jboss/DefaultJMSConnectionFactory" );
}
}
Expand Down
Expand Up @@ -20,6 +20,7 @@
import org.wildfly.swarm.config.infinispan.cache_container.*;
import org.wildfly.swarm.container.Fraction;

import java.io.File;
import java.util.Arrays;

/**
Expand All @@ -33,60 +34,86 @@ private InfinispanFraction() {
public static InfinispanFraction createDefaultFraction() {

// Default cache
CacheContainer replicatedCache = new CacheContainer("server")
CacheContainer<?> replicatedCache = new CacheContainer<>("server")
.defaultCache("default")
.aliases(Arrays.asList(new String[]{"singleton", "cluster"}))
.jgroupsTransport(new JGroupsTransport().lockTimeout(60000L))
.replicatedCache(new ReplicatedCache("default")
.mode("SYNC")
.transactionComponent(
new TransactionComponent().mode("BATCH")));
.alias("singleton")
.alias("cluster")
.jgroupsTransport((t) -> {
t.lockTimeout(60000L);
})
.replicatedCache("default", (c) -> {
c.mode("SYNC")
.transactionComponent((t) -> {
t.mode("BATCH");
});
});

// Web cache
CacheContainer webCache = new CacheContainer("web")
CacheContainer<?> webCache = new CacheContainer<>("web")
.defaultCache("dist")
.jgroupsTransport(new JGroupsTransport().lockTimeout(60000L))
.distributedCache(new DistributedCache("dist")
.mode("ASYNC")
.l1Lifespan(0L)
.owners(2)
.lockingComponent(new LockingComponent().isolation("REPEATABLE_READ"))
.transactionComponent(new TransactionComponent().mode("BATCH"))
.fileStore(new FileStore()));
.jgroupsTransport((t) -> {
t.lockTimeout(60000L);
})
.distributedCache("dist", (c) -> {
c.mode("ASYNC")
.l1Lifespan(0L)
.owners(2)
.lockingComponent(lc -> {
lc.isolation("REPEATABLE_READ");
})
.transactionComponent(tc -> {
tc.mode("BATCH");
})
.fileStore();
});


// EJB cache
CacheContainer ejbCache = new CacheContainer("ejb")
CacheContainer<?> ejbCache = new CacheContainer<>("ejb")
.defaultCache("dist")
.aliases(Arrays.asList(new String[]{"sfsb"}))
.jgroupsTransport(new JGroupsTransport().lockTimeout(60000L))
.distributedCache(new DistributedCache("dist")
.mode("ASYNC")
.l1Lifespan(0l)
.owners(2)
.lockingComponent(new LockingComponent().isolation("REPEATABLE_READ"))
.transactionComponent(new TransactionComponent().mode("BATCH"))
.fileStore(new FileStore()));
.alias("sfsb")
.jgroupsTransport(t -> {
t.lockTimeout(60000L);
})
.distributedCache("dist", (c) -> {
c.mode("ASYNC")
.l1Lifespan(0l)
.owners(2)
.lockingComponent(lc -> lc.isolation("REPEATABLE_READ"))
.transactionComponent(t -> t.mode("BATCH"))
.fileStore();
});

// Hibernate cache
CacheContainer hibernateCache = new CacheContainer("hibernate")
CacheContainer<?> hibernateCache = new CacheContainer<>("hibernate")
.defaultCache("local-query")
.jgroupsTransport(new JGroupsTransport().lockTimeout(60000L))
.localCache(new LocalCache("local-query")
.evictionComponent(new EvictionComponent().maxEntries(10000L).strategy("LRU"))
.expirationComponent(new ExpirationComponent().maxIdle(100000L)))
.invalidationCache(new InvalidationCache("entity")
.mode("SYNC")
.transactionComponent(new TransactionComponent().mode("NON_XA"))
.evictionComponent(new EvictionComponent().maxEntries(10000L).strategy("LRU"))
.expirationComponent(new ExpirationComponent().maxIdle(100000L)))
.replicatedCache(new ReplicatedCache("timestamps").mode("ASYNC"));
.jgroupsTransport(t -> {
t.lockTimeout(60000L);
})
.localCache("local-query", (c) -> {
c.evictionComponent(ec ->
ec.maxEntries(10000L).strategy("LRU")
);
c.expirationComponent(ec ->
ec.maxIdle(100000L)
);
})
.invalidationCache("entity", (c) -> {
c.mode("SYNC")
.transactionComponent(tc -> tc.mode("NON_XA"))
.evictionComponent(ec -> ec.maxEntries(10000L).strategy("LRU"))
.expirationComponent(ec -> ec.maxIdle(100000L));
})
.replicatedCache("timestamps", (c) -> {
c.mode("ASYNC");
});


InfinispanFraction fraction = new InfinispanFraction();

return fraction.cacheContainer(replicatedCache)
.cacheContainer(webCache)
.cacheContainer(ejbCache)
.cacheContainer(hibernateCache);
.cacheContainer(webCache)
.cacheContainer(ejbCache)
.cacheContainer(hibernateCache);
}
}
Expand Up @@ -54,6 +54,5 @@ public List<ModelNode> getList(InfinispanFraction fraction) throws Exception {
list.addAll(Marshaller.marshal(fraction));

return list;

}
}
Expand Up @@ -20,29 +20,29 @@

import org.wildfly.swarm.config.messaging_activemq.server.ConnectionFactory;
import org.wildfly.swarm.config.messaging_activemq.server.JMSQueue;
import org.wildfly.swarm.config.messaging_activemq.server.JMSQueueConfigurator;
import org.wildfly.swarm.config.messaging_activemq.server.JMSQueueConsumer;
import org.wildfly.swarm.config.messaging_activemq.server.JMSTopic;
import org.wildfly.swarm.config.messaging_activemq.server.JMSTopicConfigurator;
import org.wildfly.swarm.config.messaging_activemq.server.JMSTopicConsumer;
import org.wildfly.swarm.config.messaging_activemq.server.PooledConnectionFactory;

/**
* @author Bob McWhirter
*/
public class Server extends org.wildfly.swarm.config.messaging_activemq.Server<Server> {
public class EnhancedServer extends org.wildfly.swarm.config.messaging_activemq.Server<EnhancedServer> {
private static final AtomicInteger COUNTER = new AtomicInteger();

public Server(String key) {
public EnhancedServer(String key) {
super(key);
}

public Server enableInVm() {
public EnhancedServer enableInVm() {
int serverId = COUNTER.getAndIncrement();

inVmConnector( "in-vm", (c)->{
c.serverId( serverId );
inVmConnector("in-vm", (c) -> {
c.serverId(serverId);
});

inVmAcceptor( "in-vm", (a)->{
inVmAcceptor("in-vm", (a) -> {
a.serverId(serverId);
});

Expand All @@ -59,30 +59,26 @@ public Server enableInVm() {
}

@Override
public Server jmsQueue(String childKey, JMSQueueConfigurator config) {
JMSQueue queue = new JMSQueue(childKey);
if ( config != null ) {
config.configure(queue);
}
System.err.println( "queeu entries: " + queue.entries() );
if ( queue.entries() == null ) {
queue.entries( Arrays.asList( "java:/jms/queue/" + childKey ));
}
jmsQueue(queue);
return this;
public EnhancedServer jmsQueue(String childKey, JMSQueueConsumer config) {
return super.jmsQueue(childKey, (q) -> {
if (config != null) {
config.accept(q);
}
if (q.entries() == null || q.entries().isEmpty()) {
q.entry("java:/jms/queue/" + childKey);
}
});
}

@Override
public Server jmsTopic(String childKey, JMSTopicConfigurator config) {
JMSTopic topic = new JMSTopic(childKey);
if( config != null ) {
config.configure(topic);
}
System.err.println( "topic entries: " + topic.entries() );
if ( topic.entries() == null ) {
topic.entries( Arrays.asList( "java:/jms/topic/" + childKey ));
}
jmsTopic(topic);
return this;
public EnhancedServer jmsTopic(String childKey, JMSTopicConsumer config) {
return super.jmsTopic(childKey, (t) -> {
if (config != null) {
config.accept(t);
}
if (t.entries() == null || t.entries().isEmpty()) {
t.entry("java:/jms/topic/" + childKey);
}
});
}
}
@@ -0,0 +1,9 @@
package org.wildfly.swarm.messaging;

import org.wildfly.swarm.config.messaging_activemq.ServerConsumer;

/**
* @author Bob McWhirter
*/
public interface EnhancedServerConsumer extends ServerConsumer<EnhancedServer> {
}
Expand Up @@ -15,11 +15,7 @@
*/
package org.wildfly.swarm.messaging;

import java.util.Arrays;

import org.wildfly.swarm.config.MessagingActiveMQ;
import org.wildfly.swarm.config.messaging_activemq.server.ConnectionFactory;
import org.wildfly.swarm.config.messaging_activemq.server.PooledConnectionFactory;
import org.wildfly.swarm.container.Fraction;

/**
Expand All @@ -32,24 +28,24 @@ private MessagingFraction() {
}

public static MessagingFraction createDefaultFraction() {
return new MessagingFraction();
}

public MessagingFraction server(String childKey, ServerConfigurator config) {
Server s = new Server(childKey);
config.configure(s);
return server(s);
return new MessagingFraction().defaultServer();
}

public MessagingFraction defaultServer() {
return defaultServer( (s)->{} );
return defaultServer((s) -> {
s.enableInVm();
});
}

public MessagingFraction defaultServer(ServerConfigurator config) {
server("default", (s) -> {
s.enableInVm();
config.configure(s);
public MessagingFraction server(String childKey, EnhancedServerConsumer consumer) {
return super.server( ()->{
EnhancedServer s = new EnhancedServer(childKey);
consumer.accept(s);
return s;
});
return this;
}

public MessagingFraction defaultServer(EnhancedServerConsumer config) {
return server( "default", config );
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -40,7 +40,7 @@


<version.wildfly>10.0.0.CR4</version.wildfly>
<version.wildfly.config-api>0.3.12</version.wildfly.config-api>
<version.wildfly.config-api>0.3.13</version.wildfly.config-api>
<version.org.jboss.msc.jboss-msc>1.2.6.Final</version.org.jboss.msc.jboss-msc>
<version.org.jboss.spec.javax.sql.jboss-javax-sql-api_7.0_spec>2.0.0.Final</version.org.jboss.spec.javax.sql.jboss-javax-sql-api_7.0_spec>
<version.org.arquillian>1.1.8.Final</version.org.arquillian>
Expand Down

0 comments on commit 6bfb0b6

Please sign in to comment.