All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.frameworkset.web.socket.handler.BeanCreatingHandlerProvider Maven / Gradle / Ivy

Go to download

bboss is a j2ee framework include aop/ioc,mvc,persistent,taglib,rpc,event ,bean-xml serializable and so on.http://www.bbossgroups.com

There is a newer version: 6.2.7
Show newest version
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 handlerType;

	private BaseApplicationContext beanFactory;


	public BeanCreatingHandlerProvider(Class 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 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