Example #1
0
  public void invoke(
      org.omg.CORBA.ServerRequest request) { // Ensure that the operation name is correct
    System.out.println("invocato metodo " + request.operation() + " in AccounManagerImpl");
    Float balance;
    String name = new String(_object_id());

    if (request.operation().equals("open")) {
      org.omg.CORBA.NVList params = orb.create_list(1);
      org.omg.CORBA.Any any = orb.create_any();
      any.insert_string(new String(""));
      params.add_value("nomeFile", any, org.omg.CORBA.ARG_IN.value);
      request.arguments(params);
      try {
        name = params.item(0).value().extract_string();
      } catch (Exception e) {
        System.out.println("ERRORE:");
        e.printStackTrace();
      }
      // Invoke the actual implementation and fill out the result
      org.omg.CORBA.Object account = open(name);
      org.omg.CORBA.Any result = orb.create_any();
      result.insert_Object(account);
      request.set_result(result);
    } else {
      System.out.println("Errore nell'ivocazione dinamica del metodo open");
      throw new org.omg.CORBA.BAD_PARAM();
    }
  }
Example #2
0
  public static void main(String[] args) {
    java.util.Properties props = new Properties();
    props.putAll(System.getProperties());
    props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
    props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");

    int status = 0;
    ORB orb = null;

    try {
      orb = ORB.init(args, props);
      status = run(orb, false, args);
    } catch (Exception ex) {
      ex.printStackTrace();
      status = 1;
    }

    if (orb != null) {
      try {
        orb.destroy();
      } catch (Exception ex) {
        ex.printStackTrace();
        status = 1;
      }
    }

    System.exit(status);
  }
Example #3
0
  public void init() {
    add(intitule);
    add(texte);
    add(bouton);
    bouton.addActionListener(this);

    try {
      ORB orb = ORB.init(this, null);
      FileReader file = new FileReader(iorfile.value);
      BufferedReader in = new BufferedReader(file);
      String ior = in.readLine();
      file.close();
      org.omg.CORBA.Object obj = orb.string_to_object(ior);
      annuaire = AnnuaireHelper.narrow(obj);

    } catch (org.omg.CORBA.SystemException ex) {
      System.err.println("Error");
      ex.printStackTrace();
    } catch (FileNotFoundException fnfe) {
      System.err.println(fnfe.getMessage());
    } catch (IOException io) {
      System.err.println(io.getMessage());
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
  }
Example #4
0
  public static void main(String args[]) {
    try {
      // create and initialize the ORB
      ORB orb = ORB.init(args, null);

      System.out.println("ORB initialised\n");

      // get the root naming context
      org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");

      // Use NamingContextExt instead of NamingContext,
      // part of the Interoperable naming Service.
      NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

      // resolve the Object Reference in Naming
      String name = "Hello1";
      helloImpl = HelloHelper.narrow(ncRef.resolve_str(name));

      System.out.println("Obtained a handle on server object: " + helloImpl);
      System.out.println(helloImpl.sayHello());
      helloImpl.shutdown();

    } catch (Exception e) {
      System.out.println("ERROR : " + e);
      e.printStackTrace(System.out);
    }
  } // end main
Example #5
0
  public static void main(String args[]) {
    if (args.length == 0) {
      System.out.println("Koordinator Namen eingeben...");
    } else {

      try {
        // ORB Eigenschaften setzen
        Properties props = new Properties();
        props.put("org.omg.CORBA.ORBInitialPort", "1050");
        props.put("org.omg.CORBA.ORBInitialHost", "localhost");
        orb = ORB.init(args, props);

        // Referenz von rootPOA holen und POA Manager aktivieren
        POA rootPoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
        rootPoa.the_POAManager().activate();

        // NamingContext besorgen
        NamingContextExt nc =
            NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));

        // Objektreferenz mit Namen "koordinator" besorgen
        org.omg.CORBA.Object obj = nc.resolve_str(args[1]);

        // Referenz fuer den Servant besorgen
        ggt.Koordinator koord = KoordinatorHelper.narrow(obj);

        // Servant erzeugen
        StarterImpl starter = new StarterImpl(args[0], koord, rootPoa);

        // Referenz fuer den Servant besorgen
        org.omg.CORBA.Object ref = rootPoa.servant_to_reference(starter);

        // Downcast Corba-Objekt -> koordinator
        ggt.Starter href = StarterHelper.narrow(ref);

        // starter bei koordinator anmelden
        koord.activateStarter(href, args[0]);

        // binde die Object Reference an einen Namen
        String name = args[0];
        NameComponent path[] = nc.to_name(name);
        nc.rebind(path, href);
        System.out.println("Koordinator laeuft ...");

        // Orb starten und auf Clients warten
        orb.run();
      } catch (Exception e) {
        System.err.println("Fehler: " + e);
        e.printStackTrace(System.out);
      }
      System.out.println("BankServer Exit");
    }
  }
Example #6
0
  public static void main(String[] args) {
    java.util.Properties props = new Properties();
    props.putAll(System.getProperties());
    props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
    props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");

    int status = 0;
    ORB orb = null;

    try {
      Client.ClientRegisterInterceptors(props, true);
      Server.ServerRegisterInterceptors(props);

      props.put("yoko.orb.id", "myORB");
      orb = ORB.init(args, props);
      status = Server.ServerRun(orb, true, args);

      if (status == 0) {
        status = Client.ClientRun(orb, true, args);

        //
        // The ORB must be totally shutdown before the servants
        // are deleted.
        //
        orb.shutdown(true);

        Server.ServerCleanup();
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      status = 1;
    }

    if (orb != null) {
      try {
        orb.destroy();
      } catch (Exception ex) {
        ex.printStackTrace();
        status = 1;
      }
    }

    System.exit(status);
  }
Example #7
0
  public synchronized org.omg.CORBA.Object open(String name) {
    org.omg.CORBA.Object obj = (org.omg.CORBA.Object) _registry.get(name);
    if (obj == null) {
      try {
        System.out.println("simulate the delay while creating the new account");
        Thread.currentThread().sleep(1200);
        float balance = new Float(Math.abs(_random.nextInt()) % 100000 / 100f).floatValue();
        AccountImpl account = new AccountImpl(balance, orb, name);
        byte[] accountId = name.getBytes();
        obj = _default_POA().servant_to_reference(account);
        System.out.println("Created " + name + "'s account: " + balance);
        _registry.put(name, obj); // registra l'account come esistente nella tabella
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else System.out.println("Esiste già un account con il nome " + name);

    return obj; // Return object reference
  }
  public static void main(String args[]) {
    try {
      // 创建和初始化ORB
      ORB orb = ORB.init(args, null);

      // 获得命名服务的Context
      org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
      NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

      // 获得名为“HelloService”的HelloService对象的远程引用
      String name = "HelloService";
      helloServiceImpl = HelloServiceHelper.narrow(ncRef.resolve_str(name));

      // 调用HelloService对象的远程方法
      System.out.println("Obtained a handle on server object: " + helloServiceImpl);
      System.out.println(helloServiceImpl.sayHello());
      helloServiceImpl.shutdown();
    } catch (Exception e) {
      System.out.println("ERROR : " + e);
      e.printStackTrace(System.out);
    }
  }
  public static void main(String[] args) {
    loggedUser = args[0];
    try {
      ORB orb = ORB.init(args, null); // initialize ORB
      o = orb.resolve_initial_references("NameService");

      // get reference to Deal object
      NamingContext ncRef = NamingContextHelper.narrow(o);
      NameComponent[] nc = new NameComponent[1];
      nc[0] = new NameComponent();
      nc[0].id = "Auction";
      nc[0].kind = "";
      a = AuctionHelper.narrow(ncRef.resolve(nc));

      isr = new InputStreamReader(System.in);
      in = new BufferedReader(isr);
      int sel = 0;
      System.out.println("******* You have logged in Successfully! ********");
      while (sel == 0) {
        System.out.println("Please make a selection");
        System.out.println("\t1. Get all the listed auctions");
        System.out.println("\t2. List a new item for auction.");
        System.out.println("\t3. Lookup an auction.");
        System.out.println("\t4. Place a bid on an auction.");
        System.out.println("\t5. Logout.");
        System.out.print("Please make your selection > ");
        String f = in.readLine();
        try {
          sel = Integer.parseInt(f);
        } catch (Exception e) {
          sel = 42;
        }
        switch (sel) {
          case 1:
            allItems();
            sel = 0;
            break;
          case 2:
            newAuction();
            sel = 0;
            break;
          case 3:
            System.out.println("Stub");
            sel = 0;
            break;
          case 4:
            placeBid();
            sel = 0;
            break;
          case 5:
            a.logout(loggedUser);
            System.out.println("BYE!");
            System.exit(0);
          default:
            System.out.println("You have not made a valid selection, please try again.");
            sel = 0;
            break;
        }
      }
    } catch (Exception e) {
      System.out.println("ERROR : " + e);
      e.printStackTrace(System.out);
    }
  }
Example #10
0
  public synchronized void update(RtecEventComm.Event event) {

    // System.out.println ("in NavWeapDataHandler.update");

    Any any_value;
    PersianRecursion.Data persian_recursion_data;

    any_value = event.data.any_value;

    if (any_value.type().equal(PersianRecursion.DataHelper.type())) {
      //        System.out.println ("type matched PersianRecursion.Data");

      try {
        persian_recursion_data = PersianRecursion.DataHelper.extract(any_value);
      } catch (Exception e) {
        System.err.println(e.getMessage() + "\nThe stack trace is:\n");
        e.printStackTrace();
        return;
      }

      //       System.out.println ("extracted any");

      if (persian_recursion_data.criticality_level.equals(
              RtecScheduler.Criticality_t.HIGH_CRITICALITY)
          || persian_recursion_data.criticality_level.equals(
              RtecScheduler.Criticality_t.VERY_HIGH_CRITICALITY)) {
        //            System.out.println ("obtaining high priority persian recursion observable");

        PersianObservable pobs_hi =
            (PersianObservable) ObservablesTable.get("High Consumer Persian Recursion");

        //            System.out.println ("updating high priority persian recursion observable");

        pobs_hi.updatePersianData(persian_recursion_data);

        // LatencyObservable lobs_hi =
        // (LatencyObservable) ObservablesTable.get ("High Consumer Execution Time (100 ns)");

        // lobs_hi.updateLatency (persian_recursion_data.computation_time);
      } else {
        //            System.out.println ("obtaining low priority persian recursion observable");
        PersianObservable pobs_lo =
            (PersianObservable) ObservablesTable.get("Low Consumer Persian Recursion");

        //            System.out.println ("obtained low priority persian recursion observable");
        // System.out.println ("updating low priority persian recursion observable");

        pobs_lo.updatePersianData(persian_recursion_data);

        //            System.out.println ("updated low priority persian recursion observable");

        // LatencyObservable lobs_lo =
        // (LatencyObservable) ObservablesTable.get ("Low Consumer Execution Time (100 ns)");

        // lobs_lo.updateLatency (persian_recursion_data.computation_time);
      }

      //        System.out.println ("done updating PersianObservables");

      received_events_++;

      //        System.out.println ("total events received: " + received_events_);
    } else if (any_value.type().equal(NavigationHelper.type())) {
      Navigation navigation_ = NavigationHelper.extract(any_value);

      // if the navigation data structure's update data flag is set,
      // update its scheduling data with actual values from the EC
      if (navigation_.update_data > 0) {
        navigation_.arrival_time = event.header.creation_time;
        navigation_.completion_time = event.header.ec_send_time;
        navigation_.deadline_time += event.header.creation_time;
      }

      NavigationObservable nobs = (NavigationObservable) ObservablesTable.get("Navigation");
      nobs.updateNavigation(navigation_);
      Cpu_UsageObservable cobs = (Cpu_UsageObservable) ObservablesTable.get("CPU Usage");
      cobs.updateCpu_Usage(navigation_.utilization);
      OverheadObservable oobs = (OverheadObservable) ObservablesTable.get("Overhead");
      oobs.updateOverhead(navigation_.overhead);
      JitterObservable jobs = (JitterObservable) ObservablesTable.get("Latency Jitter (100 ns)");
      jobs.updateJitter(
          navigation_.completion_time, navigation_.computation_time, navigation_.arrival_time);
      JitterObservable njobs =
          (JitterObservable) ObservablesTable.get("Navigation Latency Jitter (100 ns)");
      njobs.updateJitter(
          navigation_.completion_time, navigation_.computation_time, navigation_.arrival_time);
      DeadlinesObservable dobs = (DeadlinesObservable) ObservablesTable.get("Missed Deadlines");
      dobs.updateDeadlines(navigation_.deadline_time, navigation_.completion_time);
      CriticalDeadlinesObservable cdobs =
          (CriticalDeadlinesObservable) ObservablesTable.get("Missed Critical Deadlines");
      cdobs.updateDeadlines(
          navigation_.deadline_time, navigation_.completion_time, navigation_.criticality);
      LatencyObservable lobs = (LatencyObservable) ObservablesTable.get("Latency (100 ns)");
      lobs.updateLatency(
          navigation_.completion_time, navigation_.computation_time, navigation_.arrival_time);
      LatencyObservable nlobs =
          (LatencyObservable) ObservablesTable.get("Navigation Latency (100 ns)");
      nlobs.updateLatency(
          navigation_.completion_time, navigation_.computation_time, navigation_.arrival_time);
      received_events_++;
    } else if (any_value.type().equal(WeaponsHelper.type())) {
      Weapons weapons_ = WeaponsHelper.extract(any_value);

      // if the weapons structure's update data flag is set, update
      // itss scheduling data with actual values from the EC
      if (weapons_.update_data > 0) {
        weapons_.arrival_time = event.header.creation_time;
        weapons_.completion_time = event.header.ec_send_time;
        weapons_.deadline_time += event.header.creation_time;
      }

      WeaponsObservable wobs = (WeaponsObservable) ObservablesTable.get("Weapons");
      ;
      wobs.updateWeapons(weapons_);
      Cpu_UsageObservable cobs = (Cpu_UsageObservable) ObservablesTable.get("CPU Usage");
      cobs.updateCpu_Usage(weapons_.utilization);
      OverheadObservable oobs = (OverheadObservable) ObservablesTable.get("Overhead");
      oobs.updateOverhead(weapons_.overhead);
      JitterObservable jobs = (JitterObservable) ObservablesTable.get("Latency Jitter (100 ns)");
      jobs.updateJitter(weapons_.completion_time, weapons_.computation_time, weapons_.arrival_time);
      JitterObservable wjobs =
          (JitterObservable) ObservablesTable.get("Weapons Latency Jitter (100 ns)");
      wjobs.updateJitter(
          weapons_.completion_time, weapons_.computation_time, weapons_.arrival_time);
      DeadlinesObservable dobs = (DeadlinesObservable) ObservablesTable.get("Missed Deadlines");
      dobs.updateDeadlines(weapons_.deadline_time, weapons_.completion_time);
      CriticalDeadlinesObservable cdobs =
          (CriticalDeadlinesObservable) ObservablesTable.get("Missed Critical Deadlines");
      cdobs.updateDeadlines(weapons_.deadline_time, weapons_.completion_time, weapons_.criticality);
      LatencyObservable lobs = (LatencyObservable) ObservablesTable.get("Latency (100 ns)");
      lobs.updateLatency(
          weapons_.completion_time, weapons_.computation_time, weapons_.arrival_time);
      LatencyObservable wlobs =
          (LatencyObservable) ObservablesTable.get("Weapons Latency (100 ns)");
      wlobs.updateLatency(
          weapons_.completion_time, weapons_.computation_time, weapons_.arrival_time);
      received_events_++;
    } else {
      System.out.println("Received wrong type information");

      System.out.println("Received any_value.type (): [" + any_value.type() + "]");

      System.out.println("Expected NavigationHelper.type (): [" + NavigationHelper.type() + "]");

      System.out.println("OR WeaponsHelper.type (): [" + WeaponsHelper.type() + "]");

      System.out.println(
          "OR PersianRecursion.DataHelper.type (): [" + PersianRecursion.DataHelper.type() + "]");
    }
  }