001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  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 */
017package org.apache.activemq.ra;
018
019import javax.resource.spi.endpoint.MessageEndpointFactory;
020
021
022public class ActiveMQEndpointActivationKey {
023    private final MessageEndpointFactory messageEndpointFactory;
024    private final MessageActivationSpec activationSpec;
025
026    /**
027     * For testing
028     */ 
029    protected ActiveMQEndpointActivationKey() {
030        this(null, null);
031    }
032
033    /**
034     * @param messageEndpointFactory
035     * @param activationSpec
036     */
037    public ActiveMQEndpointActivationKey(MessageEndpointFactory messageEndpointFactory, MessageActivationSpec activationSpec) {
038        this.messageEndpointFactory = messageEndpointFactory;
039        this.activationSpec = activationSpec;
040    }
041
042    /**
043     * @return Returns the activationSpec.
044     */
045    public MessageActivationSpec getActivationSpec() {
046        return activationSpec;
047    }
048
049    /**
050     * @return Returns the messageEndpointFactory.
051     */
052    public MessageEndpointFactory getMessageEndpointFactory() {
053        return messageEndpointFactory;
054    }
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 || !(obj instanceof ActiveMQEndpointActivationKey)) {
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}