Main BLOGGER
Google
WWW THIS BLOG
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
i++;
}
Logger::getRootLogger()->setLevel(log4cxx::Level::DEBUG);


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);
myLayoutPtr->setConversionPattern(patternOne);

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


3. Create FileAppender on the fly

typedef log4cxx::helpers::ObjectPtrT
RollingFileAppenderPtr;

RollingFileAppenderPtr myRollingFileAppenderPtr;

LoggerPtr rootLogger = Logger::getRootLogger();

ACE_NEW_RETURN(myRollingFileAppenderPtr, RollingFileAppender, -1);

myRollingFileAppenderPtr->setFile("myLogFile_server.log");
myRollingFileAppenderPtr->setMaxBackupIndex( 10 );
myRollingFileAppenderPtr->setMaxFileSize( "10MB" );
myRollingFileAppenderPtr->setLayout(myFileLayoutPtr);
myRollingFileAppenderPtr->activateOptions();
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::NDC::push(oss.str());
}
LOG4CXX_DEBUG(rootLogger, _T("starting blocking connect"));
log4cxx::NDC::pop();

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

“set SOAM_RELEASE_BUILD=12345”

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

 

http://www.ugcs.caltech.edu/info/gcc/cpp_3.html

 

 


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
/design/symphony/tundra/soa/design

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

Reference

1. XML Schemas: Best Practices

http://www.xfront.com/BestPracticesHomepage.html

 

 

2. XML Schema Tutorial

 

http://www.w3schools.com/schema/default.asp

 

3. A Grammar for codeDOM

http://www.mondrian-script.org/codedom/CodeDom%20Grammar.html

 

 

4. Using XML schemas effectively in WSDL design

 

http://devresource.hp.com/drc/slide_presentations/schemaWSDL/index.jsp

 

 

 


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

end

 

C:\>cat file1

///this line is okay

can not see this line ///

/how about this one//

//and this?

///end

 

C:\>cat xml

this line is okay

end

 

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

 

C:\>cat xml

this line is okay

can not see this line

end

 


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
build.properties ----> 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 build.properties fileSet the following properties
j2ee.home=C:/Sun/AppServer note:using slash "/" for path
project.home=project-path
project.name=project-name

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
http://rommel.cs.binghamton.edu/~pliu/Template-SunContainer.zip

Sunday, September 04, 2005
 
C++ source
C++ columns
http://www.artima.com/cppsource/index.html

C++ library cross reference
http://www.cplusplus.com/ref/

IBM C++ standard Library reference
ftp://ftp.software.ibm.com/software/os390/czos/standlib_1017.pdf

Friday, September 02, 2005
 
Document-based Web Services, My comment
Quoted from
http://java.sun.com/developer/technicalArticles/xml/jaxrpcpatterns2/

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

Google
WWW THIS BLOG