001/*
002 * HA-JDBC: High-Availability JDBC
003 * Copyright (c) 2004-2007 Paul Ferraro
004 * 
005 * This library is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Lesser General Public License as published by the 
007 * Free Software Foundation; either version 2.1 of the License, or (at your 
008 * option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful, but WITHOUT
011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 
013 * for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public License
016 * along with this library; if not, write to the Free Software Foundation, 
017 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018 * 
019 * Contact: ferraro@users.sourceforge.net
020 */
021package net.sf.hajdbc.distributable;
022
023import java.io.Externalizable;
024import java.io.IOException;
025import java.io.ObjectInput;
026import java.io.ObjectOutput;
027
028import org.jgroups.Address;
029
030/**
031 * @author Paul Ferraro
032 * @since 2.0
033 */
034public abstract class AbstractLockDecree implements LockDecree, Externalizable
035{
036        protected String id;
037        private Address address;
038        
039        protected AbstractLockDecree(String id, Address address)
040        {
041                this.id = id;
042                this.address = address;
043        }
044
045        protected AbstractLockDecree()
046        {
047                // Required for deserialization
048        }
049        
050        /**
051         * @see net.sf.hajdbc.distributable.LockDecree#getAddress()
052         */
053        public Address getAddress()
054        {
055                return this.address;
056        }
057
058        /**
059         * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
060         */
061        @Override
062        public void writeExternal(ObjectOutput output) throws IOException
063        {
064                output.writeUTF(this.id);
065                output.writeObject(this.address);
066        }
067
068        /**
069         * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
070         */
071        @Override
072        public void readExternal(ObjectInput input) throws IOException, ClassNotFoundException
073        {
074                this.id = input.readUTF();
075                this.address = (Address) input.readObject();
076        }
077}