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

View File

@@ -34,9 +34,7 @@ import net.sf.acegisecurity.AuthenticationManager;
import org.alfresco.config.Config; import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigLookupContext; import org.alfresco.config.ConfigLookupContext;
import org.alfresco.config.ConfigSource; import org.alfresco.config.ConfigService;
import org.alfresco.config.source.UrlConfigSource;
import org.alfresco.config.xml.XMLConfigService;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.filesys.ftp.FTPPath; import org.alfresco.filesys.ftp.FTPPath;
import org.alfresco.filesys.ftp.InvalidPathException; import org.alfresco.filesys.ftp.InvalidPathException;
@@ -137,10 +135,10 @@ public class ServerConfiguration
private static final String TokenLocalName = "${localname}"; private static final String TokenLocalName = "${localname}";
// Acegi authentication manager // Acegi authentication manager
private AuthenticationManager acegiAuthMgr; private AuthenticationManager authenticationManager;
// Path to configuration file // Configuration service
private String configLocation; private ConfigService configService;
/** the device to connect use */ /** the device to connect use */
private DiskInterface diskInterface; private DiskInterface diskInterface;
@@ -293,43 +291,19 @@ public class ServerConfiguration
// Authentication component, for internal functions // Authentication component, for internal functions
private AuthenticationComponent m_authComponent; private AuthenticationComponent m_authenticationComponent;
// Various services // Various services
private NodeService m_nodeService; private NodeService m_nodeService;
private PersonService m_personService; private PersonService m_personService;
private TransactionService m_transactionService; private TransactionService m_transactionService;
/** /**
* Class constructor * 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, public ServerConfiguration()
AuthenticationComponent authComponent, NodeService nodeService, PersonService personService,
TransactionService transactionService, String configPath, DiskInterface diskInterface)
{ {
// 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 // Allocate the shared device list
m_shareList = new SharedDeviceList(); m_shareList = new SharedDeviceList();
@@ -384,6 +358,46 @@ public class ServerConfiguration
m_serverList = new NetworkServerList(); 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 * @return Returns true if the configuration was fully initialised
@@ -398,14 +412,42 @@ public class ServerConfiguration
*/ */
public void init() 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; initialised = false;
// Create the configuration source
ConfigSource configSource = new UrlConfigSource(configLocation);
XMLConfigService xmlConfigService = new XMLConfigService(configSource);
xmlConfigService.init();
// Create the configuration context // Create the configuration context
ConfigLookupContext configCtx = new ConfigLookupContext(ConfigArea); ConfigLookupContext configCtx = new ConfigLookupContext(ConfigArea);
@@ -419,26 +461,25 @@ public class ServerConfiguration
// Process the CIFS server configuration // Process the CIFS server configuration
Config config = xmlConfigService.getConfig(ConfigCIFS, configCtx); Config config = configService.getConfig(ConfigCIFS, configCtx);
processCIFSServerConfig(config); processCIFSServerConfig(config);
// Process the FTP server configuration // Process the FTP server configuration
config = xmlConfigService.getConfig(ConfigFTP, configCtx); config = configService.getConfig(ConfigFTP, configCtx);
processFTPServerConfig(config); processFTPServerConfig(config);
// Process the security configuration // Process the security configuration
config = xmlConfigService.getConfig(ConfigSecurity, configCtx); config = configService.getConfig(ConfigSecurity, configCtx);
processSecurityConfig(config); processSecurityConfig(config);
// Process the filesystems configuration // Process the filesystems configuration
config = xmlConfigService.getConfig(ConfigFilesystems, configCtx); config = configService.getConfig(ConfigFilesystems, configCtx);
processFilesystemsConfig(config); processFilesystemsConfig(config);
// Successful initialisation // Successful initialisation
initialised = true; initialised = true;
} }
catch (UnsatisfiedLinkError ex) catch (UnsatisfiedLinkError ex)
@@ -1769,7 +1810,7 @@ public class ServerConfiguration
*/ */
public final AuthenticationManager getAuthenticationManager() public final AuthenticationManager getAuthenticationManager()
{ {
return acegiAuthMgr; return authenticationManager;
} }
/** /**
@@ -1820,7 +1861,7 @@ public class ServerConfiguration
*/ */
public final AuthenticationComponent getAuthenticationComponent() public final AuthenticationComponent getAuthenticationComponent()
{ {
return m_authComponent; return m_authenticationComponent;
} }
/** /**