use of org.infinispan.server.configuration.ServerConfigurationBuilder in project infinispan by infinispan.
the class Server method parseConfiguration.
private void parseConfiguration(List<Path> configurationFiles) {
ParserRegistry parser = new ParserRegistry(classLoader, false, properties);
try {
// load the defaults first
URL defaults = this.getClass().getClassLoader().getResource(SERVER_DEFAULTS);
defaultsHolder = parser.parse(defaults);
// Set a default audit logger
defaultsHolder.getGlobalConfigurationBuilder().security().authorization().auditLogger(new LoggingAuditLogger());
// base the global configuration to the default
configurationBuilderHolder = new ConfigurationBuilderHolder(classLoader);
GlobalConfigurationBuilder global = configurationBuilderHolder.getGlobalConfigurationBuilder();
global.read(defaultsHolder.getGlobalConfigurationBuilder().build());
// Copy all default templates
for (Map.Entry<String, ConfigurationBuilder> entry : defaultsHolder.getNamedConfigurationBuilders().entrySet()) {
configurationBuilderHolder.newConfigurationBuilder(entry.getKey()).read(entry.getValue().build());
}
// then load the user configurations
for (Path configurationFile : configurationFiles) {
if (!configurationFile.isAbsolute()) {
configurationFile = serverConf.toPath().resolve(configurationFile);
}
parser.parse(configurationFile.toUri().toURL(), configurationBuilderHolder);
}
if (log.isDebugEnabled()) {
StringBuilderWriter sw = new StringBuilderWriter();
try (ConfigurationWriter w = ConfigurationWriter.to(sw).build()) {
Map<String, Configuration> configs = configurationBuilderHolder.getNamedConfigurationBuilders().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().build()));
parser.serialize(w, global.build(), configs);
}
log.debugf("Actual configuration: %s", sw);
}
// Amend the named caches configurations with the defaults
for (Map.Entry<String, ConfigurationBuilder> entry : configurationBuilderHolder.getNamedConfigurationBuilders().entrySet()) {
Configuration cfg = entry.getValue().build();
ConfigurationBuilder defaultCfg = defaultsHolder.getNamedConfigurationBuilders().get("org.infinispan." + cfg.clustering().cacheMode().name());
ConfigurationBuilder rebased = new ConfigurationBuilder().read(defaultCfg.build());
rebased.read(cfg);
entry.setValue(rebased);
}
// Process the server configuration
ServerConfigurationBuilder serverBuilder = global.module(ServerConfigurationBuilder.class);
// Set up transport security
TransportSecurityConfiguration transportSecurityConfiguration = serverBuilder.security().transport().create();
if (transportSecurityConfiguration.securityRealm() != null) {
String securityRealm = transportSecurityConfiguration.securityRealm();
Supplier<SSLContext> serverSSLContextSupplier = serverBuilder.serverSSLContextSupplier(securityRealm);
Supplier<SSLContext> clientSSLContextSupplier = serverBuilder.clientSSLContextSupplier(securityRealm);
NamedSocketFactory namedSocketFactory = new NamedSocketFactory(() -> clientSSLContextSupplier.get().getSocketFactory(), () -> serverSSLContextSupplier.get().getServerSocketFactory());
global.transport().addProperty(JGroupsTransport.SOCKET_FACTORY, namedSocketFactory);
Server.log.sslTransport(securityRealm);
}
// Set the operation handler on all endpoints
ServerAdminOperationsHandler adminOperationsHandler = new ServerAdminOperationsHandler(defaultsHolder);
ServerConfigurationBuilder serverConfigurationBuilder = global.module(ServerConfigurationBuilder.class);
for (EndpointConfigurationBuilder endpoint : serverConfigurationBuilder.endpoints().endpoints().values()) {
for (ProtocolServerConfigurationBuilder<?, ?> connector : endpoint.connectors()) {
connector.adminOperationsHandler(adminOperationsHandler);
}
}
configurationBuilderHolder.validate();
} catch (IOException e) {
throw new CacheConfigurationException(e);
}
}
use of org.infinispan.server.configuration.ServerConfigurationBuilder in project infinispan by infinispan.
the class RestServerConfigurationParser method readElement.
@Override
public void readElement(ConfigurationReader reader, ConfigurationBuilderHolder holder) {
if (!holder.inScope(ServerConfigurationParser.ENDPOINTS_SCOPE)) {
throw coreLog.invalidScope(ServerConfigurationParser.ENDPOINTS_SCOPE, holder.getScope());
}
GlobalConfigurationBuilder builder = holder.getGlobalConfigurationBuilder();
Element element = Element.forName(reader.getLocalName());
switch(element) {
case REST_CONNECTOR:
{
ServerConfigurationBuilder serverBuilder = builder.module(ServerConfigurationBuilder.class);
if (serverBuilder != null) {
parseRest(reader, serverBuilder);
} else {
throw ParseUtils.unexpectedElement(reader);
}
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
use of org.infinispan.server.configuration.ServerConfigurationBuilder in project infinispan by infinispan.
the class HotRodServerConfigurationParser method readElement.
@Override
public void readElement(ConfigurationReader reader, ConfigurationBuilderHolder holder) {
if (!holder.inScope(ServerConfigurationParser.ENDPOINTS_SCOPE)) {
throw coreLog.invalidScope(ServerConfigurationParser.ENDPOINTS_SCOPE, holder.getScope());
}
GlobalConfigurationBuilder builder = holder.getGlobalConfigurationBuilder();
Element element = Element.forName(reader.getLocalName());
switch(element) {
case HOTROD_CONNECTOR:
{
ServerConfigurationBuilder serverBuilder = builder.module(ServerConfigurationBuilder.class);
if (serverBuilder != null) {
parseHotRodConnector(reader, serverBuilder, serverBuilder.endpoints().current().addConnector(HotRodServerConfigurationBuilder.class));
}
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
use of org.infinispan.server.configuration.ServerConfigurationBuilder in project infinispan by infinispan.
the class MemcachedServerConfigurationParser method readElement.
@Override
public void readElement(ConfigurationReader reader, ConfigurationBuilderHolder holder) {
if (!holder.inScope(ServerConfigurationParser.ENDPOINTS_SCOPE)) {
throw coreLog.invalidScope(ServerConfigurationParser.ENDPOINTS_SCOPE, holder.getScope());
}
GlobalConfigurationBuilder builder = holder.getGlobalConfigurationBuilder();
Element element = Element.forName(reader.getLocalName());
switch(element) {
case MEMCACHED_CONNECTOR:
{
ServerConfigurationBuilder serverBuilder = builder.module(ServerConfigurationBuilder.class);
if (serverBuilder != null) {
parseMemcached(reader, serverBuilder, serverBuilder.endpoints().current().addConnector(MemcachedServerConfigurationBuilder.class));
} else {
throw ParseUtils.unexpectedElement(reader);
}
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
use of org.infinispan.server.configuration.ServerConfigurationBuilder in project infinispan by infinispan.
the class RespServerConfigurationParser method readElement.
@Override
public void readElement(ConfigurationReader reader, ConfigurationBuilderHolder holder) {
if (!holder.inScope(ServerConfigurationParser.ENDPOINTS_SCOPE)) {
throw coreLog.invalidScope(ServerConfigurationParser.ENDPOINTS_SCOPE, holder.getScope());
}
GlobalConfigurationBuilder builder = holder.getGlobalConfigurationBuilder();
Element element = Element.forName(reader.getLocalName());
switch(element) {
case RESP_CONNECTOR:
{
ServerConfigurationBuilder serverBuilder = builder.module(ServerConfigurationBuilder.class);
if (serverBuilder != null) {
parseResp(reader, serverBuilder);
} else {
throw ParseUtils.unexpectedElement(reader);
}
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
Aggregations