1 20 package org.apache.mina.integration.spring; 21 22 import org.apache.mina.common.ExecutorThreadModel; 23 import org.springframework.beans.factory.FactoryBean; 24 import org.springframework.beans.factory.InitializingBean; 25 import org.springframework.util.Assert; 26 27 import java.util.concurrent.Executor ; 28 29 37 public class ExecutorThreadModelFactoryBean implements FactoryBean, 38 InitializingBean { 39 private String serviceName = null; 40 41 private Executor executor = null; 42 43 52 public void setExecutor(Executor executor) { 53 Assert.notNull(executor, "Property 'executor' may not be null"); 54 this.executor = executor; 55 } 56 57 66 public void setServiceName(String serviceName) { 67 Assert.notNull(serviceName, "Property 'serviceName' may not be null"); 68 this.serviceName = serviceName; 69 } 70 71 public Class getObjectType() { 72 return ExecutorThreadModel.class; 73 } 74 75 public Object getObject() throws Exception { 76 ExecutorThreadModel model = ExecutorThreadModel 77 .getInstance(serviceName); 78 if (executor != null) { 79 model.setExecutor(executor); 80 } 81 return model; 82 } 83 84 public boolean isSingleton() { 85 return true; 86 } 87 88 public void afterPropertiesSet() throws Exception { 89 Assert.notNull(serviceName, "Property 'serviceName' may not be null"); 90 } 91 92 } 93 | Popular Tags |