Ejemplo n.º 1
0
 /**
  * Connect a device to the link
  *
  * @param device
  * @throws TooManyConnectionException
  */
 public void connectDevice(Device device) throws ShanksException {
   if (this.linkedDevices.size() < deviceCapacity) {
     if (!this.linkedDevices.contains(device)) {
       this.linkedDevices.add(device);
       device.connectToLink(this);
       logger.finer(
           "Link "
               + this.getID()
               + " has Device "
               + device.getID()
               + " in its linked device list.");
     } else {
       logger.finer(
           "Link "
               + this.getID()
               + " already has Device "
               + device.getID()
               + " in its linked device list.");
     }
   } else {
     if (!this.linkedDevices.contains(device)) {
       logger.warning(
           "Link "
               + this.getID()
               + " is full of its capacity. Device "
               + device.getID()
               + " was not included in its linked device list.");
       throw new TooManyConnectionException(this);
     } else {
       logger.finer(
           "Link "
               + this.getID()
               + " already has Device "
               + device.getID()
               + " in its linked device list.");
     }
   }
 }
Ejemplo n.º 2
0
 /** @param device */
 public void disconnectDevice(Device device) {
   this.linkedDevices.remove(device);
   device.disconnectFromLink(this);
 }