1 46 50 package org.mr.kernel.services; 51 52 import java.io.IOException ; 53 54 import org.mr.core.util.byteable.Byteable; 55 import org.mr.core.util.byteable.ByteableInputStream; 56 import org.mr.core.util.byteable.ByteableOutputStream; 57 import org.mr.core.util.byteable.ByteableRegistry; 58 59 60 66 public class ServiceActorInfoContainer implements Byteable{ 67 private ServiceActor actor; 68 69 75 public String getByteableName() { 76 77 return "ServiceActorInfoCont"; 78 } 79 85 public void toBytes(ByteableOutputStream out) throws IOException { 86 out.writeByteable(actor); 87 88 89 } 90 96 public Byteable createInstance(ByteableInputStream in) throws IOException { 97 ServiceActorInfoContainer result = new ServiceActorInfoContainer(); 98 result.setActor((ServiceActor) in.readByteable()); 99 return result; 100 } 101 107 public void registerToByteableRegistry() { 108 ByteableRegistry.registerByteableFactory(getByteableName() , this); 109 } 110 115 public static void register(){ 116 ServiceActorInfoContainer instance = new ServiceActorInfoContainer(); 117 instance.actor = new ServiceProducer("","","",(byte)0); 118 instance.registerToByteableRegistry(); 119 } 120 121 122 125 public ServiceActor getActor() { 126 return actor; 127 } 128 132 public void setActor(ServiceActor actor) { 133 this.actor = actor; 134 } 135 136 137 140 public boolean equals(Object other) { 141 142 if (other==null) 143 return false; 144 if (other instanceof ServiceActor) 145 return actor.equals(other); 146 if(other instanceof ServiceActorInfoContainer){ 147 return this.actor.equals(((ServiceActorInfoContainer)other).getActor()); 148 } 149 return super.equals(other); 150 } 151 152 155 public int hashCode(){ 156 return actor.hashCode(); 157 } 158 } 159 | Popular Tags |