JaxB Unmarshaller,SchemaFactory和Schema是不可变的吗?

时间:2015-12-17 08:21:38

标签: java jaxb

我在循环中有以下代码:

final Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
final SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final URL resource = this.getClass().getResource("/schema/MySchema_1.0.xsd");
final Schema schema = sf.newSchema(resource);
jaxbUnmarshaller.setSchema(schema);
final JAXBElement<MyObject> unmarshal = (JAXBElement<MyObject>) jaxbUnmarshaller.unmarshal(inputStream);

除了实际的解组之外,其他行可以移到循环之外吗?

UnmarshallerSchemaFactorySchema是不可变的和/或线程安全的吗? (此时此代码一次只处理一个流,但将来可以并行执行。)

0 个答案:

没有答案