English 中文(简体)
如何为联合数据交换监测确定网络的名称?
原标题:How to set the name of the net.sf.ehcache.CacheManager for JMX monitoring?

我正在使用EhCache 1.4.0, Spring 3.0.5,在使用JRE 1.6在Tomcat 6的网络应用中。 我通过JMX揭露了L2的切身管理。

<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
    <property name="locateExistingServerIfPossible" value="true" />
</bean>

<util:property-path id="hibernateCacheProvider" path="sessionFactory.settings.cacheProvider" />

<bean id="hibernateEhCacheManager" class="com.mycompany.spring.beans.factory.config.UnaccessibleFieldRetrievingFactoryBean">
    <property name="targetObject" ref="hibernateCacheProvider" />
    <property name="targetField" value="manager" />
    <property name="makeInstanceFieldVisible" value="true" />
</bean>

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <description>The cacheManager configuration.</description>
    <property name="targetClass" value="net.sf.ehcache.management.ManagementService" />
    <property name="staticMethod" value="net.sf.ehcache.management.ManagementService.registerMBeans" />
    <property name="arguments">
        <list>
            <ref bean="hibernateEhCacheManager" />
            <ref bean="mbeanServer" />
            <value type="boolean">true</value>
            <value type="boolean">true</value>
            <value type="boolean">true</value>
            <value type="boolean">true</value>
        </list>
    </property>
</bean>

<bean class="org.springframework.jmx.export.annotation.AnnotationMBeanExporter">
    <property name="server" ref="mbeanServer" />
    <property name="beans">
        <map>
            <entry key="Hibernate:type=statistics,application=applicationOne">
                <bean class="org.hibernate.jmx.StatisticsService">
                    <property name="statisticsEnabled" value="true" />
                    <property name="sessionFactory" ref="sessionFactory" />
                </bean>
            </entry>
        </map>
    </property>
</bean>

<bean id="hbm.properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="properties">
        <props>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.generate_statistics">false</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
            <prop key="hibernate.cache.provider_configuration_file_resource_path">applicationOne-web/ehcache.xml</prop>
            <prop key="hibernate.cache.query_cache_factory">org.hibernate.cache.StandardQueryCacheFactory</prop>
        </props>
    </property>
</bean>

我必须允许通过使用jmxterm来清除L2中的所有条目。 工具:

run --bean net.sf.ehcache:type=CacheManager,name=net.sf.ehcache.CacheManager@605df3c5 clearAll

我知道,以确定从该背景来看准确的<代码>CacheManager,但出于某种原因,我无法使用。

迄今为止,尽管如此,但据推测,我的核查和测验仪(Tomcat服务器)有2份应用,同时允许对EhCache进行联合测验。 这两项甲基溴名称如下:

net.sf.ehcache:type=CacheManager,name=net.sf.ehcache.CacheManager@605df3c5
net.sf.ehcache:type=CacheManager,name=net.sf.ehcache.CacheManager@49ff3459

你们可以看到,在试图确定哪些切身之处时,它们并不有用。

因此,我的问题是:是否有可能确定每个CacheManager的名字,以便确定究竟用什么来清除L2藏匿点的所有条目?

Thank you.

最佳回答

一旦获得解放 有了EhCacheManager,人们可以使用其方法(制定包括在内的方法),使用以下简称。 通常,这应当使CacheManager重新命名。

 <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetObject">
            <ref local="hibernateEhCacheManager"/>
        </property>
        <property name="targetMethod">
            <value>setName</value>
        </property>
        <property name="arguments" value="<the_desired_name>"/>
</bean>
问题回答

我知道这一点很久以前就得到了答复,但我认为,把这个问题列入你的切身组合档案(申请“一个网站/www.ehcache.xml)是容易的。

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false"
    monitoring="autodetect" dynamicConfig="true" name="MY_CACHE_MANAGER_NAME">

...
</ehcache>




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签