forked from jnode/jnode
-
Notifications
You must be signed in to change notification settings - Fork 0
DeviceAlreadyConnectedException
opencode-agent[bot] edited this page May 11, 2026
·
1 revision
Exception thrown when attempting to connect a device that is already bound to a driver.
DeviceAlreadyConnectedException is a minor driver error exception (value 2) thrown within JNode's device framework when an attempt is made to connect a Driver to a Device that already has an active driver association. It extends DriverException, which itself extends Exception.
The exception enforces the one-driver-per-device invariant in JNode's device lifecycle management.
| Class | Location | Purpose |
|---|---|---|
DeviceAlreadyConnectedException |
core/src/driver/org/jnode/driver/DeviceAlreadyConnectedException.java |
The exception class |
DriverException |
core/src/driver/org/jnode/driver/DriverException.java |
Parent exception class |
Driver |
core/src/driver/org/jnode/driver/Driver.java |
Driver base class with connect() method |
Device |
core/src/driver/org/jnode/driver/Device.java |
Device base class with setDriver() method |
Exception
└── DriverException
└── DeviceAlreadyConnectedException
The exception is thrown by Driver.connect(Device) at line 73-76 in Driver.java:
protected final void connect(Device device) throws DriverException {
if (this.device != null) {
throw new DriverException("This driver is already connected to a device");
}
verifyConnect(device);
this.device = device;
afterConnect(device);
}The exception can be thrown when:
- A
Driverinstance that is already bound to oneDevicereceives a call toconnect()with a differentDevice - A
Device.setDriver()call propagates todriver.connect()where the driver is already connected
Device.setDriver(driver)
└── driver.connect(this) // Throws if driver already has a device
└── Driver.connect(device) checks this.device != null
The exception provides four constructors for flexibility:
-
DeviceAlreadyConnectedException()— No-arg -
DeviceAlreadyConnectedException(String s)— Message only -
DeviceAlreadyConnectedException(Throwable cause)— Cause only -
DeviceAlreadyConnectedException(String message, Throwable cause)— Both
-
Not directly thrown: The exception is not thrown directly; instead
Driver.connect()throws aDriverExceptionwith this as the cause or as the exception type itself - Single-device constraint: Drivers in JNode are single-device — once a driver is connected to a device, it cannot be rebound to another device
- Silent failure prevention: The exception enforces the one-driver-per-device invariant that prevents undefined system state
- Driver-Framework — Parent framework containing device and driver lifecycle management
- DeviceManager — Central registry managing device-driver bindings
- DeviceAPI — Interface pattern for device functionality exposure
- DriverException — Parent exception class for all driver-related errors