|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectlivespace.services.EntityContainer
livespace.services.EntityServer
public class EntityServer
A container that publishes its entities for access by clients. Clients may discover entities published by the server and perform create/read/write/delete operations on them.
Performance note: the server only subscribes to changes to entities it publishes which means that the server's subscription needs to change every time an entity is added or deleted. Since resubscription is a relatively costly operation it's a good idea performance-wise if services that know what their initial entity set is try to add all them to a registry and then publish them in one step. You can do this thus:
// create a registry
EntityRegistry entities = new EntityRegistry ();
// add entities to registry
...
// publish the entities
EntityServer server = new EntityServer (elvin, room, "light", entities);
EntityClient| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class livespace.services.EntityContainer |
|---|
EntityContainer.EmitNotificationTask |
| Field Summary | |
|---|---|
protected boolean |
disposed
|
| Fields inherited from class livespace.services.EntityContainer |
|---|
containerId, elvin, entities, room, scheduler |
| Constructor Summary | |
|---|---|
EntityServer(Elvin elvin,
RoomEntity room,
String entityType)
Create an instance hosting entities within a given room scope (ie contained entities are visible only to the current room). |
|
EntityServer(Elvin elvin,
RoomEntity room,
String entityType,
EntityRegistry entities)
Create an instance hosting entities within a given room scope (ie contained entities are visible only to the current room). |
|
EntityServer(Elvin elvin,
String entityType)
Create an instance with no room scope (ie contained entities have global scope). |
|
| Method Summary | |
|---|---|
void |
dispose()
Dispose of the object (unregister listeners, close open resources etc). |
boolean |
getAllowClientCreate()
|
boolean |
getAllowClientDelete()
|
protected void |
handleNotification(NotificationEvent e)
|
void |
propertyValueChanged(PropertyEvent e)
|
void |
setAllowClientCreate(boolean allowClientCreate)
Set to true to allow clients to create new entities in this server (default is false). |
void |
setAllowClientDelete(boolean allowClientDelete)
Set to true to allow clients to delete entities from this server (default is false). |
protected void |
subscribeDiscover()
Subscribe to entity discovery ("find" and "ping") requests. |
protected void |
subscribeUpdate(String expr)
Create/update the Elvin subscription for entity modification requests. |
void |
testCrash()
Used to simulate a service crash (unclean exit without notification). |
void |
testUncrash()
Reverse the effect of testCrash(). |
| Methods inherited from class livespace.services.EntityContainer |
|---|
close, connectionClosed, createEntity, createXmlInput, createXmlOutput, emit, emitAsync, getOrCreateEntity, isClosed, isInResponseToMe, mutex, notificationReceived, read, registerEntityTree, setContainerRecursively, setContainerRecursively, setDefaultUpdaterForThread, setUpdateExecutor, shouldPublish, splitPropertyPath, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected volatile boolean disposed
| Constructor Detail |
|---|
public EntityServer(Elvin elvin,
String entityType)
throws IOException
RoomEntity.
elvin - The Elvin service.entityType - The type of entity to discover. This is the
value returned by Entity.getType().
IOExceptiontodo add an allow create/delete option
public EntityServer(Elvin elvin,
RoomEntity room,
String entityType)
throws IOException
elvin - The Elvin connection.room - The room the entities are part of. This may be null
meaning the entities are not part of a room.entityType - The type of entity to discover. This is the
value returned by Entity.getType().
IOExceptionEntityServer(Elvin, String)
public EntityServer(Elvin elvin,
RoomEntity room,
String entityType,
EntityRegistry entities)
throws IOException
elvin - The Elvin connection.room - The room the entities are part of. This may be null
meaning the entities are not part of a room.entityType - The type of entity to discover. This is the
value returned by Entity.getType().entities - The initial set of entities. This instance
becomes the set of entities that is shared with clients.
IOExceptionEntityServer(Elvin, String)| Method Detail |
|---|
public boolean getAllowClientCreate()
public void setAllowClientCreate(boolean allowClientCreate)
public boolean getAllowClientDelete()
public void setAllowClientDelete(boolean allowClientDelete)
public void testCrash()
testUncrash()public void testUncrash()
testCrash(). Use only for testing.
public void dispose()
Disposable
dispose in interface Disposabledispose in class EntityContainer
protected void subscribeDiscover()
throws IOException
IOException
protected void subscribeUpdate(String expr)
throws IOException
expr - The modification subscription.
IOExceptionpublic void propertyValueChanged(PropertyEvent e)
protected void handleNotification(NotificationEvent e)
handleNotification in class EntityContainer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||