logConfigFile = new File(configFileDirectory, DEFAULT_LOG_CONFIG_FILENAME);
configureLogging(logConfigFile, logWatchTime);
}
ConfigurationFileApplicationRegistry config = new ConfigurationFileApplicationRegistry(configFile);
ServerConfiguration serverConfig = config.getConfiguration();
updateManagementPort(serverConfig, commandLine.getOptionValue("m"));
ApplicationRegistry.initialise(config);
// We have already loaded the BrokerMessages class by this point so we
// need to refresh the locale setting incase we had a different value in
// the configuration.
BrokerMessages.reload();
// AR.initialise() sets and removes its own actor so we now need to set the actor
// for the remainder of the startup, and the default actor if the stack is empty
CurrentActor.set(new BrokerActor(config.getCompositeStartupMessageLogger()));
CurrentActor.setDefault(new BrokerActor(config.getRootMessageLogger()));
GenericActor.setDefaultMessageLogger(config.getRootMessageLogger());
try
{
configureLoggingManagementMBean(logConfigFile, logWatchTime);
ConfigurationManagementMBean configMBean = new ConfigurationManagementMBean();
configMBean.register();
ServerInformationMBean sysInfoMBean =
new ServerInformationMBean(QpidProperties.getBuildVersion(), QpidProperties.getReleaseVersion());
sysInfoMBean.register();
String[] portStr = commandLine.getOptionValues("p");
Set<Integer> ports = new HashSet<Integer>();
Set<Integer> exclude_0_10 = new HashSet<Integer>();
Set<Integer> exclude_0_9_1 = new HashSet<Integer>();
Set<Integer> exclude_0_9 = new HashSet<Integer>();
Set<Integer> exclude_0_8 = new HashSet<Integer>();
if(portStr == null || portStr.length == 0)
{
parsePortList(ports, serverConfig.getPorts());
parsePortList(exclude_0_10, serverConfig.getPortExclude010());
parsePortList(exclude_0_9_1, serverConfig.getPortExclude091());
parsePortList(exclude_0_9, serverConfig.getPortExclude09());
parsePortList(exclude_0_8, serverConfig.getPortExclude08());
}
else
{
parsePortArray(ports, portStr);
parsePortArray(exclude_0_10, commandLine.getOptionValues("exclude-0-10"));
parsePortArray(exclude_0_9_1, commandLine.getOptionValues("exclude-0-9-1"));
parsePortArray(exclude_0_9, commandLine.getOptionValues("exclude-0-9"));
parsePortArray(exclude_0_8, commandLine.getOptionValues("exclude-0-8"));
}
String bindAddr = commandLine.getOptionValue("b");
if (bindAddr == null)
{
bindAddr = serverConfig.getBind();
}
InetAddress bindAddress = null;
if (bindAddr.equals("wildcard"))
{
bindAddress = new InetSocketAddress(0).getAddress();
}
else
{
bindAddress = InetAddress.getByAddress(parseIP(bindAddr));
}
String hostName = bindAddress.getCanonicalHostName();
String keystorePath = serverConfig.getKeystorePath();
String keystorePassword = serverConfig.getKeystorePassword();
String certType = serverConfig.getCertType();
SSLContextFactory sslFactory = null;
if (!serverConfig.getSSLOnly())
{
for(int port : ports)
{
NetworkDriver driver = new MINANetworkDriver();
Set<VERSION> supported = EnumSet.allOf(VERSION.class);
if(exclude_0_10.contains(port))
{
supported.remove(VERSION.v0_10);
}
if(exclude_0_9_1.contains(port))
{
supported.remove(VERSION.v0_9_1);
}
if(exclude_0_9.contains(port))
{
supported.remove(VERSION.v0_9);
}
if(exclude_0_8.contains(port))
{
supported.remove(VERSION.v0_8);
}
MultiVersionProtocolEngineFactory protocolEngineFactory =
new MultiVersionProtocolEngineFactory(hostName, supported);
driver.bind(port, new InetAddress[]{bindAddress}, protocolEngineFactory,
serverConfig.getNetworkConfiguration(), null);
ApplicationRegistry.getInstance().addAcceptor(new InetSocketAddress(bindAddress, port),
new QpidAcceptor(driver,"TCP"));
CurrentActor.get().message(BrokerMessages.LISTENING("TCP", port));
}
}
if (serverConfig.getEnableSSL())
{
sslFactory = new SSLContextFactory(keystorePath, keystorePassword, certType);
NetworkDriver driver = new MINANetworkDriver();
driver.bind(serverConfig.getSSLPort(), new InetAddress[]{bindAddress},
new AMQProtocolEngineFactory(), serverConfig.getNetworkConfiguration(), sslFactory);
ApplicationRegistry.getInstance().addAcceptor(new InetSocketAddress(bindAddress, serverConfig.getSSLPort()),
new QpidAcceptor(driver,"TCP"));
CurrentActor.get().message(BrokerMessages.LISTENING("TCP/SSL", serverConfig.getSSLPort()));
}
CurrentActor.get().message(BrokerMessages.READY());
}