Recent Notes
Displaying keyword search results 1 - 10
Created by Dr. Xi on March 21, 2013 19:47:46
Last update: March 22, 2013 12:30:27
It's normal practice to import types from an external xsd file in WSDL like this:
<wsdl:types> <xsd:schema xmlns:xsd="htt... When you use <dynamic-wsdl> and have Commons XMLSchema on the class path, Spring-WS inlines the xsd in the wsdl. But that doesn't happen when you use <static-wsdl> . You can define a SimpleXsdSchema bean to expose the xsd: <?xml version="1.0" encoding="UTF-8"?> <beans x... where the bean id "hello" should match the schemaLocation attribute in the WSDL (without the .xsd suffix). But note that the SimpleXsdSchema does not inline the xsd. It only makes the xsd available via an HTTP URL. Alternatively, you can simply put the xsd file under the content directory of the webapp (just link any CSS or JavaScript). Anyway, that's a lot of manual...
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-sources Code 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 package After the webapp is deployed (Tomcat running on port 8080), the web service (WSDL) is available via...
Created by Dr. Xi on April 19, 2012 10:10:08
Last update: April 19, 2012 10:11:06
The default servlet for Tomcat is declared in $CATALINA_HOME/conf/web.xml :
<servlet>
<servlet-name>default</servle...
Therefore, static content is rendered by the default configuration unless you override it with your own definitions.
If you want to allow directory listing, just change the listing parameter to true :
<init-param>
<param-name>listings</para...
Change the welcome-file-list to display a default page in lieu of a directory listing:
<welcome-file-list>
<welcome-file>home.xhtml</...
Welcome pages are defined at the Web application level.
Created by Fang on January 10, 2010 00:19:30
Last update: January 31, 2012 16:28:42
Maven is a powerful yet complex tool. When I started learning Maven, the first obstacle was, of course, its complexity. The second, was the lack of documentation that can get me off the ground quickly. This tutorial is an attempt to create a pragmatic guide that aims to get you familiar with Maven in the quickest way possible. The main theme is to get you on some hands on experience to start out and lead you through the creation of a simple Java EE project as quickly as possible. Instead of trying to give you a good read, I try to get you on the journey right away. The topics are roughly ordered by the logical sequence but you can jump around in any way...
Created by Fang on January 31, 2012 15:40:34
Last update: January 31, 2012 15:41:28
This is a simple Hello World application with Spring 3 MVC. Like the default Apache HTTPd welcome page, it displays " It works! " when successfully deployed. The sole purpose is to show the minimum elements needed to setup Spring 3 MVC.
I use Maven since it's so much easier than downloading the dependencies manually.
Directory layout:
./src
./src/main
./src/main/webapp
./src/...
pom.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project...
WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app...
WEB-INF/applicationContext.xml (empty, but needed):
<?xml version="1.0" encoding="UTF-8"?>
<beans x...
WEB-INF/spring-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?>
<beans x...
WEB-INF/jsp/home.jsp :
<!DOCTYPE html>
<html>
<head>
<title>H...
Build with:
mvn clean package
The resulting webapp is target/springmvc.war .
Created by Fang on January 28, 2012 13:24:09
Last update: January 28, 2012 13:31:22
This is a simple JSP custom tags library with tag body. Just like the JSF counterpart , it splits a string and repeats the body for each word, i.e., with this markup:
<%@ taglib uri="http://custom.tag.com/demo" prefix...
output:
<html>
<body>
<p>Hello Tigger!</p>
<p>H...
With Maven, this is the directory structure:
./src
./src/main
./src/main/resources
./s...
There are three files to write:
pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0"...
src/main/java/tagdemo/IterateTag.java :
package tagdemo;
import java.io.IOException...
src/main/resources/META-INF/demotag.tld :
<?xml version="1.0" encoding="UTF-8"?>
<!DO...
Build with:
mvn clean install
To use it as a dependency in other Maven projects:
<dependency>
<groupId>tag-demo</groupId>
...
Created by lokf on January 13, 2012 14:10:42
Last update: January 13, 2012 14:10:42
For some reason I don't know writing to files in Android is very complicated and tedious. Here is some code for those who might need it. Apps should write in the SD in the directory /Android/data/package_name/files/ so that it is deleted with the app uninstall. package randomname; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.ByteBuffer; import android.content.Context; import android.os.Environment; import android.util.Log; public class FileIOLibrary { String packageName; boolean mExternalStorageAvailable = false; boolean mExternalStorageWriteable = false; FileIOLibrary(String packageNamep) { this.packageName=packageNamep; } public boolean isExternalStorageAvailable() { updateExternalStorageState(); return mExternalStorageAvailable; } public boolean isExternalStorageWritable() { updateExternalStorageState(); return mExternalStorageWriteable; } /** * writes the current state of SD card to the corresponding variables */ void updateExternalStorageState() {...
Created by Dr. Xi on January 06, 2012 14:02:09
Last update: January 06, 2012 14:02:09
In Java, the OS temporary directory is identified by the system property java.io.tmpdir :
public class TmpDir {
public static void ma...
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....
Created by freyo on September 09, 2011 11:43:36
Last update: September 09, 2011 11:45:45
When you run automated Android tests with Eclipse or from the command line, you get text output, which isn't good for reporting purposes. If you run a large set of test cases with automated build, the text report isn't very helpful. Fortunately, Android CTS generates test reports in XML with accompanying XSL to make it look nice in a browser. To run your own tests with Android CTS: Download Android CTS Make a new directory MyRepository under android-cts , alongside the existing repository directory. Copy host_config.xml from repository to MyRepository Create directory plans under MyRepository , add a test plan ( MyTests.xml ):
<?xml version="1.0" encoding="UTF-8"?> <TestPla... Create directory testcases under MyRepository . Copy TestDeviceSetup.apk from repository/testcases to MyRepository/testcases Under MyRepository/testcases , create a test...