Sin descripción

469eb4b2ae209a84ea58d81a21c264ff5e7e44c3.svn-base 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.rdlze.radializebase.mocks;
  2. import java.rmi.RemoteException;
  3. import java.rmi.registry.LocateRegistry;
  4. import java.rmi.registry.Registry;
  5. import java.rmi.server.UnicastRemoteObject;
  6. import java.util.List;
  7. import com.rdlze.radializebase.interfaces.InterfaceNotifiable;
  8. import com.rdlze.radializeutils.notification.Notification;
  9. public class MockNotifiable implements InterfaceNotifiable {
  10. /**
  11. *
  12. */
  13. private static final long serialVersionUID = 1L;
  14. String name = "";
  15. MockNotifiable mn = null;
  16. public MockNotifiable(String name){
  17. this.name=name;
  18. try {
  19. LocateRegistry.createRegistry(1099);
  20. } catch (Exception e) {
  21. System.out.println("createRegistryException....");
  22. }
  23. try {
  24. InterfaceNotifiable stub = (InterfaceNotifiable) UnicastRemoteObject.exportObject(
  25. this, 0);
  26. Registry registry = LocateRegistry.getRegistry(1099);
  27. registry.rebind(name, stub);
  28. System.out.println("MockNotifiable - OnLine");
  29. } catch (Exception e) {
  30. e.printStackTrace();
  31. }
  32. }
  33. @Override
  34. public void notify(Notification notification) throws RemoteException {
  35. System.out.println(this.getName()+" received notification "+notification.getRadioId());
  36. }
  37. @Override
  38. public void notify(List list) throws RemoteException {
  39. System.out.println("received list");
  40. }
  41. @Override
  42. public void registerNotifiable(String IP, String serviceName, int port)
  43. throws RemoteException {
  44. }
  45. @Override
  46. public String getName() throws RemoteException {
  47. return this.name;
  48. }
  49. public static void main(String[] args){
  50. new MockNotifiable("teste");
  51. }
  52. }