use of java.util.MissingResourceException in project webpieces by deanhiller.
the class Messages method get.
public String get(String key, Locale locale) {
//TODO: We need to fix this so we are not throwing exceptions when bundles are not found
if (bundleName != null) {
try {
ResourceBundle b = ResourceBundleUtf8.load(bundleName, locale);
String value = b.getString(key);
if (value != null)
return value;
} catch (MissingResourceException e) {
}
}
try {
ResourceBundle global = ResourceBundleUtf8.load(globalBundleName, locale);
return global.getString(key);
} catch (MissingResourceException e) {
return null;
}
}
use of java.util.MissingResourceException in project cxf by apache.
the class LogUtils method createLogger.
/**
* Create a logger
*/
protected static Logger createLogger(Class<?> cls, String name, String loggerName) {
ClassLoader orig = getContextClassLoader();
ClassLoader n = getClassLoader(cls);
if (n != null) {
setContextClassLoader(n);
}
String bundleName = name;
try {
Logger logger = null;
ResourceBundle b = null;
if (bundleName == null) {
// grab the bundle prior to the call to Logger.getLogger(...) so the
// ResourceBundle can be loaded outside the big sync block that getLogger really is
bundleName = BundleUtils.getBundleName(cls);
try {
b = BundleUtils.getBundle(cls);
} catch (MissingResourceException rex) {
// ignore
}
} else {
bundleName = BundleUtils.getBundleName(cls, bundleName);
try {
b = BundleUtils.getBundle(cls, bundleName);
} catch (MissingResourceException rex) {
// ignore
}
}
if (b != null) {
b.getLocale();
}
if (loggerClass != null) {
try {
Constructor<?> cns = loggerClass.getConstructor(String.class, String.class);
if (name == null) {
try {
return (Logger) cns.newInstance(loggerName, bundleName);
} catch (InvocationTargetException ite) {
if (ite.getTargetException() instanceof MissingResourceException) {
return (Logger) cns.newInstance(loggerName, null);
}
throw ite;
}
}
try {
return (Logger) cns.newInstance(loggerName, bundleName);
} catch (InvocationTargetException ite) {
if (ite.getTargetException() instanceof MissingResourceException) {
throw (MissingResourceException) ite.getTargetException();
}
throw ite;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
try {
// NOPMD
logger = Logger.getLogger(loggerName, bundleName);
} catch (IllegalArgumentException iae) {
// likely a mismatch on the bundle name, just return the default
// NOPMD
logger = Logger.getLogger(loggerName);
} catch (MissingResourceException rex) {
// NOPMD
logger = Logger.getLogger(loggerName);
} finally {
b = null;
}
return logger;
} finally {
if (n != orig) {
setContextClassLoader(orig);
}
}
}
use of java.util.MissingResourceException in project rt.equinox.framework by eclipse.
the class ManifestLocalization method getHeaders.
Dictionary<String, String> getHeaders(String localeString) {
if (localeString == null)
localeString = Locale.getDefault().toString();
if (localeString.length() == 0)
return rawHeaders;
boolean isDefaultLocale = localeString.equals(Locale.getDefault().toString());
Dictionary<String, String> currentDefault = defaultLocaleHeaders;
if (isDefaultLocale && currentDefault != null) {
return currentDefault;
}
if (generation.getRevision().getRevisions().getModule().getState().equals(Module.State.UNINSTALLED)) {
// defaultLocaleHeaders should have been initialized on uninstall
if (currentDefault != null)
return currentDefault;
return rawHeaders;
}
ResourceBundle localeProperties = getResourceBundle(localeString, isDefaultLocale);
CaseInsensitiveDictionaryMap<String, String> localeHeaders = new CaseInsensitiveDictionaryMap<>(this.rawHeaders);
for (Entry<String, String> entry : localeHeaders.entrySet()) {
String value = entry.getValue();
if (value.startsWith("%") && (value.length() > 1)) {
// $NON-NLS-1$
String propertiesKey = value.substring(1);
try {
value = localeProperties == null ? propertiesKey : (String) localeProperties.getObject(propertiesKey);
} catch (MissingResourceException ex) {
value = propertiesKey;
}
entry.setValue(value);
}
}
Dictionary<String, String> result = localeHeaders.asUnmodifiableDictionary();
if (isDefaultLocale) {
defaultLocaleHeaders = result;
}
return result;
}
use of java.util.MissingResourceException in project Payara by payara.
the class JdbcConnectionPoolDeployer method getMCFConfigProperties.
/**
* Pull out the MCF configuration properties and return them as an array
* of ConnectorConfigProperty
*
* @param adminPool - The JdbcConnectionPool to pull out properties from
* @param conConnPool - ConnectorConnectionPool which will be used by Resource Pool
* @param connDesc - The ConnectorDescriptor for this JDBC RA
* @return ConnectorConfigProperty [] array of MCF Config properties specified
* in this JDBC RA
*/
private ConnectorConfigProperty[] getMCFConfigProperties(JdbcConnectionPool adminPool, ConnectorConnectionPool conConnPool, ConnectorDescriptor connDesc) {
ArrayList propList = new ArrayList();
if (adminPool.getResType() != null) {
if (ConnectorConstants.JAVA_SQL_DRIVER.equals(adminPool.getResType())) {
propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDriverClassname() == null ? "" : adminPool.getDriverClassname(), "The driver class name", "java.lang.String"));
} else {
propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDatasourceClassname() == null ? "" : adminPool.getDatasourceClassname(), "The datasource class name", "java.lang.String"));
}
} else {
// When resType is null, one of these classnames would be specified
if (adminPool.getDriverClassname() != null) {
propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDriverClassname() == null ? "" : adminPool.getDriverClassname(), "The driver class name", "java.lang.String"));
} else if (adminPool.getDatasourceClassname() != null) {
propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDatasourceClassname() == null ? "" : adminPool.getDatasourceClassname(), "The datasource class name", "java.lang.String"));
}
}
propList.add(new ConnectorConfigProperty("ConnectionValidationRequired", adminPool.getIsConnectionValidationRequired() + "", "Is connection validation required", "java.lang.String"));
propList.add(new ConnectorConfigProperty("ValidationMethod", adminPool.getConnectionValidationMethod() == null ? "" : adminPool.getConnectionValidationMethod(), "How the connection is validated", "java.lang.String"));
propList.add(new ConnectorConfigProperty("ValidationTableName", adminPool.getValidationTableName() == null ? "" : adminPool.getValidationTableName(), "Validation Table name", "java.lang.String"));
propList.add(new ConnectorConfigProperty("ValidationClassName", adminPool.getValidationClassname() == null ? "" : adminPool.getValidationClassname(), "Validation Class name", "java.lang.String"));
propList.add(new ConnectorConfigProperty("TransactionIsolation", adminPool.getTransactionIsolationLevel() == null ? "" : adminPool.getTransactionIsolationLevel(), "Transaction Isolatin Level", "java.lang.String"));
propList.add(new ConnectorConfigProperty("GuaranteeIsolationLevel", adminPool.getIsIsolationLevelGuaranteed() + "", "Transaction Isolation Guarantee", "java.lang.String"));
propList.add(new ConnectorConfigProperty("StatementWrapping", adminPool.getWrapJdbcObjects() + "", "Statement Wrapping", "java.lang.String"));
propList.add(new ConnectorConfigProperty("LogJdbcCalls", adminPool.getLogJdbcCalls() + "", "Log JDBC Calls", "java.lang.String"));
propList.add(new ConnectorConfigProperty("SlowQueryThresholdInSeconds", adminPool.getSlowQueryThresholdInSeconds() + "", "Slow Query Threshold In Seconds", "java.lang.String"));
propList.add(new ConnectorConfigProperty("StatementTimeout", adminPool.getStatementTimeoutInSeconds() + "", "Statement Timeout", "java.lang.String"));
PoolInfo poolInfo = conConnPool.getPoolInfo();
propList.add(new ConnectorConfigProperty("PoolMonitoringSubTreeRoot", ConnectorsUtil.getPoolMonitoringSubTreeRoot(poolInfo, true) + "", "Pool Monitoring Sub Tree Root", "java.lang.String"));
propList.add(new ConnectorConfigProperty("PoolName", poolInfo.getName() + "", "Pool Name", "java.lang.String"));
if (poolInfo.getApplicationName() != null) {
propList.add(new ConnectorConfigProperty("ApplicationName", poolInfo.getApplicationName() + "", "Application Name", "java.lang.String"));
}
if (poolInfo.getModuleName() != null) {
propList.add(new ConnectorConfigProperty("ModuleName", poolInfo.getModuleName() + "", "Module name", "java.lang.String"));
}
propList.add(new ConnectorConfigProperty("StatementCacheSize", adminPool.getStatementCacheSize() + "", "Statement Cache Size", "java.lang.String"));
propList.add(new ConnectorConfigProperty("StatementCacheType", adminPool.getStatementCacheType() + "", "Statement Cache Type", "java.lang.String"));
propList.add(new ConnectorConfigProperty("InitSql", adminPool.getInitSql() + "", "InitSql", "java.lang.String"));
propList.add(new ConnectorConfigProperty("SqlTraceListeners", adminPool.getSqlTraceListeners() + "", "Sql Trace Listeners", "java.lang.String"));
propList.add(new ConnectorConfigProperty("StatementLeakTimeoutInSeconds", adminPool.getStatementLeakTimeoutInSeconds() + "", "Statement Leak Timeout in seconds", "java.lang.String"));
propList.add(new ConnectorConfigProperty("StatementLeakReclaim", adminPool.getStatementLeakReclaim() + "", "Statement Leak Reclaim", "java.lang.String"));
// dump user defined poperties into the list
Set connDefDescSet = connDesc.getOutboundResourceAdapter().getConnectionDefs();
// since this a 1.0 RAR, we will have only 1 connDefDesc
if (connDefDescSet.size() != 1) {
throw new MissingResourceException("Only one connDefDesc present", null, null);
}
Iterator iter = connDefDescSet.iterator();
// Now get the set of MCF config properties associated with each
// connection-definition . Each element here is an EnviromnentProperty
Set mcfConfigProps = null;
while (iter.hasNext()) {
mcfConfigProps = ((ConnectionDefDescriptor) iter.next()).getConfigProperties();
}
if (mcfConfigProps != null) {
Map mcfConPropKeys = new HashMap();
Iterator mcfConfigPropsIter = mcfConfigProps.iterator();
while (mcfConfigPropsIter.hasNext()) {
String key = ((ConnectorConfigProperty) mcfConfigPropsIter.next()).getName();
mcfConPropKeys.put(key.toUpperCase(locale), key);
}
String driverProperties = "";
for (Property rp : adminPool.getProperty()) {
if (rp == null) {
continue;
}
String name = rp.getName();
// making it easy to compare in the event of a reconfig
if ("MATCHCONNECTIONS".equals(name.toUpperCase(locale))) {
// JDBC - matchConnections if not set is decided by the ConnectionManager
// so default is false
conConnPool.setMatchConnections(toBoolean(rp.getValue(), false));
logFine("MATCHCONNECTIONS");
} else if ("ASSOCIATEWITHTHREAD".equals(name.toUpperCase(locale))) {
conConnPool.setAssociateWithThread(toBoolean(rp.getValue(), false));
logFine("ASSOCIATEWITHTHREAD");
} else if ("LAZYCONNECTIONASSOCIATION".equals(name.toUpperCase(locale))) {
ConnectionPoolObjectsUtils.setLazyEnlistAndLazyAssocProperties(rp.getValue(), adminPool.getProperty(), conConnPool);
logFine("LAZYCONNECTIONASSOCIATION");
} else if ("LAZYCONNECTIONENLISTMENT".equals(name.toUpperCase(Locale.getDefault()))) {
conConnPool.setLazyConnectionEnlist(toBoolean(rp.getValue(), false));
logFine("LAZYCONNECTIONENLISTMENT");
} else if ("POOLDATASTRUCTURE".equals(name.toUpperCase(Locale.getDefault()))) {
conConnPool.setPoolDataStructureType(rp.getValue());
logFine("POOLDATASTRUCTURE");
} else if (ConnectorConstants.DYNAMIC_RECONFIGURATION_FLAG.equals(name.toLowerCase(locale))) {
String value = rp.getValue();
try {
conConnPool.setDynamicReconfigWaitTimeout(Long.parseLong(rp.getValue()) * 1000L);
logFine(ConnectorConstants.DYNAMIC_RECONFIGURATION_FLAG);
} catch (NumberFormatException nfe) {
_logger.log(Level.WARNING, "Invalid value for " + "'" + ConnectorConstants.DYNAMIC_RECONFIGURATION_FLAG + "' : " + value);
}
} else if ("POOLWAITQUEUE".equals(name.toUpperCase(locale))) {
conConnPool.setPoolWaitQueue(rp.getValue());
logFine("POOLWAITQUEUE");
} else if ("DATASTRUCTUREPARAMETERS".equals(name.toUpperCase(locale))) {
conConnPool.setDataStructureParameters(rp.getValue());
logFine("DATASTRUCTUREPARAMETERS");
} else if ("USERNAME".equals(name.toUpperCase(Locale.getDefault())) || "USER".equals(name.toUpperCase(locale))) {
propList.add(new ConnectorConfigProperty("User", (String) TranslatedConfigView.getTranslatedValue(rp.getValue()), "user name", "java.lang.String"));
} else if ("PASSWORD".equals(name.toUpperCase(locale))) {
propList.add(new ConnectorConfigProperty("Password", (String) TranslatedConfigView.getTranslatedValue(rp.getValue()), "Password", "java.lang.String"));
} else if ("JDBC30DATASOURCE".equals(name.toUpperCase(locale))) {
propList.add(new ConnectorConfigProperty("JDBC30DataSource", rp.getValue(), "JDBC30DataSource", "java.lang.String"));
} else if ("PREFER-VALIDATE-OVER-RECREATE".equals(name.toUpperCase(Locale.getDefault()))) {
String value = rp.getValue();
conConnPool.setPreferValidateOverRecreate(toBoolean(value, false));
logFine("PREFER-VALIDATE-OVER-RECREATE : " + value);
} else if ("STATEMENT-CACHE-TYPE".equals(name.toUpperCase(Locale.getDefault()))) {
if (adminPool.getStatementCacheType() != null) {
propList.add(new ConnectorConfigProperty("StatementCacheType", rp.getValue(), "StatementCacheType", "java.lang.String"));
}
} else if ("NUMBER-OF-TOP-QUERIES-TO-REPORT".equals(name.toUpperCase(Locale.getDefault()))) {
propList.add(new ConnectorConfigProperty("NumberOfTopQueriesToReport", rp.getValue(), "NumberOfTopQueriesToReport", "java.lang.String"));
} else if ("TIME-TO-KEEP-QUERIES-IN-MINUTES".equals(name.toUpperCase(Locale.getDefault()))) {
propList.add(new ConnectorConfigProperty("TimeToKeepQueriesInMinutes", rp.getValue(), "TimeToKeepQueriesInMinutes", "java.lang.String"));
} else if ("MAXCACHESIZE".equals(name.toUpperCase(Locale.getDefault())) || "MAX-CACHE-SIZE".equals(name.toUpperCase(Locale.getDefault()))) {
propList.add(new ConnectorConfigProperty("MaxCacheSize", rp.getValue(), "MaxCacheSize", "java.lang.String"));
} else if (mcfConPropKeys.containsKey(name.toUpperCase(Locale.getDefault()))) {
propList.add(new ConnectorConfigProperty((String) mcfConPropKeys.get(name.toUpperCase(Locale.getDefault())), rp.getValue() == null ? "" : (String) TranslatedConfigView.getTranslatedValue(rp.getValue()), "Some property", "java.lang.String"));
} else {
driverProperties = driverProperties + "set" + escape(name) + "#" + escape((String) TranslatedConfigView.getTranslatedValue(rp.getValue())) + "##";
}
}
if (!driverProperties.equals("")) {
propList.add(new ConnectorConfigProperty("DriverProperties", driverProperties, "some proprietarty properties", "java.lang.String"));
}
}
propList.add(new ConnectorConfigProperty("Delimiter", "#", "delim", "java.lang.String"));
propList.add(new ConnectorConfigProperty("EscapeCharacter", "\\", "escapeCharacter", "java.lang.String"));
// create an array of EnvironmentProperties from above list
ConnectorConfigProperty[] eProps = new ConnectorConfigProperty[propList.size()];
ListIterator propListIter = propList.listIterator();
for (int i = 0; propListIter.hasNext(); i++) {
eProps[i] = (ConnectorConfigProperty) propListIter.next();
}
return eProps;
}
use of java.util.MissingResourceException in project Payara by payara.
the class AppclientCommandArgumentsTest method useTransactionLogString.
@Test
public void useTransactionLogString() {
final Logger logger = LogDomains.getLogger(JavaEETransactionManagerSimplified.class, LogDomains.JTA_LOGGER);
final String target = "enterprise_used_delegate_name";
try {
final String result = logger.getResourceBundle().getString(target);
assertTrue("message key look-up failed", (result != null && !target.equals(result)));
} catch (MissingResourceException ex) {
fail("could not find message key");
}
}
Aggregations