001 /**
002 *
003 * Copyright 2004 Hiram Chirino
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 *
017 **/
018 package org.activemq.ra;
019
020 import javax.resource.spi.endpoint.MessageEndpointFactory;
021
022
023 public class ActiveMQEndpointActivationKey {
024 final private MessageEndpointFactory messageEndpointFactory;
025 final private ActiveMQActivationSpec activationSpec;
026
027 /**
028 * @return Returns the activationSpec.
029 */
030 public ActiveMQActivationSpec getActivationSpec() {
031 return activationSpec;
032 }
033
034 /**
035 * @return Returns the messageEndpointFactory.
036 */
037 public MessageEndpointFactory getMessageEndpointFactory() {
038 return messageEndpointFactory;
039 }
040
041 /**
042 * For testing
043 */
044 ActiveMQEndpointActivationKey() {
045 this(null, null);
046 }
047
048 /**
049 * @param messageEndpointFactory
050 * @param activationSpec
051 */
052 public ActiveMQEndpointActivationKey(MessageEndpointFactory messageEndpointFactory, ActiveMQActivationSpec activationSpec) {
053 this.messageEndpointFactory = messageEndpointFactory;
054 this.activationSpec = activationSpec;
055 }
056
057 /**
058 * @see java.lang.Object#hashCode()
059 */
060 public int hashCode() {
061 return messageEndpointFactory.hashCode() ^ activationSpec.hashCode();
062 }
063
064 /**
065 * @see java.lang.Object#equals(java.lang.Object)
066 */
067 public boolean equals(Object obj) {
068 if (this == obj) {
069 return true;
070 }
071 if (obj == null) {
072 return false;
073 }
074 ActiveMQEndpointActivationKey o = (ActiveMQEndpointActivationKey) obj;
075
076 //Per the 12.4.9 spec:
077 // MessageEndpointFactory does not implement equals()
078 // ActivationSpec does not implement equals()
079 return o.activationSpec == activationSpec && o.messageEndpointFactory == messageEndpointFactory;
080 }
081 }