[英]How to setup alfresco jlan file server as a standalone java package?
我是文件服務器實施的新手。 Alfresco jlan似乎是一個好的開始,因為它是大多數服務器協議(CIFS,NFS和FTP)的純Java實現。 有很多專用於露天的線程,但不是專門針對jlan的。 如何在NetBeans中將jlan設置為獨立的Java包?
提前致謝。
在這里,您將找到一個runsrv.bat(和runsrv.sh)腳本,以使用提供的XML配置來引導JLANServer:jlanConfig.xml
由於提供的文件(jlanConfig.xml和JLANServer)不是提供的二進制文件的一部分(例如,不是alfresco-jlan-embed v5.0.b的一部分),因此您需要自己提供類似的設置。
例如:
ServerConfiguration cfg = new JLANFileServerConfiguration();
NetBIOSNameServer netBIOSNameServer = new NetBIOSNameServer(cfg);
cfg.addServer(netBIOSNameServer);
SMBServer smbServer = new SMBServer(cfg);
cfg.addServer(smbServer);
// start servers
for (int i = 0; i < cfg.numberOfServers(); i++) {
NetworkServer server = cfg.getServer(i);
server.startServer();
}
可以從XML文件讀取ServerConfiguration,或使用Java代碼構造ServerConfiguration:
private static final String HOSTNAME = "JLANHOST";
private static final int DefaultThreadPoolInit = 25;
private static final int DefaultThreadPoolMax = 50;
private static final int[] DefaultMemoryPoolBufSizes = { 256, 4096, 16384, 66000 };
private static final int[] DefaultMemoryPoolInitAlloc = { 20, 20, 5, 5 };
private static final int[] DefaultMemoryPoolMaxAlloc = { 100, 50, 50, 50 };
public JLANFileServerConfiguration() throws InvalidConfigurationException, DeviceContextException {
super(HOSTNAME);
setServerName(HOSTNAME);
// DEBUG
DebugConfigSection debugConfig = new DebugConfigSection(this);
final GenericConfigElement debugConfigElement = new GenericConfigElement("output");
final GenericConfigElement logLevelConfigElement = new GenericConfigElement("logLevel");
logLevelConfigElement.setValue("Debug");
debugConfig.setDebug("org.alfresco.jlan.debug.ConsoleDebug", debugConfigElement);
// CORE
CoreServerConfigSection coreConfig = new CoreServerConfigSection(this);
coreConfig.setMemoryPool( DefaultMemoryPoolBufSizes, DefaultMemoryPoolInitAlloc, DefaultMemoryPoolMaxAlloc);
coreConfig.setThreadPool(DefaultThreadPoolInit, DefaultThreadPoolMax);
coreConfig.getThreadPool().setDebug(true);
// GLOBAL
GlobalConfigSection globalConfig = new GlobalConfigSection(this);
// SECURITY
SecurityConfigSection secConfig = new SecurityConfigSection(this);
DefaultAccessControlManager accessControlManager = new DefaultAccessControlManager();
accessControlManager.setDebug(true);
accessControlManager.initialize(this, new GenericConfigElement("aclManager"));
secConfig.setAccessControlManager(accessControlManager);
secConfig.setJCEProvider("cryptix.jce.provider.CryptixCrypto");
final UserAccountList userAccounts = new UserAccountList();
secConfig.setUserAccounts(userAccounts);
// SHARES
FilesystemsConfigSection filesysConfig = new FilesystemsConfigSection(this);
DiskInterface diskInterface = new org.alfresco.jlan.smb.server.disk.JavaFileDiskDriver();
final GenericConfigElement driverConfig = new GenericConfigElement("driver");
final GenericConfigElement localPathConfig = new GenericConfigElement("LocalPath");
localPathConfig.setValue(".");
driverConfig.addChild(localPathConfig);
DiskDeviceContext diskDeviceContext = (DiskDeviceContext) diskInterface.createContext("JLANSHARE", driverConfig);
diskDeviceContext.setShareName("JLANSHARE");
diskDeviceContext.setConfigurationParameters(driverConfig);
diskDeviceContext.enableChangeHandler(false);
diskDeviceContext.setDiskInformation(new SrvDiskInfo(2560000, 64, 512, 2304000));// Default to a 80Gb sized disk with 90% free space
DiskSharedDevice diskDev = new DiskSharedDevice("JLANSHARE", diskInterface, diskDeviceContext);
diskDev.setConfiguration(this);
diskDev.setAccessControlList(secConfig.getGlobalAccessControls());
diskDeviceContext.startFilesystem(diskDev);
filesysConfig.addShare(diskDev);
// SMB
CIFSConfigSection cifsConfig = new CIFSConfigSection(this);
cifsConfig.setServerName(HOSTNAME);
cifsConfig.setDomainName("MYDOMAIN");
cifsConfig.setHostAnnounceInterval(5);
cifsConfig.setHostAnnouncer(true);
final CifsAuthenticator authenticator = new LocalAuthenticator() {
@Override
public int authenticateUser(ClientInfo client, SrvSession sess, int alg) {
return AUTH_ALLOW;
}
};
authenticator.setDebug(true);
authenticator.setAllowGuest(true);
authenticator.setAccessMode(CifsAuthenticator.USER_MODE);
final GenericConfigElement authenticatorConfigElement = new GenericConfigElement("authenticator");
authenticator.initialize(this, authenticatorConfigElement);
cifsConfig.setAuthenticator(authenticator);
cifsConfig.setHostAnnounceDebug(true);
cifsConfig.setNetBIOSDebug(true);
cifsConfig.setSessionDebugFlags(-1);
cifsConfig.setTcpipSMB(true);
}
請注意,為了在Windows框中使用JLAN,您需要禁用端口445上的內置文件共享。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.