if (!initialized) {
super.init(synapseEnvironment);
ConfigurationContext cfgCtx =
((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext();
ClusteringAgent clusteringAgent = cfgCtx.getAxisConfiguration().getClusteringAgent();
if (clusteringAgent == null) {
throw new SynapseException("Axis2 ClusteringAgent not defined in axis2.xml");
}
// Add the Axis2 GroupManagement agents
if (hostContexts != null) {
// iterate through each host context
for (HostContext hostCtxt : hostContexts.values()) {
// each host can has multiple Tenant Contexts, iterate through them
for (TenantDomainContext tenantCtxt : hostCtxt.getTenantDomainContexts()) {
String domain = tenantCtxt.getDomain();
String subDomain = tenantCtxt.getSubDomain();
if (clusteringAgent.getGroupManagementAgent(domain, subDomain) == null) {
String gmAgentClass = lbConfig.getLoadBalancerConfig().getGroupManagementAgentClass();
GroupManagementAgent groupManagementAgent;
if (gmAgentClass != null) {
try {
groupManagementAgent = (GroupManagementAgent) Class.forName(gmAgentClass).newInstance();
} catch (Exception e) {
String msg = "Cannot instantiate GroupManagementAgent. Class: " + gmAgentClass;
log.error(msg, e);
throw new TenantAwareLoadBalanceEndpointException(msg, e);
}
} else {
groupManagementAgent = new SubDomainAwareGroupManagementAgent(subDomain);
}
clusteringAgent.addGroupManagementAgent(groupManagementAgent,
domain, subDomain,-1);
if (log.isDebugEnabled()) {
log.debug("Group management agent added to cluster domain: " +
domain + " and sub domain: " + subDomain);
}