示例#1
0
        public static void Main(string[] args) {
            try {
                string host = "localhost";
                int port = 8087;
                parseArgs(ref host, ref port, args);

                Console.WriteLine("input the two summands");
                Console.WriteLine("sum1:");
                double sum1 = Double.Parse(Console.ReadLine());
                Console.WriteLine("sum2:");
                double sum2 = Double.Parse(Console.ReadLine());
			
                // register the channel
                IiopClientChannel channel = new IiopClientChannel();
                ChannelServices.RegisterChannel(channel, false);

                // get the reference to the adder
                Adder adder = (Adder)RemotingServices.Connect(typeof(Adder), "iiop://" + host + ":" + port + "/adder");
                // call add
                double result = adder.add(sum1, sum2);
                Console.WriteLine("result: " + result);
            } catch (Exception e) {
                Console.WriteLine("exception: " + e);
            }
        }
示例#2
0
        public static void Main(string[] args) {
            try {
                string nameServiceHost = "localhost";
                int nameServicePort = 1050;
                parseArgs(ref nameServiceHost, ref nameServicePort, args);

                Console.WriteLine("input the two summands");
                Console.WriteLine("sum1:");
                double sum1 = Double.Parse(Console.ReadLine());
                Console.WriteLine("sum2:");
                double sum2 = Double.Parse(Console.ReadLine());

                // register the channel
                IiopClientChannel channel = new IiopClientChannel();
                ChannelServices.RegisterChannel(channel, false);

                // access COS nameing service
                RmiIiopInit init = new RmiIiopInit(nameServiceHost, nameServicePort);
                NamingContext nameService = init.GetNameService();
                NameComponent[] name = new NameComponent[] { new NameComponent("ch.elca.iiop.demo.ejbAdder.AdderHome", "") };
                // get the reference to the adder-home
                AdderHome adderHome = (AdderHome)nameService.resolve(name);
                // create Adder
                Adder adder = adderHome.create();
                // call add
                double result = adder.add(sum1, sum2);
                Console.WriteLine("result: " + result);
                // dispose the ejb
		adder.remove();
            } catch (Exception e) {
                Console.WriteLine("exception: " + e);
            }
        }
示例#3
0
        public static void Main(string[] args) {
            try {
                string nameserviceLoc = "corbaloc::localhost:8091/StandardNS/NameServer-POA/_root";
                if (args.Length > 0) {
                    nameserviceLoc = args[0];
                }

                Console.WriteLine("input the two summands");
                Console.WriteLine("sum1:");
                double sum1 = Double.Parse(Console.ReadLine());
                Console.WriteLine("sum2:");
                double sum2 = Double.Parse(Console.ReadLine());
			
                // register the channel
                IiopClientChannel channel = new IiopClientChannel();
                ChannelServices.RegisterChannel(channel, false);

                // get reference to nameservice
                NamingContext nc = (NamingContext)RemotingServices.Connect(typeof(NamingContext), nameserviceLoc);

                // get the reference to the adder
                Adder adder = 
                    (Adder)nc.resolve(new NameComponent[] { new NameComponent("Adder") });
                // call add
                double result = adder.add(sum1, sum2);
                Console.WriteLine("result: " + result);
            } catch (Exception e) {
                Console.WriteLine("exception: " + e);
            }
        }
示例#4
0
        public void SetupEnvironment() {
            // register the channel
            IDictionary props = new Hashtable();
            props[IiopChannel.CHANNEL_NAME_KEY] = "IiopClientChannelSsl";
            props[IiopChannel.TRANSPORT_FACTORY_KEY] =
               "Ch.Elca.Iiop.Security.Ssl.SslTransportFactory,SSLPlugin";
            
            props[SslTransportFactory.CLIENT_AUTHENTICATION] = 
                "Ch.Elca.Iiop.Security.Ssl.ClientMutualAuthenticationSuitableFromStore,SSLPlugin";
            // take certificates from the windows certificate store of the current user
            props[ClientMutualAuthenticationSuitableFromStore.STORE_LOCATION] =
                "CurrentUser";
            // the expected CN property of the server key
            props[DefaultClientAuthenticationImpl.EXPECTED_SERVER_CERTIFICATE_CName] = 
                "IIOP.NET demo server";
            props[IiopClientChannel.ALLOW_REQUEST_MULTIPLEX_KEY] = false;
            
            // register the channel
            m_channel = new IiopClientChannel(props);
            ChannelServices.RegisterChannel(m_channel, false);

            // get the reference to the test-service
            m_testService = (TestService)RemotingServices.Connect(typeof(TestService), 
                            "corbaloc:iiop-ssl:1.2@localhost:8087/test");

            m_newTestService = m_testService.ReturnNewTestService();
        }
示例#5
0
        public static void Main(string[] args) {
            try {
                string nameServiceHost = "localhost";
                int nameServicePort = 1050;
                parseArgs(ref nameServiceHost, ref nameServicePort, args);

                Console.WriteLine("input the two summands");
                Console.WriteLine("sum1:");
                double sum1 = Double.Parse(Console.ReadLine());
                Console.WriteLine("sum2:");
                double sum2 = Double.Parse(Console.ReadLine());
			
                // register the channel
                IiopClientChannel channel = new IiopClientChannel();
                ChannelServices.RegisterChannel(channel);

                // access COS nameing service
                CorbaInit init = CorbaInit.GetInit();
                NamingContext nameService = init.GetNameService(nameServiceHost, nameServicePort);
                NameComponent[] name = new NameComponent[] { new NameComponent("adder", "") };
                // get the reference to the adder
                Adder adder = (Adder)nameService.resolve(name);
		    // call add
                double result = adder.add(sum1, sum2);
                Console.WriteLine("result: " + result);
            } catch (Exception e) {
                Console.WriteLine("exception: " + e);
            }
        }
示例#6
0
        public void SetupEnvironment() {
            // register the channel
            m_channel = new IiopClientChannel();
            ChannelServices.RegisterChannel(m_channel, false);

            // get the reference to the test-service
            m_testService = (TestService)RemotingServices.Connect(typeof(TestService), "corbaloc:iiop:1.2@localhost:8087/test");
        }
示例#7
0
        public void SetupEnvironment() {
            // register the channel
            m_channel = new IiopClientChannel();
            ChannelServices.RegisterChannel(m_channel, false);

            NamingContext nameService = GetNameService();
            NameComponent[] name = new NameComponent[] { new NameComponent("test", "") };
            // get the reference to the test-service
            m_testService = (TestService)nameService.resolve(name);
        }
示例#8
0
        public void SetupEnvironment() {
            // register the channel
            IDictionary props = new Hashtable();
            props[IiopClientChannel.CLIENT_REQUEST_TIMEOUT_KEY] = 1000;
            m_channel = new IiopClientChannel(props);
            ChannelServices.RegisterChannel(m_channel, false);

            // get the reference to the test-service
            m_testService = (TestService)RemotingServices.Connect(typeof(TestService), "corbaloc:iiop:1.2@localhost:8087/test");
        }
示例#9
0
        public void SetupEnvironment() {
            // register the channel
            IDictionary properties = new Hashtable();
            properties[IiopClientChannel.ALLOW_REQUEST_MULTIPLEX_KEY] = false;
            m_channel = new IiopClientChannel(properties);
            ChannelServices.RegisterChannel(m_channel, false);

            // get the reference to the test-service
            m_testService = (TestService)RemotingServices.Connect(typeof(TestService), "corbaloc:iiop:1.2@localhost:8087/test");

            m_newTestService = m_testService.ReturnNewTestService();
        }
示例#10
0
        public void SetupEnvironment() {
            // register the channel
            m_channel = new IiopClientChannel();
            ChannelServices.RegisterChannel(m_channel, false);

            // access COS nameing service
            NamingContext nameService = (NamingContext)RemotingServices.Connect(typeof(NamingContext), 
                                                                                "corbaloc::localhost:11456/NameService");
            NameComponent[] name = new NameComponent[] { new NameComponent("test", "") };
            // get the reference to the test-service
            m_testService = (TestService)nameService.resolve(name);
        }
示例#11
0
        public void SetupEnvironment() {
            // register the channel
            IDictionary properties = new Hashtable();
            properties[IiopClientChannel.ALLOW_REQUEST_MULTIPLEX_KEY] = false;
            properties[IiopClientChannel.CLIENT_CONNECTION_LIMIT_KEY] = 10;
            m_channel = new IiopClientChannel(properties);
            ChannelServices.RegisterChannel(m_channel, false);

            // get the reference to the test-service
            m_testService1 = (TestService)RemotingServices.Connect(typeof(TestService), "iiop://localhost:8087/test1");
            m_testService2 = (TestService)RemotingServices.Connect(typeof(TestService), "iiop://localhost:8087/test2");
        }
示例#12
0
        public void SetupEnvironment() {
            // register the channel
            m_channel = new IiopClientChannel();
            ChannelServices.RegisterChannel(m_channel, false);

            // access COS nameing service
            RmiIiopInit init = new RmiIiopInit("localhost", 7001);
            m_nameService = init.GetNameService();
            NameComponent[] name = new NameComponent[] { new NameComponent("IntegrationTest", ""), new NameComponent("test", "") };
            // get the reference to the test-home
            TestHome testhome = (TestHome) m_nameService.resolve(name);
            m_test = testhome.create();
        }
示例#13
0
        public void SetupEnvironment() {
            // register the channel
            m_channel = new IiopClientChannel();
            ChannelServices.RegisterChannel(m_channel, false);

            // access COS nameing service
            string nameserviceLoc = "corbaloc::localhost:3528/JBoss/Naming/root";
            m_nameService = (NamingContext)RemotingServices.Connect(typeof(NamingContext), nameserviceLoc);

            NameComponent[] name = new NameComponent[] { new NameComponent("IntegrationTest", ""), 
                                                         new NameComponent("testForwarder", "") };
            // get the reference to the test-home
            TestHomeFwd testhome = (TestHomeFwd) m_nameService.resolve(name);
            m_test = testhome.create();
        }
    public static void Main(string[] args)
    {
        IiopClientChannel channel = new IiopClientChannel();
        ChannelServices.RegisterChannel(channel, false);

        NamingContext nc = (NamingContext)RemotingServices.Connect(
            typeof(NamingContext), args[0]);
        Example.Pingable pingable = (Example.Pingable)nc.resolve(
        new NameComponent[] {
            new NameComponent("test"),
            new NameComponent("ExamplePing")
        });

        pingable.ping();
    }
示例#15
0
        public void SetupEnvironment() {
            if (!m_isConfigured) {
                OrbServices orb = OrbServices.GetSingleton();
                orb.SerializerFactoryConfig.StringSerializationAllowNull = true;
                orb.SerializerFactoryConfig.SequenceSerializationAllowNull = true;
                orb.SerializerFactoryConfig.ArraySerializationAllowNull = true;
                m_isConfigured = true;
            }
            // register the channel
            m_channel = new IiopClientChannel();
            ChannelServices.RegisterChannel(m_channel, false);

            // get the reference to the test-service
            m_testService = (TestService)RemotingServices.Connect(typeof(TestService), "corbaloc:iiop:1.2@localhost:8087/test");
        }
示例#16
0
        public void SetupEnvironment() {
            // register the channel
            if (m_channel == null) {
                m_channel = new IiopClientChannel();
                ChannelServices.RegisterChannel(m_channel, false);

                RegisterInterceptors();

                // get the reference to the test-service
            m_testService = (TestService)RemotingServices.Connect(typeof(TestService), "corbaloc:iiop:1.2@localhost:8087/test");

                m_interceptorControl = (TestInterceptorControlService)RemotingServices.Connect(typeof(TestInterceptorControlService),
                                                                                               "corbaloc:iiop:1.2@localhost:8087/interceptorControl");
            }
        }
        public static void Main(string[] args)
        {
            try {
                // register the channel
                IiopClientChannel channel = new IiopClientChannel();
                ChannelServices.RegisterChannel(channel);

            Object obj = new Object();
            try {
            // access COS naming Service
            NamingContext nameService = (NamingContext)RemotingServices.Connect(typeof(NamingContext), "corbaloc::localhost:2809/NameService");
            Console.WriteLine("Got reference to nameService");

                // get the reference to the Graph
             		NameComponent[] name = new NameComponent[] { new NameComponent("Foo", "Test") };
            Console.WriteLine("About to resolve Foo.Test");
             		obj = (DataFlowGraph) nameService.resolve(name);
            Console.WriteLine("Got reference to graph");
            } catch (NotFound e) {
              Console.WriteLine("Could not find graph in NameService");
              return;
            } catch (TRANSIENT e) {
              Console.WriteLine("Could not contact NameService");
              return;
            }

            if (obj == null) {
              Console.WriteLine("Reference to graph is null...");
              return;
            }

            DataFlowGraph graph = (DataFlowGraph) obj;
             		KeyValuePair[] sink_attributes = new KeyValuePair[] { new KeyValuePair("name", "CORBA.Sink01") };
             		Console.WriteLine("About to create node");
            Node sink = (Node) graph.create_node("CORBASink", sink_attributes);
             		Console.WriteLine("Created CORBA sink node");
             		Node[] nodes = graph.get_nodes();
             		foreach (Node n in nodes) {
              Console.WriteLine(n.get_attribute("ID"));
             		}
              } catch (NotFound e) {
            Console.WriteLine("Could not find graph in NameService");
              } catch (TRANSIENT e) {
            Console.WriteLine("Could not contact graph");
              } catch (Exception e) {
            Console.WriteLine("exception: " + e);
              }
        }
示例#18
0
        public static void Main(string[] args) {
            try {
                string nameServiceHost = "localhost";
                int nameServicePort = 1050;
                parseArgs(ref nameServiceHost, ref nameServicePort, args);

                // register the channel
                IiopClientChannel channel = new IiopClientChannel();
                ChannelServices.RegisterChannel(channel, false);

                // access COS nameing service
                RmiIiopInit init = new RmiIiopInit(nameServiceHost, nameServicePort);
                NamingContext nameService = init.GetNameService();

                // test value object:
                Console.WriteLine("testing value object");
                NameComponent[] name = new NameComponent[] { new NameComponent("ch.elca.iiop.demo.valueObjectDemo.ValueObjDemoHome", "") };
                // get the reference to the ValObjectDemo-home
                ValObjectDemoHome valDemoHome = (ValObjectDemoHome)nameService.resolve(name);
                // create valObjectDemo
                ValObjectDemo valDemo = valDemoHome.create();
                // call retrieveValObject
                Console.WriteLine("calling retrieveValObject");
                ValObject resultVal = valDemo.retrieveValObject();
                Console.WriteLine("test-string: " + resultVal.testString);
                Console.WriteLine("test-int: " + resultVal.testValue);

                // call echoValObject
                Console.WriteLine("calling echoValObject");
                ValObject toSend = new ValObjectImpl();
                Console.WriteLine("input string: ");
                toSend.testString = Console.ReadLine();
                Console.WriteLine("input int: " );
                toSend.testValue = Int32.Parse(Console.ReadLine());
                Console.WriteLine("result of echo: ");
                ValObject echo = valDemo.echoValObject(toSend);
                Console.WriteLine("echo-string: " + echo.testString);
                Console.WriteLine("echo-value: " + echo.testValue);


                // Dispose the EJB
                valDemo.remove();

            } catch (Exception e) {
                Console.WriteLine("exception: " + e);
            }
        }
示例#19
0
        public static void Main(string[] args) {
            try {
                Console.WriteLine("input the two summands");
                Console.WriteLine("sum1:");
                double sum1 = Double.Parse(Console.ReadLine());
                Console.WriteLine("sum2:");
                double sum2 = Double.Parse(Console.ReadLine());

                string fileName = @"..\server\ior";
                if (args.Length > 0) {
                    fileName = args[0];
                }
                TextReader reader = new StreamReader(fileName);
                string ior = reader.ReadLine();
                reader.Close();
                Console.WriteLine("use ior: " + ior.ToString());

                IDictionary props = new Hashtable();
                props[IiopChannel.CHANNEL_NAME_KEY] = "IiopClientChannelSsl";
                props[IiopChannel.TRANSPORT_FACTORY_KEY] =
                   "Ch.Elca.Iiop.Security.Ssl.SslTransportFactory,SSLPlugin";
            
                props[SslTransportFactory.CLIENT_AUTHENTICATION] = 
                    "Ch.Elca.Iiop.Security.Ssl.ClientMutualAuthenticationSuitableFromStore,SSLPlugin";
                // take certificates from the windows certificate store of the current user
                props[ClientMutualAuthenticationSuitableFromStore.STORE_LOCATION] =
                    "CurrentUser";
                // the expected CN property of the server key
                props[DefaultClientAuthenticationImpl.EXPECTED_SERVER_CERTIFICATE_CName] = 
                    "IIOP.NET demo server";
            
                // register the channel
                IiopClientChannel channel = new IiopClientChannel(props);
                ChannelServices.RegisterChannel(channel, false);

                // get the reference to the adder
                Adder adder = (Adder)RemotingServices.Connect(typeof(Adder), ior);
                // call add
                double result = adder.add(sum1, sum2);
                Console.WriteLine("result: " + result);
            } catch (Exception e) {
                Console.WriteLine("exception: " + e);
            }
        }
示例#20
0
 private void SetupSslChannel() {
     IDictionary props = new Hashtable();
     props[IiopChannel.CHANNEL_NAME_KEY] = "IiopClientChannelSsl";
     props[IiopChannel.TRANSPORT_FACTORY_KEY] =
        "Ch.Elca.Iiop.Security.Ssl.SslTransportFactory,SSLPlugin";
     
     props[SslTransportFactory.CLIENT_AUTHENTICATION] = 
         "Ch.Elca.Iiop.Security.Ssl.ClientMutualAuthenticationSuitableFromStore,SSLPlugin";
     // take certificates from the windows certificate store of the current user
     props[ClientMutualAuthenticationSuitableFromStore.STORE_LOCATION] =
         "CurrentUser";
     // the expected CN property of the server key
     props[DefaultClientAuthenticationImpl.EXPECTED_SERVER_CERTIFICATE_CName] = 
         "JBoss Server IIOP.NET it-test";
  
     m_channel = new IiopClientChannel(props);
     // register the channel
     ChannelServices.RegisterChannel(m_channel, false);
 }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();
              context.Response.ContentType = "text/plain";

              string schema = "";
              //StringBuilder response = this.GetResponse();
              try
              {
            // Create and register new channel
            this.channel_ = new IiopClientChannel();

            ChannelServices.RegisterChannel(this.channel_, false);

            //Accessing the target object provided by TEM service
            this.tem_ =
              (TestExecutionManager)RemotingServices.Connect(typeof(TestExecutionManager),
               "corbaloc:iiop:localhost:50000/OASIS/TEM");

            DataAcquisitionController[] dacs = this.tem_.get_DACs();

            if (0 < dacs.Length)
            {
              foreach (DataAcquisitionController dac in dacs)
              {
            if (dac.name == context.Request.QueryString["DacName"])
            {
              schema = dac.get_schema(context.Request.QueryString["ProbeName"],
                                      context.Request.QueryString["EinodeName"]);

              break;
            }
              }
            }
              }
              finally
              {
            ChannelServices.UnregisterChannel(this.channel_);
              }

              context.Response.Write(schema);
              context.Response.End();
        }
示例#22
0
        public void SetupEnvironment() {
            MappingConfiguration.Instance.UseBoxedInAny = false; // disable boxing of string/arrays in any's
            // register the channel
            m_channel = new IiopClientChannel();
            ChannelServices.RegisterChannel(m_channel, false);

            NamingContext nameService = GetNameService();
            NameComponent[] name = new NameComponent[] { new NameComponent("test", "") };
            // get the reference to the test-service
            m_testService = (TestService)nameService.resolve(name);

            NameComponent[] nameInternal = 
                new NameComponent[] { new NameComponent("testInternal", "") };
            // get the reference to a service with a server-side only interface inherited from a public one
            m_testServiceInternalIf = 
               (TestSimpleServicePublic)nameService.resolve(nameInternal);

            m_orb = OrbServices.GetSingleton();
        }
示例#23
0
        public void SetupEnvironment() {
            // register the channel
            IDictionary properties = new Hashtable();
            properties[IiopClientChannel.ALLOW_REQUEST_MULTIPLEX_KEY] = false;
            m_channel = new IiopClientChannel(properties);
            ChannelServices.RegisterChannel(m_channel, false);

            // get the reference to the test-service
            m_testService = (TestService)RemotingServices.Connect(typeof(TestService), "corbaloc:iiop:1.2@localhost:8087/test");
            m_testExService = (TestExceptionService)RemotingServices.Connect(typeof(TestExceptionService), "corbaloc:iiop:1.2@localhost:8087/testExService");

            m_svcSingleCall = 
                (ISimpleTestInterface)RemotingServices.Connect(typeof(ISimpleTestInterface), "corbaloc:iiop:1.2@localhost:8087/testSingleCall");
            m_svcSingletonCall = 
                (ISimpleTestInterface)RemotingServices.Connect(typeof(ISimpleTestInterface), "corbaloc:iiop:1.2@localhost:8087/testSingletonCall");
            m_contextBound = 
                (ISimpleTestInterface)RemotingServices.Connect(typeof(ISimpleTestInterface), "corbaloc:iiop:1.2@localhost:8087/testContextBound");
            m_testBoxedService = (TestBoxedValuetypeService)RemotingServices.Connect(typeof(TestBoxedValuetypeService), "corbaloc:iiop:1.2@localhost:8087/testBoxedService");
        }
示例#24
0
        public void SetupEnvironment() {
            // register the channel
            m_channel = new IiopClientChannel();
            ChannelServices.RegisterChannel(m_channel, false);

            // access COS nameing service
            CorbaInit init = CorbaInit.GetInit();
            NamingContext nameService = init.GetNameService("localhost", 1050);
            NameComponent[] name = new NameComponent[] { new NameComponent("testPlugin", "") };
            // get the reference to the test-service
            m_testService = (TestService)nameService.resolve(name);
            
            try {
               CustomMapperRegistry reg = CustomMapperRegistry.GetSingleton();
               reg.AddMappingsFromFile(new FileInfo("customMapping.xml"));
               reg.AddMappingsFromFile(new FileInfo("customMappingTest.xml"));
            } catch (Exception e) {
                Console.WriteLine("custom mapper not loadable: " + e);
                throw e;
            }
        }
示例#25
0
        static void Main(string[] args)
        {
            CorbaInit orb = CorbaInit.GetInit();
            IiopClientChannel clientChannel = new IiopClientChannel();
            //ChannelServices.RegisterChannel(clientChannel, false);

            IiopChannel iiop = new IiopChannel(8807);
            ChannelServices.RegisterChannel(iiop, false);

            NamingContext nc = InitialRefLineParser.getNamingServiceForArgs(args);

            if (nc == null)
                Console.WriteLine("Cannot connet to Naming Service");

            Console.WriteLine(Thread.CurrentThread.ManagedThreadId);

            DFServer dfs = new DFServer(Directory.GetCurrentDirectory() );
            DFSAccess dfa = new DFSAccess(dfs, "DFSAccess", nc);
            DFSManager dfm = new DFSManager(dfs, "DFSManager", nc);
            dfs.getServerWaitHandle().WaitOne();
        }
示例#26
0
        public static void Main(string[] args) {
            try {
                string nameServiceHost = "localhost";
                int nameServicePort = 1050;
                parseArgs(ref nameServiceHost, ref nameServicePort, args);

                // register the channel
                IiopClientChannel channel = new IiopClientChannel();
                ChannelServices.RegisterChannel(channel, false);

                // access COS naming service
                CorbaInit init = CorbaInit.GetInit();
                NamingContext nameService = init.GetNameService(nameServiceHost, nameServicePort);
                NameComponent[] name = new NameComponent[] { new NameComponent("service", "") };
                // get the reference to the adder
                Service service = (Service)nameService.resolve(name);
                // call fail
                service.fail();
	    } catch (CustomEx je) {
                Console.WriteLine("Java-side exception: {0}\nReason: {1}", je.value.message, je.value.reason);
            } catch (Exception e) {
                Console.WriteLine("exception: " + e);
            }
        }
示例#27
0
        public static void Main(string[] args) {
            try {                
                string nameserviceLoc = "corbaloc::localhost:3528/JBoss/Naming/root";
                if (args.Length > 0) {
                	nameserviceLoc = args[0];
                }                
            
                IiopClientChannel channel = new IiopClientChannel();
                ChannelServices.RegisterChannel(channel, false);

                NamingContext nameService = (NamingContext)RemotingServices.Connect(typeof(NamingContext), nameserviceLoc);

                NameComponent[] name = new NameComponent[] { new NameComponent("demo", ""),
                                                             new NameComponent("commandTargetHome", "") };
                // get the command target home interface
                CommandTargetHome home = (CommandTargetHome) nameService.resolve(name);
                CommandTarget commandTarget = home.create();

                Application.Run(new Commandform(commandTarget));

            } catch (Exception e) {
                Console.WriteLine("exception: " + e);
            }
        }
 public void TearDown()
 {
     if (m_clientChannel != null)
     {
         ChannelServices.UnregisterChannel(m_clientChannel);
     }
     m_clientChannel = null;
 }
        public void SetUp()
        {
            m_orb = OrbServices.GetSingleton();

            m_profile =
                new InternetIiopProfile(new GiopVersion(1, 2),
                                        "localhost",
                                        1001,
                                        new byte[] { 1, 0, 0, 0 });

            m_clientChannel = new IiopClientChannel();
            ChannelServices.RegisterChannel(m_clientChannel, false);
        }
示例#30
0
        static void Main(string[] args)
        {
            CorbaInit orb = CorbaInit.GetInit();
            IiopClientChannel clientChannel = new IiopClientChannel();
            ChannelServices.RegisterChannel(clientChannel,false);

            DFS.DFSmanager dfsmanag = null;

            while (true)
            {
                Console.WriteLine("Select connection method:");
                Console.WriteLine("1. Direct - enter object corbaloc name");
                Console.WriteLine("2. Direct - enter object IOR");
                Console.WriteLine("3. Using Nameservice - enter nameservice host and port");
                try{
                    string response = Console.ReadLine();
                    int means = Int32.Parse(response);

                    switch (means)
                    {
                        case 1:
                            Console.WriteLine("Enter corbaloc url:");
                            string retprom = Console.ReadLine();
                            retprom = "corbaloc:iiop:localhost:8807/DFSManager";
                            dfsmanag = RemotingServices.Connect(typeof(DFS.DFSmanager), retprom) as DFS.DFSmanager;break;
                        case 2:
                            Console.WriteLine("Enter ior:");
                            string retior = Console.ReadLine();
                            dfsmanag = RemotingServices.Connect(typeof(DFS.DFSmanager), retior) as DFS.DFSmanager;break;
                        case 3:
                            Console.WriteLine("Enter nameservice host:");
                            string namhost = Console.ReadLine();
                            Console.WriteLine("Enter nameservice port:");
                            int namport = Int32.Parse(Console.ReadLine());
                            Console.WriteLine("Enter object name:");
                            string objname = Console.ReadLine();
                            NamingContext nameService = orb.GetNameService(namhost, namport);
                            NameComponent[] name = new NameComponent[] { new NameComponent(objname) };
                            dfsmanag = (DFS.DFSmanager)nameService.resolve(name);break;
                        default: Console.WriteLine("BadChoice");break;
                    }

                } catch (Exception e)
                {
                    Console.WriteLine("Couldnt connect");
                    Console.WriteLine( e.ToString() );
                }
                if ( dfsmanag != null ) break;
            }

            bool done = false;
            do
            {
                Console.WriteLine("Issue Command:");
                Console.WriteLine("1. Add Node");
                Console.WriteLine("2. Remove Node");
                Console.WriteLine("3. List Nodes");
                Console.WriteLine("4. Shutdown server");
                Console.WriteLine("5. Exit");
                try
                {
                    string response = Console.ReadLine();
                    int means = Int32.Parse(response);

                    switch (means)
                    {
                        case 1:
                            Console.WriteLine("Enter Node Name:");
                            string nname = Console.ReadLine();
                            dfsmanag.addNode(nname); break;
                        case 2:
                            Console.WriteLine("Enter Node Name:");
                            string fnamer = Console.ReadLine();
                            dfsmanag.removeNode(fnamer);break;
                        case 3:
                            foreach (var item in dfsmanag.listNodes())
                            {
                                Console.WriteLine(item);
                            }break;
                        case 4:
                            Console.WriteLine("Shutting down server...");
                            dfsmanag.shutdownDFS();
                            break;
                        case 5:
                            done = true;break;
                        default: Console.WriteLine("BadChoice"); break;
                    }

                }
                catch (Exception e)
                {
                    Console.WriteLine("Couldnt connect");
                    Console.WriteLine(e.ToString());
                }

            } while (!done);
        }