Package org.omg.CosNaming

Examples of org.omg.CosNaming.NamingContext


     * @return
     */
    private org.omg.CORBA.Object bindReference(String name) {
        try {
            org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
            NamingContext ncRef = NamingContextHelper.narrow(objRef);
            NameComponent nc = new NameComponent(name, "");
            NameComponent path[] = {nc};
            return ncRef.resolve(path);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
View Full Code Here


                e.printStackTrace();
                Assert.fail(e.getMessage());
            }

            Object nameService = orb.resolve_initial_references("NameService");
            NamingContext namingContext = NamingContextHelper.narrow(nameService);

            PrimitivesSetterServant singleSetter = new PrimitivesSetterServant();
            ArraysSetterServant arraysSetter = new ArraysSetterServant();
            TestObjectServant complexObject = new TestObjectServant();
            CalcServant calcObject = new CalcServant();
            ObjectManagerServant objectManager = new ObjectManagerServant();
            EnumManagerServant enumManager = new EnumManagerServant();
            ArraysUnionsServant arraysUnions = new ArraysUnionsServant();

            orb.connect(singleSetter);
            orb.connect(arraysSetter);

            NameComponent nc;
            NameComponent[] path;

            nc = new NameComponent("PrimitivesSetter", "");
            path = new NameComponent[] {nc};
            namingContext.rebind(path, singleSetter);

            nc = new NameComponent("ArraysSetter", "");
            path = new NameComponent[] {nc};
            namingContext.rebind(path, arraysSetter);

            nc = new NameComponent("TestObject", "");
            path = new NameComponent[] {nc};
            namingContext.rebind(path, complexObject);

            nc = new NameComponent("CalcObject", "");
            path = new NameComponent[] {nc};
            namingContext.rebind(path, calcObject);

            nc = new NameComponent("ObjectManager", "");
            path = new NameComponent[] {nc};
            namingContext.rebind(path, objectManager);

            nc = new NameComponent("EnumManager", "");
            path = new NameComponent[] {nc};
            namingContext.rebind(path, enumManager);

            nc = new NameComponent("ArraysUnions", "");
            path = new NameComponent[] {nc};
            namingContext.rebind(path, arraysUnions);

            NamingContextExt nce = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));

            refArraysSetter = nce.resolve(nce.to_name("ArraysSetter"));
            refPrimitivesSetter = nce.resolve(nce.to_name("PrimitivesSetter"));
View Full Code Here

    public void registerServant(String uri, Object servantObject) throws CorbaHostException {
        CorbanameURL details = CorbaHostUtils.getServiceDetails(uri);
        ORB orb = createORB(details.getHost(), details.getPort(), false);
        try {
            NamingContext namingCtx = getNamingContext(orb, details.getNameService());
            for (int i = 0; i < details.getNamePath().size() - 1; i++) {
                NameComponent nc = new NameComponent(details.getNamePath().get(i), "");
                NameComponent[] path = new NameComponent[] {nc};
                try {
                    namingCtx = NamingContextHelper.narrow(namingCtx.resolve(path));
                } catch (Exception e) {
                    namingCtx = namingCtx.bind_new_context(path);
                }
            }
            NameComponent finalName =
                new NameComponent(details.getNamePath().get(details.getNamePath().size() - 1), "");
            try {
                namingCtx.resolve(new NameComponent[] {finalName});
                // no exception means that some object is already registered
                // under this name, we need to crash here
                throw new CorbaHostException(CorbaHostException.BINDING_IN_USE);
            } catch (NotFound e) {
                namingCtx.bind(new NameComponent[] {finalName}, servantObject);
            }
        } catch (CorbaHostException e) {
            throw e;
        } catch (Exception e) {
            handleException(e);
View Full Code Here

    }

    public void registerServant(String uri, Object servantObject) throws CorbaHostException {
        CorbanameURL details = CorbaHostUtils.getServiceDetails(uri);
        try {
            NamingContext namingCtx = getNamingContext(details.getNameService());
            for (int i = 0; i < details.getNamePath().size() - 1; i++) {
                NameComponent nc = new NameComponent(details.getNamePath().get(i), "");
                NameComponent[] path = new NameComponent[] {nc};
                try {
                    namingCtx = NamingContextHelper.narrow(namingCtx.resolve(path));
                } catch (Exception e) {
                    namingCtx = namingCtx.bind_new_context(path);
                }
            }
            NameComponent finalName =
                new NameComponent(details.getNamePath().get(details.getNamePath().size() - 1), "");
            try {
                namingCtx.resolve(new NameComponent[] {finalName});
                // no exception means that some object is already registered
                // under this name, we need to crash here
                throw new CorbaHostException(CorbaHostException.BINDING_IN_USE);
            } catch (NotFound e) {
                namingCtx.bind(new NameComponent[] {finalName}, servantObject);
                registerURI(uri);
            }
        } catch (CorbaHostException e) {
            throw e;
        } catch (Exception e) {
View Full Code Here

    public void registerServant(String uri, Object servantObject) throws CorbaHostException {
        CorbanameURL details = CorbaHostUtils.getServiceDetails(uri);
        ORB orb = createORB(details.getHost(), details.getPort(), false);
        try {
            NamingContext namingCtx = getNamingContext(orb, details.getNameService());
            for (int i = 0; i < details.getNamePath().size() - 1; i++) {
                NameComponent nc = new NameComponent(details.getNamePath().get(i), "");
                NameComponent[] path = new NameComponent[] {nc};
                try {
                    namingCtx = NamingContextHelper.narrow(namingCtx.resolve(path));
                } catch (Exception e) {
                    namingCtx = namingCtx.bind_new_context(path);
                }
            }
            NameComponent finalName =
                new NameComponent(details.getNamePath().get(details.getNamePath().size() - 1), "");
            try {
                namingCtx.resolve(new NameComponent[] {finalName});
                // no exception means that some object is already registered
                // under this name, we need to crash here
                throw new CorbaHostException(CorbaHostException.BINDING_IN_USE);
            } catch (NotFound e) {
                namingCtx.bind(new NameComponent[] {finalName}, servantObject);
            }
        } catch (CorbaHostException e) {
            throw e;
        } catch (Exception e) {
            handleException(e);
View Full Code Here

     * Binds servant implementation to name
     */
    private void bindServant(DynaCorbaServant servant, String name) {
        try {
            Object nameService = orb.resolve_initial_references("NameService");
            NamingContext namingContext = NamingContextHelper.narrow(nameService);

            NameComponent nc = new NameComponent(name, "");
            NameComponent[] path = new NameComponent[] {nc};
            namingContext.rebind(path, servant);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

     * @return
     */
    private org.omg.CORBA.Object bindReference(String name) {
        try {
            org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
            NamingContext ncRef = NamingContextHelper.narrow(objRef);
            NameComponent nc = new NameComponent(name, "");
            NameComponent path[] = {nc};
            return ncRef.resolve(path);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
View Full Code Here

            } catch (Throwable e) {
                e.printStackTrace();
                Assert.fail(e.getMessage());
            }
            org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
            NamingContext ncRef = NamingContextHelper.narrow(objRef);
            NameComponent nc = new NameComponent(SERVICE_NAME, "");
            NameComponent path[] = {nc};
            ScenarioOne scenarioOne = new ScenarioOneServant();
            ncRef.rebind(path, scenarioOne);
            // obtain node
            node = NodeFactory.getInstance().createNode("ScenarioOne.composite", TestCorbaHost.class.getClassLoader()).start();
        } catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

    }

    public void testServiceUsingGeneratedClient(String serviceName) {
        try {
            org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
            NamingContext ncRef = NamingContextHelper.narrow(objRef);
            NameComponent nc = new NameComponent(serviceName, "");
            NameComponent path[] = {nc};
            ScenarioOne so = ScenarioOneHelper.narrow(ncRef.resolve(path));

            RichStruct richStruct = getRichStruct();
            RichStruct result = so.setRichStruct(richStruct);
            assertTrue(equalTo(result, richStruct));
View Full Code Here

            } catch (Throwable e) {
                e.printStackTrace();
                Assert.fail(e.getMessage());
            }
            org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
            NamingContext ncRef = NamingContextHelper.narrow(objRef);
            NameComponent nc = new NameComponent(SERVICE_NAME, "");
            NameComponent path[] = {nc};
            ScenarioSix scenarioSix = new ScenarioSixServant();
            ncRef.rebind(path, scenarioSix);
            // obtain node
            node = NodeFactory.getInstance().createNode("ScenarioSix.composite", TestCorbaHost.class.getClassLoader()).start();
        } catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

TOP

Related Classes of org.omg.CosNaming.NamingContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.