Methods Summary |
---|
public void | addMQUrl(JmsHost host)Creates an instance of MQUrl from JmsHost element in
the dtd and add it to the addresslist.
MQUrl url = createUrl(host);
urlList.add(url);
|
private MQUrl | createUrl(JmsHost host)
return createUrl(host, this.jmsService);
|
private MQUrl | createUrl(JmsHost host, java.lang.String overridedHostName)
return createUrl(host, this.jmsService, overridedHostName);
|
public static MQUrl | createUrl(JmsHost host, JmsService js)
return createUrl(host, js, null);
|
public static MQUrl | createUrl(JmsHost host, JmsService js, java.lang.String overridedHostName)
try {
String name = host.getName();
String hostName = host.getHost();
// For LOCAL/EMBEDDED Clustered instances and
// standalone server instances, use
// their nodeagent's hostname as the jms host name.
ServerContext serverContext = ApplicationServer.getServerContext();
Server server = serverContext.getConfigBean();
if (overridedHostName != null && !overridedHostName.trim().equals("")) {
hostName = overridedHostName;
}
String port = host.getPort();
MQUrl url = new MQUrl(name);
url.setHost(hostName);
url.setPort(port);
if (js != null) {
String scheme = js.getMqScheme();
if (scheme != null && !scheme.trim().equals("")) {
url.setScheme(scheme);
}
String service = js.getMqService();
if (service != null && !service.trim().equals("")) {
url.setService(service);
}
}
return url;
} catch (ConfigException ce) {
ce.printStackTrace();
}
return null;
|
private void | defaultSetup()Default setup concatanates all JMSHosts in a JMSService to create the address list
logFine("performing defaultsetup");
JmsHost[] hosts = jmsService.getJmsHost();
for (int i=0; i < hosts.length; i++) {
MQUrl url = createUrl(hosts[i]);
urlList.add(url);
}
|
private com.sun.enterprise.config.ConfigContext | getAdminConfigContext()Gets the admin config context associated with this server instance
Usage Notice: Use this only for operations that are performed in DAS
and requires the admin config context
return com.sun.enterprise.admin.server.core.AdminService.
getAdminService().getAdminContext().getAdminConfigContext();
|
public java.lang.String | getMasterBroker(java.lang.String clustername)
String masterbrk = null;
if (rep != null) {
try {
JmsHost mb = rep.getMasterJmsHostInCluster(clustername);
JmsService js = rep.getJmsServiceForMasterBroker
(clustername);
MQUrl url = createUrl(mb, js);
masterbrk = url.toString();
logger.log(Level.FINE, "Master broker obtained is "
+ masterbrk);
}
catch (Exception e) {
logger.log(Level.SEVERE, "Cannot obtain master broker");
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
return masterbrk;
|
private JmsHost | getResolvedJmsHost(Server as)
logFine("getResolvedJmsHost " + as);
return rep.getResolvedJmsHost(as);
|
private JmsHost | getResolvedJmsHostForStandaloneServerInstance(java.lang.String serverName)
logFine(" getresolved " + serverName);
ConfigContext con = getAdminConfigContext();
Server serverInstance = ServerHelper.getServerByName(con, serverName);
logFine("serverinstace " + serverInstance);
JmsHost jmsHost = getResolvedJmsHost(serverInstance);
return jmsHost;
|
private static java.lang.String | getServerName()
String serverName=System.getProperty(SystemPropertyConstants.SERVER_NAME);
return serverName;
|
public int | getSize()
if (this.urlList != null) {
return this.urlList.size();
} else {
return 0;
}
|
private boolean | isAConfig(java.lang.String targetName)
return ServerHelper.isAConfig(getAdminConfigContext(), targetName);
|
private boolean | isClustered()
return JmsRaUtil.isClustered();
|
private boolean | isDAS(java.lang.String targetName)
if (isAConfig(targetName)) {
return false;
}
return ServerHelper.isDAS(getAdminConfigContext(), targetName);
|
private void | logFine(java.lang.String s)
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "MQAddressList :: " + s);
}
|
public void | removeMQUrl(JmsHost host)Deletes the url represented by the JmsHost from the AddressList.
MQUrl url = createUrl(host);
urlList.remove(url);
|
public void | setup()Sets up the addresslist.
try {
if (isClustered() && (!this.jmsService.getType().equals(ActiveJmsResourceAdapter.REMOTE)) ) {
//setup for LOCAL/EMBEDDED clusters.
logFine("setting up for cluster " + this.targetName);
setupClusterViewFromRepository();
setupForCluster();
} else {
logFine("setting up for SI/DAS " + this.targetName);
if (isAConfig(targetName) || isDAS(targetName)) {
logFine("performing default setup for DAS/remote clusters/PE instance" + targetName);
defaultSetup();
} else {
logFine("configuring for Standalone EE server instance");
//resolve and add.
setupClusterViewFromRepository();
setupForStandaloneServerInstance();
}
}
} catch (ConnectorRuntimeException ce) {
throw new ConfigException(ce);
}
|
private void | setupClusterViewFromRepository()
ServerContext context = ApplicationServer.getServerContext();
Server server = context.getConfigBean();
String domainurl = context.getServerConfigURL();
rep = new AppserverClusterViewFromCacheRepository(domainurl);
try {
nodeAgentHost = rep.getNodeAgentHostName(server);
logFine("na host" + nodeAgentHost);
} catch (Exception e) {
logger.log(Level.FINE,"Exception while attempting to get nodeagentHost", e.getMessage());
logger.log(Level.FINER, e.getMessage(), e);
}
|
private void | setupForCluster()Setup the address list after calculating the JMS hosts
belonging to the local appserver cluster members.
For LOCAL/EMBEDDED clusters the MQ broker corresponding
to "this" server instance needs to be placed ahead
of the other brokers of the other siblings in the AS
cluter to enable sticky connection balancing by MQ.
java.util.Map<String,JmsHost> hostMap =
rep.getResolvedLocalJmsHostsInMyCluster(true);
//First add my jms host.
JmsHost jmsHost = hostMap.get(myName);
MQUrl myUrl = createUrl(jmsHost, nodeAgentHost);
urlList.add(myUrl);
hostMap.remove(myName);
// Add all buddies to URL.
for (JmsHost host : hostMap.values() ) {
MQUrl url = createUrl(host);
urlList.add(url);
}
|
private void | setupForStandaloneServerInstance()Setup addresslist for Standalone server instance in EE
if (jmsService.getType().equals(ActiveJmsResourceAdapter.REMOTE)) {
logFine("REMOTE Standalone server instance and hence use default setup");
defaultSetup();
} else {
//For LOCAL or EMBEDDED standalone server instances, we need to resolve
//the JMSHost
logFine("LOCAL/EMBEDDED Standalone server instance");
JmsHost host = getResolvedJmsHostForStandaloneServerInstance(this.targetName);
MQUrl url = createUrl(host);
urlList.add(url);
}
|
public java.lang.String | toString()Creates a String representation of address list from
array list. In short, it is a comma separated list.
Actual syntax of an MQ url is inside MQUrl class.
String s = "";
Iterator it = urlList.iterator();
if (it.hasNext()) {
s = it.next().toString();
}
while (it.hasNext()) {
s = s + "," + it.next().toString();
}
logFine("toString returns :: " + s);
return s;
|
public void | updateMQUrl(JmsHost host)Updates the information about the JmsHost
in the address list.
MQUrl url = createUrl(host);
urlList.remove(url);
urlList.add(url);
|