星期一, 五月 31, 2010
LISP CDR 和 CAR意思
而 cons 就是透过这两个缓存器而实作的。) Cons 很容易使用:
星期五, 五月 28, 2010
如何在Java Mail中是用Log4j来记录Java Mail Debug 信息?的
但是这个debug是直接输出到System.out的,需要用 >>来截获。
不过Java Mail 提供了setDebugOut(PrintStream)的接口,
就用这个可以实现 Java Mail和 log4j的联合使用
首先编写一个PrintStream的类做一个Bridge 同 Log4j
package com.email;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.log4j.*;
/**
*
* @author U253MIS038
*/
public class LoggingOutputStream extends OutputStream
{
protected boolean hasBeenClosed = false;
protected byte[] buf;
protected int count;
private int bufLength;
public static final int DEFAULT_BUFFER_LENGTH = 2048;
protected Logger logger;
protected Level level;
private LoggingOutputStream()
{
}
public LoggingOutputStream(Logger log, Level level)
throws IllegalArgumentException {
if (log == null) {
throw new IllegalArgumentException("cat == null");
}
if (level == null) {
throw new IllegalArgumentException("priority == null");
}
this.level = level;
logger = log;
bufLength = DEFAULT_BUFFER_LENGTH;
buf = new byte[DEFAULT_BUFFER_LENGTH];
count = 0;
}
public void close()
{
flush();
hasBeenClosed = true;
}
public void write(final int b) throws IOException
{
if (hasBeenClosed) {
throw new IOException("The stream has been closed.");
}
if (count == bufLength)
{
final int newBufLength = bufLength + DEFAULT_BUFFER_LENGTH;
final byte[] newBuf = new byte[newBufLength];
System.arraycopy(buf, 0, newBuf, 0, bufLength);
buf = newBuf;
bufLength = newBufLength;
}
buf[count] = (byte) b;
count++;
}
public void flush()
{
if (count == 0)
{
return;
}
if (count == 1 && ((char) buf[0]) == '\n')
{
reset();
return;
}
final byte[] theBytes = new byte[buf.length];
System.arraycopy(buf, 0, theBytes, 0, count);
logger.log(level, new String(theBytes));
reset();
}
private void reset()
{
count = 0;
}
}
2,然后再调用Java Mail中使用如下方法实现了定向
static Logger log = Logger.getLogger( email.class );
Properties props = System.getProperties();
config = new PropertiesConfiguration(PROP_FILE);
String mailip = config.getString("EMAIL_SERVER_IP");
props.put("mail.smtp.host", mailip);
Session session = Session.getInstance(props, null);
session.setDebugOut(new PrintStream(new LoggingOutputStream(Logger.getRootLogger(),Level.DEBUG), true));
session.setDebug(enableDebug);
星期一, 五月 24, 2010
java 如何确定一个对象是否数组?
Java array reflection: isArray vs. instanceof
那个方法好呢?if(obj.getClass().isArray()) {}
and
if(obj instanceof Object[]) {}
In general, use the At the JVM level, the The reflective approach ( There are two special cases: null references and references to primitive arrays. A null reference will cause Applied to a primitive array, the |
Ifobj
is of typeint[]
say, then that will
have an arrayClass
but not be an instance ofObject[]
.
So what do you want to do withobj
. If you are going to
cast it, go withinstanceof
. If you are going to use
reflection, then use.getClass().isArray()
.
总结:
isArray的方位更加广泛。
instance Object[]不能确别int[]等数组。
所以,那个更好,要看自己的具体情况了
星期六, 五月 15, 2010
Lisp命名规则2
低级函数用%开始和技术(%SUM%).语言标准名字的定义只允许用字母(A-Z)和*,+,-,/,1,2,<,=,> &
self-evaluating:
自执行
最重要的两个自执行常量:T和NIL代表 true和false.
另一类最重要的自执行符号是关键词符号.其名字以:开始
最基本的程序组件:
函数,变量,及宏
function,variable,macro
星期五, 五月 14, 2010
Lisp的命名
的名字是否用在变量,函数或其它东西一无所知。.它只是按照字符序列读出并被代表一个对象的名字。
几乎所有的字符都可用在名字中.空白字符不行,因为在list中元素也是用空白字符来分割的.
数字也可以用在名字中的一部分而不是解释成一个数字.相似的,名字可以包含一个句号(.),但无法阅读
只包含一个句号的名字。10个字符用于其他目的而不能在名字中出现:
- 1.开始和结束括号() open and close parentheses
- 2.双引号和单引号 "' double and single quotes
- 3.反引号(`)backtick
- 4.逗号 comma,
- 5.冒号: colon
- 6.分号;semicolon
- 7.反斜线 \ backslash
- 8.竖线| vertical bar
星期一, 五月 10, 2010
Re: Lisp注释语句.
缩进规则:
函数调用形式参数对齐
宏和特殊形式针对最后一个左括号缩进两格
;;;; 文件级别注释
;;; 段落级别注释
;; 函数内部代码注释
; 函数内部代码单行注释,放在代码后面
在阅读 Practical Common Lisp书的时候,突然想到LISP的注释符号应该是如何写呢?
google了下。
http://www.cc.gatech.edu/computing/classes/cs2360/ghall/style/com_mechanics.html
单句注释;分号表示 ;;;header
块注释 #|
Notes:zh
#
另外一种非常规的注释,是在代码中用“ ”来表示,比如下列代码(defun mumble_fcn ( arg1 arg2 )
"This function takes two arbitrary arguments and returns some
arbitrarily random result. NOTE: both arguments should be non-nil."
(do-random-thing (do-random-thing arg1 ) arg2 ))
星期五, 五月 07, 2010
SAP NetWeaver Composition Environment 7.2 Trial Version 安装 步骤 Create secure store 出现错误
首先下载了jdk 1.6.0_07之上的版本,我下载的是 1.6.0_20版本,并且下载了jce 6的文件,很小只有8K.
安装到步骤时候出现错误:
安装 :18/29的时候,Create secure store
根据提示打开错误日志:
C:\Program Files\sapinst_instdir\NW72_DEV_ADA\SERVER\SecureStoreCreate.log
发现如下提示:
FATAL: Main class "com.sap.security.core.server.secstorefs.SecStoreFS" cannot be started:
FATAL: java.lang.ExceptionInInitializerError
at javax.crypto.Cipher.getInstance(DashoA13*..)
at javax.crypto.Cipher.getInstance(DashoA13*..)
at iaik.security.provider.IAIK.a(Unknown Source)
at iaik.security.provider.IAIK.addAsJDK14Provider(Unknown Source)
at iaik.security.provider.IAIK.addAsJDK14Provider(Unknown Source)
at com.sap.security.core.server.secstorefs.Crypt.<clinit>(Crypt.java:85)
at com.sap.security.core.server.secstorefs.SecStoreFS.setSID(SecStoreFS.java:177)
at com.sap.security.core.server.secstorefs.SecStoreFS.handleCreate(SecStoreFS.java:838)
at com.sap.security.core.server.secstorefs.SecStoreFS.main(SecStoreFS.java:1308)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sap.engine.offline.OfflineToolStart.main(OfflineToolStart.java:161)
Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
at javax.crypto.SunJCE_b.<clinit>(DashoA13*..)
... 14 more
Caused by: java.lang.SecurityException: Cannot locate policy or framework files!
at javax.crypto.SunJCE_b.i(DashoA13*..)
at javax.crypto.SunJCE_b.g(DashoA13*..)
at javax.crypto.SunJCE_b$1.run(DashoA13*..)
at java.security.AccessController.doPrivileged(Native Method)
... 15 more
FATAL: com.sap.engine.offline.OfflineToolStart will abort now with exitcode 2
Solution:
copy
C:\Program Files\Java\jre6\lib\security 下所有文件到sap临时安装JVM目录下,
如果有提示是否需要覆盖,不要覆盖SAP原来的文件。
to
C:\Program Files\sapinst_instdir\NW72_DEV_ADA\SERVER\sapjvm\sapjvm_6\jre\lib\security
Lisp注释语句.
google了下。
http://www.cc.gatech.edu/computing/classes/cs2360/ghall/style/com_mechanics.html
单句注释;分号表示 ;;;header
块注释 #|
Notes:zh
#
另外一种非常规的注释,是在代码中用“ ”来表示,比如下列代码
(defun mumble_fcn ( arg1 arg2 )
"This function takes two arbitrary arguments and returns some
arbitrarily random result. NOTE: both arguments should be non-nil."
(do-random-thing (do-random-thing arg1 ) arg2 ))