diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2012-02-01 23:56:28 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2012-02-01 23:56:28 +0000 |
| commit | 0dcfedb9a055a5ec9175a13cdce8667104cd799a (patch) | |
| tree | d195069c3d429ef502f3514d8b1faf82eba0f651 /qpid/java/jca/src | |
| parent | 08b3d439ce5cdcd127d14489ba4730ae3f2c7724 (diff) | |
| download | qpid-python-0dcfedb9a055a5ec9175a13cdce8667104cd799a.tar.gz | |
QPID-3734 Commiting patch by Weston Price.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1239411 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/jca/src')
9 files changed, 247 insertions, 90 deletions
diff --git a/qpid/java/jca/src/main/java/org/apache/qpid/ra/QpidRAManagedConnectionFactory.java b/qpid/java/jca/src/main/java/org/apache/qpid/ra/QpidRAManagedConnectionFactory.java index 377a0c6253..318485a7f2 100644 --- a/qpid/java/jca/src/main/java/org/apache/qpid/ra/QpidRAManagedConnectionFactory.java +++ b/qpid/java/jca/src/main/java/org/apache/qpid/ra/QpidRAManagedConnectionFactory.java @@ -330,7 +330,7 @@ public class QpidRAManagedConnectionFactory implements ManagedConnectionFactory, public int hashCode() { int hash = _mcfProperties.hashCode(); - hash += 31 * _ra.hashCode(); + hash += 31 * ((_ra != null) ? _ra.hashCode() : 1); return hash; } diff --git a/qpid/java/jca/src/main/java/org/apache/qpid/ra/Util.java b/qpid/java/jca/src/main/java/org/apache/qpid/ra/Util.java index 3957fa9660..491595b9fb 100644 --- a/qpid/java/jca/src/main/java/org/apache/qpid/ra/Util.java +++ b/qpid/java/jca/src/main/java/org/apache/qpid/ra/Util.java @@ -32,11 +32,10 @@ import javax.naming.Context; import javax.naming.RefAddr; import javax.naming.Reference; import javax.naming.Referenceable; +import javax.naming.spi.NamingManager; import javax.transaction.TransactionManager; import org.apache.qpid.client.AMQConnectionURL; -import org.apache.qpid.ra.admin.QpidQueue; -import org.apache.qpid.ra.admin.QpidTopic; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -88,31 +87,7 @@ public class Util if (object instanceof Reference) { - - Reference ref = (Reference) object; - String addressContent = null; - - if (ref.getClassName().equals(QpidQueue.class.getName())) - { - RefAddr addr = ref.get(QpidQueue.class.getName()); - addressContent = (String) addr.getContent(); - - if (addr != null) - { - return (T)new QpidQueue(addressContent); - } - } - - if (ref.getClassName().equals(QpidTopic.class.getName())) - { - RefAddr addr = ref.get(QpidTopic.class.getName()); - addressContent = (String) addr.getContent(); - - if (addr != null) - { - return (T)new QpidTopic(addressContent); - } - } + return (T)NamingManager.getObjectInstance(object, null, null, null); } return clazz.cast(object); diff --git a/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/AdminObjectFactory.java b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/AdminObjectFactory.java index 11f2903c72..213ea815f2 100644 --- a/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/AdminObjectFactory.java +++ b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/AdminObjectFactory.java @@ -46,26 +46,26 @@ public class AdminObjectFactory implements ObjectFactory Reference ref = (Reference) object; String bindingURLString; - if (ref.getClassName().equals(QpidQueue.class.getName())) + if (ref.getClassName().equals(QpidQueueImpl.class.getName())) { - RefAddr addr = ref.get(QpidQueue.class.getName()); + RefAddr addr = ref.get(QpidQueueImpl.class.getName()); bindingURLString = (String) addr.getContent(); if (addr != null) { - return new QpidQueue(bindingURLString); + return new QpidQueueImpl(bindingURLString); } } - if (ref.getClassName().equals(QpidTopic.class.getName())) + if (ref.getClassName().equals(QpidTopicImpl.class.getName())) { - RefAddr addr = ref.get(QpidTopic.class.getName()); + RefAddr addr = ref.get(QpidTopicImpl.class.getName()); bindingURLString = (String) addr.getContent(); if (addr != null) { - return new QpidTopic(bindingURLString); + return new QpidTopicImpl(bindingURLString); } } } diff --git a/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidDestinationProxy.java b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidDestinationProxy.java index 738ce4be0d..7fc84ea69f 100644 --- a/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidDestinationProxy.java +++ b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidDestinationProxy.java @@ -111,11 +111,11 @@ public class QpidDestinationProxy implements Externalizable, Referenceable, Dest { if(getDestinationType().equalsIgnoreCase(DEFAULT_QUEUE_TYPE)) { - _delegate = new QpidQueue(getDestinationAddress()); + _delegate = new QpidQueueImpl(getDestinationAddress()); } else if(getDestinationType().equalsIgnoreCase(DEFAULT_TOPIC_TYPE)) { - _delegate = new QpidTopic(getDestinationAddress()); + _delegate = new QpidTopicImpl(getDestinationAddress()); } else { diff --git a/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidQueue.java b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidQueue.java index caef0c8ffd..1b93d1c42c 100644 --- a/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidQueue.java +++ b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidQueue.java @@ -20,32 +20,8 @@ */ package org.apache.qpid.ra.admin; -import javax.naming.NamingException; -import javax.naming.Reference; -import javax.naming.StringRefAddr; - -import org.apache.qpid.client.AMQQueue; - -public class QpidQueue extends AMQQueue +public interface QpidQueue { - private String _url; - - public QpidQueue(final String address) throws Exception - { - super(address); - this._url = address; - } - - @Override - public Reference getReference() throws NamingException - { - return new Reference(this.getClass().getName(), new StringRefAddr(this.getClass().getName(), toURL()), - AdminObjectFactory.class.getName(), null); - } - - @Override - public String toURL() - { - return _url; - } + public void setDestinationAddress(String destinationAddress) throws Exception; + public String getDestinationAddress(); } diff --git a/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidQueueImpl.java b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidQueueImpl.java new file mode 100644 index 0000000000..417849fc5c --- /dev/null +++ b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidQueueImpl.java @@ -0,0 +1,119 @@ +/* + * + * 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.ra.admin; + +import java.io.Externalizable; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectInputStream; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NamingException; +import javax.naming.RefAddr; +import javax.naming.Reference; +import javax.naming.StringRefAddr; +import javax.naming.spi.ObjectFactory; + +import org.apache.qpid.client.AMQQueue; +import org.apache.qpid.ra.admin.AdminObjectFactory; + +public class QpidQueueImpl extends AMQQueue implements QpidQueue, Externalizable +{ + private String _url; + + public QpidQueueImpl() + { + super(); + } + + public QpidQueueImpl(final String address) throws Exception + { + super(address); + this._url = address; + } + + @Override + public Reference getReference() throws NamingException + { + return new Reference(this.getClass().getName(), new StringRefAddr(this.getClass().getName(), toURL()), + AdminObjectFactory.class.getName(), null); + } + + @Override + public String toURL() + { + return _url; + } + + public void setDestinationAddress(String destinationAddress) throws Exception + { + this._url = destinationAddress; + setDestinationString(this._url); + } + + + public String getDestinationAddress() + { + return this._url; + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException + { + this._url = (String)in.readObject(); + + try + { + setDestinationString(this._url); + + } + catch(Exception e) + { + throw new IOException(e.getMessage(), e); + } + } + + public void writeExternal(ObjectOutput out) throws IOException + { + out.writeObject(this._url); + } + + //TODO move to tests + public static void main(String[] args) throws Exception + { + QpidQueueImpl q = new QpidQueueImpl(); + q.setDestinationAddress("hello.Queue;{create:always, node:{type:queue, x-declare:{auto-delete:true}}}"); + ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("queue.out")); + os.writeObject(q); + os.close(); + + + ObjectInputStream is = new ObjectInputStream(new FileInputStream("queue.out")); + q = (QpidQueueImpl)is.readObject(); + System.out.println(q); + + } +} diff --git a/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidTopic.java b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidTopic.java index 3f181b93eb..f87c35d9e2 100644 --- a/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidTopic.java +++ b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidTopic.java @@ -20,33 +20,9 @@ */ package org.apache.qpid.ra.admin; -import javax.naming.NamingException; -import javax.naming.Reference; -import javax.naming.StringRefAddr; - -import org.apache.qpid.client.AMQTopic; - -public class QpidTopic extends AMQTopic +public interface QpidTopic { - private String _url; - - public QpidTopic(final String address) throws Exception - { - super(address); - this._url = address; - } - - @Override - public Reference getReference() throws NamingException - { - return new Reference(this.getClass().getName(), new StringRefAddr(this.getClass().getName(), toURL()), - AdminObjectFactory.class.getName(), null); - } - - @Override - public String toURL() - { - return _url; - } + public void setDestinationAddress(String destinationAddress) throws Exception; + public String getDestinationAddress(); } diff --git a/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidTopicImpl.java b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidTopicImpl.java new file mode 100644 index 0000000000..8ac1a679ea --- /dev/null +++ b/qpid/java/jca/src/main/java/org/apache/qpid/ra/admin/QpidTopicImpl.java @@ -0,0 +1,93 @@ +/* + * + * 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.ra.admin; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.naming.NamingException; +import javax.naming.Reference; +import javax.naming.StringRefAddr; + +import org.apache.qpid.client.AMQTopic; +import org.apache.qpid.ra.inflow.QpidActivation; + +public class QpidTopicImpl extends AMQTopic implements QpidTopic, Externalizable +{ + private String _url; + + public QpidTopicImpl() + { + super(); + } + public QpidTopicImpl(final String address) throws Exception + { + super(address); + this._url = address; + } + + @Override + public Reference getReference() throws NamingException + { + return new Reference(this.getClass().getName(), new StringRefAddr(this.getClass().getName(), toURL()), + AdminObjectFactory.class.getName(), null); + } + + @Override + public String toURL() + { + return _url; + } + + public void setDestinationAddress(String destinationAddress) throws Exception + { + this._url = destinationAddress; + setDestinationString(this._url); + } + + + public String getDestinationAddress() + { + return this._url; + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException + { + this._url = (String)in.readObject(); + + try + { + setDestinationString(this._url); + + } + catch(Exception e) + { + throw new IOException(e.getMessage(), e); + } + } + + public void writeExternal(ObjectOutput out) throws IOException + { + out.writeObject(this._url); + } +} diff --git a/qpid/java/jca/src/main/resources/META-INF/ra.xml b/qpid/java/jca/src/main/resources/META-INF/ra.xml index 90dc7b3b8e..2c8344c8f0 100755 --- a/qpid/java/jca/src/main/resources/META-INF/ra.xml +++ b/qpid/java/jca/src/main/resources/META-INF/ra.xml @@ -197,6 +197,23 @@ </inbound-resourceadapter> <adminobject> + <adminobject-interface>org.apache.qpid.ra.admin.QpidQueue</adminobject-interface> + <adminobject-class> org.apache.qpid.ra.admin.QpidQueueImpl</adminobject-class> + <config-property> + <config-property-name>destinationAddress </config-property-name> + <config-property-type>java.lang.String </config-property-type> + </config-property> + </adminobject> + <adminobject> + <adminobject-interface>org.apache.qpid.ra.admin.QpidTopic</adminobject-interface> + <adminobject-class> org.apache.qpid.ra.admin.QpidTopicImpl</adminobject-class> + <config-property> + <config-property-name>destinationAddress </config-property-name> + <config-property-type>java.lang.String </config-property-type> + </config-property> + </adminobject> + <!-- + <adminobject> <adminobject-interface>javax.jms.Destination</adminobject-interface> <adminobject-class> org.apache.qpid.ra.admin.QpidDestinationProxy</adminobject-class> <config-property> @@ -208,6 +225,7 @@ <config-property-type>java.lang.String </config-property-type> </config-property> </adminobject> + --> <adminobject> <adminobject-interface>javax.jms.ConnectionFactory</adminobject-interface> <adminobject-class> org.apache.qpid.ra.admin.QpidConnectionFactoryProxy</adminobject-class> |
