コード例 #1
0
ファイル: HostingSeed.cs プロジェクト: ziqew/robocode
        public static void Construct()
        {
            try
            {
                ModuleN.InitN();

                JNIEnv          env        = JNIEnv.ThreadEnv;
                JniGlobalHandle hmHandle   = env.NewGlobalRef((JniHandle)domain.GetData("hostManager"));
                JniGlobalHandle peerHandle = env.NewGlobalRef((JniHandle)domain.GetData("peer"));
                JniGlobalHandle itemHandle = env.NewGlobalRef((JniHandle)domain.GetData("item"));
                hostManager   = Bridge.CreateProxy <IHostManager>(hmHandle);
                robotPeer     = Bridge.CreateProxy <IRobotPeer>(peerHandle);
                specification = Bridge.CreateProxy <IRobotItem>(itemHandle);

                statics = ((RobotStatics)domain.GetData("statics"));
                CreateProxy();

                Assembly assembly = Assembly.LoadFrom(robotAssemblyShadowFileName);
                Reflection.CheckAssembly(assembly);
                string robotFullName = specification.getFullClassName();
                robotType = assembly.GetType(robotFullName, false);
                robotProxy.setRobotType(robotType);
            }
            catch (Exception ex)
            {
                LoggerN.logError(ex);
                throw;
            }
        }
コード例 #2
0
ファイル: HostingShell.cs プロジェクト: hgzapata/robocode
        public HostingShell(IRobotItem itemSpecification,
                            IHostManager hostManager, IRobotPeer peer,
                            IRobotStatics jstatics, string dllFileName)
        {
            robotPeer = peer;

            Init(true);
            Open(dllFileName);
            JniGlobalHandle hmHandle = ((IJvmProxy) hostManager).JvmHandle;
            JniGlobalHandle peerhandle = ((IJvmProxy)peer).JvmHandle;
            JniGlobalHandle itemHandle = ((IJvmProxy)itemSpecification).JvmHandle;

            domain.SetData("hostManager", hmHandle.DangerousGetHandle());
            domain.SetData("peer", peerhandle.DangerousGetHandle());
            domain.SetData("item", itemHandle.DangerousGetHandle());

            var statics = serializer.ConvertJ2C<RobotStatics>(RbSerializerN.RobotStatics_TYPE, (Object) jstatics);
            domain.SetData("statics", statics);
            domain.SetData("robotName", statics.getName());
            try
            {
                domain.DoCallBack(HostingSeed.Construct);
            }
            catch (Exception)
            {
                robotPeer.punishBadBehavior(BadBehavior.SECURITY_VIOLATION);
            }

            hmHandle.HoldThisHandle();
            peerhandle.HoldThisHandle();
            itemHandle.HoldThisHandle();
        }
コード例 #3
0
        public HostingShell(IRobotItem itemSpecification,
                            IHostManager hostManager, IRobotPeer peer,
                            IRobotStatics jstatics, string dllFileName)
        {
            robotPeer = peer;

            Init(true);
            Open(dllFileName);
            JniGlobalHandle hmHandle   = ((IJvmProxy)hostManager).JvmHandle;
            JniGlobalHandle peerhandle = ((IJvmProxy)peer).JvmHandle;
            JniGlobalHandle itemHandle = ((IJvmProxy)itemSpecification).JvmHandle;

            domain.SetData("hostManager", hmHandle.DangerousGetHandle());
            domain.SetData("peer", peerhandle.DangerousGetHandle());
            domain.SetData("item", itemHandle.DangerousGetHandle());

            var statics = serializer.ConvertJ2C <RobotStatics>(RbSerializerN.RobotStatics_TYPE, (Object)jstatics);

            domain.SetData("statics", statics);
            domain.SetData("robotName", statics.getName());
            try
            {
                domain.DoCallBack(HostingSeed.Construct);
            }
            catch (Exception)
            {
                robotPeer.punishBadBehavior(BadBehavior.SECURITY_VIOLATION);
            }

            hmHandle.HoldThisHandle();
            peerhandle.HoldThisHandle();
            itemHandle.HoldThisHandle();
        }
コード例 #4
0
        public bool Start()
        {
            hostManager = configuration.AutoDiscovery?.On == true ?
                          new DynamicHostManager(configuration, new NetworkScanner(TaskPoolScheduler.Default), scheduler) :
                          (IHostManager) new StaticHostManager(configuration.Known);
            if (configuration.Archive.HasValue)
            {
                var archivingObservable = Observable.Empty <bool>()
                                          .Delay(TimeSpan.FromDays(1), scheduler)
                                          .Concat(Observable.FromAsync(Archiving, scheduler))
                                          .Repeat()
                                          .SubscribeOn(scheduler)
                                          .Subscribe();
                connections.Add(archivingObservable);
            }

            if (configuration.Server != null)
            {
                log.Info("Setting FTP server");
                server = new ServerManager(configuration.Server);
                server.Start();
            }

            var observableMonitor = Observable.Empty <bool>()
                                    .Delay(TimeSpan.FromSeconds(configuration.Scan), scheduler)
                                    .Concat(Observable.FromAsync(Download, scheduler))
                                    .Repeat()
                                    .SubscribeOn(scheduler)
                                    .Subscribe();

            connections.Add(observableMonitor);
            return(true);
        }
コード例 #5
0
 public VirtualMachineController(IUnitManager _unitManager, IInventoryManager _InventoryManager, ILocationManager _locationManager, IHostManager _hostManager)
 {
     this._InventoryManager = _InventoryManager;
     this._unitManager      = _unitManager;
     this._locationManager  = _locationManager;
     this._hostManager      = _hostManager;
 }
コード例 #6
0
ファイル: HostingSeed.cs プロジェクト: Chainie/robocode
        public static void Construct()
        {
            try
            {
                ModuleN.InitN();

                JNIEnv env = JNIEnv.ThreadEnv;
                JniGlobalHandle hmHandle = env.NewGlobalRef((JniHandle)domain.GetData("hostManager"));
                JniGlobalHandle peerHandle = env.NewGlobalRef((JniHandle)domain.GetData("peer"));
                JniGlobalHandle itemHandle = env.NewGlobalRef((JniHandle)domain.GetData("item"));
                hostManager = Bridge.CreateProxy<IHostManager>(hmHandle);
                robotPeer = Bridge.CreateProxy<IRobotPeer>(peerHandle);
                specification = Bridge.CreateProxy<IRobotItem>(itemHandle);

                statics = ((RobotStatics)domain.GetData("statics"));
                CreateProxy();

                Assembly assembly = Assembly.LoadFrom(robotAssemblyShadowFileName);
                Reflection.CheckAssembly(assembly);
                string robotFullName = specification.getFullClassName();
                robotType = assembly.GetType(robotFullName, false);
                robotProxy.setRobotType(robotType);
            }
            catch (Exception ex)
            {
                LoggerN.logError(ex);
                throw;
            }
        }
コード例 #7
0
 public IHostingRobotProxy createRobotProxy(IHostManager hostManager, Object robotSpecification, IRobotStatics statics, IRobotPeer peer)
 {
     Object s = HiddenAccess.getFileSpecification(robotSpecification);
     var itemSpecification = Bridge.Cast<IRobotItem>(s);
     string file = DllRootHelper.GetDllFileName(itemSpecification);
     HostingShell hostingShell = new HostingShell(itemSpecification, hostManager, peer, statics, file);
     return hostingShell;
 }
コード例 #8
0
ファイル: DotnetHost.cs プロジェクト: jaros/robocode
 public IHostingRobotProxy createRobotProxy(IHostManager hostManager, Object robotSpecification, IRobotStatics statics, IRobotPeer peer)
 {
     Object s = HiddenAccess.getFileSpecification(robotSpecification);
     var itemSpecification = Bridge.Cast<IRobotRepositoryItem>(s);
     string file = DllRootHelper.GetDllFileName(itemSpecification);
     HostingShell hostingShell = new HostingShell(itemSpecification, hostManager, peer, statics, file);
     return hostingShell;
 }
コード例 #9
0
        public void GetInstanceTest()
        {
            IHostManager manager = HostManagerFactory.GetInstance();

            Assert.IsNotNull(manager);
            Assert.IsTrue(manager is HostManager);

            manager = HostManagerFactory.GetInstance(new HostSwitchConfig());
            Assert.IsNotNull(manager);
            Assert.IsTrue(manager is HostManager);
        }
コード例 #10
0
        protected HostingRobotProxy(IRobotRepositoryItem robotSpecification, IHostManager hostManager, IRobotPeer peer,
                                    RobotStatics statics)
        {
            this.peer = peer;
            this.statics = statics;
            this.hostManager = hostManager;
            this.robotSpecification = robotSpecification;
            outputSb = new StringBuilder(5000);
            output = TextWriter.Synchronized(new StringWriter(outputSb));
            LoggerN.robotOut = output;

            robotFileSystemManager = new RobotFileSystemManager(this, (int) hostManager.getRobotFilesystemQuota(),
                                                                robotSpecification.getWritableDirectory(),
                                                                robotSpecification.getReadableDirectory());
        }
コード例 #11
0
        protected HostingRobotProxy(IRobotItem robotSpecification, IHostManager hostManager, IRobotPeer peer,
                                    RobotStatics statics)
        {
            this.peer               = peer;
            this.statics            = statics;
            this.hostManager        = hostManager;
            this.robotSpecification = robotSpecification;

            outputSb         = new StringBuilder(5000);
            output           = TextWriter.Synchronized(new StringWriter(outputSb));
            LoggerN.robotOut = output;

            robotFileSystemManager = new RobotFileSystemManager(this, (int)hostManager.getRobotFilesystemQuota(),
                                                                robotSpecification.getWritableDirectory(),
                                                                robotSpecification.getReadableDirectory());
        }
コード例 #12
0
        public BasicRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, RobotStatics statics)
            : base(specification, hostManager, peer, statics)
        {
            eventManager = new EventManager(this);

            graphicsProxy = new GraphicsProxy();

            // dummy
            execResults = new ExecResults(null, null, null, null, null, false, false, false);

            setSetCallCount(0);
            setGetCallCount(0);

            var sharedBuffer = new byte[10*1024*100];
            execJavaBuffer = new DirectByteBuffer(sharedBuffer);
            execNetBuffer = ByteBuffer.wrap(sharedBuffer);
            rbSerializerN = new RbSerializerN();
            this.peer.setupBuffer(execJavaBuffer);
        }
コード例 #13
0
ファイル: BasicRobotProxy.cs プロジェクト: ziqew/robocode
        public BasicRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, RobotStatics statics)
            : base(specification, hostManager, peer, statics)
        {
            eventManager = new EventManager(this);

            graphicsProxy = new GraphicsProxy();

            // dummy
            execResults = new ExecResults(null, null, null, null, null, false, false, false);

            setSetCallCount(0);
            setGetCallCount(0);

            var sharedBuffer = new byte[10 * 1024 * 100];

            execJavaBuffer = new DirectByteBuffer(sharedBuffer);
            execNetBuffer  = ByteBuffer.wrap(sharedBuffer);
            rbSerializerN  = new RbSerializerN();
            this.peer.setupBuffer(execJavaBuffer);
        }
コード例 #14
0
 public TeamRobotProxy(IRobotRepositoryItem specification, IHostManager hostManager, IRobotPeer peer,
                       RobotStatics statics)
     : base(specification, hostManager, peer, statics)
 {
 }
コード例 #15
0
 public JuniorRobotProxy(IRobotRepositoryItem specification, IHostManager hostManager, IRobotPeer peer,
                         RobotStatics statics)
     : base(specification, hostManager, peer, statics)
 {
 }
コード例 #16
0
ファイル: SourceFactory.cs プロジェクト: zanderphh/YiScanner
 public IEnumerable <IDownloader> GetSources(IHostManager manager)
 {
     log.Info("Downloading...");
     return(fixedDownloaders.Union(manager.GetHosts().Select(item => ConstructDownloader(item, destination))));
 }
コード例 #17
0
ファイル: HostsController.cs プロジェクト: jangocheng/Sticky
 public HostsController(IHostManager hostManager, UserManager <User> userManager)
 {
     _userManager = userManager;
     _hostManager = hostManager;
 }
コード例 #18
0
 public CredentialController(ICredManager _cred, IInventoryManager InventoryManager, IHostManager hostManager)
 {
     this._cred            = _cred;
     this.InventoryManager = InventoryManager;
     this.hostManager      = hostManager;
 }
コード例 #19
0
 public JuniorRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer,
                         RobotStatics statics)
     : base(specification, hostManager, peer, statics)
 {
 }
コード例 #20
0
 public RuntimeHostingWorker(IApplicationService service, IHostManager <Application> manager, ILogger <RuntimeHostingWorker> logger)
 {
     this.logger  = logger ?? throw new ArgumentNullException(nameof(logger));
     this.service = service ?? throw new ArgumentNullException(nameof(service));
     this.manager = manager ?? throw new ArgumentNullException(nameof(manager));
 }
コード例 #21
0
 public StandardRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer,
                           RobotStatics statics)
     : base(specification, hostManager, peer, statics)
 {
 }
コード例 #22
0
 public HostController(IHostManager _host, IInventoryManager _InventoryManager)
 {
     this._host             = _host;
     this._InventoryManager = _InventoryManager;
 }