/** * Hook to cleanup various stuff of some used libraries (org.geotools), which depend on the * external client to call them for cleaning-up. */ private void cleanupWebapp() { LOG.info("Web application shutdown: cleaning various stuff"); WeakCollectionCleaner.DEFAULT.exit(); DeferredAuthorityFactory.exit(); }
public void run() { synchronized (DeferredAuthorityFactory.this) { if (used || !canDisposeBackingStore(backingStore)) { used = false; return; } if (cancel()) { disposer = null; if (backingStore != null) { disposeBackingStore(); } // Needed in order to lets GC do its job. hints.remove(Hints.DATUM_AUTHORITY_FACTORY); hints.remove(Hints.CS_AUTHORITY_FACTORY); hints.remove(Hints.CRS_AUTHORITY_FACTORY); hints.remove(Hints.COORDINATE_OPERATION_AUTHORITY_FACTORY); } } } }
/** * Returns the backing store authority factory. * * @return The backing store to uses in {@code createXXX(...)} methods. * @throws FactoryException if the creation of backing store failed. */ @Override protected final AbstractAuthorityFactory getBackingStore() throws FactoryException { if (backingStore == null) { synchronized (this) { if (backingStore == null) { backingStore = createBackingStore(); if (backingStore == null) { throw new FactoryNotFoundException(Errors.format(ErrorKeys.NO_DATA_SOURCE)); } completeHints(); } } } used = true; // Tell to the disposer to wait again. return backingStore; }
/** * Returns the authority for this EPSG database. This authority will contains the database * version in the {@linkplain Citation#getEdition edition} attribute, together with the * {@linkplain Citation#getEditionDate edition date}. */ @Override public Citation getAuthority() { final Citation authority = super.getAuthority(); return (authority != null) ? authority : Citations.EPSG; }
@Override public synchronized void dispose() throws FactoryException { super.dispose(); datasource = null; } }
@Override protected void disposeBackingStore() { super.disposeBackingStore(); if (dynamicDataSource) { datasource = null; } }
/** * Returns {@code true} if the backing store can be disposed now. This method is invoked * automatically after the amount of time specified by {@link #setTimeout} if the factory were * not used during that time. * * @param backingStore The backing store in process of being disposed. */ @Override protected boolean canDisposeBackingStore(final AbstractAuthorityFactory backingStore) { if (backingStore instanceof DirectEpsgFactory) { return ((DirectEpsgFactory) backingStore).canDispose(); } return super.canDisposeBackingStore(backingStore); }
/** * Creates operations from {@linkplain CoordinateReferenceSystem coordinate reference system} * codes. * * <p>This method searches in the {@linkplain #FILENAME properties file} for operations. * * <p>If not found there, it will create operations from a fallback factory (see {@link * #getFallbackAuthorityFactory}). * * @param sourceCRS Coded value of source coordinate reference system. * @param targetCRS Coded value of target coordinate reference system. * @return The operations from {@code sourceCRS} to {@code targetCRS}. * @throws NoSuchAuthorityCodeException if a specified code was not found. * @throws FactoryException if the object creation failed for some other reason. */ @Override public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes( String sourceCRS, String targetCRS) throws NoSuchAuthorityCodeException, FactoryException { Set<CoordinateOperation> coordops = super.createFromCoordinateReferenceSystemCodes(sourceCRS, targetCRS); if (coordops.isEmpty()) { // If not found, delegate to the fallback factory. CoordinateOperationAuthorityFactory fallback = getFallbackAuthorityFactory(); if (fallback != null) { coordops = fallback.createFromCoordinateReferenceSystemCodes(sourceCRS, targetCRS); } } return coordops; }
/** * Creates an operation from a single operation code. * * <p>This method searches in the {@linkplain #FILENAME properties file} for operations. * * <p>If not found there, it will create operations from a fallback factory (see {@link * #getFallbackAuthorityFactory}). * * @param code Coded value for operation. * @return The operation from {@code sourceCRS} to {@code targetCRS}. * @throws NoSuchAuthorityCodeException if a specified code was not found. * @throws FactoryException if the object creation failed for some other reason. */ public CoordinateOperation createCoordinateOperation(String code) throws NoSuchAuthorityCodeException, FactoryException { CoordinateOperation coordop = super.createCoordinateOperation(code); if (coordop == null) { CoordinateOperationAuthorityFactory fallback = getFallbackAuthorityFactory(); if (fallback != null) { coordop = fallback.createCoordinateOperation(code); } } return coordop; }
/** * Returns the authority for this EPSG database. This authority will contains the database * version in the {@linkplain Citation#getEdition edition} attribute, together with the * {@linkplain Citation#getEditionDate edition date}. */ public Citation getAuthority() { final Citation authority = super.getAuthority(); return (authority != null) ? authority : Citations.EPSG; }
DeferredAuthorityFactory.exit(); CRS.reset("all"); LOGGER.info("Shut down GT referencing threads ");
@Override public void destroy() { if (this.crsAuthority == null) { return; } if (this.crsAuthority instanceof DeferredAuthorityFactory) { DeferredAuthorityFactory.exit(); } if (this.crsAuthority instanceof AbstractAuthorityFactory) { try { ((AbstractAuthorityFactory) this.crsAuthority).dispose(); } catch (FactoryException fe) { LOGGER.error("Error while GeometryHandler clean up", fe); } } /* * close {@link WeakCollectionCleaner} * * Note: Not required if * se.jiderhamn.classloader.leak.prevention.ClassLoaderLeakPreventor is * defined in the web.xml */ // WeakCollectionCleaner.DEFAULT.exit(); }