-
Jun 5th, 2006, 06:26 AM
#1
How can I export services
Hi,
I have this beans.xml:
<beans>
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServer FactoryBean"/>
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporte r">
<property name="beans">
<map>
<entry key="bean:name=jmxBean" value-ref="jmxBean"/>
</map>
</property>
<property name="server" ref="mbeanServer"/>
</bean>
<bean id="jmxBean" class="service.JMXBean" init-method="init"/>
</beans>
JMXBean.java is:
package service;
public class JMXBean {
void init() {
System.out.println("init ...");
}
public int getValue() {
return 0;
}
}
I run Spring with this Main.java:
package service;
import org.springframework.context.support.AbstractApplic ationContext;
import org.springframework.context.support.ClassPathXmlAp plicationContext;
public class Main {
public static void main(String[] args) throws InterruptedException {
final AbstractApplicationContext ctx =
new ClassPathXmlApplicationContext(new String []{"beans.xml"});
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
ctx.close();
}
});
Thread.sleep(Long.MAX_VALUE);
}
}
I do it in such way:
$ java -Dcom.sun.management.jmxremote -cp .:../lib/commons-logging.jar:../lib/spring.jar service/Main
05.06.2006 15:18:38 org.springframework.core.CollectionFactory <clinit>
INFO: JDK 1.4+ collections available
05.06.2006 15:18:38 org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [beans.xml]
05.06.2006 15:18:39 org.springframework.context.support.AbstractRefres hableApplicationContext refreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=2693887]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [bootstrapBean,mbeanServer,exporter,jmxBean]; root of BeanFactory hierarchy
05.06.2006 15:18:39 org.springframework.context.support.AbstractApplic ationContext refresh
INFO: 4 beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=2693887]
05.06.2006 15:18:39 org.springframework.context.support.AbstractApplic ationContext initMessageSource
INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMess ageSource@166a22b]
05.06.2006 15:18:40 org.springframework.context.support.AbstractApplic ationContext initApplicationEventMulticaster
INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@763f5d]
05.06.2006 15:18:40 org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [bootstrapBean,mbeanServer,exporter,jmxBean]; root of BeanFactory hierarchy]
init ...
05.06.2006 15:18:40 org.springframework.jmx.export.MBeanExporter afterPropertiesSet
INFO: Registering beans for JMX exposure on startup
But I can't see any MBean in service package, I see them only in java.lang, java.util.logging and in JMImplementation.
Why can it be? What's wrong in my code?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules