public abstract class AbstractProfileContainer<T extends org.apache.avro.specific.SpecificRecordBase> extends Object implements ProfileContainer
Abstract container for a profile.
Should be used to implement user profile container.
It is responsible for serializing profile and notifying Kaa stuff
about any updates (updateProfile()
).
A profile class is auto-generated according to a predefined Avro schema.
// Assume, BasicEndpointProfile is a profile class auto-generated
// according to predefined Avro schema
public class BasicProfileContainer extends AbstractProfileContainer<BasicEndpointProfile> {
private BasicEndpointProfile profile = new BasicEndpointProfile();
\@Override
public BasicEndpointProfile getProfile() {
return profile;
}
\@Override
protected Class<BasicEndpointProfile> getProfileClass() {
return BasicEndpointProfile.class;
}
public void setNewProfile(BasicEndpointProfile profile) {
this.profile = profile;
// NOTE: Update method should be called to notify about changes in the profile.
updateProfile();
}
}
Constructor and Description |
---|
AbstractProfileContainer()
Constructor for the AbstractProfileContainer.
|
Modifier and Type | Method and Description |
---|---|
abstract T |
getProfile()
Retrieves user-defined profile object.
|
protected abstract Class<T> |
getProfileClass()
Retrieves profile class object.
|
byte[] |
getSerializedProfile()
Retrieves serialized profile.
|
void |
setProfileListener(ProfileListener listener)
Kaa specific stuff.
NOTE: DO NOT use this API explicitly.
This method is used for a post initialization of a user defined
profile container.
|
protected void |
updateProfile()
Notify Kaa about profile updates.
NOTE: Need to call this method every time when profile is updated.
|
public AbstractProfileContainer()
protected abstract Class<T> getProfileClass()
public byte[] getSerializedProfile() throws IOException
getSerializedProfile
in interface ProfileContainer
IOException
protected final void updateProfile() throws IOException
IOException
public final void setProfileListener(ProfileListener listener)
setProfileListener
in interface ProfileContainer
listener
- New profile listener.public abstract T getProfile()
Copyright © 2015. All rights reserved.