com.sibvisions.rad.server
Class DefaultObjectProvider

java.lang.Object
  extended by javax.rad.server.AbstractObjectProvider
      extended by com.sibvisions.rad.server.DefaultObjectProvider
All Implemented Interfaces:
ISessionListener

public class DefaultObjectProvider
extends AbstractObjectProvider
implements ISessionListener

The DefaultObjectProvider manages the remote accessible objects. It compiles source files and offers always the current object.


Nested Class Summary
static class DefaultObjectProvider.ImplicitLifeCycleObject
          A marker class.
 
Constructor Summary
protected DefaultObjectProvider(Server pServer)
          Creates an instance of AbstractObjectProvider.
 
Method Summary
protected  java.util.Map createInstance(AbstractSession pSession, java.lang.String pInstanceName)
          Creates a new Map instance with a specific class name and, if possible, sets a parent object.
protected  java.util.Map getApplicationObject(AbstractSession pSession)
          Gets the life-cycle object for an application.
protected  java.lang.ClassLoader getClassLoader(AbstractSession pSession)
          Gets the classloader for loading LCOs.
 java.lang.Object getObject(ISession pSession, java.lang.String pObjectName)
          Returns an object from the life-cycle object container for an ISession.
 IObjectAccessController getObjectAccessController()
          Gets the object access controller.
 Server getServer()
          Gets the associated IServer.
protected  java.util.Map getSessionObject(ISession pSession)
          Gets the life-cycle object for a session.
 boolean hasObject(ISession pSession)
          Gets whether this object provider contains least one object for the given session.
 java.lang.Object invoke(ISession pSession, java.lang.String pObjectName, java.lang.String pMethodName, java.lang.Object... pParams)
          Invokes a method from a specific life-cycle object.
static boolean isIsolated(AbstractSession pSession)
          Gets whether the given session is isolated.
protected  boolean isIsolated(java.lang.Object pInstance)
          Gets whether the given object is an isolated object.
 java.lang.Object putObject(ISession pSession, java.lang.String pObjectName, java.lang.Object pObject)
          Puts an object to the life-cycle object container for an ISession.
 void sessionCreated(ISession pSession)
          Invoked when a session was created and is ready to use.
 void sessionDestroyed(ISession pSession)
          Invoked when a session was destroyed an can not be used anymore.
 void setObjectAccessController(IObjectAccessController pController)
          Sets the object access controller.
protected  void setParent(ISession pSession, java.util.Map pInstance, java.util.Map pParent)
          Sets the parent for a LCO.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultObjectProvider

protected DefaultObjectProvider(Server pServer)
Creates an instance of AbstractObjectProvider.

Parameters:
pServer - communication server
Method Detail

sessionCreated

public void sessionCreated(ISession pSession)
Invoked when a session was created and is ready to use.

Specified by:
sessionCreated in interface ISessionListener
Parameters:
pSession - the newly created session

sessionDestroyed

public void sessionDestroyed(ISession pSession)
Invoked when a session was destroyed an can not be used anymore.

Specified by:
sessionDestroyed in interface ISessionListener
Parameters:
pSession - the destroyed session

getObject

public java.lang.Object getObject(ISession pSession,
                                  java.lang.String pObjectName)
                           throws java.lang.Throwable
Returns an object from the life-cycle object container for an ISession.

Specified by:
getObject in class AbstractObjectProvider
Parameters:
pSession - the session
pObjectName - the object name (can be an EL)
Returns:
the object for the session or null for the life-cycle object container
Throws:
java.lang.Throwable - if the life-cycle object is not available

putObject

public java.lang.Object putObject(ISession pSession,
                                  java.lang.String pObjectName,
                                  java.lang.Object pObject)
                           throws java.lang.Throwable
Puts an object to the life-cycle object container for an ISession.

Specified by:
putObject in class AbstractObjectProvider
Parameters:
pSession - the session
pObjectName - the object name
pObject - the object or null to remove the object
Returns:
null if there was no object under the specified name, otherwise the previous object for the specified name
Throws:
java.lang.Throwable - if the life-cycle object is not available

invoke

public java.lang.Object invoke(ISession pSession,
                               java.lang.String pObjectName,
                               java.lang.String pMethodName,
                               java.lang.Object... pParams)
                        throws java.lang.Throwable
Invokes a method from a specific life-cycle object.

Specified by:
invoke in class AbstractObjectProvider
Parameters:
pSession - the session
pObjectName - the object name
pMethodName - the method to invoke
pParams - the method parameters
Returns:
the return value of the invoked method
Throws:
java.lang.Throwable - if the life-cycle object is not available or the method was not found

getServer

public Server getServer()
Gets the associated IServer.

Overrides:
getServer in class AbstractObjectProvider
Returns:
the server

getSessionObject

protected java.util.Map getSessionObject(ISession pSession)
                                  throws java.lang.Exception
Gets the life-cycle object for a session.

Parameters:
pSession - the accessing session
Returns:
the life-cycle object for the session
Throws:
java.lang.Exception - if the life-cycle object can not be created

hasObject

public boolean hasObject(ISession pSession)
Gets whether this object provider contains least one object for the given session.

Parameters:
pSession - the session
Returns:
true if this provider contains at least one object for pSession, false otherwise

getApplicationObject

protected java.util.Map getApplicationObject(AbstractSession pSession)
                                      throws java.lang.Exception
Gets the life-cycle object for an application.

Parameters:
pSession - the accessing session
Returns:
the life-cycle object for the application
Throws:
java.lang.Exception - if the life-cycle object can not be created

createInstance

protected java.util.Map createInstance(AbstractSession pSession,
                                       java.lang.String pInstanceName)
                                throws java.lang.Exception
Creates a new Map instance with a specific class name and, if possible, sets a parent object.

Parameters:
pSession - the calling session
pInstanceName - the full qualified class name for the instance
Returns:
the new instance
Throws:
java.lang.Exception - if the instance can not be created

getClassLoader

protected java.lang.ClassLoader getClassLoader(AbstractSession pSession)
Gets the classloader for loading LCOs.

Parameters:
pSession - the session
Returns:
the class loader or null to use the default class loader

isIsolated

protected boolean isIsolated(java.lang.Object pInstance)
Gets whether the given object is an isolated object. This means that StrictIsolation annotation was added.

Parameters:
pInstance - the object to check
Returns:
true if isolated, false otherwise

isIsolated

public static boolean isIsolated(AbstractSession pSession)
Gets whether the given session is isolated. This means that the LCO contains the StrictIsolation annotation.

Parameters:
pSession - the session to check
Returns:
true if isolated, false otherwise

setParent

protected void setParent(ISession pSession,
                         java.util.Map pInstance,
                         java.util.Map pParent)
Sets the parent for a LCO. This doesn't work if given instance is not a GenericBean or given parent is not a Bean.

Parameters:
pSession - the current session
pInstance - the LCO
pParent - the parent

setObjectAccessController

public void setObjectAccessController(IObjectAccessController pController)
Sets the object access controller.

Parameters:
pController - the controller

getObjectAccessController

public IObjectAccessController getObjectAccessController()
Gets the object access controller.

Returns:
the controller


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.