def start_service(): orb = SVMCORBA_RECORD.orb boa = BOA.BOA_init() ctx = orb.resolve_initial_references("NameService") path = [ CosNaming.NameComponent('SVM', ''), CosNaming.NameComponent(SVM_MODULE, ''), CosNaming.NameComponent(SVMCORBA_RECORD.module_name, '') ] for i in range(len(path)): try: ctx.bind_new_context(path[:i + 1]) except CosNaming.NamingContext.AlreadyBound: pass interface_name = SVMCORBA_RECORD.module_name + '_' + str( SVMCORBA_RECORD.module_num) stubpath = os.path.join( os.path.join(SVMCORBA_RECORD.work_path, 'serverif'), interface_name) sys.path = [stubpath] + sys.path impl = [] impl.append('from %s import %s' % (SVM_MODULE, SVMCORBA_RECORD.module_name)) impl.append('from %s_skel import %s_skel' % (SVM_MODULE, SVMCORBA_RECORD.module_name)) impl.append('from Fnorb.cos.naming import CosNaming') impl.append('import SVMCORBA') classdef = 'class inf_%dImpl(%s_skel.inf_%d_skel):\n' % ( SVMCORBA_RECORD.module_num, SVMCORBA_RECORD.module_name, SVMCORBA_RECORD.module_num) for p in SVMCORBA_RECORD.ports: pp = SVMCORBA_RECORD.ports[p] if pp[PORT_IN]: classdef = classdef + '\ def %s(self, event, params):\n\ SVMCORBA.receive_external_event(%s, event, params)\n' % (p, p) classdef = classdef + '\ def svm_module_add_connection(self, pserver, pclient, components):\n\ SVMCORBA.svm_module_add_connection(pserver, pclient, components)\n' impl.append(classdef) impl.append('ifimpl=inf_%dImpl()' % SVMCORBA_RECORD.module_num) impl.append('ref=boa.create("inf_%d", inf_%dImpl._FNORB_ID)' % (SVMCORBA_RECORD.module_num, SVMCORBA_RECORD.module_num)) impl.append('ctx.rebind([CosNaming.NameComponent("SVM", ""), CosNaming.NameComponent("%s", ""), CosNaming.NameComponent("%s", ""), CosNaming.NameComponent("inf_%d", "")], ref)'\ % (SVM_MODULE, SVMCORBA_RECORD.module_name, SVMCORBA_RECORD.module_num)) impl.append('boa.obj_is_ready(ref, ifimpl)') impl.append('SVMCORBA.SVMCORBA_RECORD.impl=ifimpl') ii = code.InteractiveInterpreter(locals()) for i in impl: ii.runsource(i) del sys.path[0] ThreadUtil.StartThread(boa._fnorb_mainloop, ())
def main ( argv ): # init ORB and BOA try: argv.append( "--ORBthreading-model=Threaded" ) orb = CORBA.ORB_init( argv, CORBA.ORB_ID ) boa = BOA.BOA_init( sys.argv, BOA.BOA_ID ) except: print "..... can`t initialize ORB" sys.exit( 1 ) # resolve NameService try : nsior = open( "ns.ior", "r" ).read() except : print "..... ns.ior file for NameService missing" sys.exit( 1 ) try : ns = orb.string_to_object( nsior )._narrow( CosNaming.NamingContext ) except : print "..... no NameService IOR in ns.ior file or service not running" sys.exit( 1 ) # create naming contexts nspath = [CosNaming.NameComponent( 'DCI', '' )] try: for component in nspath : ns.bind_new_context( [component] ) except CosNaming.NamingContext.AlreadyBound: pass # create ScriptProcessorRegistry object root = Tkinter.Tk() obj = boa.create( 'ScriptProcessorRegistry', ScriptProcessorRegistry._FNORB_ID ) impl = ScriptProcessorRegistry( root, orb, boa ) boa.obj_is_ready( obj, impl ) open( "script.ref", "w" ).write( orb.object_to_string( obj ) ) # bind name in name service name = nspath + [CosNaming.NameComponent( 'ScriptProcessorRegistry', '' )] ns.rebind( name, obj ) # register ScriptProcessor for Python obj2 = boa.create( uuid.uuid(), ScriptProcessor._FNORB_ID ) impl2 = ScriptProcessor( orb, boa ) boa.obj_is_ready( obj2, impl2 ) impl.register_processor( "Python", obj2 ) # mainloop print "..... ScriptProcessorRegistry running with ior:\n" print orb.object_to_string( obj ) #boa._fnorb_mainloop() thread.start_new_thread(boa._fnorb_mainloop,()) root.mainloop()
def main(argv): # init ORB and BOA try: argv.append("--ORBthreading-model=Threaded") orb = CORBA.ORB_init(argv, CORBA.ORB_ID) boa = BOA.BOA_init(sys.argv, BOA.BOA_ID) except: print "..... can`t initialize ORB" sys.exit(1) # get NameService try: nsior = open("ns.ior", "r").read() except: print "..... ns.ior file for NameService missing" sys.exit(1) try: ns = orb.string_to_object(nsior)._narrow(CosNaming.NamingContext) except: print "..... no NameService IOR in ns.ior or service not running" sys.exit(1) # create naming contexts nspath = [CosNaming.NameComponent('DCI', '')] try: for component in nspath: ns.bind_new_context([component]) except CosNaming.NamingContext.AlreadyBound: pass # create object for RuleProcessor obj = boa.create('RuleProcessor', RuleProcessor._FNORB_ID) impl = RuleProcessor(orb, boa) boa.obj_is_ready(obj, impl) open("rule.ref", "w").write(orb.object_to_string(obj)) # bind name in name service name = nspath + [CosNaming.NameComponent('RuleProcessor', '')] ns.rebind(name, obj) # mainloop print "..... RuleProcessor running with ior:\n" print orb.object_to_string(obj) boa._fnorb_mainloop()
def main(argv): try: orb = CORBA.ORB_init(argv, CORBA.ORB_ID) except: print "Can`t initialize ORB" sys.exit(1) boa = BOA.BOA_init(sys.argv, BOA.BOA_ID) obj = boa.create('TestObject', TestObject_impl._FNORB_ID) root = Tkinter.Tk() impl = TestObject_impl(root, obj, orb) boa.obj_is_ready(obj, impl) import thread thread.start_new_thread(boa._fnorb_mainloop, ()) root.mainloop()
def main ( argv ): # get orb try: argv.append("--ORBthreading-model=Threaded") orb = CORBA.ORB_init(argv, CORBA.ORB_ID) except: print "Can`t initialize ORB" sys.exit(1) # get boa boa = BOA.BOA_init(sys.argv,BOA.BOA_ID) root = Tkinter.Tk() client = TestClient( orb, boa, root ) # mainloop import thread thread.start_new_thread( boa._fnorb_mainloop, () ) root.mainloop()