Hello,
I am working on a web application, and currently we need some how to know whether a change has been done in some files adn then reload one bean declared in the context. I read about the Sprimg JMX implementation, and I think it could be a good solution.
I am using james mail server, and in the context there was already declared an mbeanserver
Code:<bean id="mbeanserver" class="org.springframework.jmx.support.MBeanServerFactoryBean"> <property name="locateExistingServerIfPossible" value="true"/> <property name="registerWithFactory" value="true"/> </bean>
With the exporter
The bean stopWordsSearch is the one I want to reload when I get some notifications. I thought that the easiest way would be to get the notifications via console. So the user that makes the change in the file, write a command in the command line and reload the bean. (The user would be an admin, this solution is only temporal).Code:<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"> <property name="beans"> <map> <entry key="bean:name=stopWordsSearchBean" value-ref="stopWordsSearch"/> <entry key="org.apache.james:type=server,name=smtpserver" value-ref="smtpserver"/> <entry key="org.apache.james:type=server,name=lmtpserver" value-ref="lmtpserver"/> <entry key="org.apache.james:type=server,name=pop3server" value-ref="pop3server"/> <entry key="org.apache.james:type=server,name=imapserver" value-ref="imapserver"/> <entry key="org.apache.james:type=component,name=domainlist" value-ref="domainlistmanagement"/> <entry key="org.apache.james:type=component,name=dnsservice" value-ref="dnsservice"/> <entry key="org.apache.james:type=component,name=recipientrewritetable" value-ref="recipientrewritetablemanagement"/> <entry key="org.apache.james:type=component,name=usersrepository" value-ref="usersrepositorymanagement"/> <entry key="org.apache.james:type=component,name=fetchmail" value-ref="fetchmail"/> <entry key="org.apache.james:type=component,name=mailboxmanagement" value-ref="mailboxmanagermanagement"/> <entry key="org.apache.james:type=component,component=mailetcontainer,name=mailspooler" value-ref="mailspooler"/> <entry key="org.apache.james:type=component,name=mailboxcopier" value-ref="mailboxcopiermanagement"/> <entry key="org.apache.james:type=component,name=james23importer" value-ref="james23importermanagement"/> <entry key="org.apache.james:type=container,name=logprovider" value-ref="logprovider"/> </map> </property> <property name="assembler"> <bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler"> <property name="managedInterfaces" value="the servers"/> </bean> </property> <property name="notificationListenerMappings"> <map> <entry key="stopWordsSearch"> <!-- When the FILE changes, the notification comes --> <bean class="project.CreateStopWordsContainerNotificationListener"/> </entry> </map> </property> </bean>
Following the documentation, I created the listener:
I would like to know which steps should I follow, I have not much exprience with JMX Spring!!Code:public class CreateStopWordsContainerNotificationListener implements NotificationListener, NotificationFilter { public void handleNotification(Notification notification, Object handback) { System.out.println(notification); System.out.println(handback); } public boolean isNotificationEnabled(Notification notification) { return AttributeChangeNotification.class.isAssignableFrom(notification.getClass()); } }
I get this warn
WARN 13:06:35,035 | org.springframework.jmx.export.MBeanExporter | Bean with key 'bean:name=stopWordsSearchBean' has been registered as an MBean but has no exp
osed attributes or operations
What does it really mean? I can not find anything googling
Thanks in advance


Reply With Quote
