本文整理汇总了Java中com.codahale.metrics.annotation.Timed类的典型用法代码示例。如果您正苦于以下问题:Java Timed类的具体用法?Java Timed怎么用?Java Timed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Timed类属于com.codahale.metrics.annotation包,在下文中一共展示了Timed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAssertionConsumerServiceUri
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
@Timed
public ResourceLocation getAssertionConsumerServiceUri(String entityId, Optional<Integer> assertionConsumerServiceIndex) {
ImmutableMap<String, String> queryParams = ImmutableMap.of();
if (assertionConsumerServiceIndex.isPresent()) {
queryParams = ImmutableMap.of(
Urls.ConfigUrls.ASSERTION_CONSUMER_SERVICE_INDEX_PARAM,
assertionConsumerServiceIndex.get().toString());
}
final URI uri = getEncodedUri(Urls.ConfigUrls.TRANSACTIONS_ASSERTION_CONSUMER_SERVICE_URI_RESOURCE, queryParams, entityId);
try {
return resourceLocation.getUnchecked(uri);
} catch (UncheckedExecutionException e) {
Throwables.throwIfUnchecked(e.getCause());
throw new RuntimeException(e.getCause());
}
}
示例2: getTicket
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* Note:
* Synchronization on ticket object in case of cache based registry doesn't serialize
* access to critical section. The reason is that cache pulls serialized data and
* builds new object, most likely for each pull. Is this synchronization needed here?
*/
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
throws InvalidTicketException {
Assert.notNull(ticketId, "ticketId cannot be null");
final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);
if (ticket == null) {
logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
throw new InvalidTicketException(ticketId);
}
if (ticket instanceof TicketGrantingTicket) {
synchronized (ticket) {
if (ticket.isExpired()) {
this.ticketRegistry.deleteTicket(ticketId);
logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
throw new InvalidTicketException(ticketId);
}
}
}
return (T) ticket;
}
示例3: createUser
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
/**
* POST /users : Creates a new user.
* <p>
* Creates a new user if the login and email are not already used, and sends an
* mail with an activation link.
* The user needs to be activated on creation.
* </p>
*
* @param managedUserVM the user to create
* @return the ResponseEntity with status 201 (Created) and with body the new user, or with status 400 (Bad Request) if the login or email is already in use
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity createUser(@RequestBody ManagedUserVM managedUserVM) throws URISyntaxException {
log.debug("REST request to save User : {}", managedUserVM);
//Lowercase the user login before comparing with database
if (userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase()).isPresent()) {
return ResponseEntity.badRequest()
.headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "userexists", "Login already in use"))
.body(null);
} else if (userRepository.findOneByEmail(managedUserVM.getEmail()).isPresent()) {
return ResponseEntity.badRequest()
.headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "emailexists", "Email already in use"))
.body(null);
} else {
User newUser = userService.createUser(managedUserVM);
mailService.sendCreationEmail(newUser);
return ResponseEntity.created(new URI("/api/users/" + newUser.getLogin()))
.headers(HeaderUtil.createAlert( "userManagement.created", newUser.getLogin()))
.body(newUser);
}
}
示例4: followed
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
/**
* 我的关注标签
*/
@RequestMapping(value = "/me/tags/following", method = GET)
@Timed
public String followed(Model model, @RequestParam(defaultValue = "1") int page) {
Long userId = userService.getCurrentUserId();
long size = tagService.countUserFollowedTags(userId);
long pages = size / PAGE_SIZE + (size % PAGE_SIZE != 0 ? 1 : 0);
page = page < 1 ? 1 : page - 1;
List<Tag> tags = tagService.getUserTags(page, PAGE_SIZE, userId);
model.addAttribute("tags", tags);
model.addAttribute("page", page + 1);
model.addAttribute("totalPages", pages);
return "tags/followed_tags";
}
示例5: getTicket
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
throws InvalidTicketException {
Assert.notNull(ticketId, "ticketId cannot be null");
final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);
if (ticket == null) {
logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
throw new InvalidTicketException(ticketId);
}
if (ticket instanceof TicketGrantingTicket) {
synchronized (ticket) {
if (ticket.isExpired()) {
this.ticketRegistry.deleteTicket(ticketId);
logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
throw new InvalidTicketException(ticketId);
}
}
}
return (T) ticket;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:29,代码来源:CentralAuthenticationServiceImpl.java
示例6: createUser
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
/**
* POST /users : Creates a new user.
* <p>
* Creates a new user if the login and email are not already used, and sends an
* mail with an activation link.
* The user needs to be activated on creation.
*
* @param userDTO the user to create
* @return the ResponseEntity with status 201 (Created) and with body the new user, or with status 400 (Bad Request) if the login or email is already in use
* @throws URISyntaxException if the Location URI syntax is incorrect
* @throws BadRequestAlertException 400 (Bad Request) if the login or email is already in use
*/
@PostMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<User> createUser(@Valid @RequestBody UserDTO userDTO) throws URISyntaxException {
log.debug("REST request to save User : {}", userDTO);
if (userDTO.getId() != null) {
throw new BadRequestAlertException("A new user cannot already have an ID", "userManagement", "idexists");
// Lowercase the user login before comparing with database
} else if (userRepository.findOneByLogin(userDTO.getLogin().toLowerCase()).isPresent()) {
throw new LoginAlreadyUsedException();
} else if (userRepository.findOneByEmailIgnoreCase(userDTO.getEmail()).isPresent()) {
throw new EmailAlreadyUsedException();
} else {
User newUser = userService.createUser(userDTO);
mailService.sendCreationEmail(newUser);
return ResponseEntity.created(new URI("/api/users/" + newUser.getLogin()))
.headers(HeaderUtil.createAlert( "userManagement.created", newUser.getLogin()))
.body(newUser);
}
}
示例7: removeService
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
@DELETE
@Path("/{group}/access/services/{service_key}")
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
@Timed(name = "removeService")
public Response removeService(
@Auth AuthPrincipal authPrincipal,
@PathParam("group") String groupKey,
@PathParam("service_key") String serviceKey
) throws AuthenticationException {
final long start = System.currentTimeMillis();
final Optional<Group> maybe = findGroup(groupKey);
if (maybe.isPresent()) {
final Group group = maybe.get();
accessControlSupport.throwUnlessGrantedFor(authPrincipal, group);
final Group updated = groupService.removeServiceAccess(group, serviceKey);
return headers.enrich(Response.ok(updated), start).build();
}
return headers.enrich(Response.status(404).entity(
Problem.clientProblem(TITLE_NOT_FOUND, "", 404)), start).build();
}
示例8: updateUser
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
/**
* PUT /users : Updates an existing User.
*
* @param managedUserVM the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user,
* or with status 400 (Bad Request) if the login or email is already in use,
* or with status 500 (Internal Server Error) if the user couldn't be updated
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@Valid @RequestBody ManagedUserVM managedUserVM) {
log.debug("REST request to update User : {}", managedUserVM);
Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "emailexists", "Email already in use")).body(null);
}
existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "userexists", "Login already in use")).body(null);
}
Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("A user is updated with identifier " + managedUserVM.getLogin(), managedUserVM.getLogin()));
}
示例9: newPosts
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
@RequestMapping(value = "posts/new", method = RequestMethod.GET)
@Timed
public String newPosts(@RequestParam(defaultValue = "1") int page, Model model) {
page = page < 1 ? 1 : page - 1;
long size = newPostsService.size();
long pages = size / PAGE_SIZE + (size % PAGE_SIZE != 0 ? 1 : 0);
List<Post> posts = postListService.getNewPostsOfPage(page, PAGE_SIZE);
model.addAttribute("page", page + 1);
model.addAttribute("totalPages", pages);
model.addAttribute("posts", posts);
model.addAttribute("votes", voteService.getCurrentUserVoteMapFor(posts));
model.addAttribute("counting", countingService.getPostListCounting(posts));
return "posts/new";
}
示例10: saveAccount
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
/**
* POST /account : update the current user information.
*
* @param userDTO the current user information
* @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already used
* @throws RuntimeException 500 (Internal Server Error) if the user login wasn't found
*/
@PostMapping("/account")
@Timed
public void saveAccount(@Valid @RequestBody UserDTO userDTO) {
final String userLogin = SecurityUtils.getCurrentUserLogin();
Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getLogin().equalsIgnoreCase(userLogin))) {
throw new EmailAlreadyUsedException();
}
Optional<User> user = userRepository.findOneByLogin(userLogin);
if (!user.isPresent()) {
throw new InternalServerErrorException("User could not be found");
}
userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(),
userDTO.getLangKey(), userDTO.getImageUrl());
}
示例11: authorize
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
@PostMapping("/authenticate")
@Timed
public ResponseEntity<?> authorize(@Valid @RequestBody LoginDTO loginDTO, HttpServletResponse response) {
UsernamePasswordAuthenticationToken authenticationToken =
new UsernamePasswordAuthenticationToken(loginDTO.getUsername(), loginDTO.getPassword());
try {
Authentication authentication = this.authenticationManager.authenticate(authenticationToken);
SecurityContextHolder.getContext().setAuthentication(authentication);
boolean rememberMe = (loginDTO.isRememberMe() == null) ? false : loginDTO.isRememberMe();
String jwt = tokenProvider.createToken(authentication, rememberMe);
response.addHeader(JWTConfigurer.AUTHORIZATION_HEADER, "Bearer " + jwt);
return ResponseEntity.ok(new JWTToken(jwt));
} catch (AuthenticationException exception) {
return new ResponseEntity<>(Collections.singletonMap("AuthenticationException",exception.getLocalizedMessage()), HttpStatus.UNAUTHORIZED);
}
}
示例12: updateUser
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
/**
* PUT /users : Updates an existing User.
*
* @param managedUserVM the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user,
* or with status 400 (Bad Request) if the login or email is already in use,
* or with status 500 (Internal Server Error) if the user couldn't be updated
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<ManagedUserVM> updateUser(@RequestBody ManagedUserVM managedUserVM) {
log.debug("REST request to update User : {}", managedUserVM);
Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("userManagement", "emailexists", "E-mail already in use")).body(null);
}
existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("userManagement", "userexists", "Login already in use")).body(null);
}
userService.updateUser(managedUserVM.getId(), managedUserVM.getLogin(), managedUserVM.getFirstName(),
managedUserVM.getLastName(), managedUserVM.getEmail(), managedUserVM.isActivated(),
managedUserVM.getLangKey(), managedUserVM.getAuthorities());
return ResponseEntity.ok()
.headers(HeaderUtil.createAlert("A user is updated with identifier " + managedUserVM.getLogin(), managedUserVM.getLogin()))
.body(new ManagedUserVM(userService.getUserWithAuthorities(managedUserVM.getId())));
}
示例13: getMatchingServices
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
public Collection<MatchingServiceConfigEntityDataDto> getMatchingServices() {
Collection<MatchingServiceConfigEntityDataDto> matchingServices = new ArrayList<>();
for (TransactionConfigEntityData transactionConfigEntityData : transactionConfigEntityDataRepository.getAllData()) {
MatchingServiceConfigEntityData matchingServiceConfigEntityData = matchingServiceConfigEntityDataRepository.getData(transactionConfigEntityData.getMatchingServiceEntityId()).get();
matchingServices.add(new MatchingServiceConfigEntityDataDto(
matchingServiceConfigEntityData.getEntityId(),
matchingServiceConfigEntityData.getUri(),
transactionConfigEntityData.getEntityId(),
matchingServiceConfigEntityData.getHealthCheckEnabled(),
matchingServiceConfigEntityData.getOnboarding(),
matchingServiceConfigEntityData.getUserAccountCreationUri()));
}
return matchingServices;
}
示例14: updateUser
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
/**
* PUT /users : Updates an existing User.
*
* @param managedUserVM the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user,
* or with status 400 (Bad Request) if the login or email is already in use,
* or with status 500 (Internal Server Error) if the user couldn't be updated
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@RequestBody ManagedUserVM managedUserVM) {
log.debug("REST request to update User : {}", managedUserVM);
Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "emailexists", "Email already in use")).body(null);
}
existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "userexists", "Login already in use")).body(null);
}
Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("userManagement.updated", managedUserVM.getLogin()));
}
示例15: getAllPhotoLocationBeacons
import com.codahale.metrics.annotation.Timed; //导入依赖的package包/类
/**
* GET /photoLocationBeacons -> get all the photoLocationBeacons.
*/
@RequestMapping(value = "/photoLocationBeacons",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<PhotoLocationBeacon> getAllPhotoLocationBeacons(@RequestParam(required = false) String filter) {
if ("exercise-is-null".equals(filter)) {
log.debug("REST request to get all PhotoLocationBeacons where exercise is null");
return StreamSupport
.stream(photoLocationBeaconRepository.findAll().spliterator(), false)
.filter(photoLocationBeacon -> photoLocationBeacon.getExercise() == null)
.collect(Collectors.toList());
}
log.debug("REST request to get all PhotoLocationBeacons");
return photoLocationBeaconRepository.findAll();
}