Merged V2.2 to HEAD

7056: Ability to disable/enable CIFS/FTP/NFS via JMX Console

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8235 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-02-08 17:22:02 +00:00
parent 840b3e45be
commit 83ab25f486
6 changed files with 140 additions and 18 deletions

View File

@@ -87,7 +87,7 @@ public class CIFSServerBean extends AbstractLifecycleBean
*/
public boolean isStarted()
{
return (m_filesysConfig != null && m_filesysConfig.isServerRunning( "CIFS"));
return (!serverList.isEmpty() && m_filesysConfig.isServerRunning( "CIFS"));
}
/**
@@ -138,7 +138,12 @@ public class CIFSServerBean extends AbstractLifecycleBean
}
catch (Throwable e)
{
m_filesysConfig = null;
for (NetworkServer server : serverList)
{
getConfiguration().removeServer(server.getProtocolName());
}
serverList.clear();
throw new AlfrescoRuntimeException("Failed to start CIFS Server", e);
}
// success
@@ -171,10 +176,9 @@ public class CIFSServerBean extends AbstractLifecycleBean
getConfiguration().removeServer(server.getProtocolName());
}
// Clear the server list and configuration
// Clear the server list
serverList.clear();
m_filesysConfig = null;
}
/**
@@ -277,6 +281,9 @@ public class CIFSServerBean extends AbstractLifecycleBean
protected void onShutdown(ApplicationEvent event)
{
stopServer();
// Clear the configuration
m_filesysConfig = null;
}
}

View File

@@ -85,7 +85,7 @@ public class FTPServerBean extends AbstractLifecycleBean
*/
public boolean isStarted()
{
return (filesysConfig != null && filesysConfig.isServerRunning("FTP"));
return (ftpServer != null && filesysConfig.isServerRunning("FTP"));
}
/**
@@ -123,7 +123,7 @@ public class FTPServerBean extends AbstractLifecycleBean
}
catch (Throwable e)
{
filesysConfig = null;
ftpServer = null;
throw new AlfrescoRuntimeException("Failed to start FTP Server", e);
}
// success
@@ -156,10 +156,6 @@ public class FTPServerBean extends AbstractLifecycleBean
getConfiguration().removeServer(ftpServer.getProtocolName());
ftpServer = null;
}
// Clear the configuration
filesysConfig = null;
}
/**
@@ -261,6 +257,9 @@ public class FTPServerBean extends AbstractLifecycleBean
protected void onShutdown(ApplicationEvent event)
{
stopServer();
// Clear the configuration
filesysConfig = null;
}
}

View File

@@ -51,6 +51,10 @@ public class FileServerConfig implements FileServerConfigMBean {
// File server configuration
private ServerConfiguration m_serverConfig;
private FTPServerBean m_ftpServer;
private CIFSServerBean m_smbServer;
private NFSServerBean m_nfsServer;
/**
* Default constructor
@@ -79,6 +83,16 @@ public class FileServerConfig implements FileServerConfigMBean {
m_serverConfig = serverConfig;
}
/**
* Set the CIFS server
*
* @param smbServer CIFS server
*/
public void setCifsServer(CIFSServerBean smbServer)
{
m_smbServer = smbServer;
}
/**
* Check if the CIFS server is enabled
*
@@ -86,7 +100,34 @@ public class FileServerConfig implements FileServerConfigMBean {
*/
public boolean isCIFSServerEnabled()
{
return m_serverConfig.hasConfigSection(CIFSConfigSection.SectionName);
return (m_smbServer.isStarted() && m_serverConfig.hasConfigSection(CIFSConfigSection.SectionName));
}
/*
* (non-Javadoc)
* @see org.alfresco.filesys.server.config.FileServerConfigMBean#setCIFSServerEnabled(boolean)
*/
public void setCIFSServerEnabled(boolean enabled) throws Exception
{
if (!enabled && isCIFSServerEnabled())
{
m_smbServer.stopServer();
}
if (enabled && !isCIFSServerEnabled())
{
m_smbServer.startServer();
}
}
/**
* Set the FTP server
*
* @param ftpServer FTP server
*/
public void setFtpServer(FTPServerBean ftpServer)
{
m_ftpServer = ftpServer;
}
/**
@@ -96,7 +137,34 @@ public class FileServerConfig implements FileServerConfigMBean {
*/
public boolean isFTPServerEnabled()
{
return m_serverConfig.hasConfigSection(FTPConfigSection.SectionName);
return (m_ftpServer.isStarted() && m_serverConfig.hasConfigSection(FTPConfigSection.SectionName));
}
/*
* (non-Javadoc)
* @see org.alfresco.filesys.server.config.FileServerConfigMBean#setFTPServerEnabled(boolean)
*/
public void setFTPServerEnabled(boolean enabled) throws Exception
{
if (!enabled && isFTPServerEnabled())
{
m_ftpServer.stopServer();
}
if (enabled && !isFTPServerEnabled())
{
m_ftpServer.startServer();
}
}
/**
* Set the NFS server
*
* @param nfsServer NFS server
*/
public void setNfsServer(NFSServerBean nfsServer)
{
m_nfsServer = nfsServer;
}
/**
@@ -106,7 +174,24 @@ public class FileServerConfig implements FileServerConfigMBean {
*/
public boolean isNFSServerEnabled()
{
return m_serverConfig.hasConfigSection(NFSConfigSection.SectionName);
return (m_nfsServer.isStarted() && m_serverConfig.hasConfigSection(NFSConfigSection.SectionName));
}
/*
* (non-Javadoc)
* @see org.alfresco.filesys.server.config.FileServerConfigMBean#setNFSServerEnabled(boolean)
*/
public void setNFSServerEnabled(boolean enabled) throws Exception
{
if (!enabled && isNFSServerEnabled())
{
m_nfsServer.stopServer();
}
if (enabled && !isNFSServerEnabled())
{
m_nfsServer.startServer();
}
}
/**

View File

@@ -38,6 +38,13 @@ public interface FileServerConfigMBean {
*/
public boolean isCIFSServerEnabled();
/**
* Enable/disable CIFS server
*
* @param enabled true to enable, false to disable
*/
public void setCIFSServerEnabled(boolean enabled) throws Exception;
/**
* Check if the FTP server is enabled
*
@@ -45,6 +52,13 @@ public interface FileServerConfigMBean {
*/
public boolean isFTPServerEnabled();
/**
* Enable/disable FTP server
*
* @param enabled true to enable, false to disable
*/
public void setFTPServerEnabled(boolean enabled) throws Exception;
/**
* Check if the NFS server is enabled
*
@@ -52,6 +66,13 @@ public interface FileServerConfigMBean {
*/
public boolean isNFSServerEnabled();
/**
* Enable/disable NFS server
*
* @param enabled true to enable, false to disable
*/
public void setNFSServerEnabled(boolean enabled) throws Exception;
/**
* Return the CIFS server name
*

View File

@@ -91,7 +91,7 @@ public class NFSServerBean extends AbstractLifecycleBean
*/
public boolean isStarted()
{
return (m_filesysConfig != null && m_filesysConfig.isServerRunning( "NFS"));
return (!m_serverList.isEmpty() && m_filesysConfig.isServerRunning( "NFS"));
}
/**
@@ -142,7 +142,12 @@ public class NFSServerBean extends AbstractLifecycleBean
}
catch (Throwable e)
{
m_filesysConfig = null;
for (NetworkServer server : m_serverList)
{
getConfiguration().removeServer(server.getProtocolName());
}
m_serverList.clear();
throw new AlfrescoRuntimeException("Failed to start NFS Server", e);
}
}
@@ -177,10 +182,9 @@ public class NFSServerBean extends AbstractLifecycleBean
getConfiguration().removeServer(server.getProtocolName());
}
// Clear the server list and configuration
// Clear the server list
m_serverList.clear();
m_filesysConfig = null;
}
/**
@@ -283,5 +287,8 @@ public class NFSServerBean extends AbstractLifecycleBean
protected void onShutdown(ApplicationEvent event)
{
stopServer();
// Clear the configuration
m_filesysConfig = null;
}
}