ChainedUploadedFileProcessor cufp[] =
{
(ChainedUploadedFileProcessor) clazz.newInstance()
};
bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
new CompositeUploadedFileProcessorImpl(Arrays.asList(cufp)));
}
else
{
//this is full override usecase
bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
clazz.newInstance());
}
}
catch (Exception e)
{
_LOG.severe("CANNOT_INSTANTIATE_UPLOADEDFILEPROCESSOR", e);
bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
new CompositeUploadedFileProcessorImpl());
}
}
else
{
try
{
//chained processors usecase, Multiple processors
List<ChainedUploadedFileProcessor> processors =
new ArrayList<ChainedUploadedFileProcessor>(classNames.length);
for (String className : classNames)
{
Class<ChainedUploadedFileProcessor> clazz =
(Class<ChainedUploadedFileProcessor>) ClassLoaderUtils.loadClass(className);
processors.add(clazz.newInstance());
}
bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
new CompositeUploadedFileProcessorImpl(processors));
}
catch(Exception e)
{
_LOG.severe("CANNOT_INSTANTIATE_UPLOADEDFILEPROCESSOR", e);
bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
new CompositeUploadedFileProcessorImpl());
}
}
}
else
{
//nothing specified, hence use default.
bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
new CompositeUploadedFileProcessorImpl());
}
UploadedFileProcessor ufp = (UploadedFileProcessor)
bean.getProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY);