1 package net.walend.somnifugi.juc; 2 3 import java.util.Hashtable ; 4 5 import javax.naming.Context ; 6 import javax.naming.NamingException ; 7 8 import javax.jms.Message ; 9 10 import net.walend.somnifugi.SomniProperties; 11 import net.walend.somnifugi.SomniDestination; 12 import net.walend.somnifugi.SomniNamingException; 13 14 import net.walend.somnifugi.channel.ChannelFactory; 15 import net.walend.somnifugi.channel.Channel; 16 import net.walend.somnifugi.channel.Puttable; 17 import net.walend.somnifugi.channel.Takable; 18 19 29 30 public class SimpleChannelFactory 31 implements ChannelFactory<Message > 32 { 33 public static final int DEFAULTCAPACITY = 10000; 34 35 public static final String DEFAULTCAPACITYPROP = SomniProperties.DEFAULT + "." + SomniProperties.CAPACITYPROP; 36 37 public SimpleChannelFactory() 38 { 39 JUCLogger.IT.finer("Creating new SimpleChannelFactory."); 40 } 41 42 45 public Channel<Message > createChannel(String destinationName,Context context) 46 throws SomniNamingException 47 { 48 try 49 { 50 Hashtable env = context.getEnvironment(); 51 52 int capacity = DEFAULTCAPACITY; 53 54 if(env.containsKey(DEFAULTCAPACITYPROP)) 55 { 56 capacity = Integer.parseInt((String )env.get(DEFAULTCAPACITYPROP)); 57 } 58 59 String destCapacityPropName = destinationName+"."+SomniProperties.CAPACITYPROP; 60 61 if(env.containsKey(destCapacityPropName)) 62 { 63 capacity = Integer.parseInt((String )env.get(destCapacityPropName)); 64 } 65 66 JUCLogger.IT.finest("Creating SimpleChannel with capacity "+capacity+" for "+destinationName); 67 68 return new SimpleChannel(capacity); 69 } 70 catch(NamingException ne) 71 { 72 throw new SomniNamingException(ne); 73 } 74 } 75 } 76 77 97 | Popular Tags |