protected InfinispanHotrodQueryable queryable;
protected Configuration configuration;
@Init
public void init() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.connectionPool().maxActive(maxConnectionsServer).maxTotal(maxConnectionsTotal);
for (String server : servers.split(";")) {
Matcher matcher = ADDRESS_PATTERN.matcher(server);
if (!matcher.matches()) {
log.error("Could not parse server address from " + server);
continue;
}
String v6host = matcher.group(2);
String v4host = matcher.group(3);
String host = v6host != null ? v6host : v4host;
String portString = matcher.group(4);
int port = portString == null
? ConfigurationProperties.DEFAULT_HOTROD_PORT
: Integer.parseInt(portString);
serverHostnames.add(host);
builder.addServer().host(host).port(port);
}
if (enableQuery) {
queryable = new InfinispanHotrodQueryable(this);
ProtoStreamMarshaller marshaller = new ProtoStreamMarshaller();
builder.marshaller(marshaller);
SerializationContext context = marshaller.getSerializationContext();
queryable.registerProtofilesLocal(context);
// remote registration has to be delayed until we have running servers
// register marshallers
for (RegisteredClass rc : classes) {
try {
context.registerMarshaller(rc.clazz, rc.getMarshaller());
} catch (Exception e) {
throw new IllegalArgumentException("Could not instantiate marshaller for " + rc.clazz, e);
}
}
}
configuration = builder.build();
}