Monday, September 26, 2005
A non-trivial log4cxx tutorial
Here we only discuss how to change the log4cxx properties on the fly.

1. Traverse current loggers list

LoggerList curLoggerList;
curLoggerList = Logger::getRootLogger()->getLoggerRepository()->getCurrentLoggers();
LoggerList::iterator i;
i = curLoggerList.begin();
while (i!=curLoggerList.end())
i->p->setLevel(log4cxx::Level::DEBUG); //i->p is the LoggerPtr

2. create Layout, Appender and change conversion pattern on the fly

static const char patternOne[] = "%r [%t] %-5p %c- %m%n %x%n";
//create PatternLayout with pattern patternOne

PatternLayoutPtr myLayoutPtr;
ConsoleAppenderPtr myConsoleAppenderPtr;

ACE_NEW_RETURN(myLayoutPtr, PatternLayout, -1);

//create ConsoleAppender with layout myLayoutPtr
ACE_NEW_RETURN(myConsoleAppenderPtr, ConsoleAppender, -1);

3. Create FileAppender on the fly

typedef log4cxx::helpers::ObjectPtrT

RollingFileAppenderPtr myRollingFileAppenderPtr;

LoggerPtr rootLogger = Logger::getRootLogger();

ACE_NEW_RETURN(myRollingFileAppenderPtr, RollingFileAppender, -1);

myRollingFileAppenderPtr->setMaxBackupIndex( 10 );
myRollingFileAppenderPtr->setMaxFileSize( "10MB" );
rootLogger->addAppender( myRollingFileAppenderPtr );

4. Use NDC

char hostname [MAXHOSTNAMELEN+1];
ACE_OS::hostname (hostname, sizeof (hostname));
int port = 8888;

{ //since we need to clean the content in oss, we set it as local
log4cxx::StringBuffer oss;
oss << "[" << hostname << ":" << port << "]" <<
__FILE__ << ":" << __LINE__ << "\n";
LOG4CXX_DEBUG(rootLogger, _T("starting blocking connect"));

Friday, September 23, 2005
UML learning

Q1. Aggregation and Composition

A1. Aggregation means a container for a collection of objects. A metaphor here is a Java Hashtable. It contains the references to one or many objects.

      Composition means an element or ingredient of an object. For example, an object A could have an object B as its member data in the form of value (Not a reference)

The value object is a composition, the reference object is a aggregation.



Monday, September 19, 2005
Auto completion in windows Command Line

Enable Command Completion (Windows NT/2000/XP) Popular
Command completion allows you to type a portion of a file name, and then have the system complete the rest by pressing the specified key. This is similar to the UNIX shell command completion feature.

Open your registry and find the key below.

Create a new DWORD value, or modify the existing value, called 'CompletionChar' and set it to equal the hex value of the required control character. For example to use the TAB key set the value to '9', to use BackSpace set the value to '8', to use Ctrl-D set the value to '4' and for Ctrl-F set the value to '6'.

Exit your registry, you may need to restart Windows for the change to take effect.

Now when you type the first part of a filename then press the specified key, Windows will complete the filename for you. Pressing the key multiple times will scroll through all the options.


Registry Settings

User Key: [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
System Key: [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
Value Name: CompletionChar
Data Type: REG_DWORD (DWORD Value)
Value Data: Hex Control Character



Thursday, September 15, 2005
An ACE online tutorial

Tricks in Resource Compiler or Compatible preprocessor

The question is:


We defined “SOAM_RELEASE_BUILD” in environment as an Integer like


but in resource script, we need the string value of it like

VALUE "ProductVersion", VersionNumber ß a string here


So we defined the following macro in the resource script like


#define xstr(x) str(x)

#define str(x) #x



If you want to stringify the result of expansion of a macro argument, you have to use two levels of macros.

#define xstr(s) str(s)

#define str(s) #s

#define foo 4

str (foo)

     ==> "foo"

xstr (foo)

     ==> xstr (4)

     ==> str (4)

     ==> "4"


quoted from



Wednesday, September 14, 2005
CVS branch or date

cvs co -r TUNDRA_DROP1 soam

Check out by date: for example 2006-01-18

cvs co -D20060118 soam

cvs up -D20060118 soam

HLD document creation and adding
For HLD, add to

cvs add -kb

-kb for binary format

1. find correspondent FS
2. finish HLD
3. start up implementation
4. testing/debugging

Sunday, September 11, 2005
XSharp Schema Draft

Saturday, September 10, 2005
XML Schema Design and XSharp


1. XML Schemas: Best Practices



2. XML Schema Tutorial


3. A Grammar for codeDOM



4. Using XML schemas effectively in WSDL design




Friday, September 09, 2005
Sed in MKS is weird

C:\>sh -c "sed -n 's_^///__w xml' < file1"


C:\>cat xml

this line is okay



C:\>cat file1

///this line is okay

can not see this line ///

/how about this one//

//and this?



C:\>cat xml

this line is okay



C:\> sed -n 's_^///__w xml' < file1


C:\>cat xml

this line is okay

can not see this line



Monday, September 05, 2005
How to create Web Service in Sun App Server
1. File list
Under the project directory, you prepare
build.xml -----> makefile for asant ----> customized properties
targets.xml ----> common targets for j2ee web services
src/${interface}.java ----> definition of the interface
src/${implementation}.java ----> implementation of the interface
conf/config-interface.xml ---> used by wscompile
conf/admin-password.txt ---> for asadmin command
lib/ ---> put any library you need
build/ ---> store the compiled class files

2. In fileSet the following properties
j2ee.home=C:/Sun/AppServer note:using slash "/" for path

3. run "asant build-service

4. start Sun App Server by running "asadmin start-domain domain1"

5. To deploy by GUI tool by running "deploytool"
6. For asant (command line)

A sample template zip file

Sunday, September 04, 2005
C++ source
C++ columns

C++ library cross reference

IBM C++ standard Library reference

Friday, September 02, 2005
Document-based Web Services, My comment
Quoted from

The strategies associated with the Document-Based Web Services pattern examined here are:

1. Using XML in the SOAP Body
2. Using a String in the SOAP Body
3. Using base64Encoded or raw bytes in the SOAP body
4. Using the xsd:any Element in WSDL
5. Using the xsd:anyType in WSDL

I have tried 2,3,4,5 before in my XSharp Project.

Pattern 1 is trivial. It is just the usage of extension of WSDL, analog to the "#include" instruction in C/C++ or "import" in Java/C#.

Pattern 2 uses String to hide the fact that this is XML string on the wire. It needs end user to validate the XML string.

Pattern 3 has no significant difference from Pattern 2. The only difference is the on-the-wire String is encoded in Base64. But Base64 is originally designed to encode binary type to String.

Pattern 4 will lead to the further XML parsing automatically since it is converted to XML element. It is end user's reponsibility to parse the incoming XML element snippet.

Pattern 5 is kind of dynamic parsing. In .NET, since every class has a root class "System.object", it is "System.object" that handles the XML snippet. In practice, we can cast this "System.object" to an object with specific class type. During the casting, XML parsing runtime system will try to match the XML to that object. But in Java world, it is handled the same as Pattern 4. Notice that in "RPC/Encoded" mode, Java will map the XML element to "Java.lang.object" at first, and try the type casting just like .NET.

Powered by Blogger