本文整理汇总了Java中com.codahale.metrics.annotation.Metered类的典型用法代码示例。如果您正苦于以下问题:Java Metered类的具体用法?Java Metered怎么用?Java Metered使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Metered类属于com.codahale.metrics.annotation包,在下文中一共展示了Metered类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTicketGrantingTicket
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
@Audit(
action="TICKET_GRANTING_TICKET",
actionResolverName="CREATE_TICKET_GRANTING_TICKET_RESOLVER",
resourceResolverName="CREATE_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "CREATE_TICKET_GRANTING_TICKET_TIMER")
@Metered(name = "CREATE_TICKET_GRANTING_TICKET_METER")
@Counted(name="CREATE_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public TicketGrantingTicket createTicketGrantingTicket(final AuthenticationContext context)
throws AuthenticationException, AbstractTicketException {
final Authentication authentication = context.getAuthentication();
final TicketGrantingTicketFactory factory = this.ticketFactory.get(TicketGrantingTicket.class);
final TicketGrantingTicket ticketGrantingTicket = factory.create(authentication);
this.ticketRegistry.addTicket(ticketGrantingTicket);
doPublishEvent(new CasTicketGrantingTicketCreatedEvent(this, ticketGrantingTicket));
return ticketGrantingTicket;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:CentralAuthenticationServiceImpl.java
示例2: destroyTicketGrantingTicket
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
/**
* {@inheritDoc}
* Destroy a TicketGrantingTicket and perform back channel logout. This has the effect of invalidating any
* Ticket that was derived from the TicketGrantingTicket being destroyed. May throw an
* {@link IllegalArgumentException} if the TicketGrantingTicket ID is null.
*
* @param ticketGrantingTicketId the id of the ticket we want to destroy
* @return the logout requests.
*/
@Audit(
action="TICKET_GRANTING_TICKET_DESTROYED",
actionResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOLVER",
resourceResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "DESTROY_TICKET_GRANTING_TICKET_TIMER")
@Metered(name="DESTROY_TICKET_GRANTING_TICKET_METER")
@Counted(name="DESTROY_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public List<LogoutRequest> destroyTicketGrantingTicket(@NotNull final String ticketGrantingTicketId) {
try {
logger.debug("Removing ticket [{}] from registry...", ticketGrantingTicketId);
final TicketGrantingTicket ticket = getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
logger.debug("Ticket found. Processing logout requests and then deleting the ticket...");
final List<LogoutRequest> logoutRequests = logoutManager.performLogout(ticket);
this.ticketRegistry.deleteTicket(ticketGrantingTicketId);
return logoutRequests;
} catch (final InvalidTicketException e) {
logger.debug("TicketGrantingTicket [{}] cannot be found in the ticket registry.", ticketGrantingTicketId);
}
return Collections.emptyList();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:31,代码来源:CentralAuthenticationServiceImpl.java
示例3: grantServiceTicket
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
@Audit(
action="SERVICE_TICKET",
actionResolverName="GRANT_SERVICE_TICKET_RESOLVER",
resourceResolverName="GRANT_SERVICE_TICKET_RESOURCE_RESOLVER")
@Timed(name = "GRANT_SERVICE_TICKET_TIMER")
@Metered(name="GRANT_SERVICE_TICKET_METER")
@Counted(name="GRANT_SERVICE_TICKET_COUNTER", monotonic=true)
@Override
public ServiceTicket grantServiceTicket(final String ticketGrantingTicketId,
final Service service) throws TicketException {
try {
return this.grantServiceTicket(ticketGrantingTicketId, service, (Credential[]) null);
} catch (final AuthenticationException e) {
throw new IllegalStateException("Unexpected authentication exception", e);
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:CentralAuthenticationServiceImpl.java
示例4: getTicket
import com.codahale.metrics.annotation.Metered; //导入依赖的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
示例5: authenticate
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
@Override
@Audit(
action = "AUTHENTICATION",
actionResolverName = "AUTHENTICATION_RESOLVER",
resourceResolverName = "AUTHENTICATION_RESOURCE_RESOLVER")
@Timed(name = "AUTHENTICATE_TIMER")
@Metered(name = "AUTHENTICATE_METER")
@Counted(name = "AUTHENTICATE_COUNT", monotonic = true)
public Authentication authenticate(final AuthenticationTransaction transaction) throws AuthenticationException {
AuthenticationCredentialsLocalBinder.bindCurrent(transaction.getCredentials());
final AuthenticationBuilder builder = authenticateInternal(transaction);
final Authentication authentication = builder.build();
final Principal principal = authentication.getPrincipal();
if (principal instanceof NullPrincipal) {
throw new UnresolvedPrincipalException(authentication);
}
addAuthenticationMethodAttribute(builder, authentication);
LOGGER.info("Authenticated principal [{}] with attributes [{}] via credentials [{}].",
principal.getId(), principal.getAttributes(), transaction.getCredentials());
populateAuthenticationMetadataAttributes(builder, transaction);
final Authentication a = builder.build();
AuthenticationCredentialsLocalBinder.bindCurrent(a);
return a;
}
示例6: authenticate
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
@Override
@Audit(
action="AUTHENTICATION",
actionResolverName="AUTHENTICATION_RESOLVER",
resourceResolverName="AUTHENTICATION_RESOURCE_RESOLVER")
@Timed(name="AUTHENTICATE_TIMED")
@Metered(name="AUTHENTICATE_METER")
@Counted(name="AUTHENTICATE_COUNT", monotonic=true)
public Authentication authenticate(final AuthenticationTransaction transaction) throws AuthenticationException {
final AuthenticationBuilder builder = authenticateInternal(transaction.getCredentials());
final Authentication authentication = builder.build();
final Principal principal = authentication.getPrincipal();
if (principal instanceof NullPrincipal) {
throw new UnresolvedPrincipalException(authentication);
}
addAuthenticationMethodAttribute(builder, authentication);
logger.info("Authenticated {} with credentials {}.", principal, transaction.getCredentials());
logger.debug("Attribute map for {}: {}", principal.getId(), principal.getAttributes());
populateAuthenticationMetadataAttributes(builder, transaction.getCredentials());
return builder.build();
}
示例7: getTicket
import com.codahale.metrics.annotation.Metered; //导入依赖的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;
}
示例8: destroyTicketGrantingTicket
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
/**
* {@inheritDoc}
* Destroy a TicketGrantingTicket and perform back channel logout. This has the effect of invalidating any
* Ticket that was derived from the TicketGrantingTicket being destroyed. May throw an
* {@link IllegalArgumentException} if the TicketGrantingTicket ID is null.
*
* @param ticketGrantingTicketId the id of the ticket we want to destroy
* @return the logout requests.
*/
@Audit(
action="TICKET_GRANTING_TICKET_DESTROYED",
actionResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOLVER",
resourceResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "DESTROY_TICKET_GRANTING_TICKET_TIMER")
@Metered(name="DESTROY_TICKET_GRANTING_TICKET_METER")
@Counted(name="DESTROY_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public List<LogoutRequest> destroyTicketGrantingTicket(@NotNull final String ticketGrantingTicketId) {
try {
logger.debug("Removing ticket [{}] from registry...", ticketGrantingTicketId);
final TicketGrantingTicket ticket = getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
logger.debug("Ticket found. Processing logout requests and then deleting the ticket...");
final List<LogoutRequest> logoutRequests = logoutManager.performLogout(ticket);
this.ticketRegistry.deleteTicket(ticketGrantingTicketId);
doPublishEvent(new CasTicketGrantingTicketDestroyedEvent(this, ticket));
return logoutRequests;
} catch (final InvalidTicketException e) {
logger.debug("TicketGrantingTicket [{}] cannot be found in the ticket registry.", ticketGrantingTicketId);
}
return Collections.emptyList();
}
示例9: destroyTicketGrantingTicket
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
/**
* {@inheritDoc}
* Destroy a TicketGrantingTicket and perform back channel logout. This has the effect of invalidating any
* Ticket that was derived from the TicketGrantingTicket being destroyed. May throw an
* {@link IllegalArgumentException} if the TicketGrantingTicket ID is null.
*
* @param ticketGrantingTicketId the id of the ticket we want to destroy
* @return the logout requests.
*/
@Audit(
action="TICKET_GRANTING_TICKET_DESTROYED",
actionResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOLVER",
resourceResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "DESTROY_TICKET_GRANTING_TICKET_TIMER")
@Metered(name="DESTROY_TICKET_GRANTING_TICKET_METER")
@Counted(name="DESTROY_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public List<LogoutRequest> destroyTicketGrantingTicket(@NotNull final String ticketGrantingTicketId) {
try {
logger.debug("Removing ticket [{}] from registry...", ticketGrantingTicketId);
final TicketGrantingTicket ticket = getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
logger.debug("Ticket found. Processing logout requests and then deleting the ticket...");
final List<LogoutRequest> logoutRequests = logoutManager.performLogout(ticket);
this.ticketRegistry.deleteTicket(ticketGrantingTicketId);
return logoutRequests;
} catch (final InvalidTicketException e) {
logger.debug("TicketGrantingTicket [{}] cannot be found in the ticket registry.", ticketGrantingTicketId);
}
return Collections.emptyList();
}
示例10: getAllProductCatalog
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
@GET
@Timed(name = "showAll-timed-get")
@Metered(name = "showAll-metered-get")
@ExceptionMetered
@CacheControl(maxAge = 12, maxAgeUnit = TimeUnit.HOURS)
public List<ProductCatalogRepresentation> getAllProductCatalog() {
LOGGER.info("Retrieving all product catalog details of the product");
List<ProductCatalog> details = productCatalogService.getAllProductDetails();
if (details == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
LOGGER.debug("Product details:" + details.toString());
List<ProductCatalogRepresentation> representations = new ArrayList<>();
for (ProductCatalog detail : details) {
representations.add(ProductRepresentationDomainConverter.toRepresentation(detail));
}
return representations;
}
示例11: getAllProductReviews
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
@GET
@Path("/{skuId}")
@Timed(name = "showAll-timed-get")
@Metered(name = "showAll-metered-get")
@ExceptionMetered
@CacheControl(maxAge = 12, maxAgeUnit = TimeUnit.HOURS)
public List<ProductReviewRepresentation> getAllProductReviews(@PathParam("skuId") String skuId) {
LOGGER.info("Retrieving all product reviews of the product:" + skuId);
List<ProductReview> reviews = productReviewService.getAllProductReviews(skuId);
if (reviews == null || reviews.isEmpty()) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
List<ProductReviewRepresentation> representations = new ArrayList<>();
for (ProductReview review : reviews) {
representations.add(ProductReviewRepresentationDomainConverter.toRepresentation(review));
}
return representations;
}
示例12: getProductCatalog
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
@GET
@Path("/{id}")
@Timed(name = "showAll-timed-get")
@Metered(name = "showAll-metered-get")
@ExceptionMetered
@CacheControl(maxAge = 12, maxAgeUnit = TimeUnit.SECONDS)
@JacksonFeatures(serializationEnable = { SerializationFeature.INDENT_OUTPUT })
public ProductRepresentation getProductCatalog(@Auth User user, @PathParam("id") String id) throws Exception {
LOGGER.info("Fetching the product catalog for the product with id:" + id);
ProductRepresentation product = new ProductRepresentation();
JSONObject productCatalog = productCatalogClient.getProductCatalog(id);
if (productCatalog == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
product.setProductCatalog((HashMap<String, Object>) productCatalog.toMap());
List<HashMap<String, Object>> reviewList = new ArrayList<>();
List<Object> reviews = productReviewClient.getProductReviews(id).toList();
for (Object review : reviews) {
reviewList.add((HashMap<String, Object>) review);
}
product.setProductReviews(reviewList);
return product;
}
示例13: getSucceed
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
/**
* Accept request and reply with OK.
*
* @param uriInfo Information about the URL for the request
* @param asyncResponse The response object to send the final response to
*/
@GET
@Timed(name = "logTimed")
@Metered(name = "logMetered")
@ExceptionMetered(name = "logException")
@Produces(MediaType.APPLICATION_JSON)
@Path("/log")
public void getSucceed(@Context UriInfo uriInfo, @Suspended AsyncResponse asyncResponse) {
RequestLog.startTiming(this);
try {
Thread.sleep(200);
} catch (InterruptedException ignore) {
// Do nothing
}
RequestLog.stopTiming(this);
Response response = Response.status(Response.Status.OK).build();
asyncResponse.resume(response);
}
示例14: getFailWithWebAppException
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
/**
* Accept request and reply with webapp exception and a simple string message.
*
* @param uriInfo Information about the URL for the request
*/
@GET
@Timed(name = "logTimed")
@Metered(name = "logMetered")
@ExceptionMetered(name = "logException")
@Produces(MediaType.APPLICATION_JSON)
@Path("/webbug")
public void getFailWithWebAppException(@Context UriInfo uriInfo) {
RequestLog.startTiming(this);
try {
Thread.sleep(200);
throw new WebApplicationException(
Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Oops! Web App Exception").build()
);
} catch (InterruptedException ignore) {
// Do nothing
}
}
示例15: getFailWithRuntimeException
import com.codahale.metrics.annotation.Metered; //导入依赖的package包/类
/**
* Accept request and reply with a generic runtime exception and a simple string message.
*
* @param uriInfo Information about the URL for the request
*/
@GET
@Timed(name = "logTimed")
@Metered(name = "logMetered")
@ExceptionMetered(name = "logException")
@Produces(MediaType.APPLICATION_JSON)
@Path("/genericbug")
public void getFailWithRuntimeException(@Context UriInfo uriInfo) {
RequestLog.startTiming(this);
try {
Thread.sleep(200);
throw new RuntimeException("Oops! Generic Exception");
} catch (InterruptedException ignore) {
// Do nothing
}
}