minPoolSize = JNDIPooledSource.DEFAULT_MIN_POOL;
else
try {
minPoolSize = Integer.parseInt(s);
} catch (NumberFormatException e) {
throw new MapperConfigurationException(
"Error in minimum size: " + s, e);
}
s = (String) env.get(JNDIPooledSource.MAX_POOL_SIZE);
if (s == null)
maxPoolSize = JNDIPooledSource.DEFAULT_MAX_POOL;
else
try {
maxPoolSize = Integer.parseInt(s);
} catch (NumberFormatException e) {
throw new MapperConfigurationException(
"Error in maximum size: " + s, e);
}
s = (String) env.get(JNDIPooledSource.TIMEOUT);
if (s == null)
timeout = JNDIPooledSource.DEFAULT_TIMEOUT;
else
try {
timeout = Integer.parseInt(s);
} catch (NumberFormatException e) {
throw new MapperConfigurationException(
"Error in timeout: " + s, e);
}
s = (String) env.get(JNDIPooledSource.RETRY);
if (s == null)
retry = -1;
else
try {
retry = Integer.parseInt(s);
} catch (NumberFormatException e) {
throw new MapperConfigurationException(
"Error in retry: " + s, e);
}
s = (String) env.get(JNDIPooledSource.FACTORY);
if (s == null)
this.factory = new JNDIConnectionFactory(env);
else {
try {
Class cl = Class.forName(s);
Constructor ctor = cl
.getDeclaredConstructor(new Class[] { Map.class });
this.factory = (ConnectionFactory) ctor
.newInstance(new Object[] { env });
} catch (NoSuchMethodException e) {
throw new MapperConfigurationException(
"No constructor for connection factory");
} catch (ClassNotFoundException e) {
throw new MapperConfigurationException(
"Connection factory class " + s + " was not found");
} catch (Exception e) {
throw new MapperConfigurationException(
"Error in constructing connection factory", e);
}
}
try {
validate();
} catch (Exception e) {
throw new MapperConfigurationException(
"Got exception while configuring pool", e);
}
if (log.isDebugEnabled())
log.debug("[" + getName()
+ "] done starting pooled source with parameters : "