KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > backupTool > ActiveMQEntryLoader


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * 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
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.backupTool;
17
18 import java.io.File JavaDoc;
19
20 import org.outerj.daisy.backupTool.dbDump.DbDumper;
21 import org.outerj.daisy.backupTool.dbDump.DbDumperFactory;
22 import org.w3c.dom.Document JavaDoc;
23 import org.w3c.dom.Element JavaDoc;
24
25 public class ActiveMQEntryLoader extends AbstractEntryLoader {
26     
27     public ActiveMQEntryLoader(File JavaDoc amqConfig) throws Exception JavaDoc{
28         super(amqConfig);
29     }
30
31     public void createEntries(BackupInstance buInstance) throws Exception JavaDoc {
32         Element JavaDoc dbConf = BackupHelper.getElementFromDomNS(configDocument, "/amq:beans/amq:bean[@id='dataSource']", "amq", "http://activemq.org/config/1.0");
33         DbDumper dbDumper = DbDumperFactory.createDbDumper(
34                 BackupHelper.getStringFromDomNS(dbConf, "amq:property[@name='url']/@value", "amq", "http://activemq.org/config/1.0"),
35                 BackupHelper.getStringFromDomNS(dbConf, "amq:property[@name='username']/@value", "amq", "http://activemq.org/config/1.0"),
36                 BackupHelper.getStringFromDomNS(dbConf, "amq:property[@name='password']/@value", "amq", "http://activemq.org/config/1.0")
37                 );
38         buInstance.addEntry(createDbEntry(buInstance, dbDumper, "activemq-dbDump.zip"));
39     }
40
41     public void reloadEntries(BackupInstance buInstance) throws Exception JavaDoc {
42         if (areFilesBackedUp(buInstance, new String JavaDoc[] {"activemq-dbDump.zip"}))
43             createEntries(buInstance);
44         else
45             System.out.println("ActiveMQ backup files were not found. Skipping restore of ActiveMQ.");
46     }
47
48 }
49
Popular Tags