public abstract class HiveCommon extends ServiceCommon<Session,SessionCommon> implements Hive
Hives are created using the constructor. There is no defined destructor. However there are start and stop methods that may create and free resources. All resources allocated in the start method should be destroyed in the stop method.
The item subscription manager will also be created in the
performStart()
method. So registering items is only possible
after the hive has been started.
protected void performStart () {
super.performStart ();
registerItem ( "abc", … );
}
DEFAULT_RESULT
Constructor and Description |
---|
HiveCommon() |
Modifier and Type | Method and Description |
---|---|
void |
addDataItemValidator(DataItemValidator dataItemValidator) |
void |
addItemFactory(DataItemFactory factory) |
protected void |
addItemSubscriptionListener(SubscriptionManagerListener<String> listener) |
void |
addSessionListener(SessionListener listener) |
void |
closeSession(Session session)
Close a session.
|
protected Session |
createSession(Future<UserInformation> loginFuture,
Properties properties,
CallbackHandler callbackHandler) |
NotifyFuture<Session> |
createSession(Properties properties,
Map<String,Object> contextInformation,
CallbackHandler callbackHandler)
Create a new session for further accessing the hive
|
HiveBrowser |
getBrowser() |
Set<String> |
getGrantedItems()
Gets a set of all items in granted state.
|
abstract String |
getHiveId()
Get a unique ID for you hive type
|
Executor |
getOperationService() |
protected ValidationStrategy |
getValidationStrategy() |
protected void |
handleSessionCreated(AbstractSessionImpl session,
Properties properties,
UserInformation userInformation) |
boolean |
isAutoEnableStats() |
DataItem |
lookupItem(String id) |
protected void |
performStart()
Called then the hive should perform its startup procedure
|
protected void |
performStop()
Called then the hive should perform its shutdown procedure
|
protected NotifyFuture<WriteResult> |
processWrite(SessionCommon session,
String itemId,
Variant value,
OperationParameters effectiveOperationParameters) |
protected NotifyFuture<WriteAttributeResults> |
processWriteAttributes(SessionCommon session,
String itemId,
Map<String,Variant> attributes,
OperationParameters operationParameters) |
void |
registerItem(DataItem item)
Register a new item with the hive
|
void |
removeItemFactory(DataItemFactory factory) |
protected void |
removeItemSubscriptionListener(SubscriptionManagerListener<String> listener) |
void |
removeItemValidator(DataItemValidator dataItemValidator) |
void |
removeSessionListener(SessionListener listener) |
protected DataItem |
retrieveItem(String id) |
void |
setAutoEnableStats(boolean autoEnableStats)
This will disable the automatic generation of the stats module when
setting
the root folder.
|
protected void |
setRootFolder(Folder rootFolder)
Set the root folder.
|
protected void |
setValidatonStrategy(ValidationStrategy validatonStrategy)
Set the validation strategy
Note: The validation strategy has to be set before the hive is started (e.g. |
void |
start() |
NotifyFuture<WriteResult> |
startWrite(Session session,
String itemId,
Variant value,
OperationParameters operationParameters,
CallbackHandler callbackHandler)
Start a write operation
The operation is not started unless
#thawOperation(Session, long)
is called. |
NotifyFuture<WriteAttributeResults> |
startWriteAttributes(Session session,
String itemId,
Map<String,Variant> attributes,
OperationParameters operationParameters,
CallbackHandler callbackHandler)
Start a write attributes operation
The operation is not started unless
#thawOperation(Session, long)
is called. |
void |
stop() |
void |
subscribeItem(Session session,
String itemId)
Register to an item for event notification
|
void |
unregisterItem(DataItem item)
Remove an item from the hive.
|
void |
unsubscribeItem(Session session,
String itemId)
Unsubscribe a session from an item
|
protected boolean |
validateItem(String id)
Validate a data item id if it can be provided by the hive.
|
SessionCommon |
validateSession(Session session)
Validate a session and return the session common instance if the session
is valid
|
authorize, authorize, extractPrivileges, fillSessionProperties, loginUser, makeEffectiveUserInformation, setAuditLogService, setAuthenticationImplementation, setAuthorizationImplementation
protected void addItemSubscriptionListener(SubscriptionManagerListener<String> listener)
protected void removeItemSubscriptionListener(SubscriptionManagerListener<String> listener)
public void start() throws Exception
start
in interface LifecycleAware
Exception
public void stop() throws Exception
stop
in interface LifecycleAware
Exception
protected void performStart() throws Exception
This is internally dispatched when the start()
method was called
and the hive was not already started.
Exception
protected void performStop() throws Exception
This is internally dispatched when the stop()
method was called
and the hive was already started.
Exception
public abstract String getHiveId()
public void addSessionListener(SessionListener listener)
public void removeSessionListener(SessionListener listener)
protected void setRootFolder(Folder rootFolder)
Note:The root folder can only be set once. All further set requests are ignored.
Note:The root folder must be set before the start method is called (e.g. in the constructor)
public SessionCommon validateSession(Session session) throws InvalidSessionException
session
- the session to validateInvalidSessionException
- in the case of an invalid sessionpublic NotifyFuture<Session> createSession(Properties properties, Map<String,Object> contextInformation, CallbackHandler callbackHandler)
Service
createSession
in interface Service<Session>
properties
- properties used to create the sessioncontextInformation
- additional context informationprotected Session createSession(Future<UserInformation> loginFuture, Properties properties, CallbackHandler callbackHandler) throws InterruptedException, ExecutionException
protected void handleSessionCreated(AbstractSessionImpl session, Properties properties, UserInformation userInformation)
public void closeSession(Session session) throws InvalidSessionException
closeSession
in interface Service<Session>
session
- the session to closeInvalidSessionException
- In the case the session is not a valid sessionpublic void subscribeItem(Session session, String itemId) throws InvalidSessionException, InvalidItemException
Hive
subscribeItem
in interface Hive
session
- the session to useitemId
- the item to register forInvalidSessionException
- In the case the session is not a valid sessionInvalidItemException
- In the case the item is not validpublic void unsubscribeItem(Session session, String itemId) throws InvalidSessionException, InvalidItemException
unsubscribeItem
in interface Hive
session
- the session to useInvalidSessionException
- In the case the session is not a valid sessionInvalidItemException
- In the case the item is not validpublic void registerItem(DataItem item)
Note that registering an item is only possible after the Hive has been started.
item
- the item to registerpublic Executor getOperationService()
public void unregisterItem(DataItem item)
item
- the item to removeprotected boolean validateItem(String id)
The hive will perform several methods to check if the item id is valid.
Implementations must not create items based an a validation check!
true
if the item id is valid false
otherwisepublic NotifyFuture<WriteAttributeResults> startWriteAttributes(Session session, String itemId, Map<String,Variant> attributes, OperationParameters operationParameters, CallbackHandler callbackHandler) throws InvalidSessionException, InvalidItemException, PermissionDeniedException
Hive
#thawOperation(Session, long)
is called.startWriteAttributes
in interface Hive
session
- the session to useitemId
- The item to write toattributes
- The attributes to writeoperationParameters
- additional parameters to the write request, can be
null
InvalidSessionException
- In the case the session is not a valid sessionInvalidItemException
- In the case the item is not validPermissionDeniedException
- if the user has no permission to perform this operationprotected NotifyFuture<WriteAttributeResults> processWriteAttributes(SessionCommon session, String itemId, Map<String,Variant> attributes, OperationParameters operationParameters)
public NotifyFuture<WriteResult> startWrite(Session session, String itemId, Variant value, OperationParameters operationParameters, CallbackHandler callbackHandler) throws InvalidSessionException, InvalidItemException
Hive
#thawOperation(Session, long)
is called.startWrite
in interface Hive
session
- the session to useitemId
- The item to write tovalue
- The value to writeoperationParameters
- additional parameters to the write request, can be
null
callbackHandler
- can be nullInvalidSessionException
- In the case the session is not a valid sessionInvalidItemException
- In the case the item is not validprotected NotifyFuture<WriteResult> processWrite(SessionCommon session, String itemId, Variant value, OperationParameters effectiveOperationParameters)
public HiveBrowser getBrowser()
getBrowser
in interface Hive
public void addItemFactory(DataItemFactory factory)
public void removeItemFactory(DataItemFactory factory)
public Set<String> getGrantedItems()
public void addDataItemValidator(DataItemValidator dataItemValidator)
public void removeItemValidator(DataItemValidator dataItemValidator)
protected ValidationStrategy getValidationStrategy()
protected void setValidatonStrategy(ValidationStrategy validatonStrategy)
validatonStrategy
- public boolean isAutoEnableStats()
public void setAutoEnableStats(boolean autoEnableStats)
setRootFolder(Folder)
autoEnableStats
- Copyright © 2016 Eclipse NeoSCADA Project. All rights reserved.