Displaying keyword search results 1 - 10
Created by Dr. Xi on September 23, 2013 09:00:22 Last update: September 23, 2013 09:17:55
Tsung is an open-source multi-protocol distributed load testing tool. It's written in Erlang , but don't let that dissuade you. Here are some simple steps to get started. Install Tsung. On Ubuntu, this is simply: sudo apt-get install tsung . Create a config file ( tsung.xml ):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYP...Beware of the dumptraffic attribute. You might want to set it to false for a real load test. Run the test:
$ tsung -f tsung.xml start Starting Tsung "L...Generate the reports:
$ cd /home/drxi/.tsung/log/20130923-1031 $ /usr...Open the report file in your browser: file:///home/drxi/.tsung/log/20130923-1031/report.html . For HTTPS testing change the server line to:
<servers> <server host="192.168.80.160" port="...
Created by Dr. Xi on March 22, 2013 12:18:39 Last update: March 22, 2013 12:18:39
This is a step-by-step guide to create a "contract-first" web service with Apache CXF. It's a lot easier than doing the same thing with Spring-WS. The project uses standard Maven directory layout. Define the data types ( src/main/resources/hello.xsd ):
<xs:schema xmlns:xs="http://www.w3.org/200...Define the service ( src/main/resources/hello.wsdl ):
<?xml version='1.1' encoding='UTF-8'?> <wsdl:de...Create pom.xml :
<project xmlns="http://maven.apache.org/POM/4....Generate jaxb bindings:
$ mvn generate-sourcesCode the web service ( src/main/java/com/example/cxfdemo/HelloPortImpl.java ):
package com.example.cxfdemo; import javax.j...Declare the CXF servlet in web.xml ( src/main/webapp/WEB-INF/web.xml ):
<?xml version="1.0" encoding="UTF-8"?> <web-app...Wire up the web service implementation ( src/main/webapp/WEB-INF/cxf-servlet.xml ):
<?xml version="1.0" encoding="UTF-8"?> <beans x...Build the WAR:
$ mvn clean packageAfter the webapp is deployed (Tomcat running on port 8080), the web service (WSDL) is available via...
Created by Dr. Xi on March 21, 2013 20:29:14 Last update: March 22, 2013 08:58:08
Spring-WS documentation says you can use a Jaxb object as parameter or return type, provided that it is annotated with javax.xml.bind.annotation.XmlRootElement , or is an instance of javax.xml.bind.JAXBElement . But that's a lot easier said than done! For example, if sayHelloResponse is defined as:
<xs:element name="sayHelloResponse" type="tns:sayH...then the JAXB generated class is not annotated with XmlRootElement , therefore, unusable for Spring-WS. You have to define the type as:
<xs:element name="sayHelloResponse"> <xs:compl...in order to generate a type annotated with XmlRootElement . But that is not always possible. Alternatively, you can use the Maven plugin maven-jaxb2-plugin with the jaxb2-basics-annotate plugin (yes, plugin inside plugin) to inject the XmlRootElement annotation into the generated JAXB class. This is the pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"...and the binding file:
<?xml version="1.0" encoding="UTF-8" standalone="y......
Created by zhidao on January 25, 2012 19:27:53 Last update: January 25, 2012 19:28:47
The spring MVC annotation-driven declaration:
<?xml version="1.0" encoding="UTF-8"?> <beans x...does the following magic : Among others, registers: RequestMappingHandlerMapping RequestMappingHandlerAdapter ExceptionHandlerExceptionResolver in support of processing requests with annotated controller methods using annotations such as @RequestMapping , @ExceptionHandler , etc. Enables Spring 3 style type conversion through a ConversionService instance in addition to the JavaBeans PropertyEditors used for Data Binding. Enables support for formatting Number fields using the @NumberFormat annotation through the ConversionService . Enables support for formatting Date, Calendar, Long, and Joda Time fields using the @DateTimeFormat annotation, if Joda Time 1.3 or higher is present on the classpath. Enables support for validating @Controller inputs with @Valid , if a JSR-303 Provider is present on the classpath. Enables HttpMessageConverter support for @RequestBody method parameters and...
Created by Dr. Xi on January 17, 2012 11:58:16 Last update: January 17, 2012 11:58:16
Steps to configure JavaMail resource for Tomcat 6 & 7: Install JavaMail jar: download the JavaMail API , unzip the archive and copy mail.jar to $CATALINA_HOME/lib . Add JavaMail resource to $CATALINA_BASE/conf/context.xml :
<?xml version="1.0"?> <Context> . ...Add resource-ref for the JavaMail resource to your webapp WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app...Use the JavaMail resource in your webapp:
// import javax.naming.*; // import javax.mail....
Created by Fang on December 06, 2011 19:03:25 Last update: December 07, 2011 08:54:11
Our custom tag, as implemented in the previous note , is broken when a template is used. Create a template file ( home-template.xhtml ):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric...and a test page that uses it ( home.xhtml ):
<?xml version="1.0" encoding="UTF-8"?> <ui:comp...Then request the page with URL: http://localhost:8080/facelet-demo/home.jsf?name=Jack . You'll find that our hello tag works inside ui:repeat but fails to get the value defined by ui:param ! What's the problem? Our hello tag implementation evaluated the EL with the wrong EL context! This is the corrected implementation:
package com.example; import java.io.IOExcep...
Created by Fang on November 22, 2011 10:40:16 Last update: November 22, 2011 10:40:16
This is an example that uses tag handler, UI component and renderer together to support a custom taglib. The main purpose is to show how these components play together. The tag renders
<ui:param name="extra" value="el interpreted"/> ...as
<h3>my:foreach</h3> <ul class="css class" extra...These are the files: The tag handler ( src/main/java/com/example/ForeachTagHandler.java ):
package com.example; import java.util.Map; ...The UI component ( src/main/java/com/example/UIForeach.java ):
package com.example; import java.io.IOExcep...The renderer ( src/main/java/com/example/ForeachRenderer.java ):
package com.example; import java.io.IOExcep...Faces config ( src/main/resources/META-INF/faces-config.xml ):
<?xml version="1.0" encoding="UTF-8"?> <faces-c...Taglib config ( src/main/resources/META-INF/foreach.taglib.xml ):
<?xml version="1.0" encoding="UTF-8"?> <facelet...
Created by Fang on November 08, 2011 20:55:00 Last update: November 21, 2011 18:19:44
In the simple taglib example , I used a tag handler class to implement a taglib. This is an example to implement a taglib with a UI component. The purpose is to use a custom tag to split a string and print each part in a separate paragraph, i.e., print
<p>john</p> <p>steve</p> <p>mike</p>with custom tag <my:foreach> :
<my:foreach var="who" value="john steve mike"> ...These are the files: pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"...src/main/java/com/example/UIForeash.java :
package com.example; import java.io.IOExcep...src/main/resources/META-INF/faces-config.xml :
<?xml version="1.0" encoding="UTF-8"?> <faces-c...src/main/resources/META-INF/foreach.taglib.xml :
<?xml version="1.0" encoding="UTF-8"?> <facelet...How to use: Put the JAR file generated by the above project in the WEB-INF/lib folder of the web app. If the web app is a Maven project, just add the taglib project as a dependency:...
Created by Fang on November 10, 2011 09:26:12 Last update: November 10, 2011 09:26:12
Syntax highlighted XML schema for JSF 2.0 Application Configuration Resource File ( faces-config.xml ). Almost 3000 lines!
<?xml version="1.0" encoding="UTF-8"?> <xsd:sch...
Created by Fang on September 07, 2009 20:44:15 Last update: November 03, 2011 14:43:19
Step 1: Repackage a web app as EAR A Java EE application is a multimodule Maven project. At the very least you'll need to package a WAR and an EAR. To get started, I'll simply re-package the simple webapp as an EAR. Create a directory named javaee-app Copy the webapp from here to javaee-app . Rename struts1app to webapp . Create pom.xml under javaee-app :
<project> <modelVersion>4.0.0</modelVersion>...Create a directory named ear under javaee-app . Create pom.xml under ear :
<project> <modelVersion>4.0.0</modelVersion>...Modify pom.xml in the webapp directory so that it looks like this:
<project> <modelVersion>4.0.0</modelVersion> ...Build with " mvn package " in the javaee-app directory. You can see that ear-1.0.ear is successfully generated in javaee-app/ear/target . Maven successfully resolves dependencies between the sub-projects....