List of usage examples for org.springframework.util StopWatch stop
public void stop() throws IllegalStateException
From source file:org.dd4t.core.filters.impl.DefaultLinkResolverFilter.java
/** * Recursively resolves all components links. * //from w w w .j a v a 2s . c om * @param item the to resolve the links * @param context the requestContext */ @Override public void doFilter(Item item, RequestContext context) throws FilterException { this.getLinkResolver().setContextPath(contextPath); StopWatch stopWatch = null; if (logger.isDebugEnabled()) { stopWatch = new StopWatch(); stopWatch.start(); } if (item instanceof GenericPage) { resolvePage((GenericPage) item); } else if (item instanceof GenericComponent) { resolveComponent((GenericComponent) item); } else { if (logger.isDebugEnabled()) { logger.debug( "DefaultLinkResolverFilter. Item is not a GenericPage or GenericComponent so no component to resolve"); } } if (logger.isDebugEnabled()) { stopWatch.stop(); logger.debug("LinkResolverFilter for " + item.getId() + " finished in " + stopWatch.getTotalTimeMillis() + " ms"); } }
From source file:be.craftworkz.ucll.config.apidoc.SwaggerConfiguration.java
/** * Swagger Springfox configuration./*w w w. j av a 2 s . c o m*/ */ @Bean public Docket swaggerSpringfoxDocket() { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start(); Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) .genericModelSubstitutes(ResponseEntity.class).forCodeGeneration(true) .genericModelSubstitutes(ResponseEntity.class) .directModelSubstitute(org.joda.time.LocalDate.class, String.class) .directModelSubstitute(org.joda.time.LocalDateTime.class, Date.class) .directModelSubstitute(org.joda.time.DateTime.class, Date.class) .directModelSubstitute(java.time.LocalDate.class, String.class) .directModelSubstitute(java.time.ZonedDateTime.class, Date.class) .directModelSubstitute(java.time.LocalDateTime.class, Date.class).select() .paths(regex(DEFAULT_INCLUDE_PATTERN)).build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return docket; }
From source file:com.springboot.demo.config.apidoc.SwaggerConfiguration.java
/** * Swagger Springfox configuration.//from w w w.ja v a 2s . c o m */ @Bean public Docket swaggerSpringfoxDocket() { log.info("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start(); Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) .genericModelSubstitutes(ResponseEntity.class).forCodeGeneration(true) .genericModelSubstitutes(ResponseEntity.class) .directModelSubstitute(org.joda.time.LocalDate.class, String.class) .directModelSubstitute(org.joda.time.LocalDateTime.class, Date.class) .directModelSubstitute(org.joda.time.DateTime.class, Date.class) .directModelSubstitute(java.time.LocalDate.class, String.class) .directModelSubstitute(java.time.ZonedDateTime.class, Date.class) .directModelSubstitute(java.time.LocalDateTime.class, Date.class).select() .paths(regex(DEFAULT_INCLUDE_PATTERN)).build(); watch.stop(); log.info("Started Swagger in {} ms", watch.getTotalTimeMillis()); return docket; }
From source file:org.dd4t.core.filters.impl.DefaultLinkResolverFilter.java
protected void resolveComponent(GenericComponent component, GenericPage page) { StopWatch stopWatch = null; if (logger.isDebugEnabled()) { stopWatch = new StopWatch(); stopWatch.start();//from w ww.j a v a2 s . c o m } if (component != null) { // resolve regular content resolveMap(component.getContent()); // resolve metadata resolveMap(component.getMetadata()); /* don't resolve Component itself; * this may very likely lead to performance issues when using * the experience manager. */ // getLinkResolver().resolve(component, page); } if (logger.isDebugEnabled()) { stopWatch.stop(); logger.debug("ResolveComponent for " + component.getId() + " finished in " + stopWatch.getTotalTimeMillis() + " ms"); } }
From source file:br.com.rockage.config.apidoc.SwaggerConfiguration.java
/** * Swagger Springfox configuration.//from w w w . jav a 2 s . co m * * @param jHipsterProperties the properties of the application * @return the Swagger Springfox configuration */ @Bean public Docket swaggerSpringfoxDocket(JHipsterProperties jHipsterProperties) { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start(); Contact contact = new Contact(jHipsterProperties.getSwagger().getContactName(), jHipsterProperties.getSwagger().getContactUrl(), jHipsterProperties.getSwagger().getContactEmail()); ApiInfo apiInfo = new ApiInfo(jHipsterProperties.getSwagger().getTitle(), jHipsterProperties.getSwagger().getDescription(), jHipsterProperties.getSwagger().getVersion(), jHipsterProperties.getSwagger().getTermsOfServiceUrl(), contact, jHipsterProperties.getSwagger().getLicense(), jHipsterProperties.getSwagger().getLicenseUrl()); Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).forCodeGeneration(true) .genericModelSubstitutes(ResponseEntity.class).select().paths(regex(DEFAULT_INCLUDE_PATTERN)) .build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return docket; }
From source file:org.fracturedatlas.athena.helper.ticketfactory.manager.TicketFactoryManager.java
public List<Ticket> createTickets(PTicket pTicket) { String performanceId = (String) pTicket.getId(); PTicket performance = athenaStage.get("performance", performanceId); //If the performace isn't found, throw a bad request if (performance == null) { throw new AthenaException("Performance with id [" + performanceId + "] was not found"); }/*from www. j a va 2 s . c o m*/ StopWatch watch = new StopWatch(); watch.start("gathering info"); String chartId = performance.get("chartId"); String eventId = performance.get("eventId"); PTicket chart = athenaStage.get("chart", chartId); PTicket event = athenaStage.get("event", eventId); AthenaSearchConstraint sectionSearch = new AthenaSearchConstraint("chartId", Operator.EQUALS, chartId); AthenaSearch athenaSearch = new AthenaSearch.Builder(sectionSearch).build(); logger.debug("Finding sections for chart [{}]", chartId); Collection<PTicket> sections = athenaStage.find("section", athenaSearch); logger.debug("Found [{}] sections", sections.size()); ArrayList<Ticket> ticketsToCreate = new ArrayList<Ticket>(); watch.stop(); //for each section for (PTicket section : sections) { watch.start("section " + section.get("name")); Integer capacity = Integer.parseInt(section.get("capacity")); logger.debug("capacity of section [{}] is [{}]", section.getId(), capacity); for (int seatNum = 0; seatNum < capacity; seatNum++) { Ticket ticket = new Ticket(section, performance, event, INITIAL_STATE); ticketsToCreate.add(ticket); } watch.stop(); } watch.start("creating tickets"); List<Ticket> tickets = saveTickets(ticketsToCreate); watch.stop(); logger.debug("{}", watch.prettyPrint()); return tickets; }
From source file:com.persistent.cloudninja.scheduler.TenantDBSizeProcessor.java
/** * Calculates DB size of tenant DB.//from w w w.j a v a 2 s . c om */ @Override public boolean execute() { boolean retVal = true; String tenantId = null; try { LOGGER.debug("In Processor"); long dbSize = 0; TenantDBSizeQueue queue = (TenantDBSizeQueue) getWorkQueue(); tenantId = queue.dequeue(SchedulerSettings.MessageVisibilityTimeout); if (tenantId == null) { retVal = false; LOGGER.debug("Processor : msg is null"); } else { StopWatch watch = new StopWatch(); watch.start(); LOGGER.debug("Processor : msg is " + tenantId); dbSize = partitionStatsAndBWUsageDao.getDBSize(tenantId); MeteringEntity metering = new MeteringEntity(); metering.setTenantId(tenantId); Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); String date = dateFormat.format(calendar.getTime()); metering.setSnapshotTime(dateFormat.parse(date)); metering.setDatabaseSize(dbSize); meteringDao.add(metering); LOGGER.info("Processor : dbSize is " + dbSize); watch.stop(); taskCompletionDao.updateTaskCompletionDetails(watch.getTotalTimeSeconds(), "ProcessMeteringTenantDatabaseSize", "Measured " + dbSize + " for tenant " + tenantId + " database"); } } catch (StorageException e) { retVal = false; LOGGER.error(e.getMessage(), e); } catch (ParseException e) { retVal = false; LOGGER.error(e.getMessage(), e); } return retVal; }
From source file:com.github.aksakalli.todo.config.SwaggerConfiguration.java
/** * Swagger Springfox configuration.//from w ww . ja v a 2 s. c o m */ @Bean public Docket swaggerSpringfoxDocket() { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start(); Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) .securitySchemes(newArrayList(new BasicAuth("test"))).genericModelSubstitutes(ResponseEntity.class) .forCodeGeneration(true).genericModelSubstitutes(ResponseEntity.class) .directModelSubstitute(org.joda.time.LocalDate.class, String.class) .directModelSubstitute(org.joda.time.LocalDateTime.class, Date.class) .directModelSubstitute(org.joda.time.DateTime.class, Date.class) .directModelSubstitute(java.time.LocalDate.class, String.class) .directModelSubstitute(java.time.ZonedDateTime.class, Date.class) .directModelSubstitute(java.time.LocalDateTime.class, Date.class).select() .paths(regex(DEFAULT_INCLUDE_PATTERN)).build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return docket; }
From source file:cn.fintecher.print.service.summons.config.apidoc.SwaggerConfiguration.java
/** * Swagger Springfox configuration.//w w w . java2 s . c o m * * @param summonsServiceProperties the properties of the application * @return the Swagger Springfox configuration */ @Bean public Docket swaggerSpringfoxDocket(SummonsServiceProperties summonsServiceProperties) { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start(); Contact contact = new Contact(summonsServiceProperties.getSwagger().getContactName(), summonsServiceProperties.getSwagger().getContactUrl(), summonsServiceProperties.getSwagger().getContactEmail()); ApiInfo apiInfo = new ApiInfo(summonsServiceProperties.getSwagger().getTitle(), summonsServiceProperties.getSwagger().getDescription(), summonsServiceProperties.getSwagger().getVersion(), summonsServiceProperties.getSwagger().getTermsOfServiceUrl(), contact, summonsServiceProperties.getSwagger().getLicense(), summonsServiceProperties.getSwagger().getLicenseUrl()); Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).forCodeGeneration(true) .genericModelSubstitutes(ResponseEntity.class).select().paths(regex(DEFAULT_INCLUDE_PATTERN)) .build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return docket; }
From source file:io.github.jhipster.config.apidoc.SwaggerConfiguration.java
/** * Swagger Springfox configuration./*from ww w . j a va2 s. co m*/ * * @param jHipsterProperties the properties of the application * @return the Swagger Springfox configuration */ @Bean public Docket swaggerSpringfoxDocket(JHipsterProperties jHipsterProperties) { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start(); Contact contact = new Contact(jHipsterProperties.getSwagger().getContactName(), jHipsterProperties.getSwagger().getContactUrl(), jHipsterProperties.getSwagger().getContactEmail()); ApiInfo apiInfo = new ApiInfo(jHipsterProperties.getSwagger().getTitle(), jHipsterProperties.getSwagger().getDescription(), jHipsterProperties.getSwagger().getVersion(), jHipsterProperties.getSwagger().getTermsOfServiceUrl(), contact, jHipsterProperties.getSwagger().getLicense(), jHipsterProperties.getSwagger().getLicenseUrl()); Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).forCodeGeneration(true) .directModelSubstitute(java.nio.ByteBuffer.class, String.class) .genericModelSubstitutes(ResponseEntity.class).select() .paths(regex(jHipsterProperties.getSwagger().getDefaultIncludePattern())).build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return docket; }