All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgroups.util.Owner Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up with different versions on classes on the class path).

There is a newer version: 33.0.2.Final
Show newest version
package org.jgroups.util;


import org.jgroups.Address;

import java.io.DataInput;
import java.io.DataOutput;


/**
 * Represents an 'owner', which is an address and thread ID
 * @author Bela Ban
 */
public class Owner implements Streamable {
    protected Address address;
    protected long    thread_id;

    public Owner() {
    }

    public Owner(Address address, long thread_id) {
        this.address=address;
        this.thread_id=thread_id;
    }

    public Address getAddress() {
        return address;
    }

    public long getThreadId() {
        return thread_id;
    }

    public void writeTo(DataOutput out) throws Exception {
        Util.writeAddress(address, out);
        Bits.writeLong(thread_id, out);
    }

    public void readFrom(DataInput in) throws Exception {
        address=Util.readAddress(in);
        thread_id=Bits.readLong(in);
    }

    public boolean equals(Object obj) {
        if(obj == null)
            return false;
        Owner other=(Owner)obj;
        return address.equals(other.address) && thread_id == other.thread_id;
    }

    public int hashCode() {
        return (int)(address.hashCode() + thread_id);
    }

    public String toString() {
        return thread_id < 0? address.toString() : address + "::" + thread_id;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy