Кэшированная карта Unmarshallers:
Код: Выделить всё
private Map cachedUnmarshallers = new HashMap();
Код: Выделить всё
cachedUnmarshallers.put(AKey, createUnmarshaller(AKey));
cachedUnmarshallers.put(BKey, createUnmarshaller(BKey));
cachedUnmarshallers.put(CKey, createUnmarshaller(CKey));
cachedUnmarshallers.put(DKey, createUnmarshaller(DKey));
Код: Выделить всё
private Unmarshaller createUnmarshaller(String key) throws JAXBException {
JAXBContext jaxbContext =
JAXBContext.newInstance(keyToClassMap.get(key));
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
MessageValidationEventHandler validationEventHandler = new MessageValidationEventHandler();
unmarshaller.setEventHandler(validationEventHandler);
return unmarshaller;
}
Если бы я удалил свою карту, которая кэшируется С Unmarshallers все снова станет медленным, создание Unmarshallers занимает полсекунды, а в zip-архиве есть сотни файлов, для проверки которых требуется много времени. Итак, вы знаете, как это решить?
Подробнее здесь: https://stackoverflow.com/questions/790 ... by-threads