示例#1
0
        public void PostStart(StartContext context)
        {
            var app    = context.AppHost.GetRequired <IAppBuilder>();
            var config = context.AppHost.GetRequired <HttpConfiguration>();

            app.UseWebApi(config);
        }
示例#2
0
        /// <summary>
        /// Configures the OWIN pipeline.
        /// </summary>
        /// <param name="startup">Startup function used to configure the OWIN pipeline.</param>
        /// <param name="options">Settings to control the startup behavior of an OWIN application</param>
        protected void Configure(Action <IAppBuilder> startup, StartOptions options)
        {
            // Compare with WebApp.StartImplementation
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            options = options ?? new StartOptions();
            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var testServerFactory     = new TestServerFactory();
            IServiceProvider services = ServicesFactory.Create();
            var engine  = services.GetService <IHostingEngine>();
            var context = new StartContext(options);

            context.ServerFactory = new ServerFactoryAdapter(testServerFactory);
            context.Startup       = startup;
            _started = engine.Start(context);
            _next    = testServerFactory.Invoke;
        }
示例#3
0
        public void Start(StartContext context)
        {
            // Ensure that the X-AspNetMvc-Version HTTP header is not
            MvcHandler.DisableMvcResponseHeader = true;

            ConfigureViewEngines(ViewEngines.Engines);
            ConfigureAntiForgeryTokens();

            if (RegisterAllAreasEnabled)
            {
                AreaRegistration.RegisterAllAreas();
            }
            if (RegisterRoutesEnabled)
            {
                RegisterRoutes(RouteTable.Routes);
            }
            if (RegisterBundlesEnabled)
            {
                RegisterBundles(BundleTable.Bundles);
            }
            if (RegisterGlobalFiltersEnabled)
            {
                RegisterGlobalFilters(System.Web.Mvc.GlobalFilters.Filters);
            }
        }
示例#4
0
        private void Configure(AzureServiceBusOwinServiceConfiguration config, Action <IAppBuilder> startup)
        {
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            var options = new StartOptions();

            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var serverFactory = new AzureServiceBusOwinServerFactory(config);
            var services      = ServicesFactory.Create();
            var engine        = services.GetService <IHostingEngine>();
            var context       = new StartContext(options)
            {
                ServerFactory = new ServerFactoryAdapter(serverFactory),
                Startup       = startup
            };

            _started = engine.Start(context);
        }
示例#5
0
        private static IDisposable StartImplementation(IServiceProvider services, StartOptions options, Action <IAppBuilder> startup)
        {
            if (services == null)
            {
                throw new ArgumentNullException("services");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var engine = services.GetService <IHostingEngine>();

            if (engine == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                                                          Resources.Exception_FailedToResolveService, "IHostingEngine"));
            }
            var context = new StartContext(options);

            context.Startup = startup;
            return(engine.Start(context));
        }
示例#6
0
        private void Configure(Action <IAppBuilder> startup, StartOptions options = null)
        {
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            options = options ?? new StartOptions();
            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var testServerFactory     = new OwinEmbeddedServerFactory();
            IServiceProvider services = ServicesFactory.Create(
                serviceProvider => serviceProvider.AddInstance <ITraceOutputFactory>(new NullTraceOutputFactory())
                );
            var engine  = services.GetService <IHostingEngine>();
            var context = new StartContext(options)
            {
                ServerFactory = new ServerFactoryAdapter(testServerFactory),
                Startup       = startup
            };

            _started = engine.Start(context);
            _next    = testServerFactory.Invoke;
        }
示例#7
0
        private static IDisposable Start(StartContext context, IListen listener)
        {
            IServiceProvider services = ServicesFactory.Create();
            var engine = services.GetService <IHostingEngine>();

            context.ServerFactory = new ServerFactoryAdapter(new CustomListenerHostFactory(listener));
            return(engine.Start(context));
        }
示例#8
0
        private static IDisposable StartImplementation(IServiceProvider services, StartOptions options, Action <IAppBuilder> startup)
        {
            var engine  = services.GetService <IHostingEngine>();
            var context = new StartContext(options);

            context.Startup = startup;
            return(engine.Start(context));
        }
示例#9
0
        public void Start(StartContext context)
        {
            var container = context.AppHost.GetRequired <ILifetimeScope>();

            var app = context.AppHost.GetRequired <IAppBuilder>();

            app.UseAutofacMiddleware(container);
            app.UseAutofacMvc();
        }
示例#10
0
        public static IDisposable Start <TStartup>(IListen listener)
        {
            var options = new StartOptions();

            options.AppStartup = typeof(TStartup).AssemblyQualifiedName;
            var context = new StartContext(options);

            return(Start(context, listener));
        }
示例#11
0
        public void Start(StartContext context)
        {
            var ourStartContext = new Abstractions.Boot.StartContext
            {
                ServiceProvider = _serviceProvider
            };

            _reportAnalyzerModuleStarter.Start(ourStartContext);
        }
示例#12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private ProcessApplicationDeploymentService getDeploymentService(org.jboss.msc.service.StartContext context, org.jboss.msc.service.ServiceName deploymentServiceName)
        private ProcessApplicationDeploymentService getDeploymentService(StartContext context, ServiceName deploymentServiceName)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.msc.service.ServiceContainer serviceContainer = context.getController().getServiceContainer();
            ServiceContainer serviceContainer = context.Controller.ServiceContainer;
            ServiceController <ProcessApplicationDeploymentService> deploymentService = (ServiceController <ProcessApplicationDeploymentService>)serviceContainer.getRequiredService(deploymentServiceName);

            return(deploymentService.Value);
        }
示例#13
0
        public static IDisposable Start(Action <IAppBuilder> startup, IListen listener)
        {
            var options = new StartOptions();

            options.AppStartup = startup.Method.ReflectedType.FullName;
            var context = new StartContext(options);

            context.Startup = startup;
            return(Start(context, listener));
        }
示例#14
0
        public void Start(StartContext context)
        {
            var config = context.AppHost.GetRequired <HttpConfiguration>();

            config.MapHttpAttributeRoutes();

            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy;

            ConfigureFormatters(config);
        }
示例#15
0
        // Lifecycle /////////////////////////////////////////////////

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void start(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException
        public virtual void start(StartContext context)
        {
            serviceContainer = context.Controller.ServiceContainer;
            childTarget      = context.ChildTarget;

            startTrackingServices();
            createJndiBindings();

            // set this implementation as Runtime Container
            org.camunda.bpm.container.RuntimeContainerDelegate_Fields.INSTANCE.set(this);
        }
示例#16
0
        public void Start(StartContext context)
        {
            var adapter = new DependencyInjectionAdapter(context.ServiceProvider);

            _appManager = _appManager = new ApplicationServiceManager(adapter)
            {
                Settings = new ApplicationServiceManagerSettingsWithDefaultOn(_configuration)
            };
            _appManager.ServiceFailed += OnServiceFailed;
            _appManager.Start();
        }
示例#17
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void startInternal(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException
        public virtual void startInternal(StartContext context)
        {
            // setting the TCCL to the Classloader of this module.
            // this exploits a hack in MyBatis allowing it to use the TCCL to load the
            // mapping files from the process engine module
            Tccl.runUnderClassloader(new OperationAnonymousInnerClass(this)
                                     , typeof(ProcessEngine).ClassLoader);

            // invoke super start behavior.
            base.start(context);
        }
示例#18
0
        /// <summary>
        ///     Invoked after ConfigureServices.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="applicationLifetime"></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              IApplicationLifetime applicationLifetime)
        {
            applicationLifetime.ApplicationStopping.Register(OnShutdown);
            ConfigureCoderr(app);
            UpgradeDatabaseSchema();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
                {
                    HotModuleReplacement = true
                });
            }

            app.UseStaticFiles();
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                if (!IsConfigured)
                {
                    routes.MapRoute(
                        "areas",
                        "{area:exists}/{controller=Setup}/{action=Index}/{id?}",
                        new { area = "Installation" }
                        );
                }

                routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
                routes.MapSpaFallbackRoute(
                    "spa-fallback",
                    new
                {
                    controller = "Home",
                    action     = "Index"
                });
            });

            if (!IsConfigured)
            {
                return;
            }

            _serviceProvider = app.ApplicationServices;
            var context = new StartContext
            {
                ServiceProvider = app.ApplicationServices
            };

            _moduleStarter.Start(context);
        }
示例#19
0
        public virtual IDisposable Start(StartOptions options)
        {
            StartContext context = new StartContext(options);

            IServiceProvider services = ServicesFactory.Create(context.Options.Settings);

            IHostingEngine engine = services.GetService <IHostingEngine>();

            IDisposable disposable = engine.Start(context);

            return(new Disposable(disposable.Dispose));
        }
        public void Start(StartContext context)
        {
            var adapter = new DependencyInjectionAdapter(context.ServiceProvider);

            _backgroundJobManager = new BackgroundJobManager(adapter);
            _backgroundJobManager.ExecuteSequentially = true;
            _backgroundJobManager.JobFailed          += OnBackgroundJobFailed;
            _backgroundJobManager.StartInterval       = TimeSpan.FromSeconds(Debugger.IsAttached ? 0 : 10);
            _backgroundJobManager.ExecuteInterval     = TimeSpan.FromSeconds(Debugger.IsAttached ? 0 : 30);
            _backgroundJobManager.ScopeClosing       += OnBackgroundJobScopeClosing;
            _backgroundJobManager.Start();
        }
示例#21
0
        public virtual void Start(StartOptions options)
        {
            var context = new StartContext(options);

            IServiceProvider services = ServicesFactory.Create(context.Options.Settings);

            var engine = services.GetService <IHostingEngine>();

            _runningApp = engine.Start(context);

            _lease = (ILease)RemotingServices.GetLifetimeService(this);
            _lease.Register(this);
        }
示例#22
0
        public static IDisposable Start <TStartup>(IListen listener)
        {
            var options = new StartOptions();

            options.AppStartup = typeof(TStartup).AssemblyQualifiedName;
            var context = new StartContext(options);

            context.ServerFactory = new ServerFactoryAdapter(new CustomListenerHostFactory(listener));
            IServiceProvider services = ServicesFactory.Create();
            var engine = services.GetService <IHostingEngine>();

            return(engine.Start(context));
        }
示例#23
0
        public void Open(Action <IAppBuilder> startup, StartOptions options)
        {
            var testAppLoaderProvider = new TestAppLoaderFactory(startup);
            var testServerFactory     = new TestServerFactory();

            IServiceProvider services = ServicesFactory.Create(container => container.AddInstance <IAppLoaderFactory>(testAppLoaderProvider));
            var engine  = services.GetService <IHostingEngine>();
            var context = new StartContext(options ?? new StartOptions());

            context.ServerFactory = new ServerFactoryAdapter(testServerFactory);
            _started = engine.Start(context);
            _invoke  = testServerFactory.Invoke;
        }
示例#24
0
        /// <summary>
        /// Configures the OWIN pipeline.
        /// </summary>
        /// <typeparam name="TStartup">Class containing a startup function used to configure the OWIN pipeline.</typeparam>
        /// <param name="options">Settings to control the startup behavior of an OWIN application.</param>
        protected void Configure <TStartup>(StartOptions options)
        {
            // Compare with WebApp.StartImplementation
            options            = options ?? new StartOptions();
            options.AppStartup = typeof(TStartup).AssemblyQualifiedName;

            var webSocketHttpServerFactory = new OwinHttpServerFactory();
            var services = ServicesFactory.Create();
            var engine   = services.GetService <IHostingEngine>();
            var context  = new StartContext(options);

            context.ServerFactory = new ServerFactoryAdapter(webSocketHttpServerFactory);
            _started = engine.Start(context);
        }
示例#25
0
        public static IDisposable Start(Action <IAppBuilder> startup, IListen listener)
        {
            var options = new StartOptions();

            options.AppStartup = startup.Method.ReflectedType.FullName;
            var context = new StartContext(options);

            context.Startup       = startup;
            context.ServerFactory = new ServerFactoryAdapter(new CustomListenerHostFactory(listener));
            IServiceProvider services = ServicesFactory.Create();
            var engine = services.GetService <IHostingEngine>();

            return(engine.Start(context));
        }
示例#26
0
        public void CreateShouldBeProvidedWithAdaptedAppIfNeeded()
        {
            var serverFactoryBeta = new ServerFactoryBeta();
            var startInfo         = new StartContext(new StartOptions());

            startInfo.ServerFactory = new ServerFactoryAdapter(serverFactoryBeta);
            startInfo.App           = new AppFunc(env => Task.FromResult(0));

            var engine = ServicesFactory.Create().GetService <IHostingEngine>();

            serverFactoryBeta.CreateCalled.ShouldBe(false);
            IDisposable server = engine.Start(startInfo);

            serverFactoryBeta.CreateCalled.ShouldBe(true);
            server.Dispose();
        }
示例#27
0
        public void MultipleUrlsSpecified()
        {
            var startOptions = new StartOptions();

            startOptions.Urls.Add("beta://localhost:3333");
            startOptions.Urls.Add("delta://foo/");
            startOptions.Urls.Add("gama://*:4444/");
            startOptions.Port = 1111; // Ignored because of Url(s)

            var serverFactory = new ServerFactoryAlpha();
            var startInfo     = new StartContext(startOptions);

            startInfo.ServerFactory = new ServerFactoryAdapter(serverFactory);
            startInfo.App           = new AppFunc(env => Task.FromResult(0));

            var engine = ServicesFactory.Create().GetService <IHostingEngine>();

            serverFactory.InitializeCalled.ShouldBe(false);
            serverFactory.CreateCalled.ShouldBe(false);
            IDisposable server = engine.Start(startInfo);

            serverFactory.InitializeProperties["host.Addresses"].ShouldBeTypeOf <IList <IDictionary <string, object> > >();

            var addresses = (IList <IDictionary <string, object> >)serverFactory.InitializeProperties["host.Addresses"];

            Assert.Equal(3, addresses.Count);

            var expectedAddresses = new[]
            {
                new[] { "beta", "localhost", "3333", string.Empty },
                new[] { "delta", "foo", string.Empty, "/" },
                new[] { "gama", "*", "4444", "/" },
            };

            for (int i = 0; i < addresses.Count; i++)
            {
                IDictionary <string, object> addressDictionary = addresses[i];
                string[] expectedValues = expectedAddresses[i];
                Assert.Equal(expectedValues.Length, addressDictionary.Count);
                Assert.Equal(expectedValues[0], (string)addressDictionary["scheme"]);
                Assert.Equal(expectedValues[1], (string)addressDictionary["host"]);
                Assert.Equal(expectedValues[2], (string)addressDictionary["port"]);
                Assert.Equal(expectedValues[3], (string)addressDictionary["path"]);
            }

            server.Dispose();
        }
示例#28
0
        /// <summary>
        /// Configures the OWIN pipeline.
        /// </summary>
        /// <typeparam name="TStartup">Class containing a startup function used to configure the OWIN pipeline.</typeparam>
        /// <param name="options">Settings to control the startup behavior of an OWIN application.</param>
        protected void Configure <TStartup>(StartOptions options)
        {
            // Compare with WebApp.StartImplementation
            options            = options ?? new StartOptions();
            options.AppStartup = typeof(TStartup).AssemblyQualifiedName;

            var testServerFactory     = new TestServerFactory();
            IServiceProvider services = ServicesFactory.Create();
            var engine  = services.GetService <IHostingEngine>();
            var context = new StartContext(options)
            {
                ServerFactory = new ServerFactoryAdapter(testServerFactory)
            };

            _started = engine.Start(context);
            _next    = testServerFactory.Invoke;
        }
示例#29
0
        public void InitializeAndCreateShouldBeCalledWithProperties()
        {
            var serverFactoryAlpha = new ServerFactoryAlpha();
            var startInfo          = new StartContext(new StartOptions());

            startInfo.ServerFactory = new ServerFactoryAdapter(serverFactoryAlpha);
            startInfo.App           = new AppFunc(env => Task.FromResult(0));

            var engine = ServicesFactory.Create().GetService <IHostingEngine>();

            serverFactoryAlpha.InitializeCalled.ShouldBe(false);
            serverFactoryAlpha.CreateCalled.ShouldBe(false);
            IDisposable server = engine.Start(startInfo);

            serverFactoryAlpha.InitializeCalled.ShouldBe(true);
            serverFactoryAlpha.CreateCalled.ShouldBe(true);
            serverFactoryAlpha.InitializeProperties.ShouldBeSameAs(serverFactoryAlpha.CreateProperties);
            server.Dispose();
        }
示例#30
0
        private void startServer(OwinSettings settings, string physicalPath, int port)
        {
            var parameters = new StartOptions {
                Port = port
            };

            parameters.Urls.Add("http://*:" + port); //for netsh http add urlacl


            if (physicalPath != null)
            {
                FubuMvcPackageFacility.PhysicalRootPath = physicalPath;
            }

            var context = new StartContext(parameters)
            {
                App = FubuOwinHost.ToAppFunc(_runtime, settings),
            };

            settings.EnvironmentData.ToDictionary().Each(pair => context.EnvironmentData.Add(pair));


            settings.EnvironmentData[OwinConstants.AppMode] = FubuMode.Mode().ToLower();
            context.EnvironmentData.AddRange(settings.EnvironmentData.ToDictionary());

            var engine = new HostingEngine(new AppBuilderFactory(), new TraceOutputFactory(),
                                           new AppLoader(new IAppLoaderFactory[0]),
                                           new ServerFactoryLoader(new ServerFactoryActivator(new ServiceProvider())));

            try
            {
                _server = engine.Start(context);
            }
            catch (TargetInvocationException e)
            {
                if (e.InnerException != null && e.InnerException.Message.Contains("Access is denied"))
                {
                    throw new KatanaRightsException(e.InnerException);
                }

                throw;
            }
        }