public ThreadPoolProfile getDefaultThreadPoolProfile() {
return getThreadPoolProfile(defaultThreadPoolProfileId);
}
public void setDefaultThreadPoolProfile(ThreadPoolProfile defaultThreadPoolProfile) {
ThreadPoolProfile oldProfile = threadPoolProfiles.remove(defaultThreadPoolProfileId);
if (oldProfile != null) {
// the old is no longer default
oldProfile.setDefaultProfile(false);
// fallback and use old default values for new default profile if absent (convention over configuration)
if (defaultThreadPoolProfile.getKeepAliveTime() == null) {
defaultThreadPoolProfile.setKeepAliveTime(oldProfile.getKeepAliveTime());
}
if (defaultThreadPoolProfile.getMaxPoolSize() == null) {
defaultThreadPoolProfile.setMaxPoolSize(oldProfile.getMaxPoolSize());
}
if (defaultThreadPoolProfile.getRejectedPolicy() == null) {
defaultThreadPoolProfile.setRejectedPolicy(oldProfile.getRejectedPolicy());
}
if (defaultThreadPoolProfile.getMaxQueueSize() == null) {
defaultThreadPoolProfile.setMaxQueueSize(oldProfile.getMaxQueueSize());
}
if (defaultThreadPoolProfile.getPoolSize() == null) {
defaultThreadPoolProfile.setPoolSize(oldProfile.getPoolSize());
}
if (defaultThreadPoolProfile.getTimeUnit() == null) {
defaultThreadPoolProfile.setTimeUnit(oldProfile.getTimeUnit());
}
}
// validate that all options has been given as its mandatory for a default thread pool profile
// as it is used as fallback for other profiles if they do not have that particular value