org.frameworkset.web.socket.handler.BeanCreatingHandlerProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bboss-websocket Show documentation
Show all versions of bboss-websocket Show documentation
bboss is a j2ee framework include aop/ioc,mvc,persistent,taglib,rpc,event ,bean-xml serializable and so on.http://www.bbossgroups.com
package org.frameworkset.web.socket.handler;
import org.frameworkset.spi.ApplicationContextAware;
import org.frameworkset.spi.BaseApplicationContext;
import org.frameworkset.util.Assert;
import com.frameworkset.util.BeanUtils;
public class BeanCreatingHandlerProvider implements ApplicationContextAware {
private final Class extends T> handlerType;
private BaseApplicationContext beanFactory;
public BeanCreatingHandlerProvider(Class extends T> handlerType) {
Assert.notNull(handlerType, "handlerType must not be null");
this.handlerType = handlerType;
}
@Override
public void setApplicationContext(BaseApplicationContext beanFactory) {
if (beanFactory instanceof BaseApplicationContext) {
this.beanFactory = (BaseApplicationContext) beanFactory;
}
}
public void destroy(T handler) {
if (this.beanFactory != null) {
this.beanFactory.destroyBean(handler);
}
}
public Class extends T> getHandlerType() {
return this.handlerType;
}
public T getHandler() {
if (this.beanFactory != null) {
return this.beanFactory.createBean(this.handlerType);
}
else {
return BeanUtils.instantiate(this.handlerType);
}
}
@Override
public String toString() {
return "BeanCreatingHandlerProvider[handlerType=" + this.handlerType + "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy