/** * Returns a JAXB unmarshaller from the pool. If there is no unmarshaller currently available * in the pool, then this method will {@linkplain #createUnmarshaller() create} a new one. * * <p>This method shall be used as below:</p> * * {@preformat java * Unmarshaller unmarshaller = pool.acquireUnmarshaller(); * Unmarshaller.unmarchall(...); * pool.recycle(unmarshaller); * } * * Note that {@link #recycle(Unmarshaller)} shall not be invoked in case of exception, * since the unmarshaller may be in an invalid state. * * @return a unmarshaller configured for parsing OGC/ISO XML. * @throws JAXBException if an error occurred while creating and configuring the unmarshaller. */ public Unmarshaller acquireUnmarshaller() throws JAXBException { Unmarshaller unmarshaller = unmarshallers.poll(); if (unmarshaller == null) { unmarshaller = new PooledUnmarshaller(createUnmarshaller(), template); } return unmarshaller; }
/** * Returns a JAXB unmarshaller from the pool. If there is no unmarshaller currently available * in the pool, then this method will {@linkplain #createUnmarshaller() create} a new one. * * <p>This method shall be used as below:</p> * * {@preformat java * Unmarshaller unmarshaller = pool.acquireUnmarshaller(); * Unmarshaller.unmarchall(...); * pool.recycle(unmarshaller); * } * * Note that {@link #recycle(Unmarshaller)} shall not be invoked in case of exception, * since the unmarshaller may be in an invalid state. * * @return a unmarshaller configured for parsing OGC/ISO XML. * @throws JAXBException if an error occurred while creating and configuring the unmarshaller. */ public Unmarshaller acquireUnmarshaller() throws JAXBException { Unmarshaller unmarshaller = unmarshallers.poll(); if (unmarshaller == null) { unmarshaller = new PooledUnmarshaller(createUnmarshaller(), template); } return unmarshaller; }