/** * Completes the creation of a {@link PooledMarshaller} or {@link PooledUnmarshaller}. * This method is not invoked in the {@link #Pooled(Pooled)} constructor in order to * give to subclasses a chance to complete their construction first. * * @param template the {@link PooledTemplate} from which to get the initial values. * @throws JAXBException if an error occurred while setting a property. */ final void initialize(final Pooled template) throws JAXBException { reset(template); // Set the SIS properties first. JAXB properties are set below. for (final Map.Entry<Object,Object> entry : template.initialProperties.entrySet()) { setStandardProperty((String) entry.getKey(), entry.getValue()); } }
/** * Completes the creation of a {@link PooledMarshaller} or {@link PooledUnmarshaller}. * This method is not invoked in the {@link #Pooled(Pooled)} constructor in order to * give to subclasses a chance to complete their construction first. * * @param template the {@link PooledTemplate} from which to get the initial values. * @throws JAXBException if an error occurred while setting a property. */ final void initialize(final Pooled template) throws JAXBException { reset(template); // Set the SIS properties first. JAXB properties are set below. for (final Map.Entry<Object,Object> entry : template.initialProperties.entrySet()) { setStandardProperty((String) entry.getKey(), entry.getValue()); } }
/** * Releases resources and resets the (un)marshaller to its initial state. * This method is invoked by {@link MarshallerPool} just before to push a * (un)marshaller in the pool after its usage. * * @param template the {@link PooledTemplate} from which to get the initial values. * @throws JAXBException if an error occurred while restoring a property. */ public final void reset(final Pooled template) throws JAXBException { for (final Map.Entry<Object,Object> entry : initialProperties.entrySet()) { reset(entry.getKey(), entry.getValue()); } initialProperties.clear(); bitMasks = template.bitMasks; locale = template.locale; timezone = template.timezone; schemas = template.schemas; versionGML = template.versionGML; versionMetadata = template.versionMetadata; resolver = template.resolver; converter = template.converter; rootAdapters = template.rootAdapters; warningListener = template.warningListener; resetTime = System.nanoTime(); if (this instanceof Marshaller) { bitMasks |= Context.MARSHALLING; } }
/** * Releases resources and resets the (un)marshaller to its initial state. * This method is invoked by {@link MarshallerPool} just before to push a * (un)marshaller in the pool after its usage. * * @param template the {@link PooledTemplate} from which to get the initial values. * @throws JAXBException if an error occurred while restoring a property. */ public final void reset(final Pooled template) throws JAXBException { for (final Map.Entry<Object,Object> entry : initialProperties.entrySet()) { reset(entry.getKey(), entry.getValue()); } initialProperties.clear(); bitMasks = template.bitMasks; locale = template.locale; timezone = template.timezone; schemas = template.schemas; xmlnsReplaceCode = template.xmlnsReplaceCode; versionGML = template.versionGML; resolver = template.resolver; converter = template.converter; rootAdapters = template.rootAdapters; warningListener = template.warningListener; resetTime = System.nanoTime(); if (this instanceof Marshaller) { bitMasks |= Context.MARSHALLING; } }
/** * Marks the given marshaller or unmarshaller available for further reuse. * This method: * * <ul> * <li>{@link Pooled#reset(Pooled) Resets} the (un)marshaller to its initial state.</li> * <li>{@linkplain Deque#push(Object) Pushes} the (un)marshaller in the given queue.</li> * <li>Registers a delayed task for disposing expired (un)marshallers after the timeout.</li> * </ul> */ private <T> void recycle(final Deque<T> queue, final T marshaller) { try { ((Pooled) marshaller).reset(template); } catch (JAXBException exception) { /* * Not expected to happen because we are supposed * to reset the properties to their initial values. */ Logging.unexpectedException(Logging.getLogger(Loggers.XML), MarshallerPool.class, "recycle", exception); return; } queue.push(marshaller); scheduleRemoval(); }
/** * Marks the given marshaller or unmarshaller available for further reuse. * This method: * * <ul> * <li>{@link Pooled#reset(Pooled) Resets} the (un)marshaller to its initial state.</li> * <li>{@linkplain Deque#push(Object) Pushes} the (un)marshaller in the given queue.</li> * <li>Registers a delayed task for disposing expired (un)marshallers after the timeout.</li> * </ul> */ private <T> void recycle(final Deque<T> queue, final T marshaller) { try { ((Pooled) marshaller).reset(template); } catch (JAXBException exception) { /* * Not expected to happen because we are supposed * to reset the properties to their initial values. */ Logging.unexpectedException(Logging.getLogger(Loggers.XML), MarshallerPool.class, "recycle", exception); return; } queue.push(marshaller); scheduleRemoval(); }