instance = factoryInstance.applicationInstance;
}
else if (factoryInstance.getScope().equalsIgnoreCase(SCOPE_SESSION))
{
// See if an instance already exists in this http session first
FlexSession session = FlexContext.getFlexSession();
if (session != null)
{
instance = session.getAttribute(factoryInstance.getAttributeId());
if (instance != null)
{
Class configuredClass = factoryInstance.getInstanceClass();
Class instClass = instance.getClass();
if (configuredClass != instClass &&
!configuredClass.isAssignableFrom(instClass))
{
ServiceException e = new ServiceException();
e.setMessage(INVALID_CLASS_FOUND, new Object[] {
factoryInstance.getAttributeId(),
"session",
factoryInstance.getId(),
factoryInstance.getInstanceClass(), instance.getClass()});
e.setCode("Server.Processing");
throw e;
}
}
else
{
// none exists - create it the first time for each session
instance = factoryInstance.createInstance();
session.setAttribute(factoryInstance.getAttributeId(), instance);
}
}
else
instance = null;