You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2006/09/20 00:07:25 UTC

svn commit: r447994 [39/46] - in /incubator/qpid/trunk/qpid: ./ cpp/ cpp/bin/ cpp/broker/ cpp/broker/inc/ cpp/broker/src/ cpp/broker/test/ cpp/client/ cpp/client/inc/ cpp/client/src/ cpp/client/test/ cpp/common/ cpp/common/concurrent/ cpp/common/concur...

Added: incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/ssl/SSLSocketFactory.java?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/ssl/SSLSocketFactory.java (added)
+++ incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/ssl/SSLSocketFactory.java Tue Sep 19 15:06:50 2006
@@ -0,0 +1,135 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.ssl;
+
+import javax.net.SocketFactory;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.GeneralSecurityException;
+
+/**
+ * Simple Socket factory to create sockets with or without SSL enabled.
+ * If SSL enabled a "bogus" SSL Context is used (suitable for test purposes).
+ * <p/>
+ * This is based on an example that comes with MINA, written by Trustin Lee.
+ */
+public class SSLSocketFactory extends SocketFactory
+{
+    private static boolean sslEnabled = false;
+
+    private static javax.net.ssl.SSLSocketFactory sslFactory = null;
+
+    private static javax.net.SocketFactory factory = null;
+
+    public SSLSocketFactory()
+    {
+        super();
+    }
+
+    public Socket createSocket(String arg1, int arg2) throws IOException,
+            UnknownHostException
+    {
+        if (isSslEnabled())
+        {
+            return getSSLFactory().createSocket(arg1, arg2);
+        }
+        else
+        {
+            return new Socket(arg1, arg2);
+        }
+    }
+
+    public Socket createSocket(String arg1, int arg2, InetAddress arg3,
+                               int arg4) throws IOException,
+            UnknownHostException
+    {
+        if (isSslEnabled())
+        {
+            return getSSLFactory().createSocket(arg1, arg2, arg3, arg4);
+        }
+        else
+        {
+            return new Socket(arg1, arg2, arg3, arg4);
+        }
+    }
+
+    public Socket createSocket(InetAddress arg1, int arg2)
+            throws IOException
+    {
+        if (isSslEnabled())
+        {
+            return getSSLFactory().createSocket(arg1, arg2);
+        }
+        else
+        {
+            return new Socket(arg1, arg2);
+        }
+    }
+
+    public Socket createSocket(InetAddress arg1, int arg2, InetAddress arg3,
+                               int arg4) throws IOException
+    {
+        if (isSslEnabled())
+        {
+            return getSSLFactory().createSocket(arg1, arg2, arg3, arg4);
+        }
+        else
+        {
+            return new Socket(arg1, arg2, arg3, arg4);
+        }
+    }
+
+    public static javax.net.SocketFactory getSocketFactory()
+    {
+        if (factory == null)
+        {
+            factory = new SSLSocketFactory();
+        }
+        return factory;
+    }
+
+    private javax.net.ssl.SSLSocketFactory getSSLFactory()
+    {
+        if (sslFactory == null)
+        {
+            try
+            {
+                sslFactory = BogusSSLContextFactory.getInstance(false)
+                        .getSocketFactory();
+            }
+            catch (GeneralSecurityException e)
+            {
+                throw new RuntimeException("could not create SSL socket", e);
+            }
+        }
+        return sslFactory;
+    }
+
+    public static boolean isSslEnabled()
+    {
+        return sslEnabled;
+    }
+
+    public static void setSslEnabled(boolean newSslEnabled)
+    {
+        sslEnabled = newSslEnabled;
+    }
+
+}

Propchange: incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/ssl/SSLSocketFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/AMQBindingURL.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/AMQBindingURL.java?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/AMQBindingURL.java (added)
+++ incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/AMQBindingURL.java Tue Sep 19 15:06:50 2006
@@ -0,0 +1,260 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.url;
+
+import org.apache.qpid.url.BindingURL;
+import org.apache.qpid.url.URLHelper;
+import org.apache.qpid.exchange.ExchangeDefaults;
+
+import java.util.HashMap;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class AMQBindingURL implements BindingURL
+{
+    String _url;
+    String _exchangeClass;
+    String _exchangeName;
+    String _destinationName;
+    String _queueName;
+    private HashMap<String, String> _options;
+
+
+    public AMQBindingURL(String url) throws URLSyntaxException
+    {
+        //format:
+        // <exch_class>://<exch_name>/[<destination>]/[<queue>]?<option>='<value>'[,<option>='<value>']*
+
+        _url = url;
+        _options = new HashMap<String, String>();
+
+        parseBindingURL();
+    }
+
+    private void parseBindingURL() throws URLSyntaxException
+    {
+        try
+        {
+            URI connection = new URI(_url);
+
+            String exchangeClass = connection.getScheme();
+
+            if (exchangeClass == null)
+            {
+                _url = ExchangeDefaults.DIRECT_EXCHANGE_CLASS + "://" +
+                        ExchangeDefaults.DIRECT_EXCHANGE_NAME + "//" + _url;
+                //URLHelper.parseError(-1, "Exchange Class not specified.", _url);
+                parseBindingURL();
+                return;
+            }
+            else
+            {
+                setExchangeClass(exchangeClass);
+            }
+
+            String exchangeName = connection.getHost();
+
+            if (exchangeName == null)
+            {
+                URLHelper.parseError(-1, "Exchange Name not specified.", _url);
+            }
+            else
+            {
+                setExchangeName(exchangeName);
+            }
+
+            if (connection.getPath() == null ||
+                    connection.getPath().equals(""))
+            {
+                URLHelper.parseError(_url.indexOf(_exchangeName) + _exchangeName.length(),
+                        "Destination or Queue requried", _url);
+            }
+            else
+            {
+                int slash = connection.getPath().indexOf("/", 1);
+                if (slash == -1)
+                {
+                    URLHelper.parseError(_url.indexOf(_exchangeName) + _exchangeName.length(),
+                            "Destination requried", _url);
+                }
+                else
+                {
+                    String path = connection.getPath();
+                    setDestinationName(path.substring(1, slash));
+
+                    setQueueName(path.substring(slash + 1));
+
+                }
+            }
+
+            URLHelper.parseOptions(_options, connection.getQuery());
+
+            processOptions();
+
+            //Fragment is #string (not used)
+            //System.out.println(connection.getFragment());
+
+        }
+        catch (URISyntaxException uris)
+        {
+
+            URLHelper.parseError(uris.getIndex(), uris.getReason(), uris.getInput());
+
+        }
+    }
+
+    private void processOptions()
+    {
+        //this is where we would parse any options that needed more than just storage.
+    }
+
+    public String getURL()
+    {
+        return _url;
+    }
+
+    public String getExchangeClass()
+    {
+        return _exchangeClass;
+    }
+
+    public void setExchangeClass(String exchangeClass)
+    {
+        _exchangeClass = exchangeClass;
+    }
+
+    public String getExchangeName()
+    {
+        return _exchangeName;
+    }
+
+    public void setExchangeName(String name)
+    {
+        _exchangeName = name;
+
+        if (name.equals(ExchangeDefaults.TOPIC_EXCHANGE_NAME))
+        {
+            setOption(BindingURL.OPTION_EXCLUSIVE, "true");
+        }
+    }
+
+    public String getDestinationName()
+    {
+        return _destinationName;
+    }
+
+    public void setDestinationName(String name)
+    {
+        _destinationName = name;
+    }
+
+    public String getQueueName()
+    {
+        if (_exchangeClass.equals(ExchangeDefaults.TOPIC_EXCHANGE_CLASS))
+        {
+            if (Boolean.parseBoolean(getOption(OPTION_DURABLE)))
+            {
+                if (containsOption(BindingURL.OPTION_CLIENTID) && containsOption(BindingURL.OPTION_SUBSCRIPTION))
+                {
+                    return getOption(BindingURL.OPTION_CLIENTID + ":" + BindingURL.OPTION_SUBSCRIPTION);
+                }
+                else
+                {
+                    return getDestinationName();
+                }
+            }
+            else
+            {
+                return getDestinationName();
+            }
+        }
+        else
+        {
+            return _queueName;
+        }
+    }
+
+    public void setQueueName(String name)
+    {
+        _queueName = name;
+    }
+
+    public String getOption(String key)
+    {
+        return _options.get(key);
+    }
+
+    public void setOption(String key, String value)
+    {
+        _options.put(key, value);
+    }
+
+    public boolean containsOption(String key)
+    {
+        return _options.containsKey(key);
+    }
+
+    public String getRoutingKey()
+    {
+        if (_exchangeClass.equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS))
+        {
+            return getQueueName();
+        }
+
+        if (containsOption(BindingURL.OPTION_ROUTING_KEY))
+        {
+            return getOption(OPTION_ROUTING_KEY);
+        }
+
+        return getDestinationName();
+    }
+
+    public void setRoutingKey(String key)
+    {
+        setOption(OPTION_ROUTING_KEY, key);
+    }
+
+
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append(_exchangeClass);
+        sb.append("://");
+        sb.append(_exchangeName);
+        sb.append('/');
+        sb.append(_destinationName);
+        sb.append('/');
+        sb.append(_queueName);
+
+        sb.append(URLHelper.printOptions(_options));
+        return sb.toString();
+    }
+
+    public static void main(String args[]) throws URLSyntaxException
+    {
+        String url = "exchangeClass://exchangeName/Destination/Queue?option='value',option2='value2'";
+
+        AMQBindingURL dest = new AMQBindingURL(url);
+
+        System.out.println(url);
+        System.out.println(dest);
+
+    }
+
+}
\ No newline at end of file

Propchange: incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/AMQBindingURL.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/BindingURL.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/BindingURL.java?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/BindingURL.java (added)
+++ incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/BindingURL.java Tue Sep 19 15:06:50 2006
@@ -0,0 +1,65 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.url;
+
+import java.util.List;
+
+/*
+    Binding URL format:
+    <exch_class>://<exch_name>/[<destination>]/[<queue>]?<option>='<value>'[,<option>='<value>']*
+*/
+public interface BindingURL
+{
+    public static final String OPTION_EXCLUSIVE = "exclusive";
+    public static final String OPTION_AUTODELETE = "autodelete";
+    public static final String OPTION_DURABLE = "durable";
+    public static final String OPTION_CLIENTID = "clientid";
+    public static final String OPTION_SUBSCRIPTION = "subscription";
+    public static final String OPTION_ROUTING_KEY = "routingkey";
+
+
+    String getURL();
+
+    String getExchangeClass();
+
+    void setExchangeClass(String exchangeClass);
+
+    String getExchangeName();
+
+    void setExchangeName(String name);
+
+    String getDestinationName();
+
+    void setDestinationName(String name);
+
+    String getQueueName();
+
+    void setQueueName(String name);
+
+    String getOption(String key);
+
+    void setOption(String key, String value);
+
+    boolean containsOption(String key);
+
+    String getRoutingKey();
+
+    void setRoutingKey(String key);
+
+    String toString();
+}

Propchange: incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/BindingURL.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/URLHelper.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/URLHelper.java?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/URLHelper.java (added)
+++ incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/URLHelper.java Tue Sep 19 15:06:50 2006
@@ -0,0 +1,173 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.url;
+
+import java.util.HashMap;
+
+public class URLHelper
+{
+    public static char DEFAULT_OPTION_SEPERATOR = '&';
+    public static char ALTERNATIVE_OPTION_SEPARATOR = ',';
+    public static char BROKER_SEPARATOR = ';';
+
+    public static void parseOptions(HashMap<String, String> optionMap, String options) throws URLSyntaxException
+    {
+        //options looks like this
+        //brokerlist='tcp://host:port?option='value',option='value';vm://:3/virtualpath?option='value'',failover='method?option='value',option='value''
+
+        if (options == null || options.indexOf('=') == -1)
+        {
+            return;
+        }
+
+        int optionIndex = options.indexOf('=');
+
+        String option = options.substring(0, optionIndex);
+
+        int length = options.length();
+
+        int nestedQuotes = 0;
+
+        // to store index of final "'"
+        int valueIndex = optionIndex;
+
+        //Walk remainder of url.
+        while (nestedQuotes > 0 || valueIndex < length)
+        {
+            valueIndex++;
+
+            if (valueIndex >= length)
+            {
+                break;
+            }
+
+            if (options.charAt(valueIndex) == '\'')
+            {
+                if (valueIndex + 1 < options.length())
+                {
+                    if (options.charAt(valueIndex + 1) == DEFAULT_OPTION_SEPERATOR ||
+                            options.charAt(valueIndex + 1) == ALTERNATIVE_OPTION_SEPARATOR ||
+                            options.charAt(valueIndex + 1) == BROKER_SEPARATOR ||
+                            options.charAt(valueIndex + 1) == '\'')
+                    {
+                        nestedQuotes--;
+//                        System.out.println(
+//                                options + "\n" + "-" + nestedQuotes + ":" + getPositionString(valueIndex - 2, 1));
+                        if (nestedQuotes == 0)
+                        {
+                            //We've found the value of an option
+                            break;
+                        }
+                    }
+                    else
+                    {
+                        nestedQuotes++;
+//                        System.out.println(
+//                                options + "\n" + "+" + nestedQuotes + ":" + getPositionString(valueIndex - 2, 1));
+                    }
+                }
+                else
+                {
+                    // We are at the end of the string
+                    // Check to see if we are corectly closing quotes
+                    if (options.charAt(valueIndex) == '\'')
+                    {
+                        nestedQuotes--;
+                    }
+
+                    break;
+                }
+            }
+        }
+
+        if (nestedQuotes != 0 || valueIndex < (optionIndex + 2))
+        {
+            int sepIndex = 0;
+
+            //Try and identify illegal separator character
+            if (nestedQuotes > 1)
+            {
+                for (int i = 0; i < nestedQuotes; i++)
+                {
+                    sepIndex = options.indexOf('\'', sepIndex);
+                    sepIndex++;
+                }
+            }
+
+            if (sepIndex >= options.length() || sepIndex == 0)
+            {
+                parseError(valueIndex, "Unterminated option", options);
+            }
+            else
+            {
+                parseError(sepIndex, "Unterminated option. Possible illegal option separator:'" +
+                        options.charAt(sepIndex) + "'", options);
+            }
+        }
+
+        // optionIndex +2 to skip "='"
+        String value = options.substring(optionIndex + 2, valueIndex);
+
+        optionMap.put(option, value);
+
+        if (valueIndex < (options.length() - 1))
+        {
+            //Recurse to get remaining options
+            parseOptions(optionMap, options.substring(valueIndex + 2));
+        }
+    }
+
+
+    public static void parseError(int index, String error, String url) throws URLSyntaxException
+    {
+        parseError(index, 1, error, url);
+    }
+
+    public static void parseError(int index, int length, String error, String url) throws URLSyntaxException
+    {
+        throw new URLSyntaxException(url, error, index, length);
+    }
+
+    public static String printOptions(HashMap<String, String> options)
+    {
+        if (options.isEmpty())
+        {
+            return "";
+        }
+        else
+        {
+            StringBuffer sb = new StringBuffer();
+            sb.append('?');
+            for (String key : options.keySet())
+            {
+                sb.append(key);
+
+                sb.append("='");
+
+                sb.append(options.get(key));
+
+                sb.append("'");
+                sb.append(DEFAULT_OPTION_SEPERATOR);
+            }
+
+            sb.deleteCharAt(sb.length() - 1);
+
+            return sb.toString();
+        }
+    }
+}

Propchange: incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/URLHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/URLSyntaxException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/URLSyntaxException.java?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/URLSyntaxException.java (added)
+++ incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/URLSyntaxException.java Tue Sep 19 15:06:50 2006
@@ -0,0 +1,94 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.url;
+
+import java.net.URISyntaxException;
+
+public class URLSyntaxException extends URISyntaxException
+{
+    private int _length;
+
+    public URLSyntaxException(String url, String error, int index, int length)
+    {
+        super(url, error, index);
+
+        _length = length;
+    }
+
+    private static String getPositionString(int index, int length)
+    {
+        StringBuffer sb = new StringBuffer(index + 1);
+
+        for (int i = 0; i < index; i++)
+        {
+            sb.append(" ");
+        }
+
+        if (length > -1)
+        {
+            for (int i = 0; i < length; i++)
+            {
+                sb.append('^');
+            }
+        }
+
+        return sb.toString();
+    }
+
+
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append(getReason());
+
+        if (getIndex() > -1)
+        {
+            if (_length != -1)
+            {
+                sb.append(" between indicies ");
+                sb.append(getIndex());
+                sb.append(" and ");
+                sb.append(_length);
+            }
+            else
+            {
+                sb.append(" at index ");
+                sb.append(getIndex());
+            }
+        }
+
+        sb.append(" ");
+        if (getIndex() != -1)
+        {
+            sb.append("\n");
+        }
+
+        sb.append(getInput());
+
+        if (getIndex() != -1)
+        {
+            sb.append("\n");
+            sb.append(getPositionString(getIndex(), _length));
+        }
+
+        return sb.toString();
+    }
+
+
+}

Propchange: incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/url/URLSyntaxException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/stylesheets/framing.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/stylesheets/framing.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/stylesheets/framing.xsl (added)
+++ incubator/qpid/trunk/qpid/java/common/stylesheets/framing.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,61 @@
+<?xml version='1.0'?> 
+<!--
+ -
+ - Copyright (c) 2006 The Apache Software Foundation
+ -
+ - Licensed 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.
+ -
+ -->
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amq="http://amq.org"> 
+
+<xsl:import href="prepare1.xsl"/>
+<xsl:import href="prepare2.xsl"/>
+<xsl:import href="prepare3.xsl"/>
+<xsl:import href="java.xsl"/>
+
+<xsl:output indent="yes"/> 
+<xsl:output method="text" indent="yes" name="textFormat"/> 
+
+<xsl:template match="/">
+    <xsl:variable name="prepare1">
+        <xsl:apply-templates mode="prepare1" select="."/>
+    </xsl:variable>
+
+    <xsl:variable name="prepare2">
+        <xsl:apply-templates mode="prepare2" select="$prepare1"/>
+    </xsl:variable>
+
+    <xsl:variable name="model">
+        <xsl:apply-templates mode="prepare3" select="$prepare2"/>
+    </xsl:variable>
+
+    <xsl:apply-templates mode="generate-multi" select="$model"/>
+    <xsl:apply-templates mode="list-registry" select="$model"/>
+
+    <!-- dump out the intermediary files for debugging -->
+    <!--
+    <xsl:result-document href="prepare1.out">
+        <xsl:copy-of select="$prepare1"/> 
+    </xsl:result-document>
+
+    <xsl:result-document href="prepare2.out">
+        <xsl:copy-of select="$prepare2"/> 
+    </xsl:result-document>
+
+    <xsl:result-document href="model.out">
+        <xsl:copy-of select="$model"/> 
+    </xsl:result-document>
+    -->
+</xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/java/common/stylesheets/framing.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/stylesheets/java.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/stylesheets/java.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/stylesheets/java.xsl (added)
+++ incubator/qpid/trunk/qpid/java/common/stylesheets/java.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,247 @@
+<?xml version='1.0'?> 
+<!--
+ -
+ - Copyright (c) 2006 The Apache Software Foundation
+ -
+ - Licensed 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.
+ -
+ -->
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amq="http://amq.org"> 
+
+<!-- this class contains the templates for generating java source code for a given framing model -->
+<xsl:import href="utils.xsl"/>
+<xsl:output method="text" indent="yes" name="textFormat"/> 
+
+<xsl:param name="major"/>
+<xsl:param name="minor"/>
+<xsl:param name="registry_name"/>
+<xsl:param name="version_list_name"/>
+
+<xsl:template match="/"> 
+    <xsl:apply-templates mode="generate-multi" select="frames"/>
+    <xsl:apply-templates mode="generate-registry" select="frames"/>
+</xsl:template>
+
+<!-- processes all frames outputting the classes in a single stream -->
+<!-- (useful for debugging etc) -->
+<xsl:template match="frame" mode="generate-single"> 
+    <xsl:call-template name="generate-class">
+        <xsl:with-param name="f" select="."/>
+    </xsl:call-template>
+</xsl:template>
+
+<!-- generates seperate file for each class/frame -->
+<xsl:template match="frame" mode="generate-multi"> 
+    <xsl:variable name="uri" select="concat(@name, '.java')"/> 
+    wrote <xsl:value-of select="$uri"/> 
+    <xsl:result-document href="{$uri}" format="textFormat"> 
+    <xsl:call-template name="generate-class">
+        <xsl:with-param name="f" select="."/>
+    </xsl:call-template>
+    </xsl:result-document> 
+</xsl:template> 
+
+<!-- main class generation template -->
+<xsl:template name="generate-class"> 
+    <xsl:param name="f"/>
+    <xsl:value-of select="amq:copyright()"/>    
+<!-- package org.apache.qpid.framing_<xsl:value-of select="$major"/>_<xsl:value-of select="$minor"/>; -->
+package org.apache.qpid.framing;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.qpid.framing.AMQFrame;
+import org.apache.qpid.framing.AMQFrameDecodingException;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.EncodableAMQDataBlock;
+import org.apache.qpid.framing.EncodingUtils;
+import org.apache.qpid.framing.FieldTable;
+
+/**
+ * This class is autogenerated, do not modify. [From <xsl:value-of select="$f/parent::frames/@protocol"/>]
+ */
+public class <xsl:value-of select="$f/@name"/> extends AMQMethodBody implements EncodableAMQDataBlock
+{ 
+    public static final int CLASS_ID = <xsl:value-of select="$f/@class-id"/>; 	
+    public static final int METHOD_ID = <xsl:value-of select="$f/@method-id"/>; 	
+
+    <xsl:for-each select="$f/field"> 
+        <xsl:text>public </xsl:text><xsl:value-of select="@java-type"/>
+        <xsl:text> </xsl:text>
+        <xsl:value-of select="@name"/>;    
+    </xsl:for-each> 
+
+    protected int getClazz()
+    {
+        return <xsl:value-of select="$f/@class-id"/>;
+    }
+   
+    protected int getMethod()
+    {
+        return <xsl:value-of select="$f/@method-id"/>;
+    }
+
+    protected int getBodySize()
+    {
+        <xsl:choose> 
+        <xsl:when test="$f/field">
+        return
+        <xsl:for-each select="$f/field">
+            <xsl:if test="position() != 1">+
+            </xsl:if>
+            <xsl:value-of select="amq:field-length(.)"/>
+        </xsl:for-each>		 
+        ;
+        </xsl:when>
+        <xsl:otherwise>return 0;</xsl:otherwise>
+        </xsl:choose> 
+    }
+
+    protected void writeMethodPayload(ByteBuffer buffer)
+    {
+        <xsl:for-each select="$f/field">
+            <xsl:if test="@type != 'bit'">
+                <xsl:value-of select="amq:encoder(.)"/>;
+            </xsl:if>
+            <xsl:if test="@type = 'bit' and @boolean-index = 1">
+                <xsl:text>EncodingUtils.writeBooleans(buffer, new boolean[]{</xsl:text>
+                <xsl:value-of select="$f/field[@type='bit']/@name" separator=", "/>});
+            </xsl:if>
+        </xsl:for-each>		 
+    }
+
+    public void populateMethodBodyFromBuffer(ByteBuffer buffer) throws AMQFrameDecodingException
+    {
+        <xsl:for-each select="$f/field">
+            <xsl:value-of select="amq:decoder(.)"/>;
+        </xsl:for-each>		 
+    }
+
+    public String toString()
+    {
+        StringBuffer buf = new StringBuffer(super.toString());
+        <xsl:for-each select="$f/field">
+            <xsl:text>buf.append(" </xsl:text><xsl:value-of select="@name"/>: ").append(<xsl:value-of select="@name"/>);
+        </xsl:for-each> 
+        return buf.toString();
+    }
+
+    public static AMQFrame createAMQFrame(int channelId<xsl:if test="$f/field">, </xsl:if><xsl:value-of select="$f/field/concat(@java-type, ' ', @name)" separator=", "/>)
+    {
+        <xsl:value-of select="@name"/> body = new <xsl:value-of select="@name"/>();
+        <xsl:for-each select="$f/field">
+            <xsl:value-of select="concat('body.', @name, ' = ', @name)"/>;
+        </xsl:for-each>		 
+        AMQFrame frame = new AMQFrame();
+        frame.channel = channelId;
+        frame.bodyFrame = body;
+        return frame;
+    }
+} 
+</xsl:template> 
+
+<xsl:template match="/" mode="generate-registry">
+     <xsl:text>Matching root for registry mode!</xsl:text>
+     <xsl:value-of select="."/> 
+     <xsl:apply-templates select="frames" mode="generate-registry"/>
+</xsl:template>
+
+<xsl:template match="registries" mode="generate-registry">
+Wrote MethodBodyDecoderRegistry.java
+    <xsl:result-document href="MethodBodyDecoderRegistry.java" format="textFormat">
+    <xsl:value-of select="amq:copyright()"/>    
+<!-- package org.apache.qpid.framing_<xsl:value-of select="$major"/>_<xsl:value-of select="$minor"/>; -->
+package org.apache.qpid.framing;
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.log4j.Logger;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQFrameDecodingException;
+import org.apache.qpid.framing.AMQMethodBody;
+
+/**
+ * This class is autogenerated, do not modify.
+ */
+public final class MethodBodyDecoderRegistry
+{
+    private static final Logger _log = Logger.getLogger(MethodBodyDecoderRegistry.class);
+
+    private static final Map _classMethodProductToMethodBodyMap = new HashMap();
+
+    static
+    {
+        <xsl:for-each select="registry">
+            <xsl:value-of select="concat(@name, '.register(_classMethodProductToMethodBodyMap)')"/>;         
+        </xsl:for-each>
+    }
+
+    public static AMQMethodBody get(int clazz, int method) throws AMQFrameDecodingException
+    {
+	Class bodyClass = (Class) _classMethodProductToMethodBodyMap.get(new Integer(clazz * 1000 + method));
+	if (bodyClass != null)
+	{
+	    try
+	    {
+	        return (AMQMethodBody) bodyClass.newInstance();
+	    }
+	    catch (Exception e)
+	    {
+	    	throw new AMQFrameDecodingException(_log,
+                    "Unable to instantiate body class for class " + clazz + " and method " + method + ": " + e, e);
+	    }
+	}
+	else
+	{
+	    throw new AMQFrameDecodingException(_log,
+                "Unable to find a suitable decoder for class " + clazz + " and method " + method);
+	}    
+    }
+}
+</xsl:result-document>
+</xsl:template>
+
+<xsl:template match="frames" mode="list-registry">	
+    <xsl:if test="$registry_name">
+
+    <xsl:variable name="file" select="concat($registry_name, '.java')"/> 
+    wrote <xsl:value-of select="$file"/> 
+    <xsl:result-document href="{$file}" format="textFormat">
+    <xsl:value-of select="amq:copyright()"/>
+<!-- package org.apache.qpid.framing_<xsl:value-of select="$major"/>_<xsl:value-of select="$minor"/>; -->
+package org.apache.qpid.framing;
+
+import java.util.Map;
+
+/**
+ * This class is autogenerated, do not modify. [From <xsl:value-of select="@protocol"/>]
+ */
+class <xsl:value-of select="$registry_name"/>
+{
+    static void register(Map map)
+    {
+        <xsl:for-each select="frame">
+            <xsl:text>map.put(new Integer(</xsl:text>
+            <xsl:value-of select="@class-id"/>         
+	    <xsl:text> * 1000 + </xsl:text> 
+            <xsl:value-of select="@method-id"/>         
+	    <xsl:text>), </xsl:text> 
+            <xsl:value-of select="concat(@name, '.class')"/>);         
+        </xsl:for-each>
+    }
+}
+    </xsl:result-document>
+
+    </xsl:if>
+</xsl:template>
+
+</xsl:stylesheet>

Propchange: incubator/qpid/trunk/qpid/java/common/stylesheets/java.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/stylesheets/prepare1.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/stylesheets/prepare1.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/stylesheets/prepare1.xsl (added)
+++ incubator/qpid/trunk/qpid/java/common/stylesheets/prepare1.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,111 @@
+<?xml version='1.0'?> 
+<!--
+ -
+ - Copyright (c) 2006 The Apache Software Foundation
+ -
+ - Licensed 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.
+ -
+ -->
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amq="http://amq.org"> 
+
+<xsl:import href="utils.xsl"/>
+
+<xsl:output indent="yes"/> 
+<xsl:param name="asl_base"/>
+
+<!-- pre-process, phase 1 -->
+
+<xsl:template match="/">
+    <xsl:apply-templates select="protocol" mode="prepare1"/> 
+</xsl:template> 
+
+<xsl:template match="amqp"  mode="prepare1"> 
+    <frames>
+        <xsl:attribute name="protocol">
+            <xsl:value-of select="@comment"/>
+            <xsl:text> (</xsl:text>
+                <xsl:text>major=</xsl:text><xsl:value-of select="@major"/>
+                <xsl:text>, minor=</xsl:text><xsl:value-of select="@minor"/> 
+            <xsl:text>)</xsl:text>
+        </xsl:attribute>  
+        <xsl:attribute name="major">
+            <xsl:value-of select="@major"/>
+        </xsl:attribute>  
+        <xsl:attribute name="minor">
+            <xsl:value-of select="@minor"/>
+        </xsl:attribute>  
+        <xsl:apply-templates mode="prepare1" select="inherit"/> 
+        <xsl:apply-templates mode="prepare1" select="include"/> 
+        <xsl:apply-templates mode="prepare1" select="domain"/> 
+        <xsl:apply-templates mode="prepare1" select="class"/> 
+    </frames> 
+</xsl:template> 
+
+<xsl:template match="include" mode="prepare1"> 
+    <xsl:if test="@filename != 'asl_constants.asl'">
+        <!-- skip asl_constants.asl, we don't need it and it is not well formed so causes error warnings -->   
+        <xsl:apply-templates select="document(@filename)" mode="prepare1"/> 
+    </xsl:if> 
+</xsl:template> 
+
+<xsl:template match="inherit" mode="prepare1"> 
+    <xsl:variable name="ibase" select="concat('file:///', $asl_base, '/', @name, '.asl')"/>
+    <xsl:choose>
+        <xsl:when test="document($ibase)">  
+            <xsl:apply-templates select="document($ibase)" mode="prepare1"/>         
+        </xsl:when> 
+        <xsl:otherwise>
+            <xsl:message>
+            Could not inherit from <xsl:value-of select="$ibase"/>; file not found.
+            </xsl:message>
+        </xsl:otherwise>
+    </xsl:choose>
+</xsl:template> 
+
+<xsl:template match="class[@index]" mode="prepare1"> 
+    <xsl:apply-templates select="method" mode="prepare1"/> 
+</xsl:template> 
+
+<xsl:template match="method" mode="prepare1">
+    <xsl:if test="parent::class[@index]"><!-- there is a template class that has no index, which we want to skip -->
+    <frame>
+        <xsl:attribute name="name"><xsl:value-of select="amq:class-name(parent::class/@name, @name)"/></xsl:attribute>
+        <xsl:attribute name="class-id"><xsl:value-of select="parent::class/@index"/></xsl:attribute>
+        <xsl:if test="@index">
+            <xsl:attribute name="method-id"><xsl:value-of select="@index"/></xsl:attribute>
+        </xsl:if>
+        <xsl:if test="not(@index)">
+            <xsl:attribute name="method-id"><xsl:number count="method"/></xsl:attribute>
+        </xsl:if>
+
+        <xsl:apply-templates select="field" mode="prepare1"/>
+    </frame>
+    </xsl:if>
+</xsl:template>
+
+<xsl:template match="domain" mode="prepare1"> 
+    <domain> 
+        <name><xsl:value-of select="@name"/></name> 
+        <type><xsl:value-of select="@type"/></type> 
+    </domain> 
+</xsl:template> 
+
+<xsl:template match="field" mode="prepare1">
+    <field>
+        <xsl:copy-of select="@name"/>
+        <xsl:copy-of select="@type"/>
+        <xsl:copy-of select="@domain"/>
+    </field>
+</xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/java/common/stylesheets/prepare1.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/stylesheets/prepare2.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/stylesheets/prepare2.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/stylesheets/prepare2.xsl (added)
+++ incubator/qpid/trunk/qpid/java/common/stylesheets/prepare2.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,66 @@
+<?xml version='1.0'?> 
+<!--
+ -
+ - Copyright (c) 2006 The Apache Software Foundation
+ -
+ - Licensed 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.
+ -
+ -->
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amq="http://amq.org"> 
+
+<xsl:import href="utils.xsl"/>
+
+<xsl:output indent="yes"/> 
+
+<!-- pre-process, phase 2 -->
+
+<xsl:key name="domain-lookup" match="domain" use="name"/>
+
+<xsl:template match="/"> 
+    <xsl:apply-templates mode="prepare2" select="frames"/> 
+</xsl:template> 
+
+<xsl:template match="field[@domain]" mode="prepare2">
+     <field> 
+         <xsl:variable name="t1" select="key('domain-lookup', @domain)/type"/>
+         <xsl:attribute name="name"><xsl:value-of select="amq:field-name(@name)"/></xsl:attribute>
+         <xsl:attribute name="type"><xsl:value-of select="$t1"/></xsl:attribute>
+     </field> 
+</xsl:template> 
+
+<xsl:template match="field[@type]" mode="prepare2">
+     <field> 
+         <xsl:attribute name="name"><xsl:value-of select="amq:field-name(@name)"/></xsl:attribute>
+         <xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
+     </field> 
+</xsl:template> 
+
+<xsl:template match="frames" mode="prepare2">
+    <frames>
+        <xsl:copy-of select="@protocol"/>
+        <xsl:copy-of select="@major"/>
+        <xsl:copy-of select="@minor"/>
+        <xsl:apply-templates mode="prepare2"/>
+    </frames>
+</xsl:template>
+
+<xsl:template match="frame" mode="prepare2">
+    <xsl:element name="{name()}">
+        <xsl:copy-of select="@*"/>
+        <xsl:apply-templates mode="prepare2" select="field"/>  
+    </xsl:element>
+</xsl:template>
+
+<xsl:template match="domain" mode="prepare2"></xsl:template> 
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/java/common/stylesheets/prepare2.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/stylesheets/prepare3.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/stylesheets/prepare3.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/stylesheets/prepare3.xsl (added)
+++ incubator/qpid/trunk/qpid/java/common/stylesheets/prepare3.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,62 @@
+<?xml version='1.0'?> 
+<!--
+ -
+ - Copyright (c) 2006 The Apache Software Foundation
+ -
+ - Licensed 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.
+ -
+ -->
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amq="http://amq.org"> 
+
+<xsl:import href="utils.xsl"/>
+
+<xsl:output indent="yes"/> 
+
+<!-- final preparation of the model -->
+
+<xsl:template match="/">
+    <xsl:apply-templates mode="prepare3"/>
+</xsl:template>
+
+<xsl:template match="frames" mode="prepare3">
+    <frames>
+        <xsl:copy-of select="@protocol"/>
+        <xsl:copy-of select="@major"/>
+        <xsl:copy-of select="@minor"/>
+        <xsl:apply-templates mode="prepare3"/>
+    </frames>
+</xsl:template>
+
+<xsl:template match="frame" mode="prepare3">
+    <xsl:element name="frame">
+        <xsl:copy-of select="@*"/>
+	<xsl:if test="field[@type='bit']"><xsl:attribute name="has-bit-field">true</xsl:attribute></xsl:if>
+        <xsl:apply-templates mode="prepare3"/>
+    </xsl:element>
+</xsl:template>
+
+
+<xsl:template match="field" mode="prepare3">
+     <field>
+         <xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
+         <!-- ensure the field name is processed to be a valid java name -->
+         <xsl:attribute name="name"><xsl:value-of select="amq:field-name(@name)"/></xsl:attribute>
+         <!-- add some attributes to make code generation easier -->
+         <xsl:attribute name="java-type"><xsl:value-of select="amq:java-type(@type)"/></xsl:attribute>
+         <xsl:if test="@type='bit'">
+             <xsl:attribute name="boolean-index"><xsl:number count="field[@type='bit']"/></xsl:attribute>
+         </xsl:if>
+     </field>
+</xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/java/common/stylesheets/prepare3.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/stylesheets/readme.txt
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/stylesheets/readme.txt?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/stylesheets/readme.txt (added)
+++ incubator/qpid/trunk/qpid/java/common/stylesheets/readme.txt Tue Sep 19 15:06:50 2006
@@ -0,0 +1,52 @@
+This directory contains the xsl stylesheets used to generate the code from the
+AMQP protocol specification. They require an XSLT2.0 processor, currently 
+Saxon 8 is used.
+
+The generation process is controlled by the framing.xsl stylesheet. This performs
+several phases of transformation, using the other stylesheets. The transformation
+in each phase is defined in a separate file, and these are designed to also allow
+then to be run individually. 
+
+The generation takes the amq.asl as input, it also requires that the path to the 
+directory where the base asl definitions reside (those definitions that the main
+amq.asl defintion inherits from) be passed in via a paramter called asl_base.
+
+The files involved are as follows:
+
+    framing.xsl    The control file for the entire generation process
+
+    prepare1.xsl   Resolves the separate files that make up the protocol 
+                   definition, building a single tree containing all the
+                   information as a set of 'frame' elements, each of which
+                   has attributes for its name, and ids for the class and
+                   method it refers to and contains zero or more field 
+                   elements. 
+
+                   A method id is generated based on the order of the 
+                   method elements within the class elements in the original
+                   specification. The class id is taken from the enclosing
+                   class element.  
+
+    prepare2.xsl   Resolves domains into their corresponding types. (This is
+                   much easier when all the information is in a single tree, 
+                   hence the separate frame). 
+
+    prepare3.xsl   Converts names into valid java names and augments the
+                   tree to include information that makes the subsequent
+                   generation phase simpler e.g. the index of boolean 
+                   fields as several boolean flags are combined into a
+                   single byte. (This is easier once the domains have been
+                   resolved, hence the separate phase).
+
+    java.xsl       Generates java classes for each frame, and a registry of 
+                   all the frames to a 'magic' number generated from their 
+                   class and method id.
+
+    utils.xsl      Contains some utility methods for e.g. producing valid
+                   java names.
+
+For debugging the framing.xsl can output the intermediary files. This can be
+enabled by uncommenting the relevant lines (a comment explaining this is
+provided inline).     
+ 
+ 
\ No newline at end of file

Propchange: incubator/qpid/trunk/qpid/java/common/stylesheets/readme.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/stylesheets/registry.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/stylesheets/registry.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/stylesheets/registry.xsl (added)
+++ incubator/qpid/trunk/qpid/java/common/stylesheets/registry.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,29 @@
+<?xml version='1.0'?> 
+<!--
+ -
+ - Copyright (c) 2006 The Apache Software Foundation
+ -
+ - Licensed 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.
+ -
+ -->
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amq="http://amq.org"> 
+
+<xsl:import href="java.xsl"/>
+
+<xsl:output method="text" indent="yes" name="textFormat"/> 
+
+<xsl:template match="/">
+    <xsl:apply-templates mode="generate-registry" select="registries"/>
+</xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/java/common/stylesheets/registry.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/common/stylesheets/utils.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/stylesheets/utils.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/stylesheets/utils.xsl (added)
+++ incubator/qpid/trunk/qpid/java/common/stylesheets/utils.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,201 @@
+<?xml version='1.0'?>
+<!--
+ -
+ - Copyright (c) 2006 The Apache Software Foundation
+ -
+ - Licensed 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.
+ -
+ -->
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amq="http://amq.org">
+
+<!-- This file contains functions that are used in the generation of the java classes for framing -->
+
+<!-- create copyright notice for generated files -->
+<xsl:function name="amq:copyright">/**
+*
+* Copyright (c) 2006 The Apache Software Foundation
+*
+* Licensed 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.
+*
+*/
+</xsl:function>
+
+<!-- retrieve the java type of a given amq type -->
+<xsl:function name="amq:java-type">
+    <xsl:param name="t"/>
+    <xsl:choose>
+	 <xsl:when test="$t='char'">char</xsl:when> 		 		 
+	 <xsl:when test="$t='octet'">short</xsl:when> 		 		 
+	 <xsl:when test="$t='short'">int</xsl:when> 		 		 
+	 <xsl:when test="$t='shortstr'">String</xsl:when> 		 		 
+	 <xsl:when test="$t='longstr'">byte[]</xsl:when> 		 		 
+	 <xsl:when test="$t='bit'">boolean</xsl:when> 		 		 
+	 <xsl:when test="$t='long'">long</xsl:when> 		 		 
+	 <xsl:when test="$t='longlong'">long</xsl:when> 		 		 
+	 <xsl:when test="$t='table'">FieldTable</xsl:when> 		 		 
+         <xsl:otherwise>Object /*WARNING: undefined type*/</xsl:otherwise>
+    </xsl:choose>
+</xsl:function>
+
+<!-- retrieve the code to get the field size of a given amq type -->
+<xsl:function name="amq:field-length">
+    <xsl:param name="f"/>
+    <xsl:choose>
+        <xsl:when test="$f/@type='bit' and $f/@boolean-index=1">
+            <xsl:value-of select="concat('1 /*', $f/@name, '*/')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='bit' and $f/@boolean-index &gt; 1">
+            <xsl:value-of select="concat('0 /*', $f/@name, '*/')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='char'">
+            <xsl:value-of select="concat('1 /*', $f/@name, '*/')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='octet'">
+            <xsl:value-of select="concat('1 /*', $f/@name, '*/')"/>
+        </xsl:when>
+	<xsl:when test="$f/@type='short'">
+            <xsl:value-of select="concat('2 /*', $f/@name, '*/')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='long'">
+            <xsl:value-of select="concat('4 /*', $f/@name, '*/')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='longlong'">
+            <xsl:value-of select="concat('8 /*', $f/@name, '*/')"/>
+        </xsl:when>
+	<xsl:when test="$f/@type='shortstr'">
+            <xsl:value-of select="concat('EncodingUtils.encodedShortStringLength(', $f/@name, ')')"/>
+        </xsl:when> 		 		 
+	<xsl:when test="$f/@type='longstr'">
+            <xsl:value-of select="concat('4 + (', $f/@name, ' == null ? 0 : ', $f/@name, '.length)')"/>
+        </xsl:when> 		 		 
+	<xsl:when test="$f/@type='table'">
+            <xsl:value-of select="concat('EncodingUtils.encodedFieldTableLength(', $f/@name, ')')"/>
+        </xsl:when> 		 		 
+        <xsl:otherwise><xsl:text>/* WARNING: COULD NOT DETERMINE FIELD SIZE */</xsl:text></xsl:otherwise>
+    </xsl:choose>    
+</xsl:function>
+
+<!-- retrieve the code to encode a field of a given amq type -->
+<!-- Note:
+     This method will not provide an encoder for a bit field. 
+     Bit fields should be encoded together separately. -->
+
+<xsl:function name="amq:encoder">
+    <xsl:param name="f"/>
+    <xsl:choose>
+        <xsl:when test="$f/@type='char'">
+            <xsl:value-of select="concat('EncodingUtils.writeChar(buffer, ', $f/@name, ')')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='octet'">
+            <xsl:value-of select="concat('EncodingUtils.writeUnsignedByte(buffer, ', $f/@name, ')')"/>
+        </xsl:when>
+	<xsl:when test="$f/@type='short'">
+            <xsl:value-of select="concat('EncodingUtils.writeUnsignedShort(buffer, ', $f/@name, ')')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='long'">
+            <xsl:value-of select="concat('EncodingUtils.writeUnsignedInteger(buffer, ', $f/@name, ')')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='longlong'">
+            <xsl:value-of select="concat('buffer.putLong(', $f/@name, ')')"/>
+        </xsl:when>
+	<xsl:when test="$f/@type='shortstr'">
+            <xsl:value-of select="concat('EncodingUtils.writeShortStringBytes(buffer, ', $f/@name, ')')"/>
+        </xsl:when> 		 		 
+	<xsl:when test="$f/@type='longstr'">
+            <xsl:value-of select="concat('EncodingUtils.writeLongstr(buffer, ', $f/@name, ')')"/>
+        </xsl:when> 		 		 
+	<xsl:when test="$f/@type='table'">
+            <xsl:value-of select="concat('EncodingUtils.writeFieldTableBytes(buffer, ', $f/@name, ')')"/>
+        </xsl:when> 		 		 
+        <xsl:otherwise><xsl:text>/* WARNING: COULD NOT DETERMINE ENCODER */</xsl:text></xsl:otherwise>
+    </xsl:choose>    
+</xsl:function>
+
+<!-- retrieve the code to decode a field of a given amq type -->
+<xsl:function name="amq:decoder">
+    <xsl:param name="f"/>
+    <xsl:choose>
+        <xsl:when test="$f/@type='bit'">
+            <xsl:if test="$f/@boolean-index = 1">
+                <xsl:text>boolean[] bools = EncodingUtils.readBooleans(buffer);</xsl:text>
+            </xsl:if>
+            <xsl:value-of select="concat($f/@name, ' = bools[', $f/@boolean-index - 1 , ']')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='char'">
+            <xsl:value-of select="concat($f/@name, ' = buffer.getChar()')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='octet'">
+            <xsl:value-of select="concat($f/@name, ' = buffer.getUnsigned()')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='short'">
+            <xsl:value-of select="concat($f/@name, ' = buffer.getUnsignedShort()')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='long'">
+            <xsl:value-of select="concat($f/@name, ' = buffer.getUnsignedInt()')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='longlong'">
+            <xsl:value-of select="concat($f/@name, ' = buffer.getLong()')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='shortstr'">
+            <xsl:value-of select="concat($f/@name, ' = EncodingUtils.readShortString(buffer)')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='longstr'">
+            <xsl:value-of select="concat($f/@name, ' = EncodingUtils.readLongstr(buffer)')"/>
+        </xsl:when>
+        <xsl:when test="$f/@type='table'">
+            <xsl:value-of select="concat($f/@name, ' = EncodingUtils.readFieldTable(buffer)')"/>
+        </xsl:when>
+        <xsl:otherwise><xsl:text>/* WARNING: COULD NOT DETERMINE DECODER */</xsl:text></xsl:otherwise>
+    </xsl:choose>    
+</xsl:function>
+
+<!-- create the class name for a frame, based on class and method (passed in) -->
+<xsl:function name="amq:class-name">
+    <xsl:param name="class"/>
+    <xsl:param name="method"/>
+    <xsl:value-of select="concat(amq:upper-first($class),amq:upper-first(amq:field-name($method)), 'Body')"/>
+</xsl:function>
+
+<!-- get a valid field name, processing spaces and '-'s where appropriate -->
+<xsl:function name="amq:field-name">
+    <xsl:param name="name"/>
+    <xsl:choose>
+        <xsl:when test="contains($name, ' ')">
+            <xsl:value-of select="concat(substring-before($name, ' '), amq:upper-first(substring-after($name, ' ')))"/>
+        </xsl:when>
+        <xsl:when test="contains($name, '-')">
+            <xsl:value-of select="concat(substring-before($name, '-'), amq:upper-first(substring-after($name, '-')))"/>
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select="$name"/>
+        </xsl:otherwise>
+    </xsl:choose>
+</xsl:function>
+
+<!-- convert the first character of the input to upper-case -->
+<xsl:function name="amq:upper-first">
+    <xsl:param name="in"/>
+    <xsl:value-of select="concat(upper-case(substring($in, 1, 1)), substring($in, 2))"/>
+</xsl:function>
+
+</xsl:stylesheet>

Propchange: incubator/qpid/trunk/qpid/java/common/stylesheets/utils.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/doc/AMQBlazeDetailedDesign.vsd
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/doc/AMQBlazeDetailedDesign.vsd?view=auto&rev=447994
==============================================================================
Binary file - no diff available.

Propchange: incubator/qpid/trunk/qpid/java/doc/AMQBlazeDetailedDesign.vsd
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/qpid/trunk/qpid/java/doc/FramingClassDiagram.vsd
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/doc/FramingClassDiagram.vsd?view=auto&rev=447994
==============================================================================
Binary file - no diff available.

Propchange: incubator/qpid/trunk/qpid/java/doc/FramingClassDiagram.vsd
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/qpid/trunk/qpid/java/management/cli/bin/stac.bat
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/cli/bin/stac.bat?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/cli/bin/stac.bat (added)
+++ incubator/qpid/trunk/qpid/java/management/cli/bin/stac.bat Tue Sep 19 15:06:50 2006
@@ -0,0 +1,38 @@
+@REM
+@REM Copyright (c) 2006 The Apache Software Foundation
+@REM
+@REM Licensed under the Apache License, Version 2.0 (the "License");
+@REM you may not use this file except in compliance with the License.
+@REM You may obtain a copy of the License at
+@REM
+@REM    http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM
+
+@echo off
+set COREROOT=..\..\core
+set AMQROOT=..\..\..\clients_java
+
+set CP=..\lib\jython\jython.jar
+set CP=%CP%;..\dist\amqp-stac.jar
+set CP=%CP%;%COREROOT%\dist\amqp-management-common.jar
+set CP=%CP%;%COREROOT%\lib\log4j\log4j-1.2.9.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\jsr173_api.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\resolver.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\xbean.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\xbean_xpath.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\xmlpublic.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\saxon8.jar
+set CP=%CP%;%AMQROOT%\dist\amqp-common.jar
+set CP=%CP%;%AMQROOT%\dist\amqp-jms.jar
+set CP=%CP%;%AMQROOT%\lib\mina\mina-0.7.3.jar
+set CP=%CP%;%AMQROOT%\lib\jms\jms.jar
+set CP=%CP%;%AMQROOT%\lib\util-concurrent\backport-util-concurrent.jar
+set CP=%CP%;%AMQROOT%\lib\jakarta-commons\commons-collections-3.1.jar
+
+%JAVA_HOME%\bin\java -Damqj.logging.level="ERROR" -cp %CP% org.apache.qpid.stac.Stac

Propchange: incubator/qpid/trunk/qpid/java/management/cli/bin/stac.bat
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Added: incubator/qpid/trunk/qpid/java/management/cli/bin/stac.sh
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/cli/bin/stac.sh?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/cli/bin/stac.sh (added)
+++ incubator/qpid/trunk/qpid/java/management/cli/bin/stac.sh Tue Sep 19 15:06:50 2006
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 The Apache Software Foundation
+#
+# Licensed 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.
+#
+
+
+COREROOT=../../core
+AMQROOT=../../../clients_java
+
+CP=../lib/jython/jython.jar
+CP=$CP:../dist/amqp-stac.jar
+CP=$CP:$COREROOT/dist/amqp-management-common.jar
+CP=$CP:$COREROOT/lib/log4j/log4j-1.2.9.jar
+CP=$CP:$COREROOT/lib/xmlbeans/jsr173_api.jar
+CP=$CP:$COREROOT/lib/xmlbeans/resolver.jar
+CP=$CP:$COREROOT/lib/xmlbeans/xbean.jar
+CP=$CP:$COREROOT/lib/xmlbeans/xbean_xpath.jar
+CP=$CP:$COREROOT/lib/xmlbeans/xmlpublic.jar
+CP=$CP:$COREROOT/lib/xmlbeans/saxon8.jar
+CP=$CP:$AMQROOT/dist/amqp-common.jar
+CP=$CP:$AMQROOT/dist/amqp-jms.jar
+CP=$CP:$AMQROOT/lib/mina/mina-0.7.3.jar
+CP=$CP:$AMQROOT/lib/jms/jms.jar
+CP=$CP:$AMQROOT/lib/util-concurrent/backport-util-concurrent.jar
+CP=$CP:$AMQROOT/lib/jakarta-commons/commons-collections-3.1.jar
+
+$JAVA_HOME/bin/java -Damqj.logging.level="ERROR" -cp $CP org.apache.qpid.stac.Stac

Propchange: incubator/qpid/trunk/qpid/java/management/cli/bin/stac.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/java/management/cli/bin/stac.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/qpid/trunk/qpid/java/management/cli/bin/stacDEV.bat
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/cli/bin/stacDEV.bat?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/cli/bin/stacDEV.bat (added)
+++ incubator/qpid/trunk/qpid/java/management/cli/bin/stacDEV.bat Tue Sep 19 15:06:50 2006
@@ -0,0 +1,41 @@
+@REM
+@REM Copyright (c) 2006 The Apache Software Foundation
+@REM
+@REM Licensed under the Apache License, Version 2.0 (the "License");
+@REM you may not use this file except in compliance with the License.
+@REM You may obtain a copy of the License at
+@REM
+@REM    http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM
+
+@echo off
+set COREROOT=..\..\core
+set AMQROOT=..\..\..\clients_java
+
+set CP=..\lib\jython\jython.jar
+set CP=%CP%;..\intellijclasses
+set CP=%CP%;%COREROOT%\intellijclasses
+set CP=%CP%;%COREROOT%\classes
+set CP=%CP%;%COREROOT%\lib\log4j\log4j-1.2.9.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\jsr173_api.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\resolver.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\xbean.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\xbean_xpath.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\xmlpublic.jar
+set CP=%CP%;%COREROOT%\lib\xmlbeans\saxon8.jar
+set CP=%CP%;%AMQROOT%\dist\amqp-common.jar
+set CP=%CP%;%AMQROOT%\dist\amqp-jms.jar
+set CP=%CP%;%AMQROOT%\lib\mina\mina-0.7.3.jar
+set CP=%CP%;%AMQROOT%\lib\jms\jms.jar
+set CP=%CP%;%AMQROOT%\lib\util-concurrent\backport-util-concurrent.jar
+set CP=%CP%;%AMQROOT%\lib\jakarta-commons\commons-collections-3.1.jar
+
+
+@rem %JAVA_HOME%\bin\java -Damqj.logging.level="ERROR" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -cp %CP% org.amqp.blaze.stac.Stac
+%JAVA_HOME%\bin\java -Damqj.logging.level="ERROR" -cp %CP% org.amqp.blaze.stac.Stac
\ No newline at end of file

Propchange: incubator/qpid/trunk/qpid/java/management/cli/bin/stacDEV.bat
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Added: incubator/qpid/trunk/qpid/java/management/cli/build-module.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/cli/build-module.xml?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/cli/build-module.xml (added)
+++ incubator/qpid/trunk/qpid/java/management/cli/build-module.xml Tue Sep 19 15:06:50 2006
@@ -0,0 +1,21 @@
+<!--
+ -
+ - Copyright (c) 2006 The Apache Software Foundation
+ -
+ - Licensed 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.
+ -
+ -->
+<project name="AMQ Management Client" default="build">
+  <property name="module.depends" value="common,client,management/core"/>
+  <import file="../../module.xml"/>
+</project>

Propchange: incubator/qpid/trunk/qpid/java/management/cli/build-module.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/management/cli/build-old.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/cli/build-old.xml?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/cli/build-old.xml (added)
+++ incubator/qpid/trunk/qpid/java/management/cli/build-old.xml Tue Sep 19 15:06:50 2006
@@ -0,0 +1,122 @@
+<?xml version="1.0"?>
+<!--
+ -
+ - Copyright (c) 2006 The Apache Software Foundation
+ -
+ - Licensed 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.
+ -
+ -->
+
+<!-- AMQP STAC Java build file -->
+
+<project name="management-stac" default="jar" basedir=".">
+    <property name="lib" value="${basedir}/lib"/>
+    <property name="src" value="${basedir}/src"/>
+    <property name="tests" value="${basedir}/test"/>
+    <property name="classes" value="${basedir}/classes"/>
+    <property name="testclasses" value="${basedir}/testclasses"/>
+    <property name="dist" value="${basedir}/dist"/>
+    <property name="amqp.root" value="${basedir}/../../clients_java"/>
+    <property name="amqp.lib" value="${amqp.root}/lib"/>
+    <property name="amqp.dist" value="${amqp.root}/dist"/>
+    <property name="managementcore.root" value="${basedir}/../core"/>
+    <property name="managementcore.dist" value="${managementcore.root}/dist"/>
+    <property name="managementcore.lib" value="${managementcore.root}/lib"/>
+
+    <!-- Setup details -->
+    <target name="init">
+        <tstamp>
+            <format property="release" pattern="-dMMMyy" locale="en" timezone="GMT"/>
+        </tstamp>
+
+        <mkdir dir="${classes}"/>
+        <mkdir dir="${testclasses}"/>
+        <mkdir dir="${dist}"/>
+    </target>
+
+    <path id="core.classpath">
+        <fileset dir="${lib}">
+            <include name="**/*.jar"/>
+        </fileset>
+        <pathelement path="${classes}"/>
+        <pathelement path="${testclasses}/"/>
+        <fileset dir="${managementcore.dist}">
+            <include name="**/*.jar"/>
+        </fileset>
+        <fileset dir="${managementcore.lib}">
+            <include name="**/*.jar"/>
+        </fileset>
+        <fileset dir="${amqp.dist}">
+            <include name="**/*.jar"/>
+        </fileset>
+        <fileset dir="${amqp.lib}">
+            <include name="**/*.jar"/>
+        </fileset>
+    </path>
+
+    <!-- Remove all built files -->
+    <target name="clean" depends="init">
+        <delete dir="${classes}"/>
+        <delete dir="${dist}"/>
+        <delete dir="${testclasses}"/>
+    </target>
+
+    <!-- Compile Java -->
+    <target name="compile" depends="init">
+        <javac destdir="${classes}" target="1.5" source="1.5" debug="on">
+            <classpath refid="core.classpath"/>
+            <src path="${src}"/>
+        </javac>
+
+        <copy todir="${classes}">
+            <!-- copy any non java src files into the build tree, e.g. log4j.properties -->
+            <fileset dir="${src}">
+                <exclude name="**/*.java"/>
+                <exclude name="**/package.html"/>
+            </fileset>
+        </copy>
+    </target>
+
+
+    <target name="compiletests" depends="compile">
+        <javac destdir="${testclasses}" target="1.5" source="1.5" classpathref="core.classpath"
+               debug="on">
+            <src path="${tests}"/>
+        </javac>
+
+        <copy todir="${testclasses}">
+            <!-- copy any non java src files into the build tree, e.g. log4j.properties -->
+            <fileset dir="${tests}">
+                <exclude name="**/*.java"/>
+                <exclude name="**/package.html"/>
+            </fileset>
+        </copy>
+    </target>
+
+    <!-- Build jar archive -->
+    <target name="jar" depends="compiletests">
+        <mkdir dir="${dist}"/>
+        <jar basedir="${classes}" jarfile="${dist}/amqp-stac.jar"/>
+        <jar basedir="${testclasses}" jarfile="${dist}/amqp-stac-tests.jar"/>
+    </target>
+
+
+    <target name="javadoc" depends="compile, compiletests">
+        <mkdir dir="${dist}/docs/api"/>
+        <javadoc sourcepath="${src}" destdir="${dist}/docs/api"
+                 packagenames="org.apache.qpid.*" classpathref="amqp.classpath" author="true"
+                 version="true" windowTitle="AMQP STAC API" doctitle="AMQP STAC API"
+                 footer="See &lt;a href=&quot;http://www.amqp.org&quot;&gt;www.amqp.org&lt;/a&gt; for more information."
+                 use="true" verbose="false"/>
+    </target>
+</project>

Propchange: incubator/qpid/trunk/qpid/java/management/cli/build-old.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/management/cli/lib/jython/jython.jar
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/cli/lib/jython/jython.jar?view=auto&rev=447994
==============================================================================
Binary file - no diff available.

Propchange: incubator/qpid/trunk/qpid/java/management/cli/lib/jython/jython.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/Stac.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/Stac.java?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/Stac.java (added)
+++ incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/Stac.java Tue Sep 19 15:06:50 2006
@@ -0,0 +1,94 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.stac;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+
+public class Stac
+{
+    public static void main(String[] args)
+    {
+        BufferedReader terminal = new BufferedReader(new InputStreamReader(System.in));
+        System.out.println("\nInitializing the Scripting Tool for AMQ Console (STAC) ...");
+        String var = System.getProperty("python.verbose");
+        if (var != null)
+        {
+            System.setProperty("python.verbose", var);
+        }
+        else
+        {
+            System.setProperty("python.verbose", "warning");
+        }
+        StacInterpreter interp = new StacInterpreter();
+        InputStream is = Stac.class.getResourceAsStream("/python/stac.py");
+        if (is == null)
+        {
+            System.err.println("Unable to load STAC Python library. Terminating.");
+            System.exit(1);
+        }
+        interp.execfile(is);
+
+        boolean running = true;
+
+        while (running)
+        {
+            interp.write(interp.get("commandPrompt").toString());
+
+            String line = null;
+            try
+            {
+                line = terminal.readLine();
+                if (line != null)
+                {
+                    if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit"))
+                    {
+                        running = false;
+                        line = "quit()";
+                    }
+                    while (interp.runsource(line))
+                    {
+                        interp.write("...");
+                        try
+                        {
+                            String s = terminal.readLine();
+                            line = line + "\n" + s;
+                        }
+                        catch (IOException e)
+                        {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                else
+                {
+                    System.out.println();
+                    running = false;
+                }
+            }
+            catch (IOException ie)
+            {
+                System.err.println("An error occurred: " + ie);
+                ie.printStackTrace(System.err);
+            }
+        }
+        System.exit(0);
+    }
+}

Propchange: incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/Stac.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/StacInterpreter.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/StacInterpreter.java?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/StacInterpreter.java (added)
+++ incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/StacInterpreter.java Tue Sep 19 15:06:50 2006
@@ -0,0 +1,31 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.stac;
+
+import org.python.util.InteractiveInterpreter;
+import org.python.core.PySystemState;
+
+public class StacInterpreter extends InteractiveInterpreter
+{
+    public StacInterpreter()
+    {
+        PySystemState.initialize();
+        super.set("theInterpreter", this);
+        super.exec("import sys\n");
+    }
+}

Propchange: incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/StacInterpreter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/commands/CdCommand.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/commands/CdCommand.java?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/commands/CdCommand.java (added)
+++ incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/commands/CdCommand.java Tue Sep 19 15:06:50 2006
@@ -0,0 +1,50 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.stac.commands;
+
+import org.apache.qpid.stac.jmx.MBeanServerConnectionContext;
+import org.apache.qpid.stac.jmx.CurrentMBean;
+import org.apache.qpid.AMQException;
+
+public class CdCommand
+{
+    public static void execute(MBeanServerConnectionContext context, String destination)
+            throws AMQException
+    {
+        // check if it is an absolute path and if so change to the root first
+        if (destination.startsWith("/"))
+        {
+            context.changeBean("/");
+            destination = destination.substring(1);
+        }
+        if (destination.length() == 0)
+        {
+            return;
+        }
+        String[] destinations = destination.split("/");
+        for (String item : destinations)
+        {
+            if ("..".equals(item))
+            {
+                item = CurrentMBean.PARENT_ATTRIBUTE;
+            }
+            context.changeBean(item);
+        }
+    }
+
+}

Propchange: incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/commands/CdCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/commands/InvokeCommand.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/commands/InvokeCommand.java?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/commands/InvokeCommand.java (added)
+++ incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/commands/InvokeCommand.java Tue Sep 19 15:06:50 2006
@@ -0,0 +1,31 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.stac.commands;
+
+import org.apache.qpid.stac.jmx.MBeanServerConnectionContext;
+import org.apache.qpid.AMQException;
+
+public class InvokeCommand
+{
+    public static void execute(MBeanServerConnectionContext context, String methodName, Object... args)
+            throws AMQException
+    {
+        // Not used currently
+
+    }
+}

Propchange: incubator/qpid/trunk/qpid/java/management/cli/src/org/apache/qpid/stac/commands/InvokeCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native