/Users/lyon/j4p/src/classUtils/pack/util/pool2/Configuration.java

1    package classUtils.pack.util.pool2; 
2     
3    import java.io.File; 
4     
5    import classUtils.pack.util.Setup; 
6     
7    /** 
8     * An object definining the configuration for a given {@link ObjectPool object pool}. 
9     * <p> 
10    *  
11    * @author Cristiano Sadun 
12    */ 
13   public class Configuration { 
14    
15       private File storageDirectory; 
16       private int poolSize; 
17       private ObjectPool.PassivationManagerFactory passivationManagerFactory; 
18    
19       /** 
20        * Create a configuration object with the given parameters. 
21        *  
22        * @param storageDirectory the directory where to store passivated object 
23        * @param poolSize the desired size of the pool 
24        * @param a {@link ObjectPool.PassivationManagerFactory passivation manager factory} to use 
25        *         for determining the passivation policy. 
26        */  
27       public Configuration(File storageDirectory, int poolSize, ObjectPool.PassivationManagerFactory passivationManagerFactory) { 
28           this.storageDirectory = storageDirectory; 
29           this.poolSize = poolSize; 
30           this.passivationManagerFactory=passivationManagerFactory; 
31       } 
32        
33       /** 
34        * Create a configuration object with the given parameters but associating an 
35        * {@link DefaultPassivationManager default passivation manager} to 
36        * the configured pool. 
37        *  
38        * @param storageDirectory the directory where to store passivated object 
39        * @param poolSize the desired size of the pool 
40        */  
41       public Configuration(File storageDirectory, int poolSize) { 
42           this(storageDirectory, poolSize, new ObjectPool.DefaultPassivationManagerFactory()); 
43       } 
44        
45       /** 
46        * Create a configuration object with the given parameters but usin the  
47        * system's temporary directory as storage directory and associating an 
48        * {@link DefaultPassivationManager default passivation  
49        * manager} to the configured pool. 
50        *  
51        * @param poolSize the desired size of the pool 
52        */  
53       public Configuration(int poolSize) { 
54           this(new File(System.getProperty("java.io.tmpdir")), poolSize, new ObjectPool.DefaultPassivationManagerFactory()); 
55       } 
56    
57       /** 
58        * Returns the storageDirectory. 
59        * @return File 
60        */ 
61       public File getStorageDirectory() { 
62           return storageDirectory; 
63       } 
64    
65       /** 
66        * Sets the storageDirectory. 
67        * @param storageDirectory The storageDirectory to set 
68        */ 
69       public void setStorageDirectory(File storageDirectory) { 
70           this.storageDirectory = storageDirectory; 
71       } 
72    
73       /** 
74        * Returns the poolSize. 
75        * @return int 
76        */ 
77       public int getPoolSize() { 
78           return poolSize; 
79       } 
80    
81       /** 
82        * Sets the poolSize. 
83        * @param poolSize The poolSize to set 
84        */ 
85       public void setPoolSize(int poolSize) { 
86           this.poolSize = poolSize; 
87       } 
88    
89       /** 
90        * Returns the passivationManagerFactory. 
91        * @return ExtendedObjectPool.PassivationManagerFactory 
92        */ 
93       public ObjectPool.PassivationManagerFactory getPassivationManagerFactory() { 
94           return passivationManagerFactory; 
95       } 
96    
97       /** 
98        * Sets the passivationManagerFactory. 
99        * @param passivationManagerFactory The passivationManagerFactory to set 
100       */ 
101      public void setPassivationManagerFactory( 
102          ObjectPool.PassivationManagerFactory passivationThreadFactory) { 
103          this.passivationManagerFactory = passivationThreadFactory; 
104      } 
105   
106  } 
107