Class JposBase
- All Implemented Interfaces:
jpos.services.BaseService
- Direct Known Subclasses:
BeltService,BillAcceptorService,BillDispenserService,BiometricsService,BumpBarService,CashChangerService,CashDrawerService,CATService,CheckScannerService,CoinAcceptorService,CoinDispenserService,DeviceMonitorService,ElectronicJournalService,ElectronicValueRWService,FiscalPrinterService,GateService,GestureControlService,GraphicDisplayService,HardTotalsService,ImageScannerService,IndividualRecognitionService,ItemDispenserService,KeylockService,LightsService,LineDisplayService,MICRService,MotionSensorService,MSRService,PINPadService,PointCardRWService,POSKeyboardService,POSPowerService,POSPrinterService,RemoteOrderDisplayService,RFIDScannerService,ScaleService,ScannerService,SignatureCaptureService,SmartCardRWService,SoundPlayerService,SoundRecorderService,SpeechSynthesisService,ToneIndicatorService,VideoCaptureService,VoiceRecognitionService
Whenever accessing a property or method, the service performs all plausibility checks that are possible without detailed knowledge about a specific physical device. Whenever all parameters are plausible and a method or setter call is generally allowed, a corresponding method of a class that implements the device specific interface be called. This is almost always the correspondong property property set class which implements the corresponding default methods.
These methods have the same name as the method or property name
originally called.
Interface methods corresponding to JavaPOS properties have one parameter -
the new property value.
Interface methods corresponding to JavaPOS methods that are always
be called synchronously have the same parameters as the original method.
For JavaPOS methods that can be called asynchronously, two property set methods are available:
- A validation method that has the same parameters as the original method. This method must return an object of a method specific class derived from JposOutputRequest with the method's name.
- An executor method that has one parameter - the object returned by the corresponding validation method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionDevice object that holds the service implementation.Instance of a class implementing the JposBaseInterface for common getter and method calls bound to the property set.Property set that forms the device service together with class JposDevice and the JposBaseInterface, normally implemented within the property set. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancallNowOrLater(JposOutputRequest request)Call method bound to a specific output request synchronously or asynchronously, depending on AsyncMode property.voidCheck method for device classes that support a subsystem of up to 32 units.voidCheck method for device classes that support a subsystem of up to 32 units.static voidTo allow calling JposDevice method check without JposDevice.voidCheck method for device classes that support a subsystem of up to 32 units.voidChecks whether the device is enabled and not busy.voidChecks whether the device has been claimed.voidChecks whether the device is enabled.voidChecks whether the device is enabled and not claimed by another instance.voidChecks whether the device has just been enabled once.voidcheckHealth(int level)voidcheckNoChangedOrClaimed(Object oldval, Object newval)Checks within property set methods whether old and new values are equal or the device has been claimed.voidChecks whether the device has been opened.voidclaim(int timeout)voidCommon method clearInput, see UPOS specificationvoidCommon method clearInputProperties, see UPOS specificationvoidCommon method clearOutput, se UPOS specificationvoidclose()voidcompareFirmwareVersion(String firmwareFileName, int[] result)Common method compareFirmwareVersion, see UPOS specificationdeepToString(Object value, int maxlen)Converts object to String.voidDeletes the service instance.voidbooleanGet common property AsyncMode, see UPOS specificationbooleanGet common property AutoDisable, see UPOS specificationbooleanGet common property CapCompareFirmwareVersion, see UPOS specificationintGet common property CapPowerReporting, see UPOS specificationbooleanGet common property CapStatisticsReporting, see UPOS specificationbooleanGet common property CapUpdateFirmware, see UPOS specificationbooleanGet common property CapUpdateStatistics, see UPOS specificationbooleanintGet common property DataCount, see UPOS specificationbooleanGet common property DataEventEnabled, see UPOS specificationbooleanintbooleanintGet common property OutputID, see UPOS specificationintGet common property PowerNotify, see UPOS specificationintGet common property CapCompareFirmwareVersion, see UPOS specificationgetPropertyString(Object obj, String propertyName)Returns a property value of an object as String, using its getter method.intgetState()voidlogAsyncCall(String method)Generate logging message after successful enqueueing an asynchronous method call.voidGenerate logging message after successful method call.voidGenerate logging message after successful method call.voidGenerates logging message for the named property of the given object.voidGenerates logging message for the named property.voidlogPreCall(String method)Generates logging message before named method will be called.voidlogPreCall(String method, String args)Generates logging message before named method will be called.voidGenerates logging message before setting named property.voidGenerates logging message after named property has been setvoidvoidrelease()removeOuterArraySpecifier(Object object, int maxlen)Removes outer array specifiers '{' and '}' from string representation of an object created via deepToString.voidresetStatistics(String statisticsBuffer)Common method resetStatistics, see UPOS specificationvoidretrieveStatistics(String[] statisticsBuffer)Common method retrieveStatistics, see UPOS specificationvoidsetAsyncMode(boolean b)Get common property AsyncMode, see UPOS specificationvoidsetAutoDisable(boolean b)Set common property AutoDisable, see UPOS specificationvoidsetDataEventEnabled(boolean b)Set common property DataEventEnabled, see UPOS specificationvoidsetDeviceEnabled(boolean enable)voidsetFreezeEvents(boolean freezeEvents)voidsetPowerNotify(int powerNotify)Set common property PowerNotify, see UPOS specificationvoidSignals release after claim.startClaiming(SyncObject waiter)Starts claiming.voidupdateFirmware(String firmwareFileName)Common method updateFirmware, see UPOS specificationvoidupdateStatistics(String statisticsBuffer)Common method updateStatistics, see UPOS specification
-
Field Details
-
Props
Property set that forms the device service together with class JposDevice and the JposBaseInterface, normally implemented within the property set. -
Device
Device object that holds the service implementation. Only used to access device object directly instead of indirectly via the stored property set. -
DeviceInterface
Instance of a class implementing the JposBaseInterface for common getter and method calls bound to the property set. Almost always the same object as Props.
-
-
Constructor Details
-
JposBase
Constructor. Stores given property set and device implementation object.- Parameters:
props- Property set.device- Device implementation object.
-
-
Method Details
-
deleteInstance
public void deleteInstance() throws jpos.JposExceptionDeletes the service instance. Called to perform cleanup operations.- Throws:
jpos.JposException- If close() failed or if device cannot be found in list of all devices.
-
logGet
Generates logging message for the named property.- Parameters:
propertyName- Name of the property.
-
logGet
Generates logging message for the named property of the given object.- Parameters:
obj- Object that holds the requested property.propertyName- Name of the property.
-
getPropertyString
Returns a property value of an object as String, using its getter method. Usually, simply the toString method of the specified object will be used to retrieve its string representation. If the property is an array, the string representations of all elements stored within the array will be concatenated separated by comma. Keep in mind that this might be confusing if the string representation of an element itself contains a comma, and that at least MaxArrayStringElements will be retrieved. If an array has more than MaxArrayStringElements elements, further elements will be represented by "...".- Parameters:
obj- Object that contains the requested property.propertyName- Name of the requested property.- Returns:
- String representation of the property.
- Throws:
Exception- Getter not available.
-
removeOuterArraySpecifier
Removes outer array specifiers '{' and '}' from string representation of an object created via deepToString. This means, if a String returned by deepToString starts with '{' end ends with '}', both, the first and the last character will be removed from the string.- Parameters:
object- The object for which the String representation shall be returned.maxlen- Maximum array length, if object or a component of object is an array.- Returns:
- String representation of object, in case of an array without the starting and final '{' and '}'.
-
deepToString
Converts object to String. Uses method toString to convert the object to a String, but in case of Array objects, a comma separated list of the toString results of the first maxlen elements of the array will be returned instead.- Parameters:
value- The object to be converted to a string.maxlen- Maximum number of array elements converted to String. If an array consists of more than maxlen elements, the remaining elements will be represented by "...".- Returns:
- The String representation of value.
-
logPreSet
Generates logging message before setting named property.- Parameters:
propertyName- Name of property to be set.
-
logSet
Generates logging message after named property has been set- Parameters:
propertyName- Name of property to be set.
-
logPreCall
Generates logging message before named method will be called.- Parameters:
method- Method name.args- String specifying the parameters passed to the method.
-
logPreCall
Generates logging message before named method will be called. Version that suppresses parameter dump.- Parameters:
method- Method name.
-
logCall
Generate logging message after successful method call.- Parameters:
method- Method name.args- empty string or comma separated list of arguments.
-
logCall
Generate logging message after successful method call. Version without return parameter list.- Parameters:
method- Method name.
-
logAsyncCall
Generate logging message after successful enqueueing an asynchronous method call.- Parameters:
method- Method name.
-
callNowOrLater
Call method bound to a specific output request synchronously or asynchronously, depending on AsyncMode property.- Parameters:
request- JposOutputRequest to be enqueued- Returns:
- true if corresponding method will be called asynchronously, false in case of synchronous operation.
- Throws:
jpos.JposException- If an error occurs during synchronous operation.
-
getAutoDisable
public boolean getAutoDisable() throws jpos.JposExceptionGet common property AutoDisable, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property AutoDisable
-
setAutoDisable
public void setAutoDisable(boolean b) throws jpos.JposExceptionSet common property AutoDisable, see UPOS specification- Parameters:
b- New property value- Throws:
jpos.JposException- See UPOS specification, property AutoDisable
-
getDataCount
public int getDataCount() throws jpos.JposExceptionGet common property DataCount, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property DataCount
-
getDataEventEnabled
public boolean getDataEventEnabled() throws jpos.JposExceptionGet common property DataEventEnabled, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property DataEventEnabled
-
setDataEventEnabled
public void setDataEventEnabled(boolean b) throws jpos.JposExceptionSet common property DataEventEnabled, see UPOS specification- Parameters:
b- New property value- Throws:
jpos.JposException- See UPOS specification, property DataEventEnabled
-
getCapCompareFirmwareVersion
public boolean getCapCompareFirmwareVersion() throws jpos.JposExceptionGet common property CapCompareFirmwareVersion, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property CapCompareFirmwareVersion
-
getCapUpdateFirmware
public boolean getCapUpdateFirmware() throws jpos.JposExceptionGet common property CapUpdateFirmware, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property CapUpdateFirmware
-
getCapStatisticsReporting
public boolean getCapStatisticsReporting() throws jpos.JposExceptionGet common property CapStatisticsReporting, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property CapStatisticsReporting
-
getCapUpdateStatistics
public boolean getCapUpdateStatistics() throws jpos.JposExceptionGet common property CapUpdateStatistics, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property CapUpdateStatistics
-
getCapPowerReporting
public int getCapPowerReporting() throws jpos.JposExceptionGet common property CapPowerReporting, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property CapPowerReporting
-
getPowerNotify
public int getPowerNotify() throws jpos.JposExceptionGet common property PowerNotify, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property PowerNotify
-
setPowerNotify
public void setPowerNotify(int powerNotify) throws jpos.JposExceptionSet common property PowerNotify, see UPOS specification- Parameters:
powerNotify- New property value- Throws:
jpos.JposException- See UPOS specification, property PowerNotify
-
getPowerState
public int getPowerState() throws jpos.JposExceptionGet common property CapCompareFirmwareVersion, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property
-
getAsyncMode
public boolean getAsyncMode() throws jpos.JposExceptionGet common property AsyncMode, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property
-
setAsyncMode
public void setAsyncMode(boolean b) throws jpos.JposExceptionGet common property AsyncMode, see UPOS specification- Parameters:
b- New property value- Throws:
jpos.JposException- See UPOS specification, property PowerNotify
-
checkEnabled
public void checkEnabled() throws jpos.JposExceptionChecks whether the device is enabled. If not, throws a JposException with an error code and message that describe the state of the device.- Throws:
jpos.JposException- Will be thrown whenever the device is not enabled.
-
checkBusy
public void checkBusy() throws jpos.JposExceptionChecks whether the device is enabled and not busy. If not, throws a JposException with an error code and message that describe the state of the device.- Throws:
jpos.JposException- Will be thrown whenever the device is not enabled or busy.
-
checkEnabledUnclaimed
public void checkEnabledUnclaimed() throws jpos.JposExceptionChecks whether the device is enabled and not claimed by another instance. If not, throws a JposException with an error code and message that describe the state of the device.- Throws:
jpos.JposException- Will be thrown whenever the device is not enabled.
-
checkFirstEnabled
public void checkFirstEnabled() throws jpos.JposExceptionChecks whether the device has just been enabled once. If not, throws a JposException with an error code and message that describe the state of the device.- Throws:
jpos.JposException- Will be thrown whenever the device has never been enabled.
-
checkClaimed
public void checkClaimed() throws jpos.JposExceptionChecks whether the device has been claimed. If not, a JposException will be thrown with the corresponding error code.- Throws:
jpos.JposException- Will be thrown whenever the device has not been claimed.
-
checkOpened
public void checkOpened() throws jpos.JposExceptionChecks whether the device has been opened. If not, a JposException will be thrown with the corresponding error code.- Throws:
jpos.JposException- Will be thrown whenever the device has not been opened or has been closed.
-
checkNoChangedOrClaimed
Checks within property set methods whether old and new values are equal or the device has been claimed. If the device is an exclusive-use device and AllowAlwaysSetProperties has been set to false via jpos.xml, a JposException will be thrown.- Parameters:
oldval- Property value to be changed.newval- New property value.- Throws:
jpos.JposException- Will be thrown whenever the throwing condition is met.
-
check
To allow calling JposDevice method check without JposDevice. prefix, we pass all parameters to JposDevice.check unchanged.- Parameters:
condition- Same condition as in JposDevice.err- Same error code as in JposDevice.errtxt- Same text as in JposDevice.- Throws:
jpos.JposException- If condition is true.
-
check
public void check(boolean condition, int units, int error, int ext, String message) throws jpos.JposExceptionCheck method for device classes that support a subsystem of up to 32 units. Checks condition and if true, sets error properties and throws JposException. This method may only be used if it is absolutely clear that the check is made within a synchronous UPOS method. If this is not the case, use method checkwith additional parameter synchrone. This is almost always the case in methods that have one parameter derived from JposOutputRequest. You can check whether property EndSync of the request equals null (asynchronous call) or not (synchronous call).- Parameters:
condition- Error condition.units- Units to be filled in ErrorUnits.error- Error code.ext- Extended error code.message- Error message, same message for ErrorString and JposException.- Throws:
jpos.JposException- If Error condition is true.
-
check
public void check(boolean condition, int units, int error, int ext, String message, boolean synchrone) throws jpos.JposExceptionCheck method for device classes that support a subsystem of up to 32 units. Checks condition and if true, sets error properties and throws JposException.- Parameters:
condition- Error condition.units- Units to be filled in ErrorUnits.error- Error code.ext- Extended error code.message- Error message, same message for ErrorString and JposException.synchrone- True if method has been called synchronously, false otherwise.- Throws:
jpos.JposException- If Error condition is true.
-
check
public void check(Exception cause, int units, int error, int ext, boolean synchrone) throws jpos.JposExceptionCheck method for device classes that support a subsystem of up to 32 units. Check condition and if true, sets error properties and throws JposException. If the error cause- Parameters:
cause- The Exception that caused the error. A value of null can be passed if no error occurred.units- Units to be filled in ErrorUnits.error- Error code.ext- Extended error code.synchrone- True if method has been called synchronously, false otherwise.- Throws:
jpos.JposException- If Error condition is true.
-
getOutputID
public int getOutputID() throws jpos.JposExceptionGet common property OutputID, see UPOS specification- Returns:
- property value
- Throws:
jpos.JposException- See UPOS specification, property
-
compareFirmwareVersion
public void compareFirmwareVersion(String firmwareFileName, int[] result) throws jpos.JposExceptionCommon method compareFirmwareVersion, see UPOS specification- Parameters:
firmwareFileName- See UPOS specification, method compareFirmwareVersionresult- See UPOS specification, method compareFirmwareVersion- Throws:
jpos.JposException- See UPOS specification, method compareFirmwareVersion
-
updateFirmware
Common method updateFirmware, see UPOS specification- Parameters:
firmwareFileName- See UPOS specification, method updateFirmware- Throws:
jpos.JposException- See UPOS specification, method updateFirmware
-
resetStatistics
Common method resetStatistics, see UPOS specification- Parameters:
statisticsBuffer- See UPOS specification, method resetStatistics- Throws:
jpos.JposException- See UPOS specification, method resetStatistics
-
retrieveStatistics
Common method retrieveStatistics, see UPOS specification- Parameters:
statisticsBuffer- See UPOS specification, method retrieveStatistics- Throws:
jpos.JposException- See UPOS specification, method retrieveStatistics
-
updateStatistics
Common method updateStatistics, see UPOS specification- Parameters:
statisticsBuffer- See UPOS specification, method updateStatistics- Throws:
jpos.JposException- See UPOS specification, method updateStatistics
-
clearOutput
public void clearOutput() throws jpos.JposExceptionCommon method clearOutput, se UPOS specification- Throws:
jpos.JposException- See UPOS specification, method clearOutput
-
clearInput
public void clearInput() throws jpos.JposExceptionCommon method clearInput, see UPOS specification- Throws:
jpos.JposException- see UPOS specification
-
clearInputProperties
public void clearInputProperties() throws jpos.JposExceptionCommon method clearInputProperties, see UPOS specification- Throws:
jpos.JposException- see UPOS specification
-
getCheckHealthText
- Specified by:
getCheckHealthTextin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
getClaimed
public boolean getClaimed() throws jpos.JposException- Specified by:
getClaimedin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
getDeviceEnabled
public boolean getDeviceEnabled() throws jpos.JposException- Specified by:
getDeviceEnabledin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
setDeviceEnabled
public void setDeviceEnabled(boolean enable) throws jpos.JposException- Specified by:
setDeviceEnabledin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
getDeviceServiceDescription
- Specified by:
getDeviceServiceDescriptionin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
getDeviceServiceVersion
public int getDeviceServiceVersion() throws jpos.JposException- Specified by:
getDeviceServiceVersionin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
getFreezeEvents
public boolean getFreezeEvents() throws jpos.JposException- Specified by:
getFreezeEventsin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
setFreezeEvents
public void setFreezeEvents(boolean freezeEvents) throws jpos.JposException- Specified by:
setFreezeEventsin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
getPhysicalDeviceDescription
- Specified by:
getPhysicalDeviceDescriptionin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
getPhysicalDeviceName
- Specified by:
getPhysicalDeviceNamein interfacejpos.services.BaseService- Throws:
jpos.JposException
-
getState
public int getState() throws jpos.JposException- Specified by:
getStatein interfacejpos.services.BaseService- Throws:
jpos.JposException
-
claim
public void claim(int timeout) throws jpos.JposException- Specified by:
claimin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
startClaiming
Starts claiming. Should be called whenever a device tries to claim a device.
Returns null, if the device is not claimed. Otherwise, the given SyncObject instance will be inserted into the ClaimWaiters list of the claiming instance. Since this object will be signalled during release or close of that instance, it should be used to wait before retrying start claiming.- Parameters:
waiter- SyncOject to be used for synchronization with currently claiming instance, if any.- Returns:
- null on success, property set of currently claiming instance otherwise.
-
signalRelease
public void signalRelease()Signals release after claim. Should be called whenever a claimed device becomes unclaimed to wake up any other waiting instances. -
close
public void close() throws jpos.JposException- Specified by:
closein interfacejpos.services.BaseService- Throws:
jpos.JposException
-
checkHealth
public void checkHealth(int level) throws jpos.JposException- Specified by:
checkHealthin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
directIO
- Specified by:
directIOin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
open
public void open(String logicalName, jpos.services.EventCallbacks eventCallbacks) throws jpos.JposException- Specified by:
openin interfacejpos.services.BaseService- Throws:
jpos.JposException
-
release
public void release() throws jpos.JposException- Specified by:
releasein interfacejpos.services.BaseService- Throws:
jpos.JposException
-