private Context createContext() throws XException {
try {
Hashtable env = new Hashtable();
Configuration config = Configuration.getInstance();
String factory = config.getValue("Connection", "MQ",
"ContextFactory");
env.put(Context.INITIAL_CONTEXT_FACTORY, factory);
String url = config.getValueOptional("Connection", "MQ", "URL");
if (url != null) {
env.put(Context.PROVIDER_URL, url);
}
String user = config.getValueOptional("Connection", "MQ", "User");
if (user != null) {
env.put(Context.SECURITY_PRINCIPAL, user);
}
String password = config.getValueOptional("Connection", "MQ",
"Password");
if (password != null) {
env.put(Context.SECURITY_CREDENTIALS, password);
}
String referral = config.getValueOptional("Connection", "MQ",
"Referral");
if (referral != null) {
env.put(Context.REFERRAL, referral);
}
String authorative = config.getValueOptional("Connection", "MQ",
"Authorative");
if (authorative != null) {
env.put(Context.AUTHORITATIVE, authorative);
}
String batchSize = config.getValueOptional("Connection", "MQ",
"BatchSize");
if (batchSize != null) {
env.put(Context.BATCHSIZE, batchSize);
}
String language = config.getValueOptional("Connection", "MQ",
"Language");
if (language != null) {
env.put(Context.LANGUAGE, language);
}
String dnsUrl = config.getValueOptional("Connection", "MQ",
"DNS_URL");
if (dnsUrl != null) {
env.put(Context.DNS_URL, dnsUrl);
}
String objectFactories = config.getValueOptional("Connection",
"MQ", "ObjectFactories");
if (objectFactories != null) {
env.put(Context.OBJECT_FACTORIES, objectFactories);
}
String securityProtocol = config.getValueOptional("Connection",
"MQ", "SecurityProtocol");
if (securityProtocol != null) {
env.put(Context.SECURITY_PROTOCOL, securityProtocol);
}
String securityAuthentication = config.getValueOptional(
"Connection", "MQ", "SecurityAuthentication");
if (securityAuthentication != null) {
env
.put(Context.SECURITY_AUTHENTICATION,
securityAuthentication);
}
String stateFactories = config.getValueOptional("Connection", "MQ",
"StateFactories");
if (stateFactories != null) {
env.put(Context.STATE_FACTORIES, stateFactories);
}
String urlPkgPrefixes = config.getValueOptional("Connection", "MQ",
"URLPkgPrefixes");
if (urlPkgPrefixes != null) {
env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes);
}
String port = config.getValueOptional("Connection", "MQ", "Port");
if (port != null) {
env.put("javax.naming.factory.port", port);
}
String host = config.getValueOptional("Connection", "MQ", "Host");
if (host != null) {
env.put("javax.naming.factory.host", host);
}
return new InitialContext(env);
} catch (NamingException e) {