예제 #1
0
        public gov.cca.Services getServices(string selfInstanceName, string selfClassName, TypeMap selfProperties)
        {
            ComponentID cid = new WorkerComponentIDImpl(selfInstanceName);

            unitProperties.Add(cid, selfProperties);
            WorkerServicesImpl services = new WorkerServicesImpl(this, cid);

            //this.registerComponentID(cid, services);

            return(services);
        }
예제 #2
0
        public ComponentID[] getComponentIDs()
        {
            ComponentID[] cids = new WorkerComponentIDImpl[unitInstances.Count];
            int           i    = 0;

            foreach (KeyValuePair <string, IUnit> pair in unitInstances)
            {
                cids[i++] = pair.Value.CID;
            }
            //unitInstances.Keys.CopyTo(cids, 0);
            return(cids);
        }
예제 #3
0
        public ComponentID createInstance(string instanceName, string class_name, TypeMap properties)
        {
            Console.WriteLine("CREATE INSTANCE");
            Connector.openConnection();

            ComponentID cid = new WorkerComponentIDImpl(instanceName);

            try {
                Console.WriteLine("createInstanceBaseForAllKinds - 1 " + instanceName);
                unitProperties.Add(cid, properties);

                Console.WriteLine("createInstanceBaseForAllKinds - 2");
                string   id_unit          = properties.getString(Constants.UNIT_KEY, "");
                string   library_path     = properties.getString(Constants.COMPONENT_KEY, "");
                string   assembly_string  = properties.getString(Constants.ASSEMBLY_STRING_KEY, "");
                string[] portNames        = properties.getStringArray(Constants.PORT_NAMES_KEY, new string[0]);
                int      kind             = Constants.kindMapping[properties.getString(Constants.KIND_KEY, "")];
                string   unit_mapping_xml = properties.getString(Constants.NODES_KEY, "");
                Instantiator.UnitMappingType[] unit_mapping = LoaderApp.deserialize <Instantiator.UnitMappingType[]>(unit_mapping_xml);

                Console.WriteLine("createInstanceBaseForAllKinds - 3 ; assembly_string = " + assembly_string + "; class name = " + class_name);

                ObjectHandle    obj        = Activator.CreateInstance(assembly_string, class_name);
                hpe.basic.IUnit unit_slice = (hpe.basic.IUnit)obj.Unwrap();
                unit_slice.Id_unit   = id_unit;
                unit_slice.PortNames = portNames;
                unit_slice.Kind      = kind;
                unit_slice.ClassName = class_name;
                unit_slice.QualifiedComponentTypeName = library_path;

                unit_registry.Add(instanceName, unit_slice);

                Console.WriteLine("createInstanceBaseForAllKinds - 4");

                Services services = new WorkerServicesImpl(this, cid, unit_slice);
                unit_slice.setServices(services);

                Console.WriteLine("createInstanceBaseForAllKinds - 6");

                if (properties.hasKey(Constants.KEY_KEY))
                {
                    int[] facet_topology      = properties.getIntArray(Constants.FACET_TOPOLOGY, new int[0]);
                    int   this_facet_instance = properties.getInt(Constants.FACET_INSTANCE, 0);
                    int   this_facet          = properties.getInt(Constants.FACET, 0);
                    unit_slice.ThisFacetInstance = this_facet_instance;
                    unit_slice.ThisFacet         = facet_topology[this_facet_instance];

                    Console.WriteLine("createInstanceBaseForAllKinds - 7 - PASSOU DIRETO");

                    unit_slice.configure_facet_topology(facet_topology, unit_mapping);

                    if (kind == Constants.KIND_BINDING)
                    {
                        Console.WriteLine("createInstanceBaseForAllKinds - 8");

                        IBindingKind unit_slice_binding_root = (IBindingKind)unit_slice;
                        string[]     ip_address_facets       = properties.getStringArray(Constants.FACET_IP_ADDRESS, new string[0]);
                        int[]        port_facets             = properties.getIntArray(Constants.FACET_PORT, new int[0]);
                        Console.WriteLine("createInstanceBaseForAllKinds - 9" + ip_address_facets.Length + "," + port_facets.Length);
                        configure_facet_address(unit_slice_binding_root, ip_address_facets, port_facets);
                        Console.WriteLine("createInstanceBaseForAllKinds - 10");

                        Console.WriteLine("createInstanceBaseForAllKinds - 11 ");
                    }
                }
                else
                {
                    Console.WriteLine("createInstanceBaseForAllKinds - NO SPLIT");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("createInstanceBaseForAllKinds - EXCEPTION");
                Console.WriteLine("EXCEPTION MESSAGE -" + e.Message);
                Console.WriteLine("INNER EXCEPTION MESSAGE -" + e.InnerException.Message);
                throw e;
            }

            Connector.closeConnection();

            return(cid);
        }