public NotificationTestCaseSetup() throws Exception {
    ifrServerSetup =
        new IFRServerSetup(
            TestUtils.testHome() + "/src/test/idl/TypedNotification.idl", null, null);

    ORBSetUp();

    serverORB = ORB.init(new String[0], orbProps);

    POAHelper.narrow(serverORB.resolve_initial_references("RootPOA")).the_POAManager().activate();

    container_ = PicoContainerFactory.createRootContainer((org.jacorb.orb.ORB) serverORB);
    container_.unregisterComponent(Repository.class);
    container_.registerComponent(
        new AbstractComponentAdapter(Repository.class, Repository.class) {

          public Object getComponentInstance(PicoContainer picocontainer)
              throws PicoInitializationException, PicoIntrospectionException {
            try {
              return getRepository();
            } catch (Exception e) {
              throw new RuntimeException(e);
            }
          }

          public void verify(PicoContainer picocontainer) throws PicoIntrospectionException {}
        });

    testUtils_ = new NotificationTestUtils(getServerORB());

    POAHelper.narrow(orb.resolve_initial_references("RootPOA")).the_POAManager().activate();
  }
  public static void main(String[] args) {
    try {
      // init ORB
      ORB orb = ORB.init(args, null);

      // init POA
      POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

      poa.the_POAManager().activate();

      // create a Adder object
      AdderImpl adderImpl = new AdderImpl();

      // create the object reference
      org.omg.CORBA.Object adderRef = poa.servant_to_reference(adderImpl);

      org.omg.CORBA.Object nsObject = orb.resolve_initial_references("NameService");
      NamingContextExt nc = NamingContextExtHelper.narrow(nsObject);

      nc.rebind(nc.to_name("Adder"), adderRef);

      // wait for requests
      orb.run();
    } catch (Exception e) {
      System.out.println(e);
    }
  }
示例#3
0
  public void run() {

    try {
      ORB orb = ORB.init(args, null);
      // get reference to rootpoa & activate the POAManager
      POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
      poa.the_POAManager().activate();

      // get the root naming context
      org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
      // Use NamingContextExt which is part of the Interoperable
      // Naming Service (INS) specification.
      NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
      DomainParticipantFactoryImpl impl = new DomainParticipantFactoryImpl(orb, poa);

      // get object reference from the servant (and implicitly register
      // it)
      org.omg.CORBA.Object oref = poa.servant_to_reference(impl);
      DomainParticipantFactory ref = DomainParticipantFactoryHelper.narrow(oref);

      if (ncRef != null) {
        // bind the Object Reference in Naming
        NameComponent path[] = ncRef.to_name("DomainParticipantFactory");
        ncRef.rebind(path, ref);
      }
      System.out.println("Server ready and waiting ...");
      orb.run();
    } catch (Exception e) {
      System.out.println("e" + e);
      e.printStackTrace();
    }
  }
示例#4
0
  @Override
  public Emitter connect(String nickname, Receiver rcv) {

    if (isConnected(nickname)) {
      for (Emitter e : emitters) {

        if (nickname.equals(e.client())) {
          System.out.println(nickname + " est déjà connécté  ");
          return e; // je sort et je retourne l'émeteur !
        }
      }
    }

    EmitterImpl emitter = new EmitterImpl();
    receivers.add(rcv); //  J'ajoute le receiver dans le ArrayList
    clients.add(nickname);
    System.out.println("Le client " + nickname + " vient de se connecter ! ");
    Emitter em = null;

    POA rootpoa;
    try {

      rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
      rootpoa.the_POAManager().activate();
      org.omg.CORBA.Object ref = rootpoa.servant_to_reference(emitter);
      em = EmitterHelper.narrow(ref);
      em.client(nickname);
      emitters.add(em); // on ajoute cet emmetteur !

    } catch (Exception e) {
      e.printStackTrace();
    }
    return em;
  }
示例#5
0
  public void testThereShouldBeOnlyOneLogfile() throws Exception {
    File dir = TestUtils.createTempDir("bugjac384");

    Properties props = new Properties();

    props.setProperty("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
    props.setProperty("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");
    props.setProperty("jacorb.log.default.verbosity", "4");
    props.setProperty("jacorb.logfile", dir.getAbsolutePath() + "/logfile.txt");
    props.setProperty("jacorb.logfile.append", "on");
    props.setProperty("jacorb.logfile.maxLogSize", "1500");
    props.setProperty("jacorb.logfile.rotateCount", "2");

    ORB orb = ORB.init(new String[0], props);
    orb.shutdown(true);
    ((org.jacorb.config.JacORBConfiguration) ((org.jacorb.orb.ORB) orb).getConfiguration())
        .shutdownLogging();
    orb = ORB.init(new String[0], props);
    POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
    poa.destroy(true, true);
    orb.shutdown(true);

    ((org.jacorb.config.JacORBConfiguration) ((org.jacorb.orb.ORB) orb).getConfiguration())
        .shutdownLogging();

    final String[] list = dir.list();
    assertEquals(Arrays.asList(list).toString(), 2, list.length);
  }
示例#6
0
  public static void main(String args[]) {
    // public void run() {
    String nomOffice = args[0];
    // Tableau des id/nom des sites
    OfficeDBManager db = new OfficeDBManager();

    Hashtable<Short, String> codeSite = new Hashtable<Short, String>();
    // Table des id des sites
    short[] idSite = db.getIdSites();
    for (int i = 0; i < idSite.length; i++) {
      codeSite.put(idSite[i], db.getCodeSite(idSite[i]));
    }

    try {
      org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);

      // Gestion du POA
      // ****************
      // Recuperation du POA
      POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

      // Creation du servant
      // *********************
      OfficeImpl monOffice = new OfficeImpl(orb, codeSite);

      // Activer le servant au sein du POA et recuperer son ID
      byte[] monOfficeId = rootPOA.activate_object(monOffice);

      // Activer le POA manager
      rootPOA.the_POAManager().activate();

      /** ****** Enregistrement dans le service de nommage ******* */

      // Recuperation du naming service
      NamingContext nameRoot =
          org.omg.CosNaming.NamingContextHelper.narrow(
              orb.resolve_initial_references("NameService"));

      // Construction du nom a enregistrer
      org.omg.CosNaming.NameComponent[] nameToRegister = new org.omg.CosNaming.NameComponent[1];
      nameToRegister[0] = new org.omg.CosNaming.NameComponent(nomOffice, "");

      // Enregistrement de l'objet CORBA dans le service de noms
      nameRoot.rebind(nameToRegister, rootPOA.servant_to_reference(monOffice));
      System.out.println("==> Nom '" + nomOffice + "' est enregistre dans le service de noms.");

      String IORServant = orb.object_to_string(rootPOA.servant_to_reference(monOffice));
      System.out.println("L'objet possede la reference suivante :");
      System.out.println(IORServant);

      // Lancement de l'ORB et mise en attente de requete
      // **************************************************
      orb.run();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public static void main(String[] args) {

    Properties props = System.getProperties();
    props.setProperty("org.omg.CORBA.ORBClass", "com.sun.corba.se.internal.POA.POAORB");
    props.setProperty(
        "org.omg.CORBA.ORBSingletonClass", "com.sun.corba.se.internal.corba.ORBSingleton");

    try {
      // Initialize the ORB.
      org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, props);

      // get a reference to the root POA
      org.omg.CORBA.Object obj = orb.resolve_initial_references("RootPOA");
      POA poaRoot = POAHelper.narrow(obj);

      // Create policies for our persistent POA
      org.omg.CORBA.Policy[] policies = {
        // poaRoot.create_lifespan_policy(LifespanPolicyValue.PERSISTENT),
        poaRoot.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID),
        poaRoot.create_thread_policy(ThreadPolicyValue.ORB_CTRL_MODEL)
      };

      // Create myPOA with the right policies
      POA poa =
          poaRoot.create_POA("DRSCommonServiceServerImpl_poa", poaRoot.the_POAManager(), policies);

      // Create the servant
      servant = new DRSCommonServiceServerImpl(SvrInfo.SVR3_NAME_VANCOUVER);

      // Activate the servant with the ID on myPOA
      byte[] objectId = servant.svrName.getBytes();
      poa.activate_object_with_id(objectId, servant);

      // Activate the POA manager
      poaRoot.the_POAManager().activate();

      // Get a reference to the servant and write it down.
      obj = poa.servant_to_reference(servant);

      // ---- Uncomment below to enable Naming Service access. ----
      //			org.omg.CORBA.Object ncobj = orb
      //					.resolve_initial_references("NameService");
      //			NamingContextExt nc = NamingContextExtHelper.narrow(ncobj);
      //			nc.bind(nc.to_name(servant.svrName), obj);

      PrintWriter ps = new PrintWriter(new FileOutputStream(new File(servant.svrName)));
      ps.println(orb.object_to_string(obj));
      ps.close();

      System.out.println("RM3: " + servant.svrName + " is ready...");

      // Wait for incoming requests
      orb.run();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
示例#8
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");
    }
  }
  static {
    orb = ORB.init(new String[0], null);
    System.setProperty(
        "javax.rmi.CORBA.PortableRemoteObjectClass",
        PortableRemoteObjectDelegateImpl.class.getName());
    PortableRemoteObjectDelegateImpl.setORB(orb);

    try {
      POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
      poa.the_POAManager().activate();
    } catch (InvalidName e) {
      initException = e;
    } catch (AdapterInactive e) {
      initException = e;
    }
  }
示例#10
0
  private ORB getOrbForServer(int port)
      throws InvalidName, AdapterInactive, WrongPolicy, ServantNotActive, IOException {

    System.setProperty("org.omg.CORBA.ORBInitialPort", String.valueOf(port));

    final ORB orb = ORB.init(new String[0], null);

    System.clearProperty("org.omg.CORBA.ORBInitialPort");

    POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
    rootPOA.the_POAManager().activate();

    org.omg.CORBA.Object objref = rootPOA.servant_to_reference(new LibraryImpl(rootPOA));
    iorString = orb.object_to_string(objref);

    return orb;
  }
示例#11
0
  @Override
  public void start(StartContext context) throws StartException {
    log.debugf("Starting Service " + context.getController().getName().getCanonicalName());

    ORB orb = this.orbInjector.getOptionalValue();
    POA parentPOA = this.parentPOAInjector.getOptionalValue();

    // if an ORB has been injected, we will use the ORB.resolve_initial_references method to
    // instantiate the POA.
    if (orb != null) {
      try {
        this.poa = POAHelper.narrow(orb.resolve_initial_references(this.poaName));
      } catch (Exception e) {
        throw new StartException("Failed to resolve initial reference " + this.poaName, e);
      }
    }
    // if a parent POA has been injected, we use it to create the policies and then the POA itself.
    else if (parentPOA != null) {
      try {
        Policy[] poaPolicies = this.createPolicies(parentPOA);
        this.poa = parentPOA.create_POA(this.poaName, null, poaPolicies);
      } catch (Exception e) {
        throw new StartException("Failed to create POA from parent POA", e);
      }
    } else {
      throw new StartException(
          "Unable to instantiate POA: either the running ORB or the parent POA must be specified");
    }

    // check if the POA should be bound to JNDI under java:/jboss.
    if (this.bindingName != null) {
      CorbaServiceUtil.bindObject(context.getChildTarget(), this.bindingName, this.poa);
    }

    // activate the created POA.
    try {
      this.poa.the_POAManager().activate();
    } catch (Exception e) {
      throw new StartException("Failed to activate POA", e);
    }
  }
示例#12
0
  @Override
  public void start(StartContext context) throws StartException {
    JacORBLogger.ROOT_LOGGER.debugServiceStartup(
        context.getController().getName().getCanonicalName());

    ORB orb = this.orbInjector.getOptionalValue();
    POA parentPOA = this.parentPOAInjector.getOptionalValue();

    // if an ORB has been injected, we will use the ORB.resolve_initial_references method to
    // instantiate the POA.
    if (orb != null) {
      try {
        this.poa = POAHelper.narrow(orb.resolve_initial_references(this.poaName));
      } catch (Exception e) {
        throw JacORBMessages.MESSAGES.errorResolvingInitRef(this.poaName, e);
      }
    }
    // if a parent POA has been injected, we use it to create the policies and then the POA itself.
    else if (parentPOA != null) {
      try {
        Policy[] poaPolicies = this.createPolicies(parentPOA);
        this.poa = parentPOA.create_POA(this.poaName, null, poaPolicies);
      } catch (Exception e) {
        throw JacORBMessages.MESSAGES.errorCreatingPOAFromParent(e);
      }
    } else {
      throw JacORBMessages.MESSAGES.invalidPOACreationArgs();
    }

    // check if the POA should be bound to JNDI under java:/jboss.
    if (this.bindingName != null) {
      CorbaServiceUtil.bindObject(context.getChildTarget(), this.bindingName, this.poa);
    }

    // activate the created POA.
    try {
      this.poa.the_POAManager().activate();
    } catch (Exception e) {
      throw JacORBMessages.MESSAGES.errorActivatingPOA(e);
    }
  }
示例#13
0
  /** @param args the command line arguments */
  public static void main(String args[]) {

    try {
      // create and initialize the ORB
      ORB orb = ORB.init(args, null);

      // get reference to rootpoa & activate the POAManager
      POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
      rootpoa.the_POAManager().activate();

      // create servant
      Log_viewerImpl log_viewerImpl = new Log_viewerImpl();
      log_viewerImpl.setORB(orb);

      LogFrame frame = new LogFrame(log_viewerImpl);
      frame.setVisible(true);

      log_viewerImpl.setFrame(frame);

      // get object reference from the servant
      org.omg.CORBA.Object ref = rootpoa.servant_to_reference(log_viewerImpl);
      Log_viewer href = Log_viewerHelper.narrow(ref);

      // read stringified Registry to file
      FileReader fr = new FileReader(IORFILE);
      BufferedReader br = new BufferedReader(fr);
      String remoteRegistryIOR = br.readLine();

      // get the romote Registry
      org.omg.CORBA.Object ncobj = orb.string_to_object(remoteRegistryIOR);
      NamingContext rootNC = NamingContextHelper.narrow(ncobj);
      frame.println("Obtained Name Service reference.");
      log_viewerImpl.serRootNC(rootNC);

      NameComponent[] name = new NameComponent[1];
      name[0] = new NameComponent("Logger", "");

      try {

        rootNC.bind(name, href);

      } catch (org.omg.CORBA.UserException ue) {
        ue.printStackTrace();
        System.exit(-1);
      }

      frame.println("Logger Remote Interface bound in Name Service");

      // wait for invocations from client
      frame.println("Logger ready and waiting ...");
      orb.run();

      frame.println("Logger Exiting ...");
      System.out.println("Logger Exiting ...");

    } catch (Exception e) {
      System.err.println("ERROR: " + e);

      // e.printStackTrace(System.out);
    }
  }