KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > store > amq > AMQPersistenceAdapterFactory


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
4  * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
5  * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
6  * License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12  * specific language governing permissions and limitations under the License.
13  */

14
15 package org.apache.activemq.store.amq;
16
17 import java.io.File JavaDoc;
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 /**
25  * An implementation of {@link PersistenceAdapterFactory}
26  *
27  * @org.apache.xbean.XBean element="amqPersistenceAdapterFactory"
28  *
29  * @version $Revision: 1.17 $
30  */

31 public class AMQPersistenceAdapterFactory implements PersistenceAdapterFactory{
32
33     private TaskRunnerFactory taskRunnerFactory;
34     private File JavaDoc dataDirectory;
35     private int journalThreadPriority = Thread.MAX_PRIORITY;
36     private String JavaDoc brokerName="localhost";
37     private ReferenceStoreAdapter referenceStoreAdapter;
38     
39     /**
40      * @return a AMQPersistenceAdapter
41      * @see org.apache.activemq.store.PersistenceAdapterFactory#createPersistenceAdapter()
42      */

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     /**
53      * @return the dataDirectory
54      */

55     public File JavaDoc getDataDirectory(){
56         if(this.dataDirectory==null){
57             this.dataDirectory=new File JavaDoc(IOHelper.getDefaultDataDirectory(),brokerName);
58         }
59         return this.dataDirectory;
60     }
61     
62     /**
63      * @param dataDirectory the dataDirectory to set
64      */

65     public void setDataDirectory(File JavaDoc dataDirectory){
66         this.dataDirectory=dataDirectory;
67     }
68     
69     /**
70      * @return the taskRunnerFactory
71      */

72     public TaskRunnerFactory getTaskRunnerFactory(){
73         if( taskRunnerFactory == null ) {
74             taskRunnerFactory = new TaskRunnerFactory("AMQPersistenceAdaptor Task", journalThreadPriority, true, 1000);
75         }
76         return taskRunnerFactory;
77     }
78     
79     /**
80      * @param taskRunnerFactory the taskRunnerFactory to set
81      */

82     public void setTaskRunnerFactory(TaskRunnerFactory taskRunnerFactory){
83         this.taskRunnerFactory=taskRunnerFactory;
84     }
85
86     
87     /**
88      * @return the journalThreadPriority
89      */

90     public int getJournalThreadPriority(){
91         return this.journalThreadPriority;
92     }
93
94     
95     /**
96      * @param journalThreadPriority the journalThreadPriority to set
97      */

98     public void setJournalThreadPriority(int journalThreadPriority){
99         this.journalThreadPriority=journalThreadPriority;
100     }
101
102     
103     /**
104      * @return the brokerName
105      */

106     public String JavaDoc getBrokerName(){
107         return this.brokerName;
108     }
109
110     
111     /**
112      * @param brokerName the brokerName to set
113      */

114     public void setBrokerName(String JavaDoc brokerName){
115         this.brokerName=brokerName;
116     }
117
118     
119     /**
120      * @return the referenceStoreAdapter
121      */

122     public ReferenceStoreAdapter getReferenceStoreAdapter(){
123         return this.referenceStoreAdapter;
124     }
125
126     
127     /**
128      * @param referenceStoreAdapter the referenceStoreAdapter to set
129      */

130     public void setReferenceStoreAdapter(ReferenceStoreAdapter referenceStoreAdapter){
131         this.referenceStoreAdapter=referenceStoreAdapter;
132     }
133 }
134
Popular Tags