[hornetq-commits] JBoss hornetq SVN: r10699 - in branches/Branch_2_2_EAP_export_tool: src/config/common/schema and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed May 18 22:21:45 EDT 2011
Author: clebert.suconic at jboss.com
Date: 2011-05-18 22:21:45 -0400 (Wed, 18 May 2011)
New Revision: 10699
Added:
branches/Branch_2_2_EAP_export_tool/src/config/common/schema/hornetq-export.xsd
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ExportData.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ImportData.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/hornetq-export.xsd
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/AckType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsJournalType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/HornetQExport.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/ObjectFactory.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertiesType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertyType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueRefType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java
branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java
Modified:
branches/Branch_2_2_EAP_export_tool/pom.xml
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
Log:
Branch for import/export tool
Modified: branches/Branch_2_2_EAP_export_tool/pom.xml
===================================================================
--- branches/Branch_2_2_EAP_export_tool/pom.xml 2011-05-19 02:18:50 UTC (rev 10698)
+++ branches/Branch_2_2_EAP_export_tool/pom.xml 2011-05-19 02:21:45 UTC (rev 10699)
@@ -319,6 +319,11 @@
<artifactId>spring-jms</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
</dependencies>
Added: branches/Branch_2_2_EAP_export_tool/src/config/common/schema/hornetq-export.xsd
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/config/common/schema/hornetq-export.xsd (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/config/common/schema/hornetq-export.xsd 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:hornetq"
+ xmlns="urn:hornetq"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:element name="hq-journal-export">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element type="bindings-journalType" name="queues" maxOccurs="1"/>
+ <xsd:element type="messages-journalType" name="messages" maxOccurs="1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="bindings-journalType">
+ <xsd:sequence>
+ <xsd:element type="queueType" name="queue" maxOccurs="unbounded" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="messages-journalType">
+ <xsd:sequence>
+ <xsd:element type="messageType" name="message" maxOccurs="unbounded" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- bindings -->
+
+ <xsd:complexType name="bindingsType">
+ <xsd:sequence>
+ <xsd:element type="queueType" name="queue"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="queueType">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="address" type="xsd:string"/>
+ <xsd:element name="filterString" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:attribute type="xsd:long" name="id" use="required"/>
+ </xsd:complexType>
+
+ <!-- journal -->
+
+ <xsd:complexType name="messageType">
+ <xsd:sequence>
+ <xsd:element type="xsd:string" name="address"/>
+ <xsd:element type="xsd:byte" name="type">
+ <xsd:annotation>
+ <xsd:documentation>see interface Message</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element type="xsd:boolean" name="durable"/>
+ <xsd:element type="xsd:long" name="expiration"/>
+ <xsd:element type="xsd:long" name="timestamp"/>
+ <xsd:element type="propertiesType" name="properties"/>
+ <xsd:element type="xsd:byte" name="priority"/>
+ <xsd:element type="xsd:string" name="payload">
+ <xsd:annotation>
+ <xsd:documentation>ref to byte array in <msgId> directory</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element type="xsd:string" name="userId"/>
+ <xsd:element type="bindType" name="bindings"/>
+ <xsd:element type="ackType" name="acks"/>
+ </xsd:sequence>
+ <xsd:attribute type="xsd:long" name="id"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertiesType">
+ <xsd:sequence>
+ <xsd:element type="propertyType" name="property" maxOccurs="unbounded" minOccurs="1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertyType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute type="xsd:string" name="key" use="required"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="bindType">
+ <xsd:sequence>
+ <xsd:element name="queue" type="queueRefType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="ackType">
+ <xsd:sequence>
+ <xsd:element name="queue" type="queueRefType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="queueRefType">
+ <xsd:attribute name="id" type="xsd:long"/>
+ </xsd:complexType>
+</xsd:schema>
\ No newline at end of file
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2011-05-19 02:18:50 UTC (rev 10698)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -53,7 +53,6 @@
import org.hornetq.core.journal.SequentialFileFactory;
import org.hornetq.core.journal.TransactionFailureCallback;
import org.hornetq.core.journal.impl.AIOSequentialFileFactory;
-import org.hornetq.core.journal.impl.ExportJournal;
import org.hornetq.core.journal.impl.JournalFile;
import org.hornetq.core.journal.impl.JournalImpl;
import org.hornetq.core.journal.impl.JournalReaderCallback;
@@ -108,6 +107,7 @@
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
* @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
+ * @author <a href="torben at redhat.com">Torben Jaeger</a>
*
*/
public class JournalStorageManager implements StorageManager
@@ -199,6 +199,7 @@
private final Map<SimpleString, PersistedAddressSetting> mapPersistedAddressSettings = new ConcurrentHashMap<SimpleString, PersistedAddressSetting>();
+
public JournalStorageManager(final Configuration config, final ExecutorFactory executorFactory)
{
this(config, executorFactory, null);
@@ -2169,7 +2170,7 @@
}
}
- private static class PersistentQueueBindingEncoding implements EncodingSupport, QueueBindingInfo
+ protected static class PersistentQueueBindingEncoding implements EncodingSupport, QueueBindingInfo
{
long id;
@@ -2337,7 +2338,7 @@
private static class QueueEncoding implements EncodingSupport
{
- long queueID;
+ public long queueID;
public QueueEncoding(final long queueID)
{
@@ -2389,7 +2390,7 @@
}
}
- private static class RefEncoding extends QueueEncoding
+ protected static class RefEncoding extends QueueEncoding
{
public RefEncoding()
{
@@ -2839,7 +2840,7 @@
// Encoding functions for binding Journal
- private static Object newObjectEncoding(RecordInfo info)
+ protected static Object newObjectEncoding(RecordInfo info)
{
HornetQBuffer buffer = HornetQBuffers.wrappedBuffer(info.data);
long id = info.id;
@@ -2981,9 +2982,9 @@
}
}
- private static class ReferenceDescribe
+ protected static class ReferenceDescribe
{
- RefEncoding refEncoding;
+ public RefEncoding refEncoding;
public ReferenceDescribe(RefEncoding refEncoding)
{
@@ -2997,9 +2998,9 @@
}
- private static class AckDescribe
+ protected static class AckDescribe
{
- RefEncoding refEncoding;
+ public RefEncoding refEncoding;
public AckDescribe(RefEncoding refEncoding)
{
@@ -3013,14 +3014,14 @@
}
- private static class MessageDescribe
+ protected static class MessageDescribe
{
public MessageDescribe(Message msg)
{
this.msg = msg;
}
- Message msg;
+ public Message msg;
public String toString()
{
@@ -3322,5 +3323,4 @@
journal.stop();
}
-
}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ExportData.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ExportData.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ExportData.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.persistence.tools;
+
+/**
+ * A ExportData
+ *
+ * @author clebertsuconic
+ *
+ *
+ */
+public class ExportData
+{
+
+ public static void main(String args[])
+ {
+ if (args.length != 4) {
+ System.out.println("Usage Export: java org.hornetq.core.persistence.tools.ExportData <bindings-journal-dir> <messages-journal-dir>");
+ System.exit(-1);
+ }
+ try
+ {
+ ManageDataTool.exportMessages(args[0], args[1], System.out);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+
+ }
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ImportData.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ImportData.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ImportData.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.persistence.tools;
+
+/**
+ * A ImportData
+ *
+ * @author clebertsuconic
+ *
+ *
+ */
+public class ImportData
+{
+
+ public static void main(String args[])
+ {
+ if (args.length != 3) {
+ System.out.println("Usage Export: java org.hornetq.core.persistence.tools.ImportData <import-file-name> <hq-config-file> <connector-name>");
+ System.exit(-1);
+ }
+ try
+ {
+ ManageDataTool.importMessages(args[0], args[1], args[2]);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,694 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.persistence.tools;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.config.impl.FileConfiguration;
+import org.hornetq.core.journal.Journal;
+import org.hornetq.core.journal.LoaderCallback;
+import org.hornetq.core.journal.PreparedTransactionInfo;
+import org.hornetq.core.journal.RecordInfo;
+import org.hornetq.core.journal.SequentialFileFactory;
+import org.hornetq.core.journal.impl.JournalImpl;
+import org.hornetq.core.journal.impl.NIOSequentialFileFactory;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.message.impl.MessageImpl;
+import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
+import org.hornetq.core.persistence.tools.xmlmodel.BindingsJournalType;
+import org.hornetq.core.persistence.tools.xmlmodel.HornetQExport;
+import org.hornetq.core.persistence.tools.xmlmodel.MessageType;
+import org.hornetq.core.persistence.tools.xmlmodel.MessagesExportType;
+import org.hornetq.core.persistence.tools.xmlmodel.PropertyType;
+import org.hornetq.core.persistence.tools.xmlmodel.QueueRefType;
+import org.hornetq.core.persistence.tools.xmlmodel.QueueType;
+import org.hornetq.core.server.ServerMessage;
+import org.hornetq.utils.Base64;
+import org.hornetq.utils.ExecutorFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/**
+ * @author <a href="mailto:torben at redhat.com">Torben Jaeger</a>
+ */
+public class ManageDataTool extends JournalStorageManager
+{
+ private static final Logger log = Logger.getLogger(ManageDataTool.class);
+
+ private static long messageCounter = 0;
+
+ private ManageDataTool(final Configuration config, final ExecutorFactory executorFactory)
+ {
+ super(config, executorFactory);
+ }
+
+ /**
+ * Method which will export the binary HQ journal to a XML representation of messages and bindings.
+ * <p/>
+ * Some rules to keep in mind:
+ * <ul>
+ * <li> not all records of the journals are exported (no 1-to-1 copy); see exporting rules below.
+ * <li> the binary journal should not be started/loaded
+ * </ul>
+ * <p/>
+ * Rules for exporting:
+ * <ul>
+ * <li> ADD records are exported
+ * <li> REF records are exported
+ * <li> records with ACKs are <b>not</b> exported coz the messages have already been delivered
+ * <li> records which are part of a prepared TX are <b>not</b> exported due to recovery
+ * <li> records which are part of failed TX are <b>not</b> exported due to recovery
+ * <li> records with a delete request are <b>not</b> exported coz the messages have already been delivered
+ * <li> records with internal message headers (like routing) are <b>not</b> exported
+ * </ul>
+ * <p/>
+ *
+ * @param exportFile full qualified name of the export file (/path/name.xml)
+ * @param bindingsDir directory with the bindings journal
+ * @param messagesDir directory with the messages journal
+ * @param backup flag if a backup should be created before modifying the original journal
+ * @throws Exception if something goes wrong
+ */
+ public static void exportMessages(final String bindingsDir, final String messagesDir, final OutputStream out) throws Exception
+ {
+
+ // Will use only default values. The load function should adapt to anything different
+ ConfigurationImpl defaultValues = new ConfigurationImpl();
+ defaultValues.setJournalDirectory(messagesDir);
+
+ if (log.isInfoEnabled())
+ {
+ log.info("Generating backup of original journal ...");
+ }
+
+ SequentialFileFactory messagesFF = new NIOSequentialFileFactory(messagesDir);
+ JournalImpl messagesJournal = new JournalImpl(defaultValues.getJournalFileSize(),
+ defaultValues.getJournalMinFiles(),
+ 0,
+ 0,
+ messagesFF,
+ "hornetq-data",
+ "hq",
+ 1);
+
+ SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir);
+ JournalImpl bindingsJournal = new JournalImpl(1024 * 1024,
+ 2,
+ -1,
+ 0,
+ bindingsFF,
+ "hornetq-bindings",
+ "bindings",
+ 1);
+
+ HornetQExport hqJournalExport = new HornetQExport();
+
+ if (log.isInfoEnabled())
+ {
+ log.info("Exporting bindings ...");
+ }
+ hqJournalExport.setQueues(exportBindings(bindingsJournal));
+
+ if (log.isInfoEnabled())
+ {
+ log.info("Exporting journal ...");
+ }
+ hqJournalExport.setMessages(exportMessages(messagesJournal));
+
+ if (log.isInfoEnabled())
+ {
+ log.info("Writing export file ...");
+ }
+ writeExportToFile(hqJournalExport, out);
+
+ if (log.isInfoEnabled())
+ {
+ log.info("Export done!");
+ }
+ }
+
+ private static BindingsJournalType exportBindings(JournalImpl original) throws Exception
+ {
+ try
+ {
+ final List<RecordInfo> records = new LinkedList<RecordInfo>();
+ final Set<Long> recordsToDelete = new HashSet<Long>();
+
+ loadData(original, records, recordsToDelete);
+
+ return buildXmlBindings(records);
+
+ }
+ finally
+ {
+ original.stop();
+ }
+ }
+
+ /**
+ * Method to load the journal and prepare the record lists/sets to work on.
+ *
+ * @param original the journal to export
+ * @return an XML representation of the journal
+ * @throws Exception if the journal is corrupt
+ */
+ private static MessagesExportType exportMessages(JournalImpl original) throws Exception
+ {
+
+ try
+ {
+ final List<RecordInfo> records = new LinkedList<RecordInfo>();
+ final Set<Long> recordsToDelete = new HashSet<Long>();
+
+ loadData(original, records, recordsToDelete);
+
+ MessagesExportType journal = buildXmlMessages(records, recordsToDelete);
+
+ // addDelRecordsToOriginal(original, recordsToDelete, journal.getMessage());
+
+ return journal;
+
+ }
+ finally
+ {
+ original.stop();
+ }
+
+ }
+
+ /*
+ *
+ * private static void addDelRecordsToOriginal(JournalImpl original, Set<Long> recordsToDelete, List<MessageType> messages) throws Exception {
+ List<Long> originalDeletes = new ArrayList<Long>(messages.size() / 3);
+ for (MessageType message : messages) {
+ if (!recordsToDelete.contains(message.getId()) &&
+ !originalDeletes.contains(message.getId())) {
+ original.appendDeleteRecord(message.getId(), false, DummyOperationContext.getInstance());
+ originalDeletes.add(message.getId());
+ }
+ }
+ if (log.isInfoEnabled()) {
+ int size = originalDeletes.size();
+ log.info("Deleted " + size + " record" + (size > 1 ? "s" : "") + " from original journal!");
+ }
+ }
+ */
+
+ private static void loadData(Journal original, final List<RecordInfo> records, final Set<Long> recordsToDelete) throws Exception
+ {
+ original.start();
+
+ original.load(new LoaderCallback()
+ {
+ private void logNotExportedRecord(long id, String reason)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Record " + id + " will not be exported due to " + reason + "!");
+ }
+ }
+
+ private void addToNotExportedRecords(List<RecordInfo> list, String reason)
+ {
+ for (RecordInfo record : list)
+ {
+ logNotExportedRecord(record.id, reason);
+ recordsToDelete.add(record.id);
+ }
+ }
+
+ public void addPreparedTransaction(PreparedTransactionInfo preparedTransaction)
+ {
+ addToNotExportedRecords(preparedTransaction.records, "prepared TX");
+ addToNotExportedRecords(preparedTransaction.recordsToDelete, "prepared TX");
+ }
+
+ public void addRecord(RecordInfo info)
+ {
+ records.add(info);
+ }
+
+ public void deleteRecord(long id)
+ {
+ logNotExportedRecord(id, "DEL");
+ recordsToDelete.add(id);
+ }
+
+ public void updateRecord(RecordInfo info)
+ {
+ records.add(info);
+ }
+
+ public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> _recordsToDelete)
+ {
+ addToNotExportedRecords(records, "failed TX");
+ addToNotExportedRecords(_recordsToDelete, "failed TX");
+ }
+
+ });
+ }
+
+ /**
+ * Method which writes the XML export file to disk.
+ *
+ * @param hqJournalExport the root JAXB context
+ * @param exportFile the export filename
+ * @throws java.io.FileNotFoundException if the export file could not be created
+ * @throws javax.xml.bind.JAXBException if an error occurs during marshalling
+ */
+ private static void writeExportToFile(HornetQExport hqJournalExport, OutputStream os) throws JAXBException,
+ FileNotFoundException
+ {
+
+ // todo: http://jaxb.java.net/guide/Different_ways_of_marshalling.html#Marshalling_into_a_subtree
+
+ JAXBContext jc = JAXBContext.newInstance(HornetQExport.class);
+ Marshaller m = jc.createMarshaller();
+ m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ m.marshal(hqJournalExport, os);
+ }
+
+ /**
+ * Method which creates the JAXB representation of the XML export file.
+ *
+ * @param records the records to process
+ * @param recordsToDelete records which are @see DeleteRecord
+ * @return @see BindingsJournalType or @see MessagesJournalType
+ */
+ private static MessagesExportType buildXmlMessages(List<RecordInfo> records, Set<Long> recordsToDelete)
+ {
+
+ MessagesExportType journalType = new MessagesExportType();
+
+ // Export Journal
+ for (RecordInfo info : records)
+ {
+
+ if (recordsToDelete.contains(info.id))
+ {
+ // deleted records are not exported
+ continue;
+ }
+
+ switch (info.getUserRecordType())
+ {
+
+ case JournalStorageManager.ADD_MESSAGE:
+ handleAddMessage(journalType, info);
+ break;
+
+ case JournalStorageManager.ADD_REF:
+ handleAddRef(journalType, info);
+ break;
+
+ case JournalStorageManager.ACKNOWLEDGE_REF:
+ handleAckRef(journalType, info);
+ break;
+
+ default:
+ if (log.isDebugEnabled())
+ {
+ log.debug(new StringBuilder().append("Record ")
+ .append(info.id)
+ .append(" is not exported!")
+ .toString());
+ }
+ break;
+ }
+ }
+
+ return journalType;
+ }
+
+ private static void handleAddMessage(MessagesExportType journalType, RecordInfo info)
+ {
+ JournalStorageManager.MessageDescribe message = (JournalStorageManager.MessageDescribe)JournalStorageManager.newObjectEncoding(info);
+
+ MessageType messageType = new MessageType((ServerMessage)message.msg);
+
+ byte[] data = info.data;
+ messageType.setPayload(Base64.encodeBytes(data, 0, data.length, Base64.DONT_BREAK_LINES | Base64.URL_SAFE));
+
+ journalType.getMessage().add(messageType);
+ }
+
+ private static void handleAddRef(MessagesExportType journalType, RecordInfo info)
+ {
+ JournalStorageManager.ReferenceDescribe ref = (JournalStorageManager.ReferenceDescribe)JournalStorageManager.newObjectEncoding(info);
+
+ MessageType message = getMessage(journalType, info);
+
+ if (message == null)
+ {
+ throw new IllegalStateException("Journal is corrupt: AddRef without Add!");
+ }
+
+ QueueRefType queueRef = new QueueRefType();
+ queueRef.setId(ref.refEncoding.queueID);
+
+ message.getBindings().getQueue().add(queueRef);
+
+ }
+
+ private static MessageType getMessage(MessagesExportType journalType, RecordInfo info)
+ {
+ List<MessageType> messages = journalType.getMessage();
+ return messages.get(messages.indexOf(new MessageType(info.id)));
+ }
+
+ private static void handleAckRef(MessagesExportType journalType, RecordInfo info)
+ {
+ JournalStorageManager.AckDescribe ack = (JournalStorageManager.AckDescribe)JournalStorageManager.newObjectEncoding(info);
+
+ MessageType message = getMessage(journalType, info);
+
+ if (message == null)
+ {
+ throw new IllegalStateException("Journal is corrupt: Ack without Add!");
+ }
+
+ QueueRefType queueRef = new QueueRefType();
+ queueRef.setId(ack.refEncoding.queueID);
+
+ message.getAcks().getQueue().add(queueRef);
+
+ }
+
+ private static BindingsJournalType buildXmlBindings(List<RecordInfo> records)
+ {
+
+ BindingsJournalType journalType = new BindingsJournalType();
+
+ // Export Journal
+ for (RecordInfo info : records)
+ {
+
+ switch (info.getUserRecordType())
+ {
+
+ case JournalStorageManager.QUEUE_BINDING_RECORD:
+ handleQBindingRecord(journalType, info);
+ break;
+
+ default:
+ if (log.isDebugEnabled())
+ {
+ log.debug(new StringBuilder().append("Record ")
+ .append(info.id)
+ .append(" is not exported!")
+ .toString());
+ }
+ break;
+
+ }
+
+ }
+
+ return journalType;
+ }
+
+ private static void handleQBindingRecord(BindingsJournalType journalType, RecordInfo info)
+ {
+ JournalStorageManager.PersistentQueueBindingEncoding persistentQueueBindingEncoding = JournalStorageManager.newBindingEncoding(info.id,
+ HornetQBuffers.wrappedBuffer(info.data));
+
+ QueueType queueType = new QueueType();
+ queueType.setId(persistentQueueBindingEncoding.getId());
+
+ SimpleString queueName = persistentQueueBindingEncoding.getQueueName();
+ queueType.setName(queueName != null ? queueName.toString() : "");
+ SimpleString address = persistentQueueBindingEncoding.getAddress();
+ queueType.setAddress(address != null ? address.toString() : "");
+ SimpleString filterString = persistentQueueBindingEncoding.getFilterString();
+ queueType.setFilterString(filterString != null ? filterString.toString() : "");
+
+ journalType.getQueue().add(queueType);
+ }
+
+ /**
+ * Imports messages which were exported as a XML representation using @see #exportMessages(String,String,String).
+ *
+ * This is done by starting an embedded HQ server which connects the queues transparently.
+ *
+ * @param importFile full qualified name of the import file (/path/file)
+ * @param configurationFile the configuration URL of a running HQ server
+ * @param connectorName the name of the connector used to connect to the HQ server
+ * @return the number of imported records
+ * @throws Exception if an error occurs while importing
+ */
+ public static long importMessages(final String importFile, final String configurationFile, final String connectorName) throws Exception
+ {
+ FileConfiguration configuration = null;
+ try
+ {
+ configuration = new FileConfiguration();
+ configuration.setConfigurationUrl(configurationFile);
+ configuration.start();
+ }
+ finally
+ {
+ if (configuration != null)
+ {
+ configuration.stop();
+ }
+ }
+
+ ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(configuration.getConnectorConfigurations()
+ .get(connectorName));
+
+ FileInputStream input = new FileInputStream(new File(importFile));
+
+ return importMessages(input, configuration.getBindingsDirectory(), serverLocator);
+ }
+
+ public static long importMessages(final InputStream importFile,
+ final String bindingsDirectory,
+ final ServerLocator serverLocator) throws Exception
+ {
+ final JAXBContext context = JAXBContext.newInstance(HornetQExport.class);
+
+ final Unmarshaller unmarshaller = context.createUnmarshaller();
+
+ final Map<String, Long> queueBindings = loadBindings(bindingsDirectory);
+
+ ClientSessionFactory sf = null;
+
+ try
+ {
+ sf = serverLocator.createSessionFactory();
+ final ClientSession coreSession = sf.createSession();
+
+ // message notification callback
+ final MessagesExportType.Listener listener = new MessagesExportType.Listener()
+ {
+ public void handleMessage(MessageType message) throws Exception
+ {
+
+ ClientProducer producer = coreSession.createProducer(message.getAddress());
+ ClientMessage clientMessage = generateClientMessage(message);
+ producer.send(clientMessage);
+ producer.close();
+ }
+
+ private ClientMessage generateClientMessage(MessageType message) throws IOException
+ {
+ ClientMessage clientMessage = coreSession.createMessage(message.getType(),
+ message.isDurable(),
+ message.getExpiration(),
+ message.getTimestamp(),
+ message.getPriority());
+ List<QueueRefType> bindings = message.getBindings().getQueue();
+ List<QueueRefType> ackedQueues = message.getAcks().getQueue();
+ List<Long> queues = new ArrayList<Long>(bindings.size());
+
+ // Adress
+ clientMessage.setAddress(new SimpleString(message.getAddress()));
+
+ // Routing
+ // only map Q if not already ACKed
+ for (QueueRefType binding : bindings)
+ {
+ if (!ackedQueues.contains(new QueueRefType(binding.getId())))
+ {
+ queues.add(queueBindings.get(message.getAddress()));
+ }
+ }
+ clientMessage.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, getByteArrayOf(queues));
+
+ // Properties
+ List<PropertyType> properties = message.getProperties().getProperty();
+ for (PropertyType property : properties)
+ {
+ clientMessage.putStringProperty(property.getKey(), property.getValue());
+ }
+
+ // Payload
+ HornetQBuffer buffer = clientMessage.getBodyBuffer();
+ buffer.writeBytes(Base64.decode(message.getPayload(), Base64.DONT_BREAK_LINES | Base64.URL_SAFE));
+
+ // UserID
+ // todo: need to set?
+
+ return clientMessage;
+ }
+
+ private byte[] getByteArrayOf(List<Long> queues) throws IOException
+ {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(bos);
+ try
+ {
+ for (long id : queues)
+ {
+ dos.writeLong(id);
+ }
+ dos.flush();
+ }
+ finally
+ {
+ try
+ {
+ dos.close();
+ bos.close();
+ }
+ catch (IOException e)
+ {
+ // could not close streams
+ }
+ }
+
+ return bos.toByteArray();
+ }
+
+ };
+
+ messageCounter = 0;
+
+ // install the callback on all message instances
+ unmarshaller.setListener(new Unmarshaller.Listener()
+ {
+ public void beforeUnmarshal(Object target, Object parent)
+ {
+ if (target instanceof MessagesExportType)
+ {
+ ((MessagesExportType)target).setMessageListener(listener);
+ }
+ }
+
+ public void afterUnmarshal(Object target, Object parent)
+ {
+ if (target instanceof MessagesExportType)
+ {
+ ((MessagesExportType)target).setMessageListener(null);
+ messageCounter++;
+ }
+ }
+ });
+
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ XMLReader reader = factory.newSAXParser().getXMLReader();
+ reader.setContentHandler(unmarshaller.getUnmarshallerHandler());
+
+ reader.parse(new InputSource(importFile));
+ }
+ finally
+ {
+ if (sf != null)
+ {
+ sf.close();
+ }
+ }
+
+ return messageCounter;
+ }
+
+ private static Map<String, Long> loadBindings(final String bindingsDirectry) throws Exception
+ {
+ final Map<String, Long> queueMapping;
+
+ JournalImpl bindingsJournal = null;
+ try
+ {
+
+ SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDirectry);
+ bindingsJournal = new JournalImpl(FileConfiguration.DEFAULT_JOURNAL_FILE_SIZE,
+ FileConfiguration.DEFAULT_JOURNAL_MIN_FILES,
+ 0,
+ 0,
+ bindingsFF,
+ "hornetq-bindings",
+ "bindings",
+ 1);
+
+ bindingsJournal.start();
+ List<RecordInfo> committedRecordsB = new ArrayList<RecordInfo>();
+ List<PreparedTransactionInfo> preparedTxnB = new ArrayList<PreparedTransactionInfo>();
+ bindingsJournal.load(committedRecordsB, preparedTxnB, null, false);
+
+ queueMapping = new HashMap<String, Long>();
+
+ for (RecordInfo bindingRecord : committedRecordsB)
+ {
+ if (bindingRecord.getUserRecordType() == JournalStorageManager.QUEUE_BINDING_RECORD)
+ {
+ // mapping old/new queue binding
+ PersistentQueueBindingEncoding queueBinding = JournalStorageManager.newBindingEncoding(bindingRecord.id,
+ HornetQBuffers.wrappedBuffer(bindingRecord.data));
+ queueMapping.put(queueBinding.getAddress().toString(), queueBinding.getId());
+ }
+ }
+ }
+ finally
+ {
+ if (bindingsJournal != null)
+ {
+ bindingsJournal.stop();
+ }
+ }
+ return queueMapping;
+ }
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/hornetq-export.xsd
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/hornetq-export.xsd (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/hornetq-export.xsd 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:hornetq"
+ xmlns="urn:hornetq"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:element name="hq-journal-export">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element type="bindings-journalType" name="queues" maxOccurs="1"/>
+ <xsd:element type="messages-journalType" name="messages" maxOccurs="1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="bindings-journalType">
+ <xsd:sequence>
+ <xsd:element type="queueType" name="queue" maxOccurs="unbounded" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="messages-journalType">
+ <xsd:sequence>
+ <xsd:element type="messageType" name="message" maxOccurs="unbounded" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- bindings -->
+
+ <xsd:complexType name="bindingsType">
+ <xsd:sequence>
+ <xsd:element type="queueType" name="queue"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="queueType">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="address" type="xsd:string"/>
+ <xsd:element name="filterString" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:attribute type="xsd:long" name="id" use="required"/>
+ </xsd:complexType>
+
+ <!-- journal -->
+
+ <xsd:complexType name="messageType">
+ <xsd:sequence>
+ <xsd:element type="xsd:string" name="address"/>
+ <xsd:element type="xsd:byte" name="type">
+ <xsd:annotation>
+ <xsd:documentation>see interface Message</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element type="xsd:boolean" name="durable"/>
+ <xsd:element type="xsd:long" name="expiration"/>
+ <xsd:element type="xsd:long" name="timestamp"/>
+ <xsd:element type="propertiesType" name="properties"/>
+ <xsd:element type="xsd:byte" name="priority"/>
+ <xsd:element type="xsd:string" name="payload">
+ <xsd:annotation>
+ <xsd:documentation>ref to byte array in <msgId> directory</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element type="xsd:string" name="userId"/>
+ <xsd:element type="bindType" name="bindings"/>
+ <xsd:element type="ackType" name="acks"/>
+ </xsd:sequence>
+ <xsd:attribute type="xsd:long" name="id"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertiesType">
+ <xsd:sequence>
+ <xsd:element type="propertyType" name="property" maxOccurs="unbounded" minOccurs="1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertyType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute type="xsd:string" name="key" use="required"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="bindType">
+ <xsd:sequence>
+ <xsd:element name="queue" type="queueRefType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="ackType">
+ <xsd:sequence>
+ <xsd:element name="queue" type="queueRefType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="queueRefType">
+ <xsd:attribute name="id" type="xsd:long"/>
+ </xsd:complexType>
+</xsd:schema>
\ No newline at end of file
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/AckType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/AckType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/AckType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,68 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ackType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ackType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="queue" type="{urn:hornetq}queueRefType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "ackType", namespace = "urn:hornetq", propOrder = {
+ "queue"
+})
+public class AckType {
+
+ @XmlElement(namespace = "urn:hornetq")
+ protected List<QueueRefType> queue;
+
+ /**
+ * Gets the value of the queue property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the queue property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getQueue().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link QueueRefType }
+ *
+ *
+ */
+ public List<QueueRefType> getQueue() {
+ if (queue == null) {
+ queue = new ArrayList<QueueRefType>();
+ }
+ return this.queue;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,68 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for bindType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="bindType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="queue" type="{urn:hornetq}queueRefType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "bindType", namespace = "urn:hornetq", propOrder = {
+ "queue"
+})
+public class BindType {
+
+ @XmlElement(namespace = "urn:hornetq")
+ protected List<QueueRefType> queue;
+
+ /**
+ * Gets the value of the queue property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the queue property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getQueue().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link QueueRefType }
+ *
+ *
+ */
+ public List<QueueRefType> getQueue() {
+ if (queue == null) {
+ queue = new ArrayList<QueueRefType>();
+ }
+ return this.queue;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsJournalType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsJournalType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsJournalType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,68 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for bindings-journalType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="bindings-journalType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="queue" type="{urn:hornetq}queueType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "bindings-journalType", namespace = "urn:hornetq", propOrder = {
+ "queue"
+})
+public class BindingsJournalType {
+
+ @XmlElement(namespace = "urn:hornetq")
+ protected List<QueueType> queue;
+
+ /**
+ * Gets the value of the queue property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the queue property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getQueue().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link QueueType }
+ *
+ *
+ */
+ public List<QueueType> getQueue() {
+ if (queue == null) {
+ queue = new ArrayList<QueueType>();
+ }
+ return this.queue;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,61 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for bindingsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="bindingsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="queue" type="{urn:hornetq}queueType"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "bindingsType", namespace = "urn:hornetq", propOrder = {
+ "queue"
+})
+public class BindingsType {
+
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected QueueType queue;
+
+ /**
+ * Gets the value of the queue property.
+ *
+ * @return
+ * possible object is
+ * {@link QueueType }
+ *
+ */
+ public QueueType getQueue() {
+ return queue;
+ }
+
+ /**
+ * Sets the value of the queue property.
+ *
+ * @param value
+ * allowed object is
+ * {@link QueueType }
+ *
+ */
+ public void setQueue(QueueType value) {
+ this.queue = value;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/HornetQExport.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/HornetQExport.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/HornetQExport.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,91 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="queues" type="{urn:hornetq}bindings-journalType"/>
+ * <element name="messages" type="{urn:hornetq}messages-journalType"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "", propOrder = {
+ "queues",
+ "messages"
+})
+ at XmlRootElement(name = "hq-journal-export", namespace = "urn:hornetq")
+public class HornetQExport {
+
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected BindingsJournalType queues;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected MessagesExportType messages;
+
+ /**
+ * Gets the value of the queues property.
+ *
+ * @return
+ * possible object is
+ * {@link BindingsJournalType }
+ *
+ */
+ public BindingsJournalType getQueues() {
+ return queues;
+ }
+
+ /**
+ * Sets the value of the queues property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BindingsJournalType }
+ *
+ */
+ public void setQueues(BindingsJournalType value) {
+ this.queues = value;
+ }
+
+ /**
+ * Gets the value of the messages property.
+ *
+ * @return
+ * possible object is
+ * {@link MessagesExportType }
+ *
+ */
+ public MessagesExportType getMessages() {
+ return messages;
+ }
+
+ /**
+ * Sets the value of the messages property.
+ *
+ * @param value
+ * allowed object is
+ * {@link MessagesExportType }
+ *
+ */
+ public void setMessages(MessagesExportType value) {
+ this.messages = value;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,352 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.server.ServerMessage;
+
+
+/**
+ * <p>Java class for messageType complex type.
+ * <p/>
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p/>
+ * <pre>
+ * <complexType name="messageType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="address" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="type" type="{http://www.w3.org/2001/XMLSchema}byte"/>
+ * <element name="durable" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ * <element name="expiration" type="{http://www.w3.org/2001/XMLSchema}long"/>
+ * <element name="timestamp" type="{http://www.w3.org/2001/XMLSchema}long"/>
+ * <element name="properties" type="{urn:hornetq}propertiesType"/>
+ * <element name="priority" type="{http://www.w3.org/2001/XMLSchema}byte"/>
+ * <element name="payload" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="userId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="bindings" type="{urn:hornetq}bindType"/>
+ * <element name="acks" type="{urn:hornetq}ackType"/>
+ * </sequence>
+ * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}long" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "messageType", namespace = "urn:hornetq", propOrder = {
+ "address",
+ "type",
+ "durable",
+ "expiration",
+ "timestamp",
+ "properties",
+ "priority",
+ "payload",
+ "userId",
+ "bindings",
+ "acks"
+})
+public class MessageType {
+
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String address;
+ @XmlElement(namespace = "urn:hornetq")
+ protected byte type;
+ @XmlElement(namespace = "urn:hornetq")
+ protected boolean durable;
+ @XmlElement(namespace = "urn:hornetq")
+ protected long expiration;
+ @XmlElement(namespace = "urn:hornetq")
+ protected long timestamp;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected PropertiesType properties;
+ @XmlElement(namespace = "urn:hornetq")
+ protected byte priority;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String payload;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String userId;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected BindType bindings = new BindType();
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected AckType acks = new AckType();
+ @XmlAttribute
+ protected Long id;
+
+ public MessageType(ServerMessage msg) {
+ setId(msg.getMessageID());
+
+ setAddress(msg.getAddress() != null ? msg.getAddress().toString() : "");
+
+ setType(msg.getType());
+ setDurable(msg.isDurable());
+ setExpiration(msg.getExpiration());
+ setTimestamp(msg.getTimestamp());
+
+ PropertiesType properties = new PropertiesType();
+ for (SimpleString propName : msg.getPropertyNames()) {
+ PropertyType propertyType = new PropertyType();
+ propertyType.setKey(propName.toString());
+ propertyType.setValue(msg.getSimpleStringProperty(propName).toString());
+ properties.getProperty().add(propertyType);
+ }
+ setProperties(properties);
+ setPriority(msg.getPriority());
+ if (msg.getUserID() != null)
+ {
+ setUserId(msg.getUserID().toString());
+ }
+ else
+ {
+ setUserId("");
+ }
+ }
+
+ /**
+ * Ctor for equals.
+ *
+ * @param id the messageID
+ */
+ public MessageType(long id) {
+ setId(id);
+ }
+
+ /**
+ * Default Ctor.
+ */
+ public MessageType() {
+ }
+
+ /**
+ * Gets the value of the address property.
+ *
+ * @return possible object is
+ * {@link String }
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * Sets the value of the address property.
+ *
+ * @param value allowed object is
+ * {@link String }
+ */
+ public void setAddress(String value) {
+ this.address = value;
+ }
+
+ /**
+ * Gets the value of the type property.
+ */
+ public byte getType() {
+ return type;
+ }
+
+ /**
+ * Sets the value of the type property.
+ */
+ public void setType(byte value) {
+ this.type = value;
+ }
+
+ /**
+ * Gets the value of the durable property.
+ */
+ public boolean isDurable() {
+ return durable;
+ }
+
+ /**
+ * Sets the value of the durable property.
+ */
+ public void setDurable(boolean value) {
+ this.durable = value;
+ }
+
+ /**
+ * Gets the value of the expiration property.
+ */
+ public long getExpiration() {
+ return expiration;
+ }
+
+ /**
+ * Sets the value of the expiration property.
+ */
+ public void setExpiration(long value) {
+ this.expiration = value;
+ }
+
+ /**
+ * Gets the value of the timestamp property.
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Sets the value of the timestamp property.
+ */
+ public void setTimestamp(long value) {
+ this.timestamp = value;
+ }
+
+ /**
+ * Gets the value of the properties property.
+ *
+ * @return possible object is
+ * {@link PropertiesType }
+ */
+ public PropertiesType getProperties() {
+ return properties;
+ }
+
+ /**
+ * Sets the value of the properties property.
+ *
+ * @param value allowed object is
+ * {@link PropertiesType }
+ */
+ public void setProperties(PropertiesType value) {
+ this.properties = value;
+ }
+
+ /**
+ * Gets the value of the priority property.
+ */
+ public byte getPriority() {
+ return priority;
+ }
+
+ /**
+ * Sets the value of the priority property.
+ */
+ public void setPriority(byte value) {
+ this.priority = value;
+ }
+
+ /**
+ * Gets the value of the payload property.
+ *
+ * @return possible object is
+ * {@link String }
+ */
+ public String getPayload() {
+ return payload;
+ }
+
+ /**
+ * Sets the value of the payload property.
+ *
+ * @param value allowed object is
+ * {@link String }
+ */
+ public void setPayload(String value) {
+ this.payload = value;
+ }
+
+ /**
+ * Gets the value of the userId property.
+ *
+ * @return possible object is
+ * {@link String }
+ */
+ public String getUserId() {
+ return userId;
+ }
+
+ /**
+ * Sets the value of the userId property.
+ *
+ * @param value allowed object is
+ * {@link String }
+ */
+ public void setUserId(String value) {
+ this.userId = value;
+ }
+
+ /**
+ * Gets the value of the bindings property.
+ *
+ * @return possible object is
+ * {@link BindType }
+ */
+ public BindType getBindings() {
+ return bindings;
+ }
+
+ /**
+ * Sets the value of the bindings property.
+ *
+ * @param value allowed object is
+ * {@link BindType }
+ */
+ public void setBindings(BindType value) {
+ this.bindings = value;
+ }
+
+ /**
+ * Gets the value of the acks property.
+ *
+ * @return possible object is
+ * {@link AckType }
+ */
+ public AckType getAcks() {
+ return acks;
+ }
+
+ /**
+ * Sets the value of the acks property.
+ *
+ * @param value allowed object is
+ * {@link AckType }
+ */
+ public void setAcks(AckType value) {
+ this.acks = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return possible object is
+ * {@link Long }
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value allowed object is
+ * {@link Long }
+ */
+ public void setId(Long value) {
+ this.id = value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ MessageType that = (MessageType) o;
+
+ if (!id.equals(that.id)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,89 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for messages-journalType complex type.
+ * <p/>
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p/>
+ * <pre>
+ * <complexType name="messages-journalType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="message" type="{urn:hornetq}messageType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "messages-journalType", namespace = "urn:hornetq", propOrder = {
+ "message"
+})
+public class MessagesExportType {
+
+ @XmlElement(namespace = "urn:hornetq")
+ protected List<MessageType> message;
+
+ /**
+ * Gets the value of the message property.
+ * <p/>
+ * <p/>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the message property.
+ * <p/>
+ * <p/>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getMessage().add(newItem);
+ * </pre>
+ * <p/>
+ * <p/>
+ * <p/>
+ * Objects of the following type(s) are allowed in the list
+ * {@link MessageType }
+ */
+ public List<MessageType> getMessage() {
+ if (message == null) {
+ message = new ArrayList<MessageType>();
+ }
+ return this.message;
+ }
+
+ /**
+ * Install a listener for messages on this object. If listener is null, the listener
+ * is removed again.
+ */
+ public void setMessageListener(final Listener listener) {
+ message = (listener == null) ? null : new ArrayList<MessageType>() {
+ public boolean add(MessageType o) {
+ try {
+ listener.handleMessage(o);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("Could not handle message " + o);
+ }
+ return false;
+ }
+ };
+ }
+
+ /**
+ * This listener is invoked every time a new message is unmarshalled.
+ */
+ public static interface Listener {
+ void handleMessage(MessageType message) throws Exception;
+ }
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/ObjectFactory.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/ObjectFactory.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/ObjectFactory.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,119 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.hornetq.core.journal.export package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+ at XmlRegistry
+public class ObjectFactory {
+
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.hornetq.core.journal.export
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link BindType }
+ *
+ */
+ public BindType createBindType() {
+ return new BindType();
+ }
+
+ /**
+ * Create an instance of {@link HornetQExport }
+ *
+ */
+ public HornetQExport createHqJournalExport() {
+ return new HornetQExport();
+ }
+
+ /**
+ * Create an instance of {@link AckType }
+ *
+ */
+ public AckType createAckType() {
+ return new AckType();
+ }
+
+ /**
+ * Create an instance of {@link PropertiesType }
+ *
+ */
+ public PropertiesType createPropertiesType() {
+ return new PropertiesType();
+ }
+
+ /**
+ * Create an instance of {@link PropertyType }
+ *
+ */
+ public PropertyType createPropertyType() {
+ return new PropertyType();
+ }
+
+ /**
+ * Create an instance of {@link MessageType }
+ *
+ */
+ public MessageType createMessageType() {
+ return new MessageType();
+ }
+
+ /**
+ * Create an instance of {@link QueueRefType }
+ *
+ */
+ public QueueRefType createQueueRefType() {
+ return new QueueRefType();
+ }
+
+ /**
+ * Create an instance of {@link QueueType }
+ *
+ */
+ public QueueType createQueueType() {
+ return new QueueType();
+ }
+
+ /**
+ * Create an instance of {@link BindingsType }
+ *
+ */
+ public BindingsType createBindingsType() {
+ return new BindingsType();
+ }
+
+ /**
+ * Create an instance of {@link BindingsJournalType }
+ *
+ */
+ public BindingsJournalType createBindingsJournalType() {
+ return new BindingsJournalType();
+ }
+
+ /**
+ * Create an instance of {@link MessagesExportType }
+ *
+ */
+ public MessagesExportType createMessagesJournalType() {
+ return new MessagesExportType();
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertiesType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertiesType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertiesType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,68 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for propertiesType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="propertiesType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="property" type="{urn:hornetq}propertyType" maxOccurs="unbounded"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "propertiesType", namespace = "urn:hornetq", propOrder = {
+ "property"
+})
+public class PropertiesType {
+
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected List<PropertyType> property;
+
+ /**
+ * Gets the value of the property property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the property property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getProperty().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link PropertyType }
+ *
+ *
+ */
+ public List<PropertyType> getProperty() {
+ if (property == null) {
+ property = new ArrayList<PropertyType>();
+ }
+ return this.property;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertyType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertyType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertyType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,86 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+
+/**
+ * <p>Java class for propertyType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="propertyType">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="key" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "propertyType", namespace = "urn:hornetq", propOrder = {
+ "value"
+})
+public class PropertyType {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(required = true)
+ protected String key;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the key property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Sets the value of the key property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setKey(String value) {
+ this.key = value;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueRefType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueRefType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueRefType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,74 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for queueRefType complex type.
+ * <p/>
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p/>
+ * <pre>
+ * <complexType name="queueRefType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}long" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "queueRefType", namespace = "urn:hornetq")
+public class QueueRefType {
+
+ @XmlAttribute
+ protected Long id;
+
+ public QueueRefType() {
+ }
+
+ public QueueRefType(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return possible object is
+ * {@link Long }
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value allowed object is
+ * {@link Long }
+ */
+ public void setId(Long value) {
+ this.id = value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ QueueRefType that = (QueueRefType) o;
+
+ if (!id.equals(that.id)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,137 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for queueType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="queueType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="address" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="filterString" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * </sequence>
+ * <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}long" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "queueType", namespace = "urn:hornetq", propOrder = {
+ "name",
+ "address",
+ "filterString"
+})
+public class QueueType {
+
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String name;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String address;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String filterString;
+ @XmlAttribute(required = true)
+ protected long id;
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ /**
+ * Gets the value of the address property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * Sets the value of the address property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAddress(String value) {
+ this.address = value;
+ }
+
+ /**
+ * Gets the value of the filterString property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getFilterString() {
+ return filterString;
+ }
+
+ /**
+ * Sets the value of the filterString property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setFilterString(String value) {
+ this.filterString = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ */
+ public void setId(long value) {
+ this.id = value;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.persistence;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.core.persistence.tools.ManageDataTool;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.jms.client.HornetQJMSConnectionFactory;
+import org.hornetq.tests.util.ServiceTestBase;
+
+/**
+ * UnitTest for importing/exporting journal messages.
+ * <p/>
+ * Scenario:
+ *
+ * @author Torben Jaeger</a>
+ * @author Clebert Suconic</a>
+ */
+public class ExportDataTest extends ServiceTestBase {
+
+ protected static HornetQJMSConnectionFactory myCf;
+
+ public void testExportImport() throws Exception {
+
+ HornetQServer server = createServer(true);
+
+
+ server.start();
+
+ ServerLocator locator = createNonHALocator(false);
+ ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSession session = null;
+
+ try
+ {
+ session = sf.createSession();
+
+ session.createQueue("ADDRESS", "Q1");
+ session.createQueue("ADDRESS", "Q2");
+
+ ClientProducer prod = session.createProducer("ADDRESS");
+
+ for (int i = 0 ; i < 100; i++)
+ {
+ ClientMessage msg = session.createMessage(true);
+ msg.putStringProperty("prop", "TST1");
+ msg.putIntProperty("count", i);
+ for (int b = 0; b < 1024; b++)
+ {
+ msg.getBodyBuffer().writeByte(getSamplebyte(b));
+ }
+ prod.send(msg);
+ }
+
+ session.start();
+ ClientConsumer cons = session.createConsumer("Q1");
+
+ for (int i = 0; i < 50; i++)
+ {
+ ClientMessage msg = cons.receive(1000);
+ assertNotNull(msg);
+ msg.acknowledge();
+ assertEquals(i, msg.getIntProperty("count").intValue());
+ }
+
+ session.commit();
+
+ session.close();
+ sf.close();
+ locator.close();
+
+ server.stop();
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+
+ ManageDataTool.exportMessages(getBindingsDir(), getJournalDir(), bout);
+
+ InputStream is = new ByteArrayInputStream(bout.toByteArray());
+
+ clearData();
+
+ server = createServer(true);
+
+ server.start();
+
+ locator = createInVMNonHALocator();
+
+ ManageDataTool.importMessages(is, getBindingsDir(), locator);
+
+ ClientSessionFactory csf = locator.createSessionFactory();
+
+ session = csf.createSession();
+ session.start();
+ cons = session.createConsumer("Q1");
+
+ for (int i = 50; i < 100; i++)
+ {
+ ClientMessage msg = cons.receive(1000);
+ assertNotNull(msg);
+ msg.acknowledge();
+ assertEquals(i, msg.getIntProperty("count").intValue());
+ }
+
+
+
+ }
+ finally
+ {
+ sf.close();
+ locator.close();
+ }
+
+ }
+
+ public void testImport() {
+ }
+}
More information about the hornetq-commits
mailing list