.getComponentInstanceOfType(WorkspaceDataContainer.class)));
}
}
catch (ClassNotFoundException e)
{
throw new RepositoryConfigurationException("Class not found for workspace data container "
+ wsConfig.getUniqueName() + " : " + e, e);
}
// cache type
try
{
String className = wsConfig.getCache().getType();
if (className != null && className.length() > 0)
{
workspaceContainer.registerComponentImplementation(ClassLoading.forName(className,
RepositoryContainer.class));
}
else
workspaceContainer.registerComponentImplementation(LinkedWorkspaceStorageCacheImpl.class);
}
catch (ClassNotFoundException e)
{
log.warn("Workspace cache class not found " + wsConfig.getCache().getType()
+ ", will use default. Error : " + e.getMessage());
workspaceContainer.registerComponentImplementation(LinkedWorkspaceStorageCacheImpl.class);
}
if (workspaceContainer.getComponentInstanceOfType(RPCService.class) != null)
{
workspaceContainer.registerComponentImplementation(WorkspaceResumer.class);
}
workspaceContainer.registerComponentImplementation(CacheableWorkspaceDataManager.class);
workspaceContainer.registerComponentImplementation(LocalWorkspaceDataManagerStub.class);
workspaceContainer.registerComponentImplementation(ObservationManagerRegistry.class);
if (wsConfig.getLockManager() != null && wsConfig.getLockManager().getType() != null)
{
try
{
final Class<?> lockManagerType =
ClassLoading.forName(wsConfig.getLockManager().getType(), RepositoryContainer.class);
workspaceContainer.registerComponentImplementation(lockManagerType);
}
catch (ClassNotFoundException e)
{
throw new RepositoryConfigurationException("Class not found for workspace lock manager "
+ wsConfig.getLockManager().getType() + ", container " + wsConfig.getUniqueName() + " : " + e,
e);
}
}
else
{
throw new RepositoryConfigurationException(
"The configuration of lock manager is expected in container " + wsConfig.getUniqueName());
}
// Query handler
if (wsConfig.getQueryHandler() != null)
{
workspaceContainer.registerComponentImplementation(SearchManager.class);
workspaceContainer.registerComponentImplementation(QueryManager.class);
workspaceContainer.registerComponentImplementation(QueryManagerFactory.class);
workspaceContainer.registerComponentInstance(wsConfig.getQueryHandler());
if (isSystem)
{
workspaceContainer.registerComponentImplementation(SystemSearchManager.class);
}
}
// access manager
if (wsConfig.getAccessManager() != null && wsConfig.getAccessManager().getType() != null)
{
try
{
final Class<?> am = ClassLoading.forName(wsConfig.getAccessManager().getType(), RepositoryContainer.class);
workspaceContainer.registerComponentImplementation(am);
}
catch (ClassNotFoundException e)
{
throw new RepositoryConfigurationException(
"Class not found for workspace access manager " + wsConfig.getAccessManager().getType()
+ ", container " + wsConfig.getUniqueName() + " : " + e, e);
}
}
// initializer
final Class<?> initilizerType;
if (wsConfig.getInitializer() != null && wsConfig.getInitializer().getType() != null)
{
// use user defined
try
{
initilizerType = ClassLoading.forName(wsConfig.getInitializer().getType(), RepositoryContainer.class);
}
catch (ClassNotFoundException e)
{
throw new RepositoryConfigurationException("Class not found for workspace initializer "
+ wsConfig.getInitializer().getType() + ", container " + wsConfig.getUniqueName() + " : " + e,
e);
}
}
else
{
// use default
initilizerType = ScratchWorkspaceInitializer.class;
}
workspaceContainer.registerComponentImplementation(initilizerType);
workspaceContainer.registerComponentImplementation(TransactionableResourceManager.class);
workspaceContainer.registerComponentImplementation(SessionFactory.class);
final LocalWorkspaceDataManagerStub wsDataManager =
(LocalWorkspaceDataManagerStub)workspaceContainer
.getComponentInstanceOfType(LocalWorkspaceDataManagerStub.class);
if (isSystem)
{
// system workspace
systemDataManager = wsDataManager;
registerComponentInstance(systemDataManager);
}
wsDataManager.setSystemDataManager(systemDataManager);
if (!config.getWorkspaceEntries().contains(wsConfig))
config.getWorkspaceEntries().add(wsConfig);
return null;
}
});
}
catch (PrivilegedActionException pae)
{
Throwable cause = pae.getCause();
if (cause instanceof RepositoryConfigurationException)
{
throw (RepositoryConfigurationException)cause;
}
else if (cause instanceof RepositoryException)
{
throw (RepositoryException)cause;
}
else if (cause instanceof RuntimeException)
{
RuntimeException e = (RuntimeException)cause;
int depth = 0;
Throwable retval = e;
while (retval.getCause() != null && depth < 100)
{
retval = retval.getCause();
if (retval instanceof RepositoryException)
{
throw new RepositoryException(retval.getMessage(), e);
}
else if (retval instanceof RepositoryConfigurationException)
{
throw new RepositoryConfigurationException(retval.getMessage(), e);
}
else if (retval instanceof NameNotFoundException)
{
throw new RepositoryException(retval.getMessage(), e);
}