1 10 11 package org.mule.impl.space; 12 13 import org.mule.umo.endpoint.UMOImmutableEndpoint; 14 import org.mule.umo.space.UMOSpace; 15 import org.mule.umo.space.UMOSpaceException; 16 import org.mule.umo.space.UMOSpaceFactory; 17 import org.mule.util.queue.CachingPersistenceStrategy; 18 import org.mule.util.queue.MemoryPersistenceStrategy; 19 import org.mule.util.queue.QueueManager; 20 import org.mule.util.queue.QueuePersistenceStrategy; 21 import org.mule.util.xa.ResourceManagerSystemException; 22 23 27 public abstract class DefaultSpaceFactory implements UMOSpaceFactory 28 { 29 private QueuePersistenceStrategy persistenceStrategy; 30 private QueueManager queueManager; 31 private boolean enableMonitorEvents = true; 32 private int capacity = 0; 33 private boolean enableCaching = false; 34 35 public DefaultSpaceFactory() 36 { 37 super(); 38 } 39 40 public DefaultSpaceFactory(boolean enableMonitorEvents) 41 { 42 this.enableMonitorEvents = enableMonitorEvents; 43 } 44 45 public DefaultSpaceFactory(boolean enableMonitorEvents, int capacity) 46 { 47 this.enableMonitorEvents = enableMonitorEvents; 48 this.capacity = capacity; 49 } 50 51 public DefaultSpaceFactory(QueuePersistenceStrategy ps, boolean enableMonitorEvents) 52 { 53 this.persistenceStrategy = ps; 54 this.enableMonitorEvents = enableMonitorEvents; 55 } 56 57 public DefaultSpaceFactory(QueuePersistenceStrategy ps, boolean enableMonitorEvents, int capacity) 58 { 59 this.persistenceStrategy = ps; 60 this.enableMonitorEvents = enableMonitorEvents; 61 this.capacity = capacity; 62 } 63 64 public DefaultSpaceFactory(QueueManager qm, boolean enableMonitorEvents) 65 { 66 this.queueManager = qm; 67 this.enableMonitorEvents = enableMonitorEvents; 68 } 69 70 public boolean isEnableMonitorEvents() 71 { 72 return enableMonitorEvents; 73 } 74 75 public void setEnableMonitorEvents(boolean enableMonitorEvents) 76 { 77 this.enableMonitorEvents = enableMonitorEvents; 78 } 79 80 public int getCapacity() 81 { 82 return capacity; 83 } 84 85 public void setCapacity(int capacity) 86 { 87 this.capacity = capacity; 88 } 89 90 public QueuePersistenceStrategy getPersistenceStrategy() 91 { 92 return persistenceStrategy; 93 } 94 95 public void setPersistenceStrategy(QueuePersistenceStrategy persistenceStrategy) 96 { 97 this.persistenceStrategy = persistenceStrategy; 98 } 99 100 public QueueManager getQueueManager() 101 { 102 return queueManager; 103 } 104 105 public void setQueueManager(QueueManager queueManager) 106 { 107 this.queueManager = queueManager; 108 } 109 110 public boolean isEnableCaching() 111 { 112 return enableCaching; 113 } 114 115 public void setEnableCaching(boolean enableCaching) 116 { 117 this.enableCaching = enableCaching; 118 } 119 120 public UMOSpace create(String name) throws UMOSpaceException 121 { 122 123 if (capacity == 0) 124 { 125 capacity = 1024; 126 } 127 try 128 { 129 if (queueManager != null) 130 { 131 return new DefaultSpace(name, queueManager, enableMonitorEvents); 132 } 133 else if (persistenceStrategy == null) 134 { 135 persistenceStrategy = new MemoryPersistenceStrategy(); 136 } 137 if (enableCaching) 138 { 139 persistenceStrategy = new CachingPersistenceStrategy(persistenceStrategy); 140 } 141 return new DefaultSpace(name, persistenceStrategy, enableMonitorEvents, capacity); 142 143 } 144 catch (ResourceManagerSystemException e) 145 { 146 throw new CreateSpaceException(e); 147 } 148 } 149 150 158 public UMOSpace create(UMOImmutableEndpoint endpoint) throws UMOSpaceException 159 { 160 return create(endpoint.getEndpointURI().getAddress()); 161 } 162 } 163 | Popular Tags |