当前位置: 首页>>代码示例>>Java>>正文


Java Timed类代码示例

本文整理汇总了Java中com.yammer.metrics.annotation.Timed的典型用法代码示例。如果您正苦于以下问题:Java Timed类的具体用法?Java Timed怎么用?Java Timed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Timed类属于com.yammer.metrics.annotation包,在下文中一共展示了Timed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@PUT
@Timed	@Path("{id}")
@UnitOfWork
public Response update(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@PathParam("id") Long id, @Valid UserProject userProject) {
	Project p = pd.findById(currentProject.getId());
	if (p == null)
		throw new WebApplicationException(Response.Status.FORBIDDEN);
	User u = this.ud.findById(userProject.getIdForUser());
	userProject.setUser(u);
	userProject.setProject(p);
	
	UserProject newUserProject = upd.save(userProject);
	//
	URI uri = UriBuilder.fromResource(UserProjectResource.class).build(
			newUserProject.getId());
	log.info("the response uri will be " + uri);
	sro.reloadSessionForUser(u);
	return Response.created(uri).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:23,代码来源:UserProjectResource.java

示例2: delete

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@DELETE
@Timed
@Path("{id}")
@Consumes(MediaType.TEXT_PLAIN)
@UnitOfWork
public Response delete(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@PathParam("id") Long id) {
	Project p = pd.findById(currentProject.getId());

	UserProject deleteableUserProject = upd.findById(id);
	if(p.getId() != deleteableUserProject.getProject().getId()) throw new WebApplicationException(Response.Status.FORBIDDEN);
	upd.delete(id);
	sro.reloadSessionForUser(deleteableUserProject.getUser());
	return Response.ok().build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:18,代码来源:UserProjectResource.java

示例3: update

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@PUT
@Timed
@Path("{id}")
@UnitOfWork
public Response update(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@PathParam("id") Long id, @Valid Project project) {
	Project p = projectDAO.findById(id);
	if (p == null)
		throw new WebApplicationException(Response.Status.FORBIDDEN);
	if (!p.getId().equals(project.getId()))
		throw new WebApplicationException(Response.Status.FORBIDDEN);
	if(!p.getPrimaryAdmin().getId().equals(user.getId())) throw new WebApplicationException(Response.Status.FORBIDDEN);
	project.setPrimaryAdmin(user);
	
	Project newProject = projectDAO.save(project);
	//
	URI uri = UriBuilder.fromResource(ProjectResource.class).build(
			newProject.getId());
	log.info("the response uri will be " + uri);
	return Response.created(uri).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:24,代码来源:ProjectResource.java

示例4: accept

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@UnitOfWork
@Path("accept")
public Response accept(  @QueryParam("code") String code) {
	log.info("redeeming invite code "+code);
	Invite i = this.inviteDAO.findByCode(code);
	Map<String,String> m = new HashMap<String,String>();
	m.put("email",i.getEmail());
	m.put("projectName", i.getProject().getName());
	m.put("projectDesc", i.getProject().getName());
	m.put("fromUser",i.getInviter().getUsername());
	m.put("fromUserEmail",i.getInviter().getEmail());
	return Response.ok(m).build();

}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:17,代码来源:ProjectResource.java

示例5: joinProject

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
	@Timed
	@UnitOfWork
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	@Path("join")
	public Response joinProject(@SessionUser User user,JoinProjectRequest request) {
		log.info("GOT an new project "+request);
//TODO  setup a permissions sort of things.
		String name = request.getSelectedProject();
		Project p = this.projectDAO.findByName(name);
		if(p != null) {
			UserProject up = new UserProject();
			User u = this.userDAO.findById(user.getId());
			
			up.setProject(p);
			up.setUser(u);
			this.upDAO.save(up);
		} else {
			
		}
		return Response.ok().build();
	}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:24,代码来源:ProjectResource.java

示例6: getNextEvent

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@Produces(MediaType.APPLICATION_JSON)
@UnitOfWork
@Path("nextEvent")
public NextEventRecord getNextEvent(@SessionAuth(required={Priv.CATEGORIZE}) SessionFilteredAuthorization auths,@SessionCurProj Project currentProject,@SessionUser User user, @QueryParam("lastEvent") String lastEventIdStr) {
	Long lastEventId = null;
	try {
		lastEventId = Long.parseLong(lastEventIdStr);
	} catch (NumberFormatException e) {
		// stupid API ignore this exception
	}
	NextEventRecord ner = this.ds.makeNextEventRecord(user,currentProject,lastEventId);
	if(ner.getImageEvent() != null) {
		for(ImageRecord ir: ner.getImageEvent().getImageRecords()) {
			ir.getDatetime();
		}
		ImageEvent upie = initializeAndUnproxy(ner.getImageEvent());
		ner.setImageEvent(upie);
	}
	return ner;
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:23,代码来源:ImageResource.java

示例7: add

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@UnitOfWork
public Response add(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@Valid Camera camera) {
	log.info("Ok we have the following session user " + user);
	Project p = pd.findById(currentProject.getId());
	if (p == null)
		throw new WebApplicationException(Response.Status.FORBIDDEN);
	camera.setProject(p);
	Camera newCamera = cd.save(camera);

	URI uri = UriBuilder.fromResource(CameraResource.class).build(
			newCamera.getId());
	log.info("the response uri will be " + uri);
	return Response.created(uri).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:20,代码来源:CameraResource.java

示例8: update

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@PUT
@Timed
@Path("{id}")
@UnitOfWork
public Response update(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@PathParam("id") Long id, @Valid Camera camera) {
	Project p = pd.findById(currentProject.getId());
	if (p == null)
		throw new WebApplicationException(Response.Status.FORBIDDEN);
	if (!p.getId().equals(camera.getProject().getId()))
		throw new WebApplicationException(Response.Status.FORBIDDEN);

	Camera newCamera = cd.save(camera);
	//
	URI uri = UriBuilder.fromResource(CameraResource.class).build(
			newCamera.getId());
	log.info("the response uri will be " + uri);
	return Response.created(uri).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:22,代码来源:CameraResource.java

示例9: delete

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@DELETE
@Timed
@Path("{id}")
@Consumes(MediaType.TEXT_PLAIN)
@UnitOfWork
public Response delete(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@PathParam("id") Long id) {
	Project p = pd.findById(currentProject.getId());

	Camera deleteableCamera = cd.findById(id);
	if(p.getId() != deleteableCamera.getProject().getId()) throw new WebApplicationException(Response.Status.FORBIDDEN);
	cd.delete(id);
	return Response.ok().build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:17,代码来源:CameraResource.java

示例10: lookupToo

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@Path("lookup")
@UnitOfWork
public List<UserTO> lookupToo(@SessionUser User user, @QueryParam("text") String snippet,@QueryParam("p") String projectIdStr) {
	if(snippet == null) throw new NotFoundException();
	if(snippet.length() < 3) throw new NotFoundException();
	Project project = null;
	try {
		Long projectId = null;
		projectId = Long.parseLong(projectIdStr);
		project = this.projectDAO.findById(projectId);
	} catch(NumberFormatException nfe) {}
	User u = this.ud.findByPortionOfEmailUsername(snippet);
	if(u == null) return null;
	// now remove it, if it's already in existence.
	List<UserProject> current= this.upDAO.findByUserIdProjectId(u, project);
	if(current.size() > 0) throw new NotFoundException();
	ArrayList<UserTO> l = new ArrayList<UserTO>();
	l.add(new UserTO(u));
	return l;
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:23,代码来源:UserResource.java

示例11: userupdate

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
	@Timed
	@Path("userupdate")
	@UnitOfWork
	public Response userupdate(@SessionUser User user, @Context HttpServletRequest request, UserUpdate updatedCurUser) {
		int userId = user.getId();
		User editUser = this.ud.findById(userId);
		
//		email  -- this should require a REVERIFICATION
		
		
		this.ud.save(editUser);

		clearSession(request);
		loadAssociatedAndSetSessionWith(request, editUser);
		loadStartingProject(request,editUser);

		
		// there is an implicit SAVE on editUser
		return Response.status(Response.Status.OK).build();
	}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:22,代码来源:UserResource.java

示例12: lostpw

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@Path("lostpw")
@UnitOfWork
public Response lostpw(String resetemail) {
	log.info("starting reset password on "+resetemail);
	// now create and send via email a token which will return to a page on which a new PW can be chosen.
	// that page should simple reset the password IF  the token is valid and matches the email.
	// token should live for a fixed amount of time. 10 minutes ?
	User p = this.ud.findByEmail(resetemail);
	if(p != null) {
		String token = tokendao.createToken(p);
		try {
			emailService.sendPasswordResetEmail(p, token);
		} catch (MessagingException e) {

		}
	}
	// return OK regardless so that we don't "leak" data about membership.
	return Response.status(Response.Status.OK).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:22,代码来源:UserResource.java

示例13: verify

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@Path("verify")
@UnitOfWork
public Response verify(@Context HttpServletRequest request,VerifyRequest req) {
	String code = req.getVerifyCode();
	User p = ud.findByVerifyCode(code);
	if(p == null) {
		return Response.status(Response.Status.NOT_FOUND).build();
	}
	p.setVerified(true);
	try {
		this.emailService.sendUsANotification(p);
	} catch (MessagingException e) {
		// do nothing here
	}
	if(autoLoginOnVerify) {
		loadAssociatedAndSetSessionWith(request,p);
		loadStartingProject(request,p);
	}
	VerifyResponse vr = new VerifyResponse(p);
	return Response.ok(vr, MediaType.APPLICATION_JSON).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:24,代码来源:UserResource.java

示例14: getEventData

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@UnitOfWork
@Path("event/{eventId}")
public Response getEventData(@SessionAuth(required={Priv.REPORT}) SessionFilteredAuthorization auths,@SessionUser User user, @SessionCurProj Project currentProject, @PathParam("eventId") Long eventId) {
	if(eventId == null) return Response.status(Status.NOT_FOUND).build();
	ImageEvent e = eventDAO.findById(eventId);
	if(e == null) return Response.status(Status.NOT_FOUND).build();
	// load data about categorization
	List<SpeciesCount> lsc = this.rd.findCategorizationData(e);
	// load flagging data
	Integer reviewCount = this.reviewDao.getReviewFlagCount(e,user);
	
	Map<String, Integer> m = new HashMap<String,Integer>();
	// load images data included "good" images data
	for(ImageRecord ir :e.getImageRecords()) {
		Integer good = this.goodDao.getGoodFlagCount(ir,user);
		m.put(ir.getId(),good);
	}
	CurrentEventInfo cei = new CurrentEventInfo(lsc,reviewCount,m);
	return Response.ok(cei).build();		
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:23,代码来源:ReportResource.java

示例15: getFieldMappings

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@Override
@Timed
public TableFieldMapping getFieldMappings(String table) throws FoxtrotException {
    table = ElasticsearchUtils.getValidTableName(table);

    if (!tableMetadataManager.exists(table)) {
        throw FoxtrotExceptions.createTableMissingException(table);
    }
    try {
        ElasticsearchMappingParser mappingParser = new ElasticsearchMappingParser(mapper);
        Set<FieldTypeMapping> mappings = new HashSet<>();
        GetMappingsResponse mappingsResponse = connection.getClient().admin()
                .indices().prepareGetMappings(ElasticsearchUtils.getIndices(table)).execute().actionGet();

        for (ObjectCursor<String> index : mappingsResponse.getMappings().keys()) {
            MappingMetaData mappingData = mappingsResponse.mappings().get(index.value).get(ElasticsearchUtils.DOCUMENT_TYPE_NAME);
            mappings.addAll(mappingParser.getFieldMappings(mappingData));
        }
        return new TableFieldMapping(table, mappings);
    } catch (IOException e) {
        throw FoxtrotExceptions.createExecutionException(table, e);
    }
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:24,代码来源:ElasticsearchQueryStore.java


注:本文中的com.yammer.metrics.annotation.Timed类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。