Portmap.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (C) 2006-2010 Alfresco Software Limited.
  3. *
  4. * This file is part of Alfresco
  5. *
  6. * Alfresco is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Alfresco is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package org.alfresco.jlan.app;
  20. import org.alfresco.jlan.debug.Debug;
  21. import org.alfresco.jlan.oncrpc.nfs.NFSConfigSection;
  22. import org.alfresco.jlan.oncrpc.portmap.PortMapperServer;
  23. import org.alfresco.jlan.server.config.ServerConfiguration;
  24. import org.alfresco.jlan.util.ConsoleIO;
  25. /**
  26. * Portmapper service class
  27. *
  28. * @author gkspencer
  29. */
  30. public class Portmap {
  31. /**
  32. * Main application
  33. *
  34. * @param args String[]
  35. */
  36. public static void main(String[] args) {
  37. try {
  38. // Create the default configuration
  39. ServerConfiguration srvConfig = new ServerConfiguration( "PORTMAP");
  40. NFSConfigSection nfsConfig = new NFSConfigSection(srvConfig);
  41. nfsConfig.setPortMapperDebug( true);
  42. // Create the portmapper service
  43. PortMapperServer portMapper = new PortMapperServer( srvConfig);
  44. // Start the portmapper
  45. portMapper.startServer();
  46. // Wait while the server runs, user may stop server by typing a key
  47. boolean shutdown = false;
  48. while (shutdown == false) {
  49. // Check if the user has requested a shutdown, if running interactively
  50. int inChar = ConsoleIO.readCharacter();
  51. if ( inChar == 'x' || inChar == 'X')
  52. shutdown = true;
  53. // Sleep for a short while
  54. try {
  55. Thread.sleep(500);
  56. }
  57. catch (InterruptedException ex) {
  58. }
  59. }
  60. // Shutdown the portmapper service
  61. portMapper.shutdownServer( false);
  62. }
  63. catch (Exception ex) {
  64. Debug.println( ex);
  65. }
  66. }
  67. }