Simplified configuration of ServerConfiguration bean for CIFS, FTP, etc.

It is now possible to extend and replace specific sections of the file-servers.xml config file.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2340 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-02-10 14:51:00 +00:00
parent 4ca678c845
commit be2837cc0f
2 changed files with 127 additions and 66 deletions

View File

@@ -2,36 +2,56 @@
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="fileServersConfigSource" class="org.alfresco.config.source.UrlConfigSource">
<constructor-arg>
<list>
<value>classpath:alfresco/file-servers.xml</value>
</list>
</constructor-arg>
</bean>
<bean id="fileServersConfigService" class="org.alfresco.config.xml.XMLConfigService" init-method="init">
<constructor-arg>
<ref bean="fileServersConfigSource" />
</constructor-arg>
</bean>
<!-- File Server Configuration -->
<bean id="fileServerConfiguration"
class="org.alfresco.filesys.server.config.ServerConfiguration"
<bean id="fileServerConfigurationBase"
abstract="true"
init-method="init"
destroy-method="closeConfiguration"
depends-on="importerBootstrap">
<constructor-arg>
<property name="authenticationManager">
<ref bean="authenticationManager"/>
</constructor-arg>
<constructor-arg>
</property>
<property name="authenticationService">
<ref bean="authenticationService"/>
</constructor-arg>
<constructor-arg>
</property>
<property name="authenticationComponent">
<ref bean="authenticationComponent"/>
</constructor-arg>
<constructor-arg>
</property>
<property name="nodeService">
<ref bean="nodeService"/>
</constructor-arg>
<constructor-arg>
</property>
<property name="personService">
<ref bean="personService"/>
</constructor-arg>
<constructor-arg>
</property>
<property name="transactionService">
<ref bean="transactionComponent"/>
</constructor-arg>
<constructor-arg>
<value>classpath:alfresco/file-servers.xml</value>
</constructor-arg>
<constructor-arg>
</property>
<property name="diskInterface">
<ref bean="contentDiskDriver"/>
</constructor-arg>
</property>
</bean>
<bean id="fileServerConfiguration"
class="org.alfresco.filesys.server.config.ServerConfiguration"
parent="fileServerConfigurationBase" >
<property name="configService">
<ref bean="fileServersConfigService"/>
</property>
</bean>
<!-- CIFS Server -->

View File

@@ -34,9 +34,7 @@ import net.sf.acegisecurity.AuthenticationManager;
import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigLookupContext;
import org.alfresco.config.ConfigSource;
import org.alfresco.config.source.UrlConfigSource;
import org.alfresco.config.xml.XMLConfigService;
import org.alfresco.config.ConfigService;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.filesys.ftp.FTPPath;
import org.alfresco.filesys.ftp.InvalidPathException;
@@ -137,10 +135,10 @@ public class ServerConfiguration
private static final String TokenLocalName = "${localname}";
// Acegi authentication manager
private AuthenticationManager acegiAuthMgr;
private AuthenticationManager authenticationManager;
// Path to configuration file
private String configLocation;
// Configuration service
private ConfigService configService;
/** the device to connect use */
private DiskInterface diskInterface;
@@ -293,7 +291,7 @@ public class ServerConfiguration
// Authentication component, for internal functions
private AuthenticationComponent m_authComponent;
private AuthenticationComponent m_authenticationComponent;
// Various services
@@ -303,33 +301,9 @@ public class ServerConfiguration
/**
* Class constructor
*
* @param authMgr AuthenticationManager
* @param authenticationService AuthenticationService
* @param authenticationComponent AuthenticationComponent
* @param nodeService NodeService
* @param personServce PersonService
* @param transactionService TransactionService
* @param configPath String
* @param diskInterface DiskInterface
*/
public ServerConfiguration(AuthenticationManager authMgr, AuthenticationService authenticationService,
AuthenticationComponent authComponent, NodeService nodeService, PersonService personService,
TransactionService transactionService, String configPath, DiskInterface diskInterface)
public ServerConfiguration()
{
// Save details
this.diskInterface = diskInterface;
this.acegiAuthMgr = authMgr;
this.authenticationService = authenticationService;
this.configLocation = configPath;
m_authComponent = authComponent;
m_nodeService = nodeService;
m_personService = personService;
m_transactionService = transactionService;
// Allocate the shared device list
m_shareList = new SharedDeviceList();
@@ -385,6 +359,46 @@ public class ServerConfiguration
m_serverList = new NetworkServerList();
}
public void setAuthenticationManager(AuthenticationManager authenticationManager)
{
this.authenticationManager = authenticationManager;
}
public void setAuthenticationService(AuthenticationService authenticationService)
{
this.authenticationService = authenticationService;
}
public void setConfigService(ConfigService configService)
{
this.configService = configService;
}
public void setDiskInterface(DiskInterface diskInterface)
{
this.diskInterface = diskInterface;
}
public void setAuthenticationComponent(AuthenticationComponent component)
{
m_authenticationComponent = component;
}
public void setNodeService(NodeService service)
{
m_nodeService = service;
}
public void setPersonService(PersonService service)
{
m_personService = service;
}
public void setTransactionService(TransactionService service)
{
m_transactionService = service;
}
/**
* @return Returns true if the configuration was fully initialised
*/
@@ -398,14 +412,42 @@ public class ServerConfiguration
*/
public void init()
{
// check that all required properties have been set
if (authenticationManager == null)
{
throw new AlfrescoRuntimeException("Property 'authenticationManager' not set");
}
else if (m_authenticationComponent == null)
{
throw new AlfrescoRuntimeException("Property 'authenticationComponent' not set");
}
else if (authenticationService == null)
{
throw new AlfrescoRuntimeException("Property 'authenticationService' not set");
}
else if (m_nodeService == null)
{
throw new AlfrescoRuntimeException("Property 'nodeService' not set");
}
else if (m_personService == null)
{
throw new AlfrescoRuntimeException("Property 'personService' not set");
}
else if (m_transactionService == null)
{
throw new AlfrescoRuntimeException("Property 'transactionService' not set");
}
else if (diskInterface == null)
{
throw new AlfrescoRuntimeException("Property 'diskInterface' not set");
}
else if (configService == null)
{
throw new AlfrescoRuntimeException("Property 'configService' not set");
}
initialised = false;
// Create the configuration source
ConfigSource configSource = new UrlConfigSource(configLocation);
XMLConfigService xmlConfigService = new XMLConfigService(configSource);
xmlConfigService.init();
// Create the configuration context
ConfigLookupContext configCtx = new ConfigLookupContext(ConfigArea);
@@ -419,26 +461,25 @@ public class ServerConfiguration
// Process the CIFS server configuration
Config config = xmlConfigService.getConfig(ConfigCIFS, configCtx);
Config config = configService.getConfig(ConfigCIFS, configCtx);
processCIFSServerConfig(config);
// Process the FTP server configuration
config = xmlConfigService.getConfig(ConfigFTP, configCtx);
config = configService.getConfig(ConfigFTP, configCtx);
processFTPServerConfig(config);
// Process the security configuration
config = xmlConfigService.getConfig(ConfigSecurity, configCtx);
config = configService.getConfig(ConfigSecurity, configCtx);
processSecurityConfig(config);
// Process the filesystems configuration
config = xmlConfigService.getConfig(ConfigFilesystems, configCtx);
config = configService.getConfig(ConfigFilesystems, configCtx);
processFilesystemsConfig(config);
// Successful initialisation
initialised = true;
}
catch (UnsatisfiedLinkError ex)
@@ -1769,7 +1810,7 @@ public class ServerConfiguration
*/
public final AuthenticationManager getAuthenticationManager()
{
return acegiAuthMgr;
return authenticationManager;
}
/**
@@ -1820,7 +1861,7 @@ public class ServerConfiguration
*/
public final AuthenticationComponent getAuthenticationComponent()
{
return m_authComponent;
return m_authenticationComponent;
}
/**