當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanConfig.setHost方法代碼示例

本文整理匯總了Java中io.swagger.jaxrs.config.BeanConfig.setHost方法的典型用法代碼示例。如果您正苦於以下問題:Java BeanConfig.setHost方法的具體用法?Java BeanConfig.setHost怎麽用?Java BeanConfig.setHost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.swagger.jaxrs.config.BeanConfig的用法示例。


在下文中一共展示了BeanConfig.setHost方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: activate

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
@Override
public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {

    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(SwaggerArchive.SWAGGER_CONFIGURATION_PATH);

    if (in == null) {
        // No config available. Print a warning and return
        System.err.println("WARN: No swagger configuration found. Swagger not activated.");
        return;
    }
    SwaggerConfig config = new SwaggerConfig(in);

    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setHost((String) config.get(SwaggerConfig.Key.HOST));
    beanConfig.setLicense((String) config.get(SwaggerConfig.Key.LICENSE));
    beanConfig.setLicenseUrl((String) config.get(SwaggerConfig.Key.LICENSE_URL));
    beanConfig.setTermsOfServiceUrl((String) config.get(SwaggerConfig.Key.TERMS_OF_SERVICE_URL));
    beanConfig.setResourcePackage((String) config.get(SwaggerConfig.Key.PACKAGES));
    beanConfig.setVersion((String) config.get(SwaggerConfig.Key.VERSION));
    beanConfig.setBasePath((String) config.get(SwaggerConfig.Key.ROOT));
    beanConfig.setContact((String) config.get(SwaggerConfig.Key.CONTACT));
    beanConfig.setDescription((String) config.get(SwaggerConfig.Key.DESCRIPTION));
    beanConfig.setTitle((String) config.get(SwaggerConfig.Key.TITLE));
    beanConfig.setPrettyPrint((String) config.get(SwaggerConfig.Key.PRETTY_PRINT));
    beanConfig.setSchemes((String[]) config.get(SwaggerConfig.Key.SCHEMES));

    beanConfig.setScan(true);

}
 
開發者ID:wildfly-swarm-archive,項目名稱:ARCHIVE-wildfly-swarm,代碼行數:30,代碼來源:SwaggerActivator.java

示例2: swaggerConfig

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
@Bean
public BeanConfig swaggerConfig() {
	final BeanConfig beanConfig = new BeanConfig();
	beanConfig.setResourcePackage("com.github.sbugat.samplerest.resource");
	beanConfig.setVersion("1.0.0");
	beanConfig.setHost("localhost:8080");
	beanConfig.setBasePath(servletContext.getContextPath());
	beanConfig.setTitle("Swagger CXF, JAX-RS 2.0 sample");
	beanConfig.setDescription("This is a Swagger CXF, JAX-RS 2.0 sample API.");
	beanConfig.setContact("Sylvain Bugat");
	beanConfig.setLicense("Apache 2.0");
	beanConfig.setLicenseUrl("https://github.com/Sylvain-Bugat/swagger-cxf-rest-skeleton/blob/master/LICENSE");

	beanConfig.getSwagger().addSecurityDefinition("api_token", new ApiKeyAuthDefinition("api_token", In.HEADER));

	beanConfig.setScan(true);

	return beanConfig;
}
 
開發者ID:Sylvain-Bugat,項目名稱:swagger-cxf-rest-skeleton,代碼行數:20,代碼來源:ApplicationConfiguration.java

示例3: evaluateSwagger

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
private void evaluateSwagger()
        throws Exception {
    if (!runPerServiceMode(swagger)) {
        return;
    }

    // Add swagger providers
    _environment.jersey().register(io.swagger.jaxrs.listing.ApiListingResource.class);
    _environment.jersey().register(io.swagger.jaxrs.listing.SwaggerSerializers.class);

    // Configure and initialize swagger
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0");
    beanConfig.setTitle("EMO REST Resources");
    beanConfig.setSchemes(new String[] {"http"});
    beanConfig.setHost("localhost:8080");
    beanConfig.setBasePath("/");
    // add the packages that swagger should scan to pick up the resources
    beanConfig.setResourcePackage("com.bazaarvoice.emodb.web.resources");
    // this is a MUST and should be the last property - this creates a new SwaggerContextService and initialize the scanner.
    beanConfig.setScan(true);
}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:23,代碼來源:EmoService.java

示例4: getBeanConfig

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
private BeanConfig getBeanConfig() {
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setHost(getConfig("swagger.host"));
    beanConfig.setSchemes(getConfig("swagger.schemes").split(","));
    beanConfig.setTitle(getConfig("swagger.title"));
    beanConfig.setVersion(getConfig("swagger.version"));
    beanConfig.setContact(getConfig("swagger.contact"));
    beanConfig.setLicense(getConfig("swagger.license"));
    beanConfig.setBasePath(getConfig("swagger.base_path"));
    beanConfig.setLicenseUrl(getConfig("swagger.licenseUrl"));
    beanConfig.setDescription(getConfig("swagger.description"));
    beanConfig.setPrettyPrint(getConfig("swagger.pretty_print"));
    beanConfig.setTermsOfServiceUrl(getConfig("swagger.terms_of_service_url"));

    // Must be called last
    beanConfig.setResourcePackage(resourcePackages());
    beanConfig.setScan(true);

    return beanConfig;
}
 
開發者ID:labsai,項目名稱:EDDI,代碼行數:21,代碼來源:SwaggerServletContextListener.java

示例5: testReaderRead

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
@Test
public void testReaderRead() throws Exception {
    BeanConfig config = new BeanConfig();
    config.setHost("localhost:8080");
    config.setSchemes(new String[]{"http"});
    config.setBasePath("/api");
    RestSwaggerReader reader = new RestSwaggerReader();

    Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
    assertNotNull(swagger);

    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    String json = mapper.writeValueAsString(swagger);

    log.info(json);

    assertFalse(json.contains("\"/hello/bye\""));
    assertFalse(json.contains("\"summary\" : \"To update the greeting message\""));
    assertTrue(json.contains("\"/hello/bye/{name}\""));
    assertFalse(json.contains("\"/hello/hi/{name}\""));

    context.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:26,代碼來源:RestSwaggerReaderApiDocsOverrideTest.java

示例6: ApplicationJAXRS

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
public ApplicationJAXRS() {
    
    // Configurando o Swagger de forma programática
    BeanConfig beanConfig = new BeanConfig();
    // Básico
    //beanConfig.setTitle("Discovery Service");
    //beanConfig.setVersion("0.1");
    //beanConfig.setSchemes(new String[]{"http"});
    beanConfig.setHost("localhost:8080");
    beanConfig.setBasePath("/pswot/discovery/v0.1");
    beanConfig.setResourcePackage(DiscoveryService.class.getPackage().getName());
    // Licença
    //beanConfig.setLicense("Apache 2.0");
    //beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
    // Contato
    //beanConfig.setContact("mailto:[email protected]");
    //beanConfig.setDescription("This is the documentation of the "
    //        + "RESTful API to access Discovery PSWoT functionalities.");
    beanConfig.setScan(true);
    
}
 
開發者ID:nailtonvieira,項目名稱:cloudsemanticwot,代碼行數:22,代碼來源:ApplicationJAXRS.java

示例7: init

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    ConfigureAdaptor scouterConf = ConfigureManager.getConfigure();
    if (!scouterConf.isNetHttpApiSwaggerEnabled()) {
        return;
    }

    BeanConfig beanConfig = new BeanConfig();

    String serverIp = scouterConf.getNetHttpApiSwaggerHostIp();
    if (StringUtils.isNotBlank(serverIp)) {
        beanConfig.setHost(serverIp + ":" + String.valueOf(scouterConf.getNetHttpPort()));
    }

    beanConfig.setVersion(this.apiVersion);
    beanConfig.setSchemes(new String[]{"http", "https"});
    beanConfig.setDescription("<a href='https://github.com/scouter-project/scouter/blob/master/scouter.document/tech/Web-API-Guide.md' target='_blank'> [Scouter document page] Scouter Web API Guide</a>");
    beanConfig.setTitle("Scouter HTTP APIs");
    beanConfig.setBasePath("/scouter");
    beanConfig.setResourcePackage("scouterx.webapp");
    beanConfig.setFilterClass(this.filterClass);
    beanConfig.setScan(true);
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:26,代碼來源:Bootstrap.java

示例8: bildSwaggerConfig

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
private void bildSwaggerConfig() {
    BeanConfig beanConfig = new BeanConfig();
    //beanConfig.setConfigId("configId: " + contextId++);
    beanConfig.setTitle("Bagri REST server");
    beanConfig.setDescription("goto http://bagridb.com for more info");
    beanConfig.setContact("[email protected]");
    beanConfig.setLicense("Apache 2.0");
    beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
    beanConfig.setVersion(bg_version);
    beanConfig.setSchemes(new String[] {"http", "https"});
    // TODO: get host info somehow..
    beanConfig.setHost("localhost:" + port);
    beanConfig.setBasePath("/"); // /api
    beanConfig.setResourcePackage("com.bagri.rest.service");
    beanConfig.setPrettyPrint(true);
    // force Swagger to re-scan the package mentioned above and use 
    // custom ReaderListener from that package
    beanConfig.setScan(true);
}
 
開發者ID:dsukhoroslov,項目名稱:bagri,代碼行數:20,代碼來源:BagriRestServer.java

示例9: MaprMusicApp

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
public MaprMusicApp() {
    // Configure and Initialize Swagger
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0.0");
    beanConfig.setSchemes(new String[]{"http"});
    beanConfig.setHost("localhost:8080");
    beanConfig.setBasePath("/mapr-music-rest/api/1.0/");
    beanConfig.setResourcePackage("com.mapr.music.api");
    beanConfig.setScan(true);
}
 
開發者ID:mapr-demos,項目名稱:mapr-music,代碼行數:11,代碼來源:MaprMusicApp.java

示例10: swagger2Feature

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
@Bean
public BeanConfig swagger2Feature() {
    final BeanConfig swagger = new BeanConfig();
    swagger.setTitle("API");
    swagger.setVersion("1.0");
    swagger.setSchemes(new String[]{"http"});
    swagger.setHost("localhost:8080");
    swagger.setBasePath("/api");
    swagger.setResourcePackage("net.unibave.usertask.resource");
    swagger.setPrettyPrint(true);
    swagger.setScan(true);
    return swagger;
}
 
開發者ID:wesleyfuchter,項目名稱:user-task,代碼行數:14,代碼來源:JerseyConfig.java

示例11: swagger2Feature

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
@Bean
public BeanConfig swagger2Feature() {
    final BeanConfig swagger = new BeanConfig();
    swagger.setTitle("API");
    swagger.setVersion("1.0");
    swagger.setSchemes(new String[]{"http"});
    swagger.setHost("localhost:8080");
    swagger.setBasePath("/api");
    swagger.setResourcePackage("com.example.unibave.rest.resource");
    swagger.setPrettyPrint(true);
    swagger.setScan(true);
    return swagger;
}
 
開發者ID:panga,項目名稱:unibave-backend,代碼行數:14,代碼來源:JerseyConfig.java

示例12: startRestServer

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
public static HttpServer startRestServer() {
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0.0");
    beanConfig.setTitle("SlideBar REST Interface");
    beanConfig.setResourcePackage(RootResource.class.getPackage().getName());
    beanConfig.setSchemes(new String[] { "http" });
    beanConfig.setHost("localhost:5055");
    beanConfig.setScan(true);

    final ResourceConfig rc = new ResourceConfig();
    rc.packages(RootResource.class.getPackage().getName());
    rc.register(LoggingFeature.class);
    rc.register(JacksonFeature.class);
    rc.register(ApiListingResource.class);
    rc.register(SwaggerSerializers.class);
    rc.property(ServerProperties.WADL_FEATURE_DISABLE, true);

    Logger l = Logger.getLogger("org.glassfish.grizzly.http.server.HttpHandler");
    l.setLevel(Level.FINE);
    l.setUseParentHandlers(false);
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.ALL);
    l.addHandler(ch);

    try {
        return GrizzlyHttpServerFactory.createHttpServer(new URI("http://localhost:5055"), rc);
    } catch (URISyntaxException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:SlideKB,項目名稱:SlideBar,代碼行數:32,代碼來源:MainBack.java

示例13: startServer

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
/**
 * Starts Grizzly HTTP server exposing JAX-RS resources defined in this application.
 * @return Grizzly HTTP server.
 */
public static HttpServer startServer(int port) {
    HashMap properties = new HashMap();

    bridgeLog();

    // create a resource config that scans for JAX-RS resources and providers
    // in io.github.javathought.devoxx package
    final ResourceConfig rc = new ResourceConfig().packages("io.github.javathought.devoxx", "org.glassfish.jersey.examples.jackson");
    rc.register(SecurityFilter.class);
    rc.register(CrossDomainFilter.class);
    rc.register(SelectableEntityFilteringFeature.class);
    rc.property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME, "select");
    rc.register(JacksonFeature.class);
    rc.register(RolesAllowedDynamicFeature.class);
    rc.register(CsrfProtectionFilter.class);

    rc.register(ApiListingResource.class);
    rc.register(SwaggerSerializers.class);
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0");
    beanConfig.setSchemes(new String[]{"http"});
    beanConfig.setHost("localhost:8084");
    beanConfig.setBasePath("/myapp");
    beanConfig.setResourcePackage("io.github.javathought.devoxx.resources");
    beanConfig.setPrettyPrint(true);
    beanConfig.setScan(true);
    // create and start a new instance of grizzly http server
    // exposing the Jersey application at BASE_URI
    return GrizzlyHttpServerFactory.createHttpServer(URI.create(getBaseUri(port)), rc);
}
 
開發者ID:javathought,項目名稱:devoxx-2017,代碼行數:35,代碼來源:Main.java

示例14: Application

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
public Application() {
	super(Settings.WEB_ROOT_PACKAGE_NAME + ".jersey");
	BeanConfig beanConfig = new BeanConfig();
	beanConfig.setSchemes(new String[] { WebUtil.getHttpScheme() });
	beanConfig.setHost(WebUtil.getHttpHost());
	beanConfig.setBasePath("/" + WebUtil.REST_API_PATH);
	beanConfig.setTitle(Settings.getString(SettingCodes.API_TITLE, Bundle.SETTINGS, DefaultSettings.API_TITLE));
	// beanConfig.setDescription(Settings.getString(SettingCodes.API_INSTANCE, Bundle.SETTINGS, DefaultSettings.API_INSTANCE));
	beanConfig.setVersion(Settings.getString(SettingCodes.API_VERSION, Bundle.SETTINGS, DefaultSettings.API_VERSION));
	beanConfig.setContact(Settings.getContactEmail());
	// beanConfig.setResourcePackage("io.swagger.resources");
	beanConfig.setResourcePackage(Settings.WEB_ROOT_PACKAGE_NAME + ".jersey.resource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.shared.HyperlinkResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.course.CourseResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.inventory.InventoryResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.staff.StaffResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.shared.SearchResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.trial.VisitResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.proband.ProbandResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.inputfield.InputFieldResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.trial.VisitScheduleItemResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.user.UserResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.trial.InquiryResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.shared.FileResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.trial.ProbandListEntryResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.trial.ProbandListEntryTagResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.trial.ProbandListEntryTagValuesResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.trial.ProbandListStatusEntryResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.shared.JournalResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.proband.InquiryValuesResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.shared.IndexResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.shared.SelectionSetResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.shared.ToolsResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.inputfield.SelectionSetValueResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.trial.ProbandGroupResource");
	// beanConfig.setResourcePackage("org.phoenixctms.ctsms.web.jersey.resource.trial.TrialResource");
	beanConfig.setScan(true);
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:39,代碼來源:Application.java

示例15: main

import io.swagger.jaxrs.config.BeanConfig; //導入方法依賴的package包/類
public static void main(String[] args) {
    IpFinder ipFinder = new IpFinder();
    String host = ipFinder.findIp() + ":9005";

    String BASE_URI = "http://0.0.0.0:9005/elo-api/";

    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("BETA");
    beanConfig.setSchemes(new String[]{"http"});
    beanConfig.setHost("");
    beanConfig.setBasePath("/elo-api");
    beanConfig.setResourcePackage("com.github.wakingrufus.elo.api");
    beanConfig.setTitle("ELO API");
    beanConfig.setScan(true);

    //   ServletContainer sc = new ServletContainer(new JerseyApplication());
    ServiceLocator locator = ServiceLocatorUtilities.createAndPopulateServiceLocator();

    HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), new JerseyApplication(), locator);

    try {
        httpServer.start();
        CLStaticHttpHandler staticHttpHandler = new CLStaticHttpHandler(Main.class.getClassLoader(), "swagger-ui/");
        httpServer.getServerConfiguration().addHttpHandler(staticHttpHandler, "/docs");

        System.out.println(String.format("Jersey app started with WADL available at "
                + "%sapplication.wadl\nHit enter to stop it...", BASE_URI));
        System.in.read();
        // httpServer.shutdown();
    } catch (IOException e) {
        e.printStackTrace();
    }

}
 
開發者ID:wakingrufus,項目名稱:elo-api,代碼行數:35,代碼來源:Main.java


注:本文中的io.swagger.jaxrs.config.BeanConfig.setHost方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。