google Analytics

Thursday, July 15, 2010

Jboss Management Interface Example

import javax.interceptor.Interceptors;
import org.jboss.ejb3.annotation.Clustered;
import org.jboss.ejb3.annotation.Depends;
import org.jboss.ejb3.annotation.Management;
import org.jboss.ejb3.annotation.Service;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor;

/**
* @author Anish
*
*/
@Service (name = "AnishService")
@Management (PlcService.class)
@Clustered
@Depends ({"jboss.ha:service=HASingletonDeployer,type=Barrier"})
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class AnishServiceBean implements AnishService{

private CISLogger logger = new CISLogger(getClass().getName());

@Override
public void create() throws Exception {
logger.info("Anish service created");
}

@Override
public void destroy() {
logger.info("Anish service destroyed");
}

@Override
public void start() throws Exception {
logger.info("Anish Cluster Wide Singleton Started");

/*
* deploys all spring beans.
* setting the application context will let other projects to use these beans.
*/


ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
AnishConstants.SPRING_CONTEXT_PATH);

ApplicationContext AnishContext = (ApplicationContext) applicationContext
.getBean(AnishConstants.Anish_CONTEXT_BEAN_NAME);

for(String name : AnishContext.getBeanDefinitionNames())
logger.debug(name + " spring bean loaded");

AnishApplicationManager applicationManager = (AnishApplicationManager) AnishContext
.getBean("AnishApplicationManager");


}

@Override
public void stop() {
logger.info("Anish Cluster Wide Singleton Stoped");
}

}

public interface AnishService {

void create() throws Exception;
void start() throws Exception;
void stop();
void destroy();
}

1 comment: