qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ai...@apache.org
Subject svn commit: r619823 [4/19] - in /incubator/qpid/branches/thegreatmerge/qpid: ./ cpp/ dotnet/ dotnet/Qpid.Buffer.Tests/Properties/ dotnet/Qpid.Buffer/Properties/ dotnet/Qpid.Client.Tests/ dotnet/Qpid.Client.Tests/Channel/ dotnet/Qpid.Client.Tests/Common...
Date Fri, 08 Feb 2008 10:10:11 GMT
Modified: incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/Generator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/Generator.java?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/Generator.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/Generator.java Fri Feb  8 02:09:37 2008
@@ -1,848 +1,857 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF 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.apache.qpid.gentools;
-
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.w3c.dom.Node;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.LineNumberReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-
-public abstract class Generator implements LanguageConverter
-{
-    protected static String CR = Utils.LINE_SEPARATOR;
-
-
-    private static final Map<String, Integer> FIXED_SIZE_TYPES = new HashMap<String, Integer>();
-
-    static
-    {
-        FIXED_SIZE_TYPES.put("bit", 1);
-        FIXED_SIZE_TYPES.put("bitfield", 1);
-        FIXED_SIZE_TYPES.put("long", 4);
-        FIXED_SIZE_TYPES.put("longlong", 8);
-        FIXED_SIZE_TYPES.put("octet", 1);
-        FIXED_SIZE_TYPES.put("short", 2);
-        FIXED_SIZE_TYPES.put("timestamp", 8);
-
-    }
-
-    private String _templateDirectory;
-    private String _outputDirectory;
-
-    public AmqpDomainMap getDomainMap()
-    {
-        return _domainMap;
-    }
-
-    public AmqpConstantSet getConstantSet()
-    {
-        return _constantSet;
-    }
-
-    public AmqpModel getModel()
-    {
-        return _model;
-    }
-
-    abstract public String getNativeType(String type);
-
-    abstract public String getEncodingType(String type);
-
-
-
-    protected static enum EnumConstOutputTypes
-    {
-        OUTPUT_STRING,
-        OUTPUT_INTEGER,
-        OUTPUT_DOUBLE;
-    }
-
-    ;
-
-    public static enum TemplateType
-    {
-        model("model"),
-        clazz("class"),
-        method("method"),
-        field("field");
-
-        private final String _name;
-
-        private TemplateType(String name)
-        {
-            _name = name;
-        }
-
-        public String getName()
-        {
-            return _name;
-        }
-    }
-
-    ;
-
-
-    public static interface Factory<X extends Generator>
-    {
-        public X newInstance();
-    }
-
-
-    protected static final class NamedTemplate
-    {
-        private final String _name;
-        private final String _template;
-        private final File _file;
-
-
-        public NamedTemplate(String relativePath, File templateFile)
-        {
-            _file = templateFile;
-            _name = relativePath + Utils.FILE_SEPARATOR + templateFile.getName();
-
-            _template = loadTemplate(templateFile);
-        }
-
-
-        public String getName()
-        {
-            return _name;
-        }
-
-        public String getTemplate()
-        {
-            return _template;
-        }
-
-
-        public File getFile()
-        {
-            return _file;
-        }
-
-    }
-
-
-    private static final String VELOCITY_TEMPLATE_SUFFIX = ".vm";
-    private static final String STANDARD_TEMPLATE_SUFFIX = ".tmpl";
-    private static FilenameFilter _tmplFileFilter = new FilenameFilter()
-    {
-
-        public boolean accept(File dir, String name)
-        {
-            return name.endsWith(STANDARD_TEMPLATE_SUFFIX) || name.endsWith(VELOCITY_TEMPLATE_SUFFIX);
-        }
-    };
-
-
-    // This string is reproduced in every generated file as a comment
-    // TODO: Tie the version info into the build system.
-    protected static final String GENERATOR_INFO = "Qpid Gentools v.0.1";
-
-
-    private final Map<TemplateType, Collection<NamedTemplate>> _templates =
-            new EnumMap<TemplateType, Collection<NamedTemplate>>(TemplateType.class);
-
-    private final Map<TemplateType, Collection<NamedTemplate>> _versionSpecificTemplates =
-            new EnumMap<TemplateType, Collection<NamedTemplate>>(TemplateType.class);
-
-
-    private final AmqpVersionSet _versionSet;
-
-    private final AmqpDomainMap _domainMap;
-    private final Map<AmqpVersion, AmqpDomainMap> _versionToDomainMapMap = new HashMap<AmqpVersion, AmqpDomainMap>();
-
-    private final AmqpConstantSet _constantSet;
-    private final Map<AmqpVersion, AmqpConstantSet> _versionToConstantSetMap = new HashMap<AmqpVersion, AmqpConstantSet>();
-
-
-    public AmqpVersionSet getVersionSet()
-    {
-        return _versionSet;
-    }
-
-    private final AmqpModel _model;
-    private final Map<AmqpVersion, AmqpModel> _versionToModelMap = new HashMap<AmqpVersion, AmqpModel>();
-
-    protected int generatedFileCounter;
-
-    public Generator()
-    {
-        _versionSet = new AmqpVersionSet();
-        _model = new AmqpModel(this);
-        _constantSet = new AmqpConstantSet(this);
-        _domainMap = new AmqpDomainMap(this);
-
-        generatedFileCounter = 0;
-    }
-
-//    public final AmqpVersionSet getVersionSet()
-//    {
-//        return _versionSet;
-//    }
-
-
-    public void addVersion(AmqpVersion version)
-    {
-        _versionSet.add(version);
-        if (!_versionToModelMap.containsKey(version))
-        {
-            _versionToModelMap.put(version, new AmqpModel(this));
-        }
-        if (!_versionToDomainMapMap.containsKey(version))
-        {
-            _versionToDomainMapMap.put(version, new AmqpDomainMap(this));
-        }
-        if (!_versionToConstantSetMap.containsKey(version))
-        {
-            _versionToConstantSetMap.put(version, new AmqpConstantSet(this));
-        }
-    }
-
-    public int getNumberGeneratedFiles()
-    {
-        return generatedFileCounter;
-    }
-
-//	public AmqpDomainMap getDomainMap()
-//	{
-//		return _domainMap;
-//	}
-//
-//    public AmqpConstantSet getConstantSet()
-//    {
-//        return _constantSet;
-//    }
-//
-//
-//	public AmqpModel getModel()
-//	{
-//		return _model;
-//	}
-
-    public void initializeTemplates() throws IOException
-    {
-
-        for (TemplateType type : EnumSet.allOf(TemplateType.class))
-        {
-            ArrayList<NamedTemplate> typeTemplates = new ArrayList<NamedTemplate>();
-            _templates.put(type, typeTemplates);
-            ArrayList<NamedTemplate> versionSpecificTypeTemplates = new ArrayList<NamedTemplate>();
-            _versionSpecificTemplates.put(type, versionSpecificTypeTemplates);
-
-            File templateDirectory = new File(getTemplateDirectory() + Utils.FILE_SEPARATOR + type.getName());
-            File versionTemplateDirectory = new File(getTemplateDirectory() + Utils.FILE_SEPARATOR + type.getName() + Utils.FILE_SEPARATOR + "version");
-
-            File[] templateFiles = templateDirectory.listFiles(_tmplFileFilter);
-
-            File[] versionTemplateFiles = new File[0];
-            if (versionTemplateDirectory.exists())
-            {
-                versionTemplateFiles = versionTemplateDirectory.listFiles(_tmplFileFilter);
-            }
-
-			if(templateFiles != null)
-			{
-	            for (File templateFile : templateFiles)
-	            {
-	                System.out.println(type.getName() + " template file(s):");
-	                System.out.println("  " + templateFile.getCanonicalPath());
-	                typeTemplates.add(new NamedTemplate(type.getName(), templateFile));
-	            }
-			}
-
-            if(versionTemplateFiles != null)
-			{
-				for (File versionTemplateFile : versionTemplateFiles)
-	            {
-	                System.out.println(type.getName() + " template file(s):");
-	                System.out.println("  " + versionTemplateFile.getCanonicalPath());
-	                versionSpecificTypeTemplates.add(new NamedTemplate(type.getName() + Utils.FILE_SEPARATOR + "version", versionTemplateFile));
-	            }
-			}
-
-        }
-    }
-
-    public String getTemplateDirectory()
-    {
-        return _templateDirectory;
-    }
-
-
-    public void setTemplateDirectory(String templateDirectory)
-    {
-        _templateDirectory = templateDirectory;
-    }
-
-
-    public void setOutputDirectory(String outputDirectory)
-    {
-        _outputDirectory = outputDirectory;
-    }
-
-    public void generate()
-    {
-        prepareTargetDirectory(new File(_outputDirectory), true);
-        System.out.println("Generation directory: " + _outputDirectory);
-
-
-        processModelTemplates(_templates);
-
-        for (AmqpClass amqpClass : _model.getClassMap().values())
-        {
-            processClassTemplates(_templates, amqpClass);
-
-            for (AmqpMethod amqpMethod : amqpClass.getMethodMap().values())
-            {
-                processMethodTemplates(_templates, amqpClass, amqpMethod);
-
-                for (AmqpField amqpField : amqpMethod.getFieldMap().values())
-                {
-                    processFieldTemplates(_templates, amqpClass, amqpMethod, amqpField, null);
-                }
-            }
-        }
-
-
-        for (AmqpVersion version : _versionSet)
-        {
-            AmqpModel model = _versionToModelMap.get(version);
-            processModelTemplates(_versionSpecificTemplates, version);
-
-            for (AmqpClass amqpClass : model.getClassMap().values())
-            {
-                processClassTemplates(_versionSpecificTemplates, amqpClass, version);
-
-                for (AmqpMethod amqpMethod : amqpClass.getMethodMap().values())
-                {
-                    processMethodTemplates(_versionSpecificTemplates, amqpClass, amqpMethod, version);
-
-                    for (AmqpField amqpField : amqpMethod.getFieldMap().values())
-                    {
-                        processFieldTemplates(_versionSpecificTemplates, amqpClass, amqpMethod, amqpField, version);
-                    }
-                }
-            }
-
-        }
-    }
-
-    private void processMethodTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpClass amqpClass, AmqpMethod amqpMethod, AmqpVersion version)
-    {
-        for (NamedTemplate template : templates.get(TemplateType.method))
-        {
-            if(isVelocityTemplate(template))
-            {
-                processVelocityTemplate(template,version,amqpClass,amqpMethod,null);
-            }
-            else
-            {
-                processMethodTemplate(template, amqpClass, amqpMethod);
-            }
-        }
-        
-    }
-
-    private void processClassTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpClass amqpClass, AmqpVersion version)
-    {
-        for (NamedTemplate template : templates.get(TemplateType.clazz))
-        {
-            if(isVelocityTemplate(template))
-            {
-                processVelocityTemplate(template,version,amqpClass,null,null);
-            }
-            else
-            {
-                processClassTemplate(template, amqpClass);
-            }
-        }
-
-    }
-
-
-    private void processModelTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpVersion version)
-    {
-        for (NamedTemplate template : templates.get(TemplateType.model))
-        {
-            if (isVelocityTemplate(template))
-            {
-                processModelVelocityTemplate(template, version);
-            }
-            else
-            {
-                processModelTemplate(template, version);
-            }
-        }
-    }
-
-    abstract void processModelTemplate(NamedTemplate template, AmqpVersion version);
-
-
-    protected void processModelTemplates(Map<TemplateType, Collection<NamedTemplate>> templates)
-    {
-        for (NamedTemplate template : templates.get(TemplateType.model))
-        {
-            if (isVelocityTemplate(template))
-            {
-                processModelVelocityTemplate(template, null);
-            }
-            else
-            {
-                processModelTemplate(template);
-            }
-        }
-    }
-
-    private boolean isVelocityTemplate(NamedTemplate template)
-    {
-        return template.getName().endsWith(VELOCITY_TEMPLATE_SUFFIX);
-    }
-
-    private void processModelVelocityTemplate(NamedTemplate template, AmqpVersion version)
-    {
-        processVelocityTemplate(template,version,null,null,null);
-    }
-
-    private void processVelocityTemplate(NamedTemplate template, AmqpVersion version,
-                                              AmqpClass amqpClass, AmqpMethod amqpMethod, AmqpField amqpField)
-    {
-
-        VelocityContext context = new VelocityContext();
-
-        AmqpModel model = _model;
-        if(version != null)
-        {
-            model = _versionToModelMap.get(version);
-        }
-        context.put("model", model);
-        context.put("generator", GENERATOR_INFO);
-
-        if (version != null)
-        {
-            context.put("version", version);
-        }
-        if(amqpClass != null)
-        {
-            context.put("amqpClass", amqpClass);
-        }
-
-        if(amqpClass != null)
-        {
-            context.put("amqpMethod", amqpMethod);
-        }
-
-
-        StringWriter sw = new StringWriter();
-
-
-        try
-        {
-            Template velocityTemplate = Velocity.getTemplate(template.getName());
-            velocityTemplate.merge(context, sw);
-            String filename = String.valueOf(context.get("filename"));
-            FileWriter outputFileWriter = new FileWriter(getOutputDirectory() + Utils.FILE_SEPARATOR + filename);
-            outputFileWriter.append(sw.toString());
-            outputFileWriter.close();
-
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-
-
-    }
-
-
-    protected void processClassTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpClass amqpClass)
-    {
-        for (NamedTemplate template : templates.get(TemplateType.clazz))
-        {
-            if(isVelocityTemplate(template))
-            {
-                processVelocityTemplate(template,null,amqpClass,null,null);
-            }
-            else
-            {
-                processClassTemplate(template, amqpClass);
-            }
-        }
-    }
-
-    protected void processMethodTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpClass amqpClass, AmqpMethod amqpMethod)
-    {
-        for (NamedTemplate template : templates.get(TemplateType.method))
-        {
-            if(isVelocityTemplate(template))
-            {
-                processVelocityTemplate(template,null,amqpClass,amqpMethod,null);
-            }
-            else
-            {
-                processMethodTemplate(template, amqpClass, amqpMethod);
-            }
-        }
-    }
-
-
-    protected void processFieldTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpClass amqpClass, AmqpMethod amqpMethod, AmqpField amqpField, AmqpVersion amqpVersion)
-    {
-        for (NamedTemplate template : templates.get(TemplateType.field))
-        {
-            if(isVelocityTemplate(template))
-            {
-                processVelocityTemplate(template,amqpVersion,amqpClass,amqpMethod,amqpField);
-            }
-            else
-            {
-                processTemplate(template, amqpClass, amqpMethod, amqpField, amqpVersion);
-            }
-        }
-    }
-
-
-    protected void processVersionList(StringBuffer sb, int tokStart, int tokEnd)
-    {
-        int lend = sb.indexOf(Utils.LINE_SEPARATOR, tokStart) + 1; // Include cr at end of line
-        String tline = sb.substring(tokEnd, lend); // Line excluding line marker, including cr
-        sb.delete(tokStart, lend);
-
-        for (AmqpVersion v : _versionSet)
-        {
-            // Insert copy of target line
-            StringBuffer isb = new StringBuffer(tline);
-            if (isb.indexOf("${protocol-version-list-entry}") >= 0)
-            {
-                String versionListEntry = "       { ${major}, ${minor} }" +
-                                          (v.equals(_versionSet.last()) ? "" : ",");
-                replaceToken(isb, "${protocol-version-list-entry}", String.valueOf(versionListEntry));
-            }
-            if (isb.indexOf("${major}") >= 0)
-            {
-                replaceToken(isb, "${major}", String.valueOf(v.getMajor()));
-            }
-            if (isb.indexOf("${minor}") >= 0)
-            {
-                replaceToken(isb, "${minor}", String.valueOf(v.getMinor()));
-            }
-            sb.insert(tokStart, isb.toString());
-            tokStart += isb.length();
-        }
-    }
-
-    // Helper functions common to all generators
-
-    protected static void prepareTargetDirectory(File dir, boolean createFlag)
-    {
-        if (dir.exists())
-        {
-            if (!dir.isDirectory())
-            {
-                throw new TargetDirectoryException("\"" + dir.getAbsolutePath() +
-                                                   "\" exists, but is not a directory.");
-            }
-        }
-        else if (createFlag) // Create dir
-        {
-            if (!dir.mkdirs())
-            {
-                throw new TargetDirectoryException("Unable to create directory \"" +
-                                                   dir.getAbsolutePath() + "\".");
-            }
-        }
-        else
-        {
-            throw new TargetDirectoryException("Directory \"" + dir.getAbsolutePath() +
-                                               "\" not found.");
-        }
-
-    }
-
-    protected void processAllLists(StringBuffer sb, AmqpClass thisClass, AmqpMethod method, AmqpVersion version)
-    {
-        AmqpModel model = (version == null) ? _model : _versionToModelMap.get(version);
-
-
-        int lstart = sb.indexOf("%{");
-        while (lstart != -1)
-        {
-            int lend = sb.indexOf("}", lstart + 2);
-            if (lend > 0)
-            {
-                String listToken = sb.substring(lstart + 2, lend);
-                if (listToken.compareTo("VLIST") == 0)
-                {
-                    processVersionList(sb, lstart, lend + 1);
-                }
-                else if (listToken.compareTo("CLIST") == 0)
-                {
-                    processClassList(sb, lstart, lend + 1, model, version);
-                }
-                else if (listToken.compareTo("MLIST") == 0)
-                {
-                    processMethodList(sb, lstart, lend + 1, thisClass);
-                }
-                else if (listToken.compareTo("FLIST") == 0)
-                {
-                    // Pass the FieldMap from either a class or a method.
-                    // If this is called from a class-level template, we assume that the
-                    // class field list is required. In this case, method will be null.
-                    processFieldList(sb, lstart, lend + 1,
-                                     (method == null ? thisClass.getFieldMap() : method.getFieldMap()),
-                                     version);
-                }
-                else if (listToken.compareTo("TLIST") == 0)
-                {
-                    processConstantList(sb, lstart, lend + 1, _constantSet);
-                }
-                else
-                {
-                    throw new AmqpTemplateException("Unknown list token \"%{" + listToken +
-                                                    "}\" found in template at index " + lstart + ".");
-                }
-            }
-            lstart = sb.indexOf("%{", lstart + 1);
-        }
-    }
-
-    protected void processAllTokens(StringBuffer sb, AmqpClass thisClass, AmqpMethod method, AmqpField field,
-                                    AmqpVersion version)
-    {
-        int lstart = sb.indexOf("${");
-        while (lstart != -1)
-        {
-            int lend = sb.indexOf("}", lstart + 2);
-            if (lend > 0)
-            {
-                String token = sb.substring(lstart, lend + 1);
-                replaceToken(sb, lstart, token, processToken(token, thisClass, method, field, version));
-            }
-            lstart = sb.indexOf("${", lstart);
-        }
-    }
-
-    protected static void writeTargetFile(StringBuffer sb, File f)
-    {
-        try
-        {
-            f.getParentFile().mkdirs();
-            FileWriter fw = new FileWriter(f);
-            fw.write(sb.toString().toCharArray());
-            fw.flush();
-            fw.close();
-        }
-        catch (IOException e)
-        {
-            throw new AmqpTemplateException(e.getMessage());
-        }
-    }
-
-
-    protected static String getTemplateFileName(StringBuffer sb)
-    {
-        if (sb.charAt(0) != '&')
-        {
-            throw new AmqpTemplateException("No filename marker &{filename} found at start of template.");
-        }
-        int cr = sb.indexOf(Utils.LINE_SEPARATOR);
-        if (cr < 0)
-        {
-            throw new AmqpTemplateException("Bad template structure - unable to find first line.");
-        }
-        String fileName = sb.substring(2, cr - 1);
-        sb.delete(0, cr + 1);
-        return fileName;
-    }
-
-    protected static void replaceToken(StringBuffer sb, String token, String replacement)
-    {
-        replaceToken(sb, 0, token, replacement);
-    }
-
-    protected static void replaceToken(StringBuffer sb, int index, String token, String replacement)
-    {
-        if (replacement != null)
-        {
-            int start = sb.indexOf(token, index);
-            if (start != -1)
-            {
-                int len = token.length();
-                // Find first letter in token and determine if it is capitalized
-                char firstTokenLetter = getFirstLetter(token);
-                if (firstTokenLetter != 0 && Character.isUpperCase(firstTokenLetter))
-                {
-                    sb.replace(start, start + len, Utils.firstUpper(replacement));
-                }
-                else
-                {
-                    sb.replace(start, start + len, replacement);
-                }
-            }
-        }
-    }
-
-    private static char getFirstLetter(String str)
-    {
-        int len = str.length();
-        int index = 0;
-        char tokChar = str.charAt(index);
-        while (!Character.isLetter(tokChar) && index < len - 1)
-        {
-            tokChar = str.charAt(++index);
-        }
-        if (Character.isLetter(tokChar))
-        {
-            return tokChar;
-        }
-        return 0;
-    }
-
-    private static String loadTemplate(File f)
-    {
-        try
-        {
-            StringBuffer sb = new StringBuffer();
-            FileReader fr = new FileReader(f);
-            LineNumberReader lnr = new LineNumberReader(fr);
-            String line = lnr.readLine();
-            while (line != null)
-            {
-
-                sb.append(line);
-                sb.append(Utils.LINE_SEPARATOR);
-
-                line = lnr.readLine();
-            }
-            lnr.close();
-            fr.close();
-            return sb.toString();
-        }
-        catch (FileNotFoundException e)
-        {
-            throw new AmqpTemplateException("File not found: " + e.getMessage());
-        }
-        catch (IOException e)
-        {
-            throw new AmqpTemplateException("IOException: " + e.getMessage());
-        }
-    }
-
-    public String getDomainType(String domainName, AmqpVersion version)
-    {
-        if (version == null)
-        {
-            version = _versionSet.first();
-        }
-        return getDomainMap().getDomainType(domainName, version);
-    }
-
-
-    public void addFromNode(Node amqpNode, AmqpVersion version)
-    {
-        // 1c. Extract domains
-        getConstantSet().addFromNode(amqpNode, 0, version);
-        _versionToConstantSetMap.get(version).addFromNode(amqpNode, 0, version);
-
-        // 1d. Extract domains
-        getDomainMap().addFromNode(amqpNode, 0, version);
-        _versionToDomainMapMap.get(version).addFromNode(amqpNode, 0, version);
-
-        // 1e. Extract class/method/field heirarchy
-        getModel().addFromNode(amqpNode, 0, version);
-        _versionToModelMap.get(version).addFromNode(amqpNode, 0, version);
-    }
-
-
-    public String getOutputDirectory()
-    {
-        return _outputDirectory;
-    }
-
-    public String prepareConstantName(String constantName)
-    {
-        return prepareDomainName(constantName);
-    }
-
-
-    public boolean isFixedSizeType(String type)
-    {
-        return FIXED_SIZE_TYPES.containsKey(type);
-    }
-
-
-    public int getTypeSize(String type)
-    {
-        return FIXED_SIZE_TYPES.get(type);
-    }
-
-
-
-    // Model-level template processing
-    abstract protected void processModelTemplate(NamedTemplate template);
-
-    // Class-level template processing
-    abstract protected void processClassTemplate(NamedTemplate template, AmqpClass thisClass);
-
-    // Method-level template processing
-    abstract protected void processMethodTemplate(NamedTemplate template, AmqpClass thisClass,
-                                                  AmqpMethod method);
-
-    // Field-level template processing
-    abstract protected void processTemplate(NamedTemplate template, AmqpClass thisClass,
-                                            AmqpMethod method, AmqpField field, AmqpVersion version);
-
-    abstract protected String prepareFilename(String filenameTemplate, AmqpClass thisClass, AmqpMethod method,
-                                              AmqpField field, AmqpVersion version);
-
-    abstract protected String processToken(String token, AmqpClass thisClass, AmqpMethod method,
-                                           AmqpField field, AmqpVersion version);
-
-    abstract protected void processClassList(StringBuffer sb, int listMarkerStartIndex, int listMarkerEndIndex,
-                                             AmqpModel model, AmqpVersion version);
-
-    abstract protected void processMethodList(StringBuffer sb, int listMarkerStartIndex, int listMarkerEndIndex,
-                                              AmqpClass thisClass);
-
-
-    abstract protected void processFieldList(StringBuffer sb, int listMarkerStartIndex, int listMarkerEndIndex,
-                                             AmqpFieldMap fieldMap, AmqpVersion version);
-
-    abstract protected void processConstantList(StringBuffer sb, int listMarkerStartIndex, int listMarkerEndIndex,
-                                                AmqpConstantSet constantSet);
-
-
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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.apache.qpid.gentools;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.w3c.dom.Node;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class Generator implements LanguageConverter
+{
+    protected static String CR = Utils.LINE_SEPARATOR;
+
+
+    private static final Map<String, Integer> FIXED_SIZE_TYPES = new HashMap<String, Integer>();
+
+    static
+    {
+        FIXED_SIZE_TYPES.put("bit", 1);
+        FIXED_SIZE_TYPES.put("bitfield", 1);
+        FIXED_SIZE_TYPES.put("long", 4);
+        FIXED_SIZE_TYPES.put("longlong", 8);
+        FIXED_SIZE_TYPES.put("octet", 1);
+        FIXED_SIZE_TYPES.put("short", 2);
+        FIXED_SIZE_TYPES.put("timestamp", 8);
+
+    }
+
+    private String _templateDirectory;
+    private String _outputDirectory;
+
+    public AmqpDomainMap getDomainMap()
+    {
+        return _domainMap;
+    }
+
+    public AmqpConstantSet getConstantSet()
+    {
+        return _constantSet;
+    }
+
+    public AmqpModel getModel()
+    {
+        return _model;
+    }
+
+    abstract public String getNativeType(String type);
+
+    abstract public String getEncodingType(String type);
+
+
+
+    protected static enum EnumConstOutputTypes
+    {
+        OUTPUT_STRING,
+        OUTPUT_INTEGER,
+        OUTPUT_DOUBLE;
+    }
+
+    ;
+
+    public static enum TemplateType
+    {
+        model("model"),
+        clazz("class"),
+        method("method"),
+        field("field");
+
+        private final String _name;
+
+        private TemplateType(String name)
+        {
+            _name = name;
+        }
+
+        public String getName()
+        {
+            return _name;
+        }
+    }
+
+    ;
+
+
+    public static interface Factory<X extends Generator>
+    {
+        public X newInstance();
+    }
+
+
+    protected static final class NamedTemplate
+    {
+        private final String _name;
+        private final String _template;
+        private final File _file;
+
+
+        public NamedTemplate(String relativePath, File templateFile)
+        {
+            _file = templateFile;
+            _name = relativePath + Utils.FILE_SEPARATOR + templateFile.getName();
+
+            _template = loadTemplate(templateFile);
+        }
+
+
+        public String getName()
+        {
+            return _name;
+        }
+
+        public String getTemplate()
+        {
+            return _template;
+        }
+
+
+        public File getFile()
+        {
+            return _file;
+        }
+
+    }
+
+
+    private static final String VELOCITY_TEMPLATE_SUFFIX = ".vm";
+    private static final String STANDARD_TEMPLATE_SUFFIX = ".tmpl";
+    private static FilenameFilter _tmplFileFilter = new FilenameFilter()
+    {
+
+        public boolean accept(File dir, String name)
+        {
+            return name.endsWith(STANDARD_TEMPLATE_SUFFIX) || name.endsWith(VELOCITY_TEMPLATE_SUFFIX);
+        }
+    };
+
+
+    // This string is reproduced in every generated file as a comment
+    // TODO: Tie the version info into the build system.
+    protected static final String GENERATOR_INFO = "Qpid Gentools v.0.1";
+
+
+    private final Map<TemplateType, Collection<NamedTemplate>> _templates =
+            new EnumMap<TemplateType, Collection<NamedTemplate>>(TemplateType.class);
+
+    private final Map<TemplateType, Collection<NamedTemplate>> _versionSpecificTemplates =
+            new EnumMap<TemplateType, Collection<NamedTemplate>>(TemplateType.class);
+
+
+    private final AmqpVersionSet _versionSet;
+
+    private final AmqpDomainMap _domainMap;
+    private final Map<AmqpVersion, AmqpDomainMap> _versionToDomainMapMap = new HashMap<AmqpVersion, AmqpDomainMap>();
+
+    private final AmqpConstantSet _constantSet;
+    private final Map<AmqpVersion, AmqpConstantSet> _versionToConstantSetMap = new HashMap<AmqpVersion, AmqpConstantSet>();
+
+
+    public AmqpVersionSet getVersionSet()
+    {
+        return _versionSet;
+    }
+
+    private final AmqpModel _model;
+    private final Map<AmqpVersion, AmqpModel> _versionToModelMap = new HashMap<AmqpVersion, AmqpModel>();
+
+    protected int generatedFileCounter;
+
+    public Generator()
+    {
+        _versionSet = new AmqpVersionSet();
+        _model = new AmqpModel(this);
+        _constantSet = new AmqpConstantSet(this);
+        _domainMap = new AmqpDomainMap(this);
+
+        generatedFileCounter = 0;
+    }
+
+//    public final AmqpVersionSet getVersionSet()
+//    {
+//        return _versionSet;
+//    }
+
+
+    public void addVersion(AmqpVersion version)
+    {
+        _versionSet.add(version);
+        if (!_versionToModelMap.containsKey(version))
+        {
+            _versionToModelMap.put(version, new AmqpModel(this));
+        }
+        if (!_versionToDomainMapMap.containsKey(version))
+        {
+            _versionToDomainMapMap.put(version, new AmqpDomainMap(this));
+        }
+        if (!_versionToConstantSetMap.containsKey(version))
+        {
+            _versionToConstantSetMap.put(version, new AmqpConstantSet(this));
+        }
+    }
+
+    public int getNumberGeneratedFiles()
+    {
+        return generatedFileCounter;
+    }
+
+//	public AmqpDomainMap getDomainMap()
+//	{
+//		return _domainMap;
+//	}
+//
+//    public AmqpConstantSet getConstantSet()
+//    {
+//        return _constantSet;
+//    }
+//
+//
+//	public AmqpModel getModel()
+//	{
+//		return _model;
+//	}
+
+    public void initializeTemplates() throws IOException
+    {
+
+        for (TemplateType type : EnumSet.allOf(TemplateType.class))
+        {
+            ArrayList<NamedTemplate> typeTemplates = new ArrayList<NamedTemplate>();
+            _templates.put(type, typeTemplates);
+            ArrayList<NamedTemplate> versionSpecificTypeTemplates = new ArrayList<NamedTemplate>();
+            _versionSpecificTemplates.put(type, versionSpecificTypeTemplates);
+
+            File templateDirectory = new File(getTemplateDirectory() + Utils.FILE_SEPARATOR + type.getName());
+            File versionTemplateDirectory = new File(getTemplateDirectory() + Utils.FILE_SEPARATOR + type.getName() + Utils.FILE_SEPARATOR + "version");
+
+            System.out.println("Looking for template files in directory: " + templateDirectory.getAbsoluteFile());
+
+            File[] templateFiles = templateDirectory.listFiles(_tmplFileFilter);
+
+            File[] versionTemplateFiles = new File[0];
+
+            System.out.println("Looking for vesrion specific template files in directory: " + versionTemplateDirectory.getAbsoluteFile());
+
+            if (versionTemplateDirectory.exists())
+            {
+                versionTemplateFiles = versionTemplateDirectory.listFiles(_tmplFileFilter);
+            }
+
+			if(templateFiles != null)
+			{
+	            for (File templateFile : templateFiles)
+	            {
+	                System.out.println(type.getName() + " template file(s):");
+	                System.out.println("  " + templateFile.getCanonicalPath());
+	                typeTemplates.add(new NamedTemplate(type.getName(), templateFile));
+	            }
+			}
+
+            if(versionTemplateFiles != null)
+			{
+				for (File versionTemplateFile : versionTemplateFiles)
+	            {
+	                System.out.println(type.getName() + " template file(s):");
+	                System.out.println("  " + versionTemplateFile.getCanonicalPath());
+	                versionSpecificTypeTemplates.add(new NamedTemplate(type.getName() + Utils.FILE_SEPARATOR + "version", versionTemplateFile));
+	            }
+			}
+
+        }
+    }
+
+    public String getTemplateDirectory()
+    {
+        return _templateDirectory;
+    }
+
+
+    public void setTemplateDirectory(String templateDirectory)
+    {
+        _templateDirectory = templateDirectory;
+    }
+
+
+    public void setOutputDirectory(String outputDirectory)
+    {
+        _outputDirectory = outputDirectory;
+    }
+
+    public void generate()
+    {
+        prepareTargetDirectory(new File(_outputDirectory), true);
+        System.out.println("Generation directory: " + _outputDirectory);
+
+
+        processModelTemplates(_templates);
+
+        for (AmqpClass amqpClass : _model.getClassMap().values())
+        {
+            processClassTemplates(_templates, amqpClass);
+
+            for (AmqpMethod amqpMethod : amqpClass.getMethodMap().values())
+            {
+                processMethodTemplates(_templates, amqpClass, amqpMethod);
+
+                for (AmqpField amqpField : amqpMethod.getFieldMap().values())
+                {
+                    processFieldTemplates(_templates, amqpClass, amqpMethod, amqpField, null);
+                }
+            }
+        }
+
+
+        for (AmqpVersion version : _versionSet)
+        {
+            AmqpModel model = _versionToModelMap.get(version);
+            processModelTemplates(_versionSpecificTemplates, version);
+
+            for (AmqpClass amqpClass : model.getClassMap().values())
+            {
+                processClassTemplates(_versionSpecificTemplates, amqpClass, version);
+
+                for (AmqpMethod amqpMethod : amqpClass.getMethodMap().values())
+                {
+                    processMethodTemplates(_versionSpecificTemplates, amqpClass, amqpMethod, version);
+
+                    for (AmqpField amqpField : amqpMethod.getFieldMap().values())
+                    {
+                        processFieldTemplates(_versionSpecificTemplates, amqpClass, amqpMethod, amqpField, version);
+                    }
+                }
+            }
+
+        }
+    }
+
+    private void processMethodTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpClass amqpClass, AmqpMethod amqpMethod, AmqpVersion version)
+    {
+        for (NamedTemplate template : templates.get(TemplateType.method))
+        {
+            if(isVelocityTemplate(template))
+            {
+                processVelocityTemplate(template,version,amqpClass,amqpMethod,null);
+            }
+            else
+            {
+                processMethodTemplate(template, amqpClass, amqpMethod);
+            }
+        }
+        
+    }
+
+    private void processClassTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpClass amqpClass, AmqpVersion version)
+    {
+        for (NamedTemplate template : templates.get(TemplateType.clazz))
+        {
+            if(isVelocityTemplate(template))
+            {
+                processVelocityTemplate(template,version,amqpClass,null,null);
+            }
+            else
+            {
+                processClassTemplate(template, amqpClass);
+            }
+        }
+
+    }
+
+
+    private void processModelTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpVersion version)
+    {
+        for (NamedTemplate template : templates.get(TemplateType.model))
+        {
+            if (isVelocityTemplate(template))
+            {
+                processModelVelocityTemplate(template, version);
+            }
+            else
+            {
+                processModelTemplate(template, version);
+            }
+        }
+    }
+
+    abstract void processModelTemplate(NamedTemplate template, AmqpVersion version);
+
+
+    protected void processModelTemplates(Map<TemplateType, Collection<NamedTemplate>> templates)
+    {
+        for (NamedTemplate template : templates.get(TemplateType.model))
+        {
+            if (isVelocityTemplate(template))
+            {
+                processModelVelocityTemplate(template, null);
+            }
+            else
+            {
+                processModelTemplate(template);
+            }
+        }
+    }
+
+    private boolean isVelocityTemplate(NamedTemplate template)
+    {
+        return template.getName().endsWith(VELOCITY_TEMPLATE_SUFFIX);
+    }
+
+    private void processModelVelocityTemplate(NamedTemplate template, AmqpVersion version)
+    {
+        processVelocityTemplate(template,version,null,null,null);
+    }
+
+    private void processVelocityTemplate(NamedTemplate template, AmqpVersion version,
+                                              AmqpClass amqpClass, AmqpMethod amqpMethod, AmqpField amqpField)
+    {
+
+        VelocityContext context = new VelocityContext();
+
+        AmqpModel model = _model;
+        if(version != null)
+        {
+            model = _versionToModelMap.get(version);
+        }
+        context.put("model", model);
+        context.put("generator", GENERATOR_INFO);
+
+        if (version != null)
+        {
+            context.put("version", version);
+        }
+        if(amqpClass != null)
+        {
+            context.put("amqpClass", amqpClass);
+        }
+
+        if(amqpClass != null)
+        {
+            context.put("amqpMethod", amqpMethod);
+        }
+
+
+        StringWriter sw = new StringWriter();
+
+
+        try
+        {
+            Template velocityTemplate = Velocity.getTemplate(template.getName());
+            velocityTemplate.merge(context, sw);
+            String filename = String.valueOf(context.get("filename"));
+
+            File outputFile = new File(getOutputDirectory() + Utils.FILE_SEPARATOR + filename);
+            outputFile.getParentFile().mkdirs();
+            FileWriter outputFileWriter = new FileWriter(outputFile);
+
+            outputFileWriter.append(sw.toString());
+            outputFileWriter.close();
+
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+
+
+    }
+
+
+    protected void processClassTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpClass amqpClass)
+    {
+        for (NamedTemplate template : templates.get(TemplateType.clazz))
+        {
+            if(isVelocityTemplate(template))
+            {
+                processVelocityTemplate(template,null,amqpClass,null,null);
+            }
+            else
+            {
+                processClassTemplate(template, amqpClass);
+            }
+        }
+    }
+
+    protected void processMethodTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpClass amqpClass, AmqpMethod amqpMethod)
+    {
+        for (NamedTemplate template : templates.get(TemplateType.method))
+        {
+            if(isVelocityTemplate(template))
+            {
+                processVelocityTemplate(template,null,amqpClass,amqpMethod,null);
+            }
+            else
+            {
+                processMethodTemplate(template, amqpClass, amqpMethod);
+            }
+        }
+    }
+
+
+    protected void processFieldTemplates(Map<TemplateType, Collection<NamedTemplate>> templates, AmqpClass amqpClass, AmqpMethod amqpMethod, AmqpField amqpField, AmqpVersion amqpVersion)
+    {
+        for (NamedTemplate template : templates.get(TemplateType.field))
+        {
+            if(isVelocityTemplate(template))
+            {
+                processVelocityTemplate(template,amqpVersion,amqpClass,amqpMethod,amqpField);
+            }
+            else
+            {
+                processTemplate(template, amqpClass, amqpMethod, amqpField, amqpVersion);
+            }
+        }
+    }
+
+
+    protected void processVersionList(StringBuffer sb, int tokStart, int tokEnd)
+    {
+        int lend = sb.indexOf(Utils.LINE_SEPARATOR, tokStart) + 1; // Include cr at end of line
+        String tline = sb.substring(tokEnd, lend); // Line excluding line marker, including cr
+        sb.delete(tokStart, lend);
+
+        for (AmqpVersion v : _versionSet)
+        {
+            // Insert copy of target line
+            StringBuffer isb = new StringBuffer(tline);
+            if (isb.indexOf("${protocol-version-list-entry}") >= 0)
+            {
+                String versionListEntry = "       { ${major}, ${minor} }" +
+                                          (v.equals(_versionSet.last()) ? "" : ",");
+                replaceToken(isb, "${protocol-version-list-entry}", String.valueOf(versionListEntry));
+            }
+            if (isb.indexOf("${major}") >= 0)
+            {
+                replaceToken(isb, "${major}", String.valueOf(v.getMajor()));
+            }
+            if (isb.indexOf("${minor}") >= 0)
+            {
+                replaceToken(isb, "${minor}", String.valueOf(v.getMinor()));
+            }
+            sb.insert(tokStart, isb.toString());
+            tokStart += isb.length();
+        }
+    }
+
+    // Helper functions common to all generators
+
+    protected static void prepareTargetDirectory(File dir, boolean createFlag)
+    {
+        if (dir.exists())
+        {
+            if (!dir.isDirectory())
+            {
+                throw new TargetDirectoryException("\"" + dir.getAbsolutePath() +
+                                                   "\" exists, but is not a directory.");
+            }
+        }
+        else if (createFlag) // Create dir
+        {
+            if (!dir.mkdirs())
+            {
+                throw new TargetDirectoryException("Unable to create directory \"" +
+                                                   dir.getAbsolutePath() + "\".");
+            }
+        }
+        else
+        {
+            throw new TargetDirectoryException("Directory \"" + dir.getAbsolutePath() +
+                                               "\" not found.");
+        }
+
+    }
+
+    protected void processAllLists(StringBuffer sb, AmqpClass thisClass, AmqpMethod method, AmqpVersion version)
+    {
+        AmqpModel model = (version == null) ? _model : _versionToModelMap.get(version);
+
+
+        int lstart = sb.indexOf("%{");
+        while (lstart != -1)
+        {
+            int lend = sb.indexOf("}", lstart + 2);
+            if (lend > 0)
+            {
+                String listToken = sb.substring(lstart + 2, lend);
+                if (listToken.compareTo("VLIST") == 0)
+                {
+                    processVersionList(sb, lstart, lend + 1);
+                }
+                else if (listToken.compareTo("CLIST") == 0)
+                {
+                    processClassList(sb, lstart, lend + 1, model, version);
+                }
+                else if (listToken.compareTo("MLIST") == 0)
+                {
+                    processMethodList(sb, lstart, lend + 1, thisClass);
+                }
+                else if (listToken.compareTo("FLIST") == 0)
+                {
+                    // Pass the FieldMap from either a class or a method.
+                    // If this is called from a class-level template, we assume that the
+                    // class field list is required. In this case, method will be null.
+                    processFieldList(sb, lstart, lend + 1,
+                                     (method == null ? thisClass.getFieldMap() : method.getFieldMap()),
+                                     version);
+                }
+                else if (listToken.compareTo("TLIST") == 0)
+                {
+                    processConstantList(sb, lstart, lend + 1, _constantSet);
+                }
+                else
+                {
+                    throw new AmqpTemplateException("Unknown list token \"%{" + listToken +
+                                                    "}\" found in template at index " + lstart + ".");
+                }
+            }
+            lstart = sb.indexOf("%{", lstart + 1);
+        }
+    }
+
+    protected void processAllTokens(StringBuffer sb, AmqpClass thisClass, AmqpMethod method, AmqpField field,
+                                    AmqpVersion version)
+    {
+        int lstart = sb.indexOf("${");
+        while (lstart != -1)
+        {
+            int lend = sb.indexOf("}", lstart + 2);
+            if (lend > 0)
+            {
+                String token = sb.substring(lstart, lend + 1);
+                replaceToken(sb, lstart, token, processToken(token, thisClass, method, field, version));
+            }
+            lstart = sb.indexOf("${", lstart);
+        }
+    }
+
+    protected static void writeTargetFile(StringBuffer sb, File f)
+    {
+        try
+        {
+            f.getParentFile().mkdirs();
+            FileWriter fw = new FileWriter(f);
+            fw.write(sb.toString().toCharArray());
+            fw.flush();
+            fw.close();
+        }
+        catch (IOException e)
+        {
+            throw new AmqpTemplateException(e.getMessage());
+        }
+    }
+
+
+    protected static String getTemplateFileName(StringBuffer sb)
+    {
+        if (sb.charAt(0) != '&')
+        {
+            throw new AmqpTemplateException("No filename marker &{filename} found at start of template.");
+        }
+        int cr = sb.indexOf(Utils.LINE_SEPARATOR);
+        if (cr < 0)
+        {
+            throw new AmqpTemplateException("Bad template structure - unable to find first line.");
+        }
+        String fileName = sb.substring(2, cr - 1);
+        sb.delete(0, cr + 1);
+        return fileName;
+    }
+
+    protected static void replaceToken(StringBuffer sb, String token, String replacement)
+    {
+        replaceToken(sb, 0, token, replacement);
+    }
+
+    protected static void replaceToken(StringBuffer sb, int index, String token, String replacement)
+    {
+        if (replacement != null)
+        {
+            int start = sb.indexOf(token, index);
+            if (start != -1)
+            {
+                int len = token.length();
+                // Find first letter in token and determine if it is capitalized
+                char firstTokenLetter = getFirstLetter(token);
+                if (firstTokenLetter != 0 && Character.isUpperCase(firstTokenLetter))
+                {
+                    sb.replace(start, start + len, Utils.firstUpper(replacement));
+                }
+                else
+                {
+                    sb.replace(start, start + len, replacement);
+                }
+            }
+        }
+    }
+
+    private static char getFirstLetter(String str)
+    {
+        int len = str.length();
+        int index = 0;
+        char tokChar = str.charAt(index);
+        while (!Character.isLetter(tokChar) && index < len - 1)
+        {
+            tokChar = str.charAt(++index);
+        }
+        if (Character.isLetter(tokChar))
+        {
+            return tokChar;
+        }
+        return 0;
+    }
+
+    private static String loadTemplate(File f)
+    {
+        try
+        {
+            StringBuffer sb = new StringBuffer();
+            FileReader fr = new FileReader(f);
+            LineNumberReader lnr = new LineNumberReader(fr);
+            String line = lnr.readLine();
+            while (line != null)
+            {
+
+                sb.append(line);
+                sb.append(Utils.LINE_SEPARATOR);
+
+                line = lnr.readLine();
+            }
+            lnr.close();
+            fr.close();
+            return sb.toString();
+        }
+        catch (FileNotFoundException e)
+        {
+            throw new AmqpTemplateException("File not found: " + e.getMessage());
+        }
+        catch (IOException e)
+        {
+            throw new AmqpTemplateException("IOException: " + e.getMessage());
+        }
+    }
+
+    public String getDomainType(String domainName, AmqpVersion version)
+    {
+        if (version == null)
+        {
+            version = _versionSet.first();
+        }
+        return getDomainMap().getDomainType(domainName, version);
+    }
+
+
+    public void addFromNode(Node amqpNode, AmqpVersion version)
+    {
+        // 1c. Extract domains
+        getConstantSet().addFromNode(amqpNode, 0, version);
+        _versionToConstantSetMap.get(version).addFromNode(amqpNode, 0, version);
+
+        // 1d. Extract domains
+        getDomainMap().addFromNode(amqpNode, 0, version);
+        _versionToDomainMapMap.get(version).addFromNode(amqpNode, 0, version);
+
+        // 1e. Extract class/method/field heirarchy
+        getModel().addFromNode(amqpNode, 0, version);
+        _versionToModelMap.get(version).addFromNode(amqpNode, 0, version);
+    }
+
+
+    public String getOutputDirectory()
+    {
+        return _outputDirectory;
+    }
+
+    public String prepareConstantName(String constantName)
+    {
+        return prepareDomainName(constantName);
+    }
+
+
+    public boolean isFixedSizeType(String type)
+    {
+        return FIXED_SIZE_TYPES.containsKey(type);
+    }
+
+
+    public int getTypeSize(String type)
+    {
+        return FIXED_SIZE_TYPES.get(type);
+    }
+
+
+
+    // Model-level template processing
+    abstract protected void processModelTemplate(NamedTemplate template);
+
+    // Class-level template processing
+    abstract protected void processClassTemplate(NamedTemplate template, AmqpClass thisClass);
+
+    // Method-level template processing
+    abstract protected void processMethodTemplate(NamedTemplate template, AmqpClass thisClass,
+                                                  AmqpMethod method);
+
+    // Field-level template processing
+    abstract protected void processTemplate(NamedTemplate template, AmqpClass thisClass,
+                                            AmqpMethod method, AmqpField field, AmqpVersion version);
+
+    abstract protected String prepareFilename(String filenameTemplate, AmqpClass thisClass, AmqpMethod method,
+                                              AmqpField field, AmqpVersion version);
+
+    abstract protected String processToken(String token, AmqpClass thisClass, AmqpMethod method,
+                                           AmqpField field, AmqpVersion version);
+
+    abstract protected void processClassList(StringBuffer sb, int listMarkerStartIndex, int listMarkerEndIndex,
+                                             AmqpModel model, AmqpVersion version);
+
+    abstract protected void processMethodList(StringBuffer sb, int listMarkerStartIndex, int listMarkerEndIndex,
+                                              AmqpClass thisClass);
+
+
+    abstract protected void processFieldList(StringBuffer sb, int listMarkerStartIndex, int listMarkerEndIndex,
+                                             AmqpFieldMap fieldMap, AmqpVersion version);
+
+    abstract protected void processConstantList(StringBuffer sb, int listMarkerStartIndex, int listMarkerEndIndex,
+                                                AmqpConstantSet constantSet);
+
+
+}

Modified: incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/SingleVersionMethod.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/SingleVersionMethod.java?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/SingleVersionMethod.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/SingleVersionMethod.java Fri Feb  8 02:09:37 2008
@@ -140,5 +140,15 @@
     }
 
 
+    public boolean isServerMethod()
+    {
+        return _amqpMethod.isServerMethod(_amqpVersion);
+    }
+
+
+    public boolean isClientMethod()
+    {
+        return _amqpMethod.isClientMethod(_amqpVersion);        
+    }
 
 }

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/bin/qpid.start
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/bin/qpid.start?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/bin/qpid.start (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/bin/qpid.start Fri Feb  8 02:09:37 2008
@@ -18,4 +18,4 @@
 # under the License.
 #
 
-qpid-server -run:debug "$@"
\ No newline at end of file
+exec qpid-server -run:debug "$@"
\ No newline at end of file

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/etc/config.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/etc/config.xml?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/etc/config.xml (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/etc/config.xml Fri Feb  8 02:09:37 2008
@@ -33,6 +33,7 @@
             <keystorePassword>keystorepass</keystorePassword>
         </ssl>-->
         <qpidnio>true</qpidnio>
+        <protectio>true</protectio>
         <transport>nio</transport>
         <port>5672</port>
         <sslport>8672</sslport>
@@ -103,6 +104,10 @@
                 	  <class>org.apache.qpid.server.txn.MemoryTransactionManager</class>
                 </txn>
 
+                <housekeeping>
+                    <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod>
+                </housekeeping>
+
                 <security>
                     <!-- Need protocol changes to allow this-->
                     <authentication>
@@ -182,5 +187,6 @@
 
     <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
 </broker>
+
 
 

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/pom.xml?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/pom.xml (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/pom.xml Fri Feb  8 02:09:37 2008
@@ -6,9 +6,9 @@
     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
@@ -51,24 +51,60 @@
 
         <dependency>
             <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>  
-            <version>1.4.0</version> 
+            <artifactId>slf4j-api</artifactId>
+            <version>1.4.0</version>
         </dependency>
 
-        <dependency>  
-            <groupId>org.slf4j</groupId> 
-            <artifactId>slf4j-log4j12</artifactId>  
-            <version>1.4.0</version>  
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.4.0</version>
         </dependency>
 
         <dependency>
             <groupId>commons-cli</groupId>
             <artifactId>commons-cli</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>commons-logging</groupId>
+                    <artifactId>commons-logging</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
             <groupId>commons-configuration</groupId>
             <artifactId>commons-configuration</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>servlet-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>dom4j</groupId>
+                    <artifactId>dom4j</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>commons-beanutils</groupId>
+                    <artifactId>commons-beanutils</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>commons-beanutils</groupId>
+                    <artifactId>commons-beanutils-core</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>commons-digester</groupId>
+                    <artifactId>commons-digester</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>xerces</groupId>
+                    <artifactId>xercesImpl</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>xml-apis</groupId>
+                    <artifactId>xml-apis</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
@@ -82,13 +118,16 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
-
-        <dependency>
-            <groupId>org.easymock</groupId>
-            <artifactId>easymockclassextension</artifactId>
-            <scope>test</scope>
+	<dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>1.0.0</version>
+        </dependency>        
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.framework</artifactId>
+            <version>1.0.0</version>
         </dependency>
-
     </dependencies>
 
     <build>
@@ -215,10 +254,8 @@
                                         <isset property="skip.python.tests"/>
                                     </condition>
 
-                                    <property name="command" 
-                                              value="python run-tests -v -I java_failing_0-8.txt"/>
-
-                                              <-value="bash -c 'python run-tests -v -I java_failing.txt'"/>->
+                                    <property name="command"
+                                              value="python run-tests -v -I java_failing.txt -b localhost:2110"/>
 
                                     <ant antfile="python-test.xml" inheritRefs="true">
                                         <target name="run-tests" />

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/python-test.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/python-test.xml?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/python-test.xml (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/python-test.xml Fri Feb  8 02:09:37 2008
@@ -40,8 +40,11 @@
 			failonerror="true"
 			>
 		<arg value="${command}"/>
-		
-		<classpath refid="maven.test.classpath"/>
+		<arg value="-p"/>
+                <arg value="2110"/>
+                <arg value="-m"/>
+                <arg value="2111"/>
+                <classpath refid="maven.test.classpath"/>
 		<sysproperty key="QPID_HOME" value="${broker.dir}"/>
 		<sysproperty key="QPID_WORK" value="${broker.dir}${file.separator}target"/>
 	</java>

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java Fri Feb  8 02:09:37 2008
@@ -111,7 +111,7 @@
                 if (exchange == null)
                 {
                     exchange = _exchangeFactory.createExchange(new AMQShortString(exchangeName),
-                                                               new AMQShortString(type), durable, false, 0);
+                                                               new AMQShortString(type), durable, false);
                     _exchangeRegistry.registerExchange(exchange);
                 }
                 else

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java Fri Feb  8 02:09:37 2008
@@ -22,7 +22,9 @@
 
 import org.apache.log4j.Logger;
 import org.apache.qpid.AMQException;
+import org.apache.qpid.configuration.Configured;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.framing.ContentBody;
 import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.framing.FieldTable;
@@ -33,10 +35,7 @@
 import org.apache.qpid.server.exchange.MessageRouter;
 import org.apache.qpid.server.exchange.NoRouteException;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
-import org.apache.qpid.server.queue.AMQMessage;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.MessageHandleFactory;
-import org.apache.qpid.server.queue.Subscription;
+import org.apache.qpid.server.queue.*;
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.StoreContext;
 import org.apache.qpid.server.txn.LocalTransactionalContext;
@@ -120,6 +119,10 @@
     private final AMQProtocolSession _session;
     private boolean _closing;
 
+    @Configured(path = "advanced.enableJMSXUserID",
+                defaultValue = "true")
+    public boolean ENABLE_JMSXUserID;
+
     public AMQChannel(AMQProtocolSession session, int channelId, TransactionManager transactionManager,
                       MessageStore messageStore, MessageRouter exchanges) throws AMQException
     {
@@ -220,6 +223,16 @@
                 _log.trace(debugIdentity() + "Content header received on channel " + _channelId);
             }
 
+            if (ENABLE_JMSXUserID)
+            {
+                //Set JMSXUserID
+                BasicContentHeaderProperties properties = (BasicContentHeaderProperties) contentHeaderBody.properties;
+                //fixme: fudge for QPID-677
+                properties.getHeaders().keySet();
+
+                properties.setUserId(protocolSession.getAuthorizedID().getName());
+            }
+
             _currentMessage.setContentHeaderBody(contentHeaderBody);
             _currentMessage.setExpiration();
 
@@ -253,8 +266,8 @@
             // returns true iff the message was delivered (i.e. if all data was
             // received
             if (_currentMessage.addContentBodyFrame(_storeContext,
-                                                    protocolSession.getRegistry().getProtocolVersionMethodConverter().convertToContentChunk(
-                                                            contentBody)))
+                        protocolSession.getMethodRegistry().getProtocolVersionMethodConverter().convertToContentChunk(
+                            contentBody)))
             {
                 // callback to allow the context to do any post message processing
                 // primary use is to allow message return processing in the non-tx case
@@ -349,7 +362,14 @@
     {
         _txnContext.rollback();
         unsubscribeAllConsumers(session);
-        requeue();
+        try
+        {
+            requeue();
+        }
+        catch (AMQException e)
+        {
+            _log.error("Caught AMQException whilst attempting to reque:" + e);        
+        }
 
         setClosing(true);
     }
@@ -389,33 +409,32 @@
     /**
      * Add a message to the channel-based list of unacknowledged messages
      *
-     * @param message     the message that was delivered
+     * @param entry       the record of the message on the queue that was delivered
      * @param deliveryTag the delivery tag used when delivering the message (see protocol spec for description of the
      *                    delivery tag)
      * @param consumerTag The tag for the consumer that is to acknowledge this message.
-     * @param queue       the queue from which the message was delivered
      */
-    public void addUnacknowledgedMessage(AMQMessage message, long deliveryTag, AMQShortString consumerTag, AMQQueue queue)
+    public void addUnacknowledgedMessage(QueueEntry entry, long deliveryTag, AMQShortString consumerTag)
     {
         if (_log.isDebugEnabled())
         {
-            if (queue == null)
+            if (entry.getQueue() == null)
             {
-                _log.debug("Adding unacked message with a null queue:" + message.debugIdentity());
+                _log.debug("Adding unacked message with a null queue:" + entry.debugIdentity());
             }
             else
             {
                 if (_log.isDebugEnabled())
                 {
-                    _log.debug(debugIdentity() + " Adding unacked message(" + message.toString() + " DT:" + deliveryTag
-                               + ") with a queue(" + queue + ") for " + consumerTag);
+                    _log.debug(debugIdentity() + " Adding unacked message(" + entry.getMessage().toString() + " DT:" + deliveryTag
+                               + ") with a queue(" + entry.getQueue() + ") for " + consumerTag);
                 }
             }
         }
 
         synchronized (_unacknowledgedMessageMap.getLock())
         {
-            _unacknowledgedMessageMap.add(deliveryTag, new UnacknowledgedMessage(queue, message, consumerTag, deliveryTag));
+            _unacknowledgedMessageMap.add(deliveryTag, new UnacknowledgedMessage(entry, consumerTag, deliveryTag));
             checkSuspension();
         }
     }
@@ -467,16 +486,16 @@
 
         for (UnacknowledgedMessage unacked : messagesToBeDelivered)
         {
-            if (unacked.queue != null)
+            if (!unacked.isQueueDeleted())
             {
                 // Ensure message is released for redelivery
-                unacked.message.release(unacked.queue);
+                unacked.entry.release();
 
                 // Mark message redelivered
-                unacked.message.setRedelivered(true);
+                unacked.getMessage().setRedelivered(true);
 
                 // Deliver Message
-                deliveryContext.deliver(unacked.message, unacked.queue, true);
+                deliveryContext.deliver(unacked.entry, false);
 
                 // Should we allow access To the DM to directy deliver the message?
                 // As we don't need to check for Consumers or worry about incrementing the message count?
@@ -501,13 +520,13 @@
         {
 
             // Ensure message is released for redelivery
-            if (unacked.queue != null)
+            if (!unacked.isQueueDeleted())
             {
-                unacked.message.release(unacked.queue);
+                unacked.entry.release();
             }
 
             // Mark message redelivered
-            unacked.message.setRedelivered(true);
+            unacked.getMessage().setRedelivered(true);
 
             // Deliver these messages out of the transaction as their delivery was never
             // part of the transaction only the receive.
@@ -527,16 +546,16 @@
                 deliveryContext = _txnContext;
             }
 
-            if (unacked.queue != null)
+            if (!unacked.isQueueDeleted())
             {
                 // Redeliver the messages to the front of the queue
-                deliveryContext.deliver(unacked.message, unacked.queue, true);
+                deliveryContext.deliver(unacked.entry, true);
                 // Deliver increments the message count but we have already deliverted this once so don't increment it again
                 // this was because deliver did an increment changed this.
             }
             else
             {
-                _log.warn(System.identityHashCode(this) + " Requested requeue of message(" + unacked.message.debugIdentity()
+                _log.warn(System.identityHashCode(this) + " Requested requeue of message(" + unacked.getMessage().debugIdentity()
                           + "):" + deliveryTag + " but no queue defined and no DeadLetter queue so DROPPING message.");
                 // _log.error("Requested requeue of message:" + deliveryTag +
                 // " but no queue defined using DeadLetter queue:" + getDeadLetterQueue());
@@ -559,7 +578,7 @@
                     public boolean callback(UnacknowledgedMessage message) throws AMQException
                     {
                         _log.debug(
-                                (count++) + ": (" + message.message.debugIdentity() + ")" + "[" + message.deliveryTag + "]");
+                                (count++) + ": (" + message.getMessage().debugIdentity() + ")" + "[" + message.deliveryTag + "]");
 
                         return false; // Continue
                     }
@@ -598,7 +617,7 @@
             public boolean callback(UnacknowledgedMessage message) throws AMQException
             {
                 AMQShortString consumerTag = message.consumerTag;
-                AMQMessage msg = message.message;
+                AMQMessage msg = message.getMessage();
                 msg.setRedelivered(true);
                 if (consumerTag != null)
                 {
@@ -617,7 +636,7 @@
                     // Message has no consumer tag, so was "delivered" to a GET
                     // or consumer no longer registered
                     // cannot resend, so re-queue.
-                    if (message.queue != null)
+                    if (!message.isQueueDeleted())
                     {
                         if (requeue)
                         {
@@ -658,7 +677,7 @@
 
         for (UnacknowledgedMessage message : msgToResend)
         {
-            AMQMessage msg = message.message;
+            AMQMessage msg = message.getMessage();
 
             // Our Java Client will always suspend the channel when resending!
             // If the client has requested the messages be resent then it is
@@ -673,13 +692,13 @@
             // else
             // {
             // release to allow it to be delivered
-            msg.release(message.queue);
+            message.entry.release();
 
             // Without any details from the client about what has been processed we have to mark
             // all messages in the unacked map as redelivered.
             msg.setRedelivered(true);
 
-            Subscription sub = msg.getDeliveredSubscription(message.queue);
+            Subscription sub = message.entry.getDeliveredSubscription();
 
             if (sub != null)
             {
@@ -709,7 +728,7 @@
                                        + System.identityHashCode(sub));
                         }
 
-                        sub.addToResendQueue(msg);
+                        sub.addToResendQueue(message.entry);
                         _unacknowledgedMessageMap.remove(message.deliveryTag);
                     }
                 } // sync(sub.getSendLock)
@@ -757,10 +776,10 @@
         // Process Messages to Requeue at the front of the queue
         for (UnacknowledgedMessage message : msgToRequeue)
         {
-            message.message.release(message.queue);
-            message.message.setRedelivered(true);
+            message.entry.release();
+            message.entry.setRedelivered(true);
 
-            deliveryContext.deliver(message.message, message.queue, true);
+            deliveryContext.deliver(message.entry, true);
 
             _unacknowledgedMessageMap.remove(message.deliveryTag);
         }
@@ -781,17 +800,18 @@
         {
             public boolean callback(UnacknowledgedMessage message) throws AMQException
             {
-                if (message.queue == queue)
+                if (message.getQueue() == queue)
                 {
                     try
                     {
                         message.discard(_storeContext);
-                        message.queue = null;
+                        message.setQueueDeleted(true);
+                        
                     }
                     catch (AMQException e)
                     {
                         _log.error(
-                                "Error decrementing ref count on message " + message.message.getMessageId() + ": " + e, e);
+                                "Error decrementing ref count on message " + message.getMessage().getMessageId() + ": " + e, e);
                     }
                 }
 

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java Fri Feb  8 02:09:37 2008
@@ -466,7 +466,7 @@
                 }
             }
 
-            // fixme  qpid.AMQP should be using qpidproperties to get value
+            //fixme  qpid.AMQP should be using qpidproperties to get value
             _brokerLogger.info("Qpid Broker Ready :" + QpidProperties.getReleaseVersion()
                                + " build: " + QpidProperties.getBuildVersion());
         }

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/TxAck.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/TxAck.java?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/TxAck.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/TxAck.java Fri Feb  8 02:09:37 2008
@@ -87,7 +87,7 @@
         //buffer must be marked as persistent:
         for (UnacknowledgedMessage msg : _unacked)
         {
-            if (msg.message.isPersistent())
+            if (msg.getMessage().isPersistent())
             {
                 return true;
             }
@@ -100,7 +100,7 @@
         //make persistent changes, i.e. dequeue and decrementReference
         for (UnacknowledgedMessage msg : _unacked)
         {
-            msg.restoreTransientMessageData();
+            //msg.restoreTransientMessageData();
 
             //Message has been ack so discard it. This will dequeue and decrement the reference.
             msg.discard(storeContext);
@@ -116,7 +116,7 @@
         for (UnacknowledgedMessage msg : _unacked)
         {
             msg.clearTransientMessageData();
-            msg.message.takeReference();
+            msg.getMessage().takeReference();
         }
     }
 

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessage.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessage.java?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessage.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessage.java Fri Feb  8 02:09:37 2008
@@ -24,19 +24,21 @@
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.queue.AMQMessage;
 import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.store.StoreContext;
 
 public class UnacknowledgedMessage
 {
-    public final AMQMessage message;
+    public final QueueEntry entry;
     public final AMQShortString consumerTag;
     public final long deliveryTag;
-    public AMQQueue queue;
 
-    public UnacknowledgedMessage(AMQQueue queue, AMQMessage message, AMQShortString consumerTag, long deliveryTag)
+    private boolean _queueDeleted;
+
+
+    public UnacknowledgedMessage(QueueEntry entry, AMQShortString consumerTag, long deliveryTag)
     {
-        this.queue = queue;
-        this.message = message;
+        this.entry = entry;
         this.consumerTag = consumerTag;
         this.deliveryTag = deliveryTag;
     }
@@ -45,9 +47,9 @@
     {
         StringBuilder sb = new StringBuilder();
         sb.append("Q:");
-        sb.append(queue);
+        sb.append(entry.getQueue());
         sb.append(" M:");
-        sb.append(message);
+        sb.append(entry.getMessage());
         sb.append(" CT:");
         sb.append(consumerTag);
         sb.append(" DT:");
@@ -58,22 +60,42 @@
 
     public void discard(StoreContext storeContext) throws AMQException
     {
-        if (queue != null)
+        if (entry.getQueue() != null)
         {
-            message.dequeue(storeContext, queue);
+            entry.getQueue().dequeue(storeContext, entry);
         }
         //if the queue is null then the message is waiting to be acked, but has been removed.
-        message.decrementReference(storeContext);
+        entry.getMessage().decrementReference(storeContext);
     }
 
     public void restoreTransientMessageData() throws AMQException
     {
-        message.restoreTransientMessageData();
+        entry.getMessage().restoreTransientMessageData();
     }
 
     public void clearTransientMessageData()
     {
-        message.clearTransientMessageData();
+        entry.getMessage().clearTransientMessageData();
+    }
+
+    public AMQMessage getMessage()
+    {
+        return entry.getMessage();
+    }
+
+    public AMQQueue getQueue()
+    {
+        return entry.getQueue();
+    }
+
+    public void setQueueDeleted(boolean queueDeleted)
+    {
+        _queueDeleted = queueDeleted;
+    }
+
+    public boolean isQueueDeleted()
+    {
+        return _queueDeleted;
     }
 }
 

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java Fri Feb  8 02:09:37 2008
@@ -97,7 +97,7 @@
             UnacknowledgedMessage message = _map.remove(deliveryTag);
             if(message != null)
             {
-                _unackedSize -= message.message.getSize();
+                _unackedSize -= message.getMessage().getSize();
             }
 
             return message;
@@ -127,7 +127,7 @@
         synchronized (_lock)
         {
             _map.put(deliveryTag, message);
-            _unackedSize += message.message.getSize();            
+            _unackedSize += message.getMessage().getSize();
             _lastDeliveryTag = deliveryTag;
         }
     }
@@ -186,7 +186,7 @@
                 }
 
                 it.remove();
-                _unackedSize -= unacked.getValue().message.getSize();
+                _unackedSize -= unacked.getValue().getMessage().getSize();
 
                 destination.add(unacked.getValue());
                 if (unacked.getKey() == deliveryTag)

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java?rev=619823&r1=619822&r2=619823&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java Fri Feb  8 02:09:37 2008
@@ -127,7 +127,7 @@
                 boolean durable = exchangeConfiguration.getBoolean("durable", false);
                 boolean autodelete = exchangeConfiguration.getBoolean("autodelete", false);
 
-                Exchange newExchange = exchangeFactory.createExchange(exchangeName, type, durable, autodelete, 0);
+                Exchange newExchange = exchangeFactory.createExchange(exchangeName, type, durable, autodelete);
                 exchangeRegistry.registerExchange(newExchange);
             }
 



Mime
View raw message