/** ** ** MinCor-C# -Demo ** CORBA Solution for .Net with C# Language mapping ** Version: 1.0 ** ** Copyright: ** Middsol GmbH, Hamburg ** Germany 2004 ** www.Middsol.com ** info@Middsol.de ** */ using System; using System.Drawing; using System.Collections; using System.Windows.Forms; using System.Data; namespace FactorySrv { public class ServerImpl { private IFrm m_oFrm; private Middsol.CORBA.ORB m_oOrb = null; string[] m_strORBInit = { "-ORBEndpoint iiop://localhost:8545/portspan=100", "-ORBDebug Out=.\\FactorySrv.log"}; public ServerImpl( FrmFactorySrv a_oFrm) { m_oFrm = a_oFrm; m_oOrb = Middsol.CORBA._ORB.init( m_strORBInit, null); Middsol.PortableServer.POA oRootPOA = Middsol.PortableServer.POAHelper.narrow( m_oOrb.resolve_initial_references( "RootPOA" )); oRootPOA.the_POAManager.activate(); Middsol.CORBA.Object oObjRef = oRootPOA.servant_to_reference( new GreetingFactory( this)); Middsol.CORBA._ORB.wrIORtoFile( ".\\FactorySrv.ior", oObjRef); theFrm.writeLog( "Server runing"); } public void destroy() { if( m_oOrb != null) { m_oOrb.destroy(); m_oOrb = null; } } public IFrm theFrm { get{ return m_oFrm; } } } public class GreetingFactory: Factory.IGreetingFactoryPOA { private GreetingsBusiness m_GreetingsBusiness = null; private GreetingsFriends m_GreetingsFriends = null; private Middsol.CORBA.Object m_oObjRefGreetingsBusiness = null; private Middsol.CORBA.Object m_oObjRefGreetingsFriends = null; private ServerImpl m_oServer; public GreetingFactory( ServerImpl a_oServer) { m_oServer = a_oServer; } public override Factory.IGreetings createIGreetings( string _strNameOfInterface ) { Factory.IGreetings oIGreetings = null; switch( _strNameOfInterface) { case "Business": if( m_GreetingsBusiness == null) { m_GreetingsBusiness = new GreetingsBusiness( m_oServer); } oIGreetings = m_GreetingsBusiness._this(); break; case "Friends": if( m_GreetingsFriends == null) { m_GreetingsFriends = new GreetingsFriends( m_oServer); } oIGreetings = m_GreetingsFriends._this(); break; default: throw new Factory.IGreetingFactoryPackage.GreetingExcp("Request for an unknown Interface", 1001); } return oIGreetings; } } public class GreetingsFriends: Factory.IGreetingsFriendsPOA { private ServerImpl m_oServer; public GreetingsFriends( ServerImpl a_oServer) { m_oServer = a_oServer; } public override string hello( string _strName ) { m_oServer.theFrm.writeLog( "Function GreetingsFriends.hello. Param.:" + _strName); string strGreeting = "Greetings to my Friend " +_strName; return strGreeting; } } public class GreetingsBusiness: Factory.IGreetingsBusinessPOA { private ServerImpl m_oServer; public GreetingsBusiness( ServerImpl a_oServer) { m_oServer = a_oServer; } public override string hello( string _strName ) { m_oServer.theFrm.writeLog( "Function GreetingsBusiness.hello. Param.:" + _strName); string strGreeting = "Greetings to my business partner " + _strName; return strGreeting; } } }