⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geoserver.java

📁 电子地图服务器,搭建自己的地图服务
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                    ". Check write permissions on target folder for user " + System.getProperty("user.name"));
        } catch (IOException e) {
            LOGGER.log(Level.WARNING, "Error trying to copy logging configuration file", e);
        } finally {
            try {
                if(is != null){
                    is.close();
                }
                if(os != null){
                    os.close();
                }
            } catch(IOException e) {
                // we tried...
            }
        }
    }
    

    
    public void initJAI(final double memCapacity, final double memoryThreshold,
        final Boolean recycling, final Boolean ImageIOCache) {
        // setting JAI wide hints
        jaiDef.setRenderingHint(JAI.KEY_CACHED_TILE_RECYCLING_ENABLED, recycling);

        // tile factory and recycler
        final RecyclingTileFactory recyclingFactory = new RecyclingTileFactory();
        jaiDef.setRenderingHint(JAI.KEY_TILE_FACTORY, recyclingFactory);
        jaiDef.setRenderingHint(JAI.KEY_TILE_RECYCLER, recyclingFactory);

        // Setting up Cache Capacity
        jaiCache = (SunTileCache) jaiDef.getTileCache();

        long jaiMemory = (long) (memCapacity * Runtime.getRuntime().maxMemory());
        jaiCache.setMemoryCapacity(jaiMemory);

        // Setting up Cahce Threshold
        jaiCache.setMemoryThreshold((float) memoryThreshold);

        jaiDef.getTileScheduler().setParallelism(tileThreads);
        jaiDef.getTileScheduler().setPrefetchParallelism(tileThreads);
        jaiDef.getTileScheduler().setPriority(tilePriority);
        jaiDef.getTileScheduler().setPrefetchPriority(tilePriority);

        // ImageIO Caching
        ImageIO.setUseCache(ImageIOCache.booleanValue());
    }

    /**
     * toDTO purpose.
     *
     * <p>
     * This method is package visible only, and returns a reference to the
     * GeoServerDTO. This method is unsafe, and should only be used with
     * extreme caution.
     * </p>
     *
     * @return DTO the generated object
     */
    public Object toDTO() {
        GeoServerDTO dto = new GeoServerDTO();
        dto.setCharSet(charSet);
        dto.setLog4jConfigFile(log4jConfigFile);
        dto.setMaxFeatures(maxFeatures);
        dto.setNumDecimals(numDecimals);
        dto.setSchemaBaseUrl(schemaBaseUrl);
        dto.setProxyBaseUrl(proxyBaseUrl);
        dto.setVerbose(verbose);
        dto.setAdminUserName(adminUserName);
        dto.setAdminPassword(adminPassword);
        dto.setVerboseExceptions(verboseExceptions);
        dto.setSuppressStdOutLogging(suppressStdOutLogging);
        dto.setLogLocation(logLocation);
        dto.setJaiMemoryCapacity(memoryCapacity);
        dto.setJaiMemoryThreshold(memoryThreshold);
        dto.setJaiTileThreads(tileThreads);
        dto.setJaiTilePriority(tilePriority);
        dto.setTileCache(tileCache);
        dto.setJaiRecycling(recycling);
        dto.setImageIOCache(imageIOCache);
        dto.setJaiJPEGNative(JPEGnativeAcc);
        dto.setJaiPNGNative(PNGnativeAcc);

        ContactDTO cdto = new ContactDTO();
        dto.setContact(cdto);

        cdto.setAddress(address);
        cdto.setAddressCity(addressCity);
        cdto.setAddressCountry(addressCountry);
        cdto.setAddressPostalCode(addressPostalCode);
        cdto.setAddressState(addressState);
        cdto.setAddressType(addressType);
        cdto.setContactEmail(contactEmail);
        cdto.setContactFacsimile(contactFacsimile);
        cdto.setContactOrganization(contactOrganization);
        cdto.setContactPerson(contactPerson);
        cdto.setContactPosition(contactPosition);
        cdto.setContactVoice(contactVoice);
        cdto.setOnlineResource(onlineResource);

        return dto;
    }

    /**
     * DOCUMENT ME!
     *
     * @return Returns the title.
     */
    public String getTitle() {
        return title;
    }

    /**
     * DOCUMENT ME!
     *
     * @param title The title to set.
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * Property representing the contact party (person, position or
     * organization).
     *
     * <p>
     * This is a derived property.
     * </p>
     *
     * @return Contact party (person, position or organization), null if
     *         unknown
     */
    public String getContactParty() {
        if ((getContactPerson() != null) && (getContactPerson().length() != 0)) {
            return getContactPerson(); // ie Chris Holmes 
        }

        if ((getContactPosition() != null) && (getContactPosition().length() != 0)) {
            return getContactPosition(); // ie Lead Developer 
        }

        if ((getContactOrganization() != null) && (getContactOrganization().length() != 0)) {
            return getContactOrganization(); // ie TOPP 
        }

        return null;
    }

    public String getAdminUserName() {
        return adminUserName;
    }

    public String getAdminPassword() {
        return adminPassword;
    }

    public String toString() {
        StringBuffer geoserver = new StringBuffer("[GeoServer: \n");
        geoserver.append("   maxFeatures - " + maxFeatures);
        geoserver.append("\n   verbose - " + verbose);
        geoserver.append("\n   numDecimals - " + numDecimals);
        geoserver.append("\n   charSet - " + charSet);
        geoserver.append("\n   log4jConfigFile - " + log4jConfigFile);
        geoserver.append("\n   adminUserName - " + adminUserName);
        geoserver.append("\n   adminPassword - " + adminPassword);

        return geoserver.toString();
    }

    /**
     * Should we display stackTraces or not? (And give them a nice
    * little message instead?)
     *
     * @return Returns the showStackTraces.
     */
    public boolean isVerboseExceptions() {
        return verboseExceptions;
    }

    /**
     * If set to true, response exceptions will throw their stack trace
    * back to the end user.
     *
     * @param showStackTraces The showStackTraces to set.
     */
    public void setVerboseExceptions(boolean showStackTraces) {
        this.verboseExceptions = showStackTraces;
    }

    /**
     * Returns the location of where the server ouputs logs. Note that this may
     * not reference an actual physical location on disk.
     * Call {@link GeoServer#getLogLocation(String, ServletContext)} to map this
     * string to a file on disk.
     *
     */
    public String getLogLocation() {
        return logLocation;
    }

    /**
     * @param logLocation The string representation of the path on disk in which
     * the server logs to.
     */
    public void setLogLocation(String logLocation) {
        this.logLocation = logLocation;
    }

    /**
     * @return True if the server is logging to file, otherwise false.
     */
    public boolean getSuppressStdOutLogging() {
        return suppressStdOutLogging;
    }

    /**
     * Toggles server logging to file.
     */
    public void setSuppressStdOutLogging(boolean loggingToFile) {
        this.suppressStdOutLogging = loggingToFile;
    }

    public JAI getJAIDefault() {
        return jaiDef;
    }

    public SunTileCache getJaiCache() {
        return jaiCache;
    }

    public double getMemoryCapacity() {
        return memoryCapacity;
    }

    public Boolean getRecycling() {
        return recycling;
    }

    public Boolean getJPEGNativeAcceleration() {
        return JPEGnativeAcc;
    }

    public Boolean getPNGNativeAcceleration() {
        return PNGnativeAcc;
    }

    public double getMemoryThreshold() {
        return memoryThreshold;
    }

    /**
     * @return Returns the imageIOCache.
     */
    public Boolean getImageIOCache() {
        return imageIOCache;
    }

    public int getTilePriority() {
        return tilePriority;
    }

    public int getTileThreads() {
        return tileThreads;
    }

    /**
     * Used when GeoServer is running beheind tile caching server.
     * <p>
     * This value should be used when writing out a url which is a getmap
     * request to reference the tile caching server and not GeoServer itself.
     * </p>
     *<p>
     * This value can be:
     * <ol>
     *  <li>A fully qualified host name + path (URL)
     *  <li>A partial path which is interpreted as relative to the host running
     *  GeoServer
     *  <li><code>null</code>
     * </ol>
     * </p>
     * <p>
     *
     * </p>
     * @see Requests#getTileCacheBaseUrl(javax.servlet.http.HttpServletRequest, GeoServer)
     */
    public String getTileCache() {
        return tileCache;
    }

    public void setTileCache(String tileCache) {
        this.tileCache = tileCache;
    }

    /**
     * Implements {@link DisposableBean#destroy()} to release resources being held
     * by the server at server shutdown, such as JDBC connection pools and ArcSDE
     * connection pools.
     * <p>
     * Note this process would greately benefit if {@link DataStoreFactorySpi} API
     * had some sort of resource releasing method, so we could just traverse
     * the available datastore factories asking them to release any resource
     * needed.
     * </p>
     */
    public void destroy() throws Exception {
        final Data catalog = (Data) config.getApplictionContext().getBean("data");
        final Set dataStores = catalog.getDataStores();
        LOGGER.info("Disposing DataStores at GeoServer shutdown...");
        for (Iterator it = dataStores.iterator(); it.hasNext();) {
            DataStoreInfo dataStoreInfo = (DataStoreInfo) it.next();
            LOGGER.fine("Disposing " + dataStoreInfo.getId());
            try {
                dataStoreInfo.dispose();
            } catch (RuntimeException e) {
                LOGGER.log(Level.WARNING, "Caught exception while disposing datastore "
                        + dataStoreInfo.getId(), e);
            }
        }
        LOGGER.info("Done disposing datastores.");
        
        /*
         *  HACK: we must get a standard API way for releasing resources...
         *  UPDATE: now we do have a standard API to release resources, though ArcSDE does not
         *  properly implements DataStore.dispose() yet.
         */
        try {
            Class sdepfClass = Class.forName("org.geotools.arcsde.pool.ArcSDEConnectionPoolFactory");

            LOGGER.fine("SDE datasource found, releasing resources");

            java.lang.reflect.Method m = sdepfClass.getMethod("getInstance", new Class[0]);
            Object pfInstance = m.invoke(sdepfClass, new Object[0]);

            LOGGER.fine("got sde connection pool factory instance: " + pfInstance);

            java.lang.reflect.Method closeMethod = pfInstance.getClass()
                                                             .getMethod("clear", new Class[0]);

            closeMethod.invoke(pfInstance, new Object[0]);
            LOGGER.info("Asking ArcSDE datasource to release connections.");
        } catch (ClassNotFoundException cnfe) {
            LOGGER.fine("No ArcSDE datasource found.");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -