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

📄 jembeanhelper.java

📁 这是个爬虫和lucece相结合最好了
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                               "Get environment statistics.",                               statParams,                               "java.lang.String",                               MBeanOperationInfo.INFO);    private static final MBeanOperationInfo OP_LOCK_STAT_INFO =         new MBeanOperationInfo(OP_LOCK_STAT,                               "Get locking statistics.",                               statParams,                               "com.sleepycat.je.LockStats",                               MBeanOperationInfo.INFO);        private static final MBeanOperationInfo OP_LOCK_STAT_STR_INFO =         new MBeanOperationInfo(OP_LOCK_STAT_STR,                               "Get locking statistics.",                               statParams,                               "java.lang.String",                               MBeanOperationInfo.INFO);    private static final MBeanOperationInfo OP_TXN_STAT_INFO =         new MBeanOperationInfo(OP_TXN_STAT,                               "Get transactional statistics.",                               statParams,                               "com.sleepycat.je.TransactionStats",                               MBeanOperationInfo.INFO);    private static final MBeanOperationInfo OP_DB_NAMES_INFO =         new MBeanOperationInfo(OP_DB_NAMES,                              "Get the names of databases in the environment.",                               new MBeanParameterInfo[0], // no params                               "java.lang.String",                               MBeanOperationInfo.INFO);    private static final MBeanOperationInfo OP_DB_STAT_INFO =         new MBeanOperationInfo(OP_DB_STAT,                               "Get database statistics.",                               statParams,                               "com.sleepycat.je.TransactionStats",                               MBeanOperationInfo.INFO);/*    private static final MBeanParameterInfo [] dbStatParams = {        new MBeanParameterInfo ("clear", "java.lang.Boolean",                                "If true, reset statistics after reading."),        new MBeanParameterInfo ("fast", "java.lang.Boolean",                                "If true, only return statistics which do " +                                "not require expensive computation."),        new MBeanParameterInfo ("databaseName", "java.lang.String",                                "database name")    };*/    /* target JE environment home directory. */    private File environmentHome;      /*      * If canConfigure is true, this helper will make environment configuration     * attributes available in the mbean metadata. Configuration attributes     * will be saved in the openConfig instance.     */    private boolean canConfigure;    private EnvironmentConfig openConfig;    /* true if the mbean metadata needs to be refreshed. */    private boolean needReset;    /*     * Save whether the environment was open the last time we fetched     * mbean attributes. Use to detect a change in environment status.     */    private boolean envWasOpen;        /**     * Instantiate a helper, specifying environment home and open capabilities.     *     * @param environmentHome home directory of the target JE environment.     * @param canConfigure If true, the helper will show environment     * configuration attributes.     */    public JEMBeanHelper(EnvironmentConfig config,            File environmentHome, boolean canConfigure) {        if (environmentHome == null) {            throw new IllegalArgumentException(                                        "Environment home cannot be null");        }        this.environmentHome = environmentHome;        this.canConfigure = canConfigure;        if (canConfigure) {            openConfig = config;        }    }    /**     * Return the target environment directory.      * @return the environment directory.     */    public File getEnvironmentHome() {        return environmentHome;    }    /**     * If the helper was instantiated with canConfigure==true, it shows     * environment configuration attributes. Those attributes are returned     * within this EnvironmentConfig object for use in opening environments.     *      * @return EnvironmentConfig object which saves configuration attributes     * recorded through MBean attributes.     */    public EnvironmentConfig getEnvironmentOpenConfig() {        return openConfig;    }    /**     * Return an Environment only if the environment has already been opened     * in this process. A helper method for MBeans which want to only access     * open environments.      * @return Environment if already open, null if not open.     */    public Environment getEnvironmentIfOpen() {        if (environmentHome == null) {            return null;        }        return DbInternal.getEnvironmentShell(environmentHome);    }    /**     * Tell the MBean if the available set of functionality has changed.     *     * @return true if the MBean should regenerate its JE metadata.     */    public synchronized boolean getNeedReset() {        return needReset;    }    /********************************************************************/    /* MBean Attributes                                                 */    /********************************************************************/    /**     * Get MBean attribute metadata for this environment.     * @param targetEnv The target JE environment. May be null if the     * environment is not open.     * @return list of MBeanAttributeInfo objects describing the available     * attributes.     */    public List<MBeanAttributeInfo> getAttributeList(Environment targetEnv) {        /* Turn off reset because the mbean metadata is being refreshed. */        setNeedReset(false);        ArrayList<MBeanAttributeInfo> attrList          = new ArrayList<MBeanAttributeInfo>();                /* Add attributes for all JE environments. */        for (int i = 0; i < COMMON_ATTR.length; i++) {            attrList.add(COMMON_ATTR[i]);        }        if (targetEnv == null) {            if (canConfigure) {                /* Add attributes for configuring an environment. */                for (int i = 0; i < CREATE_ATTR.length; i++) {                    attrList.add(CREATE_ATTR[i]);                }            }        } else {            /* Add attributes for an open environment. */            for (int i = 0; i < OPEN_ATTR.length; i++) {                attrList.add(OPEN_ATTR[i]);            }            /* Add attributes for an open, transactional environment. */            try {                EnvironmentConfig config = targetEnv.getConfig();                if (config.getTransactional()) {                    for (int i = 0; i < TRANSACTIONAL_ATTR.length; i++) {                        attrList.add(TRANSACTIONAL_ATTR[i]);                    }                }            } catch (DatabaseException ignore) {            	/* ignore */            }        }        return attrList;    }    /**     * Get an attribute value for the given environment. Check     * JEMBeanHelper.getNeedReset() after this call because the helper may     * detect that the environment has changed and that the MBean metadata     * should be reset.     *     * @param targetEnv The target JE environment. May be null if the     * environment is not open.     * @param attributeName attribute name.     * @return attribute value.     */    public Object getAttribute(Environment targetEnv,                               String attributeName)         throws AttributeNotFoundException,               MBeanException {        /* Sanity check. */        if (attributeName == null) {            throw new AttributeNotFoundException(                                            "Attribute name cannot be null");        }        /* These attributes are available regardless of environment state. */        try {            if (attributeName.equals(ATT_ENV_HOME)) {                return environmentHome.getCanonicalPath();            } else if (attributeName.equals(ATT_OPEN)) {                boolean envIsOpen = (targetEnv != null);                resetIfOpenStateChanged(envIsOpen);                return new Boolean(envIsOpen);            } else if (attributeName.equals(ATT_SET_READ_ONLY)) {                return new Boolean(openConfig.getReadOnly());            } else if (attributeName.equals(ATT_SET_TRANSACTIONAL)) {                return new Boolean(openConfig.getTransactional());            } else if (attributeName.equals(ATT_SET_SERIALIZABLE)) {                return new Boolean(openConfig.getTxnSerializableIsolation());            } else {                /* The rest are JE environment attributes. */                if (targetEnv != null) {                    EnvironmentConfig config = targetEnv.getConfig();                    if (attributeName.equals(ATT_IS_READ_ONLY)) {                        return new Boolean(config.getReadOnly());                    } else if (attributeName.equals(ATT_IS_TRANSACTIONAL)) {                        return new Boolean(config.getTransactional());                    } else if (attributeName.equals(ATT_CACHE_SIZE)) {                        return new Long(config.getCacheSize());                    } else if (attributeName.equals(ATT_CACHE_PERCENT)) {                        return new Integer(config.getCachePercent());                    } else if (attributeName.equals(ATT_LOCK_TIMEOUT)) {                        return new Long(config.getLockTimeout());                    } else if (attributeName.equals(ATT_IS_SERIALIZABLE)) {                        return new                            Boolean(config.getTxnSerializableIsolation());                    } else if (attributeName.equals(ATT_TXN_TIMEOUT)) {                        return new Long(config.getTxnTimeout());                    } else {                        throw new AttributeNotFoundException("attribute " +                                                             attributeName +                                                             " is not valid.");                    }                }                 return null;             }        } catch (Exception e) {            /*             * Add both the message and the exception for easiest deciphering             * of the problem. Sometimes the original exception stacktrace gets             * hidden in server logs.             */            throw new MBeanException(e, e.getMessage());        }    }    /**     * Set an attribute value for the given environment.     *     * @param targetEnv The target JE environment. May be null if the

⌨️ 快捷键说明

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