1 14 15 package org.apache.activemq.store.amq; 16 17 import java.io.File ; 18 import org.apache.activemq.store.PersistenceAdapter; 19 import org.apache.activemq.store.PersistenceAdapterFactory; 20 import org.apache.activemq.store.ReferenceStoreAdapter; 21 import org.apache.activemq.thread.TaskRunnerFactory; 22 import org.apache.activemq.util.IOHelper; 23 24 31 public class AMQPersistenceAdapterFactory implements PersistenceAdapterFactory{ 32 33 private TaskRunnerFactory taskRunnerFactory; 34 private File dataDirectory; 35 private int journalThreadPriority = Thread.MAX_PRIORITY; 36 private String brokerName="localhost"; 37 private ReferenceStoreAdapter referenceStoreAdapter; 38 39 43 public PersistenceAdapter createPersistenceAdapter(){ 44 AMQPersistenceAdapter result = new AMQPersistenceAdapter(); 45 result.setDirectory(getDataDirectory()); 46 result.setTaskRunnerFactory(getTaskRunnerFactory()); 47 result.setBrokerName(getBrokerName()); 48 result.setReferenceStoreAdapter(getReferenceStoreAdapter()); 49 return result; 50 } 51 52 55 public File getDataDirectory(){ 56 if(this.dataDirectory==null){ 57 this.dataDirectory=new File (IOHelper.getDefaultDataDirectory(),brokerName); 58 } 59 return this.dataDirectory; 60 } 61 62 65 public void setDataDirectory(File dataDirectory){ 66 this.dataDirectory=dataDirectory; 67 } 68 69 72 public TaskRunnerFactory getTaskRunnerFactory(){ 73 if( taskRunnerFactory == null ) { 74 taskRunnerFactory = new TaskRunnerFactory("AMQPersistenceAdaptor Task", journalThreadPriority, true, 1000); 75 } 76 return taskRunnerFactory; 77 } 78 79 82 public void setTaskRunnerFactory(TaskRunnerFactory taskRunnerFactory){ 83 this.taskRunnerFactory=taskRunnerFactory; 84 } 85 86 87 90 public int getJournalThreadPriority(){ 91 return this.journalThreadPriority; 92 } 93 94 95 98 public void setJournalThreadPriority(int journalThreadPriority){ 99 this.journalThreadPriority=journalThreadPriority; 100 } 101 102 103 106 public String getBrokerName(){ 107 return this.brokerName; 108 } 109 110 111 114 public void setBrokerName(String brokerName){ 115 this.brokerName=brokerName; 116 } 117 118 119 122 public ReferenceStoreAdapter getReferenceStoreAdapter(){ 123 return this.referenceStoreAdapter; 124 } 125 126 127 130 public void setReferenceStoreAdapter(ReferenceStoreAdapter referenceStoreAdapter){ 131 this.referenceStoreAdapter=referenceStoreAdapter; 132 } 133 } 134 | Popular Tags |