List of usage examples for org.springframework.util StopWatch start
public void start(String taskName) throws IllegalStateException
From source file:org.springframework.context.annotation.AnnotationProcessorPerformanceTests.java
@Test public void testPrototypeCreationWithAutowiredPropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh();/* w w w . ja va2 s . c om*/ RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
From source file:org.springframework.context.annotation.AnnotationProcessorPerformanceTests.java
@Test public void testPrototypeCreationWithOverriddenAutowiredPropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh();//from w w w . j a v a 2 s . com RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse")); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 6000); }
From source file:org.springframework.context.expression.ApplicationContextExpressionTests.java
@Test public void prototypeCreationIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog);// w w w . j a va 2 s.c om GenericApplicationContext ac = new GenericApplicationContext(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getConstructorArgumentValues().addGenericArgumentValue("#{systemProperties.name}"); rbd.getPropertyValues().add("country", "#{systemProperties.country}"); ac.registerBeanDefinition("test", rbd); ac.refresh(); StopWatch sw = new StopWatch(); sw.start("prototype"); System.getProperties().put("name", "juergen"); System.getProperties().put("country", "UK"); try { for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ac.getBean("test"); assertEquals("juergen", tb.getName()); assertEquals("UK", tb.getCountry()); } sw.stop(); } finally { System.getProperties().remove("country"); System.getProperties().remove("name"); } assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 6000); }
From source file:org.springframework.xd.dirt.integration.bus.MessageBusSupportBenchmarkTests.java
@Test public void run() { StopWatch watch = new StopWatch("MessageBusSupport"); watch.start("simple tuple codec"); runBenchmark(TupleBuilder.tuple().of("foo", "bar", "val", 1234)); watch.stop();/* w w w .j a v a 2 s . c o m*/ watch.start("string payload"); runBenchmark(StringUtils.leftPad("hello", 1000, "*")); watch.stop(); System.out.println(watch.prettyPrint()); }
From source file:ro.cs.cm.ws.client.om.OMWebServiceClient.java
public GetUserAuthBySecurityTokenResponse getUserAuthBySecurityToken(String securityToken) throws XmlMappingException, IOException, WSClientException { logger.debug("getUserAuthBySecurityToken START"); StopWatch sw = new StopWatch(); sw.start("getUserAuthBySecurityToken"); GetUserAuthBySecurityTokenResponse getUserAuthBySecurityTokenResponse = null; try {/*from ww w . j av a2 s.c om*/ GetUserAuthBySecurityTokenRequest getUserBySecurityTokenRequest = new GetUserAuthBySecurityTokenRequest(); getUserBySecurityTokenRequest.setSecurityToken(securityToken); getUserBySecurityTokenRequest.setModule(IConstant.MODULE_ID); //unmarshall the response to an OrganisationSimple bean getUserAuthBySecurityTokenResponse = (GetUserAuthBySecurityTokenResponse) getWebServiceTemplate() .marshalSendAndReceive(getUserBySecurityTokenRequest); logger.debug(getUserAuthBySecurityTokenResponse.getUserAuth()); } catch (SoapFaultClientException soapFault) { SoapFaultDetail soapFaultDetail = soapFault.getSoapFault().getFaultDetail(); //if the soap fault detail field is empty, it means another type of exception than EndpointException has been thrown if (soapFaultDetail == null) { throw new WSClientException(soapFault.getFaultCode().toString(), soapFault.getFaultStringOrReason(), soapFault); //soap fault detail field not empty means the Web Service has thrown an EndpointException } else { SoapFaultDetailElement soapFaultDetailElement = (SoapFaultDetailElement) soapFaultDetail .getDetailEntries().next(); //unmarshall the soap fault detail element to a WS specific bean named dmeEndpointExceptionBean JAXBElement<OMEndpointExceptionBean> endpointException = (JAXBElement<OMEndpointExceptionBean>) getWebServiceTemplate() .getUnmarshaller().unmarshal(soapFaultDetailElement.getSource()); //throw a new WSClientException with the code and message of the DMEEndpointExceptionBean retrieved previously throw new WSClientException(endpointException.getValue().getCode(), endpointException.getValue().getMessage(), soapFault); } } logger.debug("getUserAuthBySecurityToken END"); sw.stop(); logger.debug(sw.prettyPrint()); return getUserAuthBySecurityTokenResponse; }
From source file:ro.cs.cm.ws.client.om.OMWebServiceClient.java
public List<UserSimple> getUsersSimpleByOrganizationId(int organizationId, boolean isNotDeleted) throws XmlMappingException, IOException, WSClientException { logger.debug("getUsersSimpleByOrganizationId START"); StopWatch sw = new StopWatch(); sw.start("getUsersSimpleByOrganizationId"); List<UserSimple> users = null; try {// w ww . jav a 2 s .c o m //create the bean marshalled into the request GetUsersSimpleRequest getUsersSimpleRequest = new GetUsersSimpleRequest(); getUsersSimpleRequest.setOrganizationId(organizationId); getUsersSimpleRequest.setNotDeleted(isNotDeleted); //unmarshall the response to an OrganisationSimple bean users = ((GetUsersSimpleResponse) getWebServiceTemplate().marshalSendAndReceive(getUsersSimpleRequest)) .getUsers(); } catch (SoapFaultClientException soapFault) { SoapFaultDetail soapFaultDetail = soapFault.getSoapFault().getFaultDetail(); //if the soap fault detail field is empty, it means another type of exception than EndpointException has been thrown if (soapFaultDetail == null) { throw new WSClientException(soapFault.getFaultCode().toString(), soapFault.getFaultStringOrReason(), soapFault); //soap fault detail field not empty means the Web Service has thrown an EndpointException } else { SoapFaultDetailElement soapFaultDetailElement = (SoapFaultDetailElement) soapFaultDetail .getDetailEntries().next(); //unmarshall the soap fault detail element to a WS specific bean named dmeEndpointExceptionBean JAXBElement<OMEndpointExceptionBean> endpointException = (JAXBElement<OMEndpointExceptionBean>) getWebServiceTemplate() .getUnmarshaller().unmarshal(soapFaultDetailElement.getSource()); //throw a new WSClientException with the code and message of the DMEEndpointExceptionBean retrieved previously throw new WSClientException(endpointException.getValue().getCode(), endpointException.getValue().getMessage(), soapFault); } } logger.debug("getUsersSimpleByOrganizationId END"); sw.stop(); logger.debug(sw.prettyPrint()); return users; }
From source file:ro.cs.cm.ws.client.om.OMWebServiceClient.java
/** * Get a person by it's id//from w w w. jav a 2 s . c o m * * @author Adelina * * @param personId * @return * @throws XmlMappingException * @throws IOException * @throws WSClientException */ public GetPersonSimpleResponse getPersonSimple(Integer personId) throws XmlMappingException, IOException, WSClientException { logger.debug("getPersonSimple - START"); logger.debug("personId = " + personId); StopWatch sw = new StopWatch(); sw.start("getPersonSimple"); GetPersonSimpleResponse getPersonSimpleResoponse = new GetPersonSimpleResponse(); try { // create the bean marshalled into the request GetPersonSimpleRequest getPersonSimpleRequest = new GetPersonSimpleRequest(); getPersonSimpleRequest.setPersonId(personId); logger.debug("before unmarshal"); //unmarshall the response getPersonSimpleResoponse = (GetPersonSimpleResponse) getWebServiceTemplate() .marshalSendAndReceive(getPersonSimpleRequest); logger.debug( "-------------------------------------------------------------------------------------------------"); WSUser person = getPersonSimpleResoponse.getPerson(); logger.debug("person = " + person); logger.debug( "-------------------------------------------------------------------------------------------------"); } catch (SoapFaultClientException soapFault) { SoapFaultDetail soapFaultDetail = soapFault.getSoapFault().getFaultDetail(); //if the soap fault detail field is empty, it means another type of exception than EndpointException has been thrown if (soapFaultDetail == null) { throw new WSClientException(soapFault.getFaultCode().toString(), soapFault.getFaultStringOrReason(), soapFault); //soap fault detail field not empty means the Web Service has thrown an EndpointException } else { SoapFaultDetailElement soapFaultDetailElement = (SoapFaultDetailElement) soapFaultDetail .getDetailEntries().next(); //unmarshall the soap fault detail element to a WS specific bean named dmeEndpointExceptionBean JAXBElement<OMEndpointExceptionBean> endpointException = (JAXBElement<OMEndpointExceptionBean>) getWebServiceTemplate() .getUnmarshaller().unmarshal(soapFaultDetailElement.getSource()); //throw a new WSClientException with the code and message of the DMEEndpointExceptionBean retrieved previously throw new WSClientException(endpointException.getValue().getCode(), endpointException.getValue().getMessage(), soapFault); } } logger.debug("getPersonSimple - END"); sw.stop(); logger.debug(sw.prettyPrint()); return getPersonSimpleResoponse; }
From source file:ro.cs.cm.ws.client.ts.TSWebServiceClient.java
/** * Deletes the project details/*from w ww . j a v a2 s . co m*/ * * @author Adelina * * @param projectId * @throws XmlMappingException * @throws IOException * @throws WSClientException * @throws BusinessException */ public void deleteProjectDetails(Integer projectId) throws XmlMappingException, IOException, WSClientException, BusinessException { logger.debug("deleteProjectDetails START"); StopWatch sw = new StopWatch(); sw.start("deleteProjectDetails"); try { //create the bean marshalled into the request GetProjectIdForDeleteRequest getProjectIdForDeleteRequest = new GetProjectIdForDeleteRequest(); getProjectIdForDeleteRequest.setProjectId(projectId); //unmarshall the response Project project = BLProject.getInstance().getWithStatus(projectId); if (project == null) { getWebServiceTemplate().marshalSendAndReceive(getProjectIdForDeleteRequest); } } catch (SoapFaultClientException soapFault) { SoapFaultDetail soapFaultDetail = soapFault.getSoapFault().getFaultDetail(); //if the soap fault detail field is empty, it means another type of exception than EndpointException has been thrown if (soapFaultDetail == null) { throw new WSClientException(soapFault.getFaultCode().toString(), soapFault.getFaultStringOrReason(), soapFault); //soap fault detail field not empty means the Web Service has thrown an EndpointException } else { SoapFaultDetailElement soapFaultDetailElement = (SoapFaultDetailElement) soapFaultDetail .getDetailEntries().next(); //unmarshall the soap fault detail element to a WS specific bean named dmeEndpointExceptionBean JAXBElement<TSEndpointExceptionBean> endpointException = (JAXBElement<TSEndpointExceptionBean>) getWebServiceTemplate() .getUnmarshaller().unmarshal(soapFaultDetailElement.getSource()); //throw a new WSClientException with the code and message of the DMEEndpointExceptionBean retrieved previously throw new WSClientException(endpointException.getValue().getCode(), endpointException.getValue().getMessage(), soapFault); } } logger.debug("deleteProjectDetails END"); sw.stop(); logger.debug(sw.prettyPrint()); }
From source file:ro.cs.cm.ws.client.ts.TSWebServiceClient.java
/** * Finish the project details/*w ww . j a v a 2s. c o m*/ * * @author Adelina * * @param projectId * @throws XmlMappingException * @throws IOException * @throws WSClientException * @throws BusinessException */ public void finishProjectDetails(Integer projectId) throws XmlMappingException, IOException, WSClientException, BusinessException { logger.debug("finishProjectDetails START"); StopWatch sw = new StopWatch(); sw.start("finishProjectDetails"); try { //create the bean marshalled into the request GetProjectIdForFinishRequest getProjectIdForFinishRequest = new GetProjectIdForFinishRequest(); getProjectIdForFinishRequest.setProjectId(projectId); // unmarshall the response Project project = BLProject.getInstance().getWithStatus(projectId); if (project != null) { if (project.getStatus() == IConstant.NOM_PROJECT_STATUS_CLOSED) { getWebServiceTemplate().marshalSendAndReceive(getProjectIdForFinishRequest); } } } catch (SoapFaultClientException soapFault) { SoapFaultDetail soapFaultDetail = soapFault.getSoapFault().getFaultDetail(); //if the soap fault detail field is empty, it means another type of exception than EndpointException has been thrown if (soapFaultDetail == null) { throw new WSClientException(soapFault.getFaultCode().toString(), soapFault.getFaultStringOrReason(), soapFault); //soap fault detail field not empty means the Web Service has thrown an EndpointException } else { SoapFaultDetailElement soapFaultDetailElement = (SoapFaultDetailElement) soapFaultDetail .getDetailEntries().next(); //unmarshall the soap fault detail element to a WS specific bean named dmeEndpointExceptionBean JAXBElement<TSEndpointExceptionBean> endpointException = (JAXBElement<TSEndpointExceptionBean>) getWebServiceTemplate() .getUnmarshaller().unmarshal(soapFaultDetailElement.getSource()); //throw a new WSClientException with the code and message of the DMEEndpointExceptionBean retrieved previously throw new WSClientException(endpointException.getValue().getCode(), endpointException.getValue().getMessage(), soapFault); } } logger.debug("finishProjectDetails END"); sw.stop(); logger.debug(sw.prettyPrint()); }
From source file:ro.cs.cm.ws.client.ts.TSWebServiceClient.java
/** * Abort the project details/*from w ww . ja va2s . com*/ * * @author Adelina * * @param projectId * @throws XmlMappingException * @throws IOException * @throws WSClientException * @throws BusinessException */ public void abortProjectDetails(Integer projectId) throws XmlMappingException, IOException, WSClientException, BusinessException { logger.debug("abortProjectDetails START"); StopWatch sw = new StopWatch(); sw.start("abortProjectDetails"); try { //create the bean marshalled into the request GetProjectIdForAbortRequest getProjectIdForAbortRequest = new GetProjectIdForAbortRequest(); getProjectIdForAbortRequest.setProjectId(projectId); // unmarshall the response Project project = BLProject.getInstance().getWithStatus(projectId); logger.debug("project status xxxxxxxxx = " + project.getStatus()); if (project != null) { if (project.getStatus() == IConstant.NOM_PROJECT_STATUS_ABORTED) { logger.debug("yyyyyyyyyyyyyyyyy"); getWebServiceTemplate().marshalSendAndReceive(getProjectIdForAbortRequest); } } } catch (SoapFaultClientException soapFault) { SoapFaultDetail soapFaultDetail = soapFault.getSoapFault().getFaultDetail(); //if the soap fault detail field is empty, it means another type of exception than EndpointException has been thrown if (soapFaultDetail == null) { throw new WSClientException(soapFault.getFaultCode().toString(), soapFault.getFaultStringOrReason(), soapFault); //soap fault detail field not empty means the Web Service has thrown an EndpointException } else { SoapFaultDetailElement soapFaultDetailElement = (SoapFaultDetailElement) soapFaultDetail .getDetailEntries().next(); //unmarshall the soap fault detail element to a WS specific bean named dmeEndpointExceptionBean JAXBElement<TSEndpointExceptionBean> endpointException = (JAXBElement<TSEndpointExceptionBean>) getWebServiceTemplate() .getUnmarshaller().unmarshal(soapFaultDetailElement.getSource()); //throw a new WSClientException with the code and message of the DMEEndpointExceptionBean retrieved previously throw new WSClientException(endpointException.getValue().getCode(), endpointException.getValue().getMessage(), soapFault); } } logger.debug("abortProjectDetails END"); sw.stop(); logger.debug(sw.prettyPrint()); }