Guest User

Untitled

a guest
Jan 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. package at.ac.tuwien.infosys.rnue.implementation;
  2.  
  3. import java.util.Properties;
  4. import at.ac.tuwien.infosys.rnue.helpers.ShareMeException;
  5. import at.ac.tuwien.infosys.rnue.implementation.multicast.HostListImpl;
  6. import at.ac.tuwien.infosys.rnue.implementation.multicast.IsAliveReceiver;
  7. import at.ac.tuwien.infosys.rnue.implementation.multicast.ShutdownListener;
  8. import at.ac.tuwien.infosys.rnue.interfaces.IConstants;
  9. import at.ac.tuwien.infosys.rnue.interfaces.IShareMe;
  10. import at.ac.tuwien.infosys.rnue.interfaces.ISearchResult;
  11. import java.net.InetAddress;
  12. import java.net.UnknownHostException;
  13.  
  14. public class ShareMeImpl implements IShareMe {
  15.  
  16. private Properties prop;
  17. private ShutdownListener Shutlist;
  18. private IsAliveReceiver iar;
  19. private HostListImpl hli;
  20.  
  21. public ShareMeImpl(Properties prop) throws ShareMeException {
  22. this.prop = prop;
  23. this.hli = new HostListImpl();
  24. try {
  25. prop.setProperty(IConstants.RMI_REGISTRY_HOST, InetAddress.getLocalHost().toString());
  26. } catch (UnknownHostException ex) {
  27. System.out.println(ex.getMessage());
  28. }
  29. }
  30.  
  31. public void start() throws ShareMeException{
  32. System.out.println("vypis z startu");
  33. Shutlist = new ShutdownListener(this, Integer.parseInt(prop.getProperty(IConstants.SHUTDOWN_PORT)), prop.getProperty(IConstants.SHUTDOWN_PASSWORD));
  34. iar = new IsAliveReceiver(prop,hli);
  35. Thread thread = new Thread(Shutlist);
  36. Thread thread2 = new Thread(iar);
  37. thread.start();
  38. thread2.start();
  39. }
  40.  
  41. public void stop() throws ShareMeException{
  42. iar.stop();
  43. hli.stopGarbageCollector();
  44. }
  45.  
  46. public ISearchResult search(String searchString) throws ShareMeException {
  47. throw new ShareMeException("method not yet implemented");
  48. }
  49. }
Add Comment
Please, Sign In to add comment