Messages

melissa:2YJaA7 http://google.com sdf http://google.com http://google.com sdfgwq

melissa:YhmI00 http://google.com sdf http://google.com http://google.com sdfgwq

melissa:N5ppGb http://google.com sdf http://google.com http://google.com sdfgwq

Oyuduaod:comment6

Fgmaebwo:comment2

User Name:

Content:

Tags:

gae(3)    css(3)    日志(3)    python(3)    svn(3)    weblogic(2)    ie(2)    ftp(2)    c++(2)    原则(2)    bugfree(2)    jira(2)    turbolinux(2)    tinyMCE(1)    南京(1)    static_dir(1)    django(1)   

 

 Categories:   All    管理 (27)    GAE (7)    杂谈 (14)    网站 (7)    Python (6)    Java (8)    c++ (1)    生活 (8)    我的儿子 (4)    Database (4)    骗局 (2)    source code (1)

scala是一道风景

2009-08-12 03:14:42   Category:Java   Comments:0   Reference:1   Tags:

    关注并发编程有一段时间了,看到了erlang,他的函数式的变成语言很有意思,但是其自有的运行环境还是比较庞大的。现在看到了scala,他基于jvm来运行,首先具有了一个经过考验的基础,并且能够好java的类库进行比较好的整合,是进入并发编程的一个不错的选择。希望scala能够有很好的发展,我也会进一步关注这个语言。

TrackBack URL:http://jum.appspot.com/feeds/trackBack/54661/

j2ee的事务

2009-01-17 15:11:39   Category:Java   Comments:0   Reference:0   Tags: j2ee

事务---容器管理事务

       |---Bean管理事务----JDBC事务

                                           |----JTA事务

TrackBack URL:http://jum.appspot.com/feeds/trackBack/4050/

A question of OpenCMS on Weblogic 8.1

2008-12-03 00:57:09   Category:Java   Comments:0   Reference:0   Tags:

  I always see the exception in log file.

<> <> <[ServletContext(id=1038141095,name=hnisicms,context-path=)] Error-page location: "/cms/system/handler/handle500.html" for the error-code: "500" causes an infinite loop condition as it throws the same code for which it has been mapped.>

  the path is correct. I think that the handle500.html maybe can not be compiled. So I change the type to a plain text, but I still see the exception. Why there are same problem? I do not know.

  I found that there are this problem from I disabled the static export function. And somebody have same problem in OpenCMS maillist.
http://mail.opencms.org/pipermail/opencms-dev/2006q2/024392.html
 So I will enable the static export function.

TrackBack URL:http://jum.appspot.com/feeds/trackBack/2841/

Jadclipse install for eciplse 3.3

2008-09-26 08:32:05   Category:Java   Comments:0   Reference:0   Tags:

  1. Download jad file from http://www.kpdus.com/jad.html#download
  2. Unzip into any directory
  3. Download eclipse plugin from http://nchc.dl.sourceforge.net/sourceforge/jadclipse/net.sf.jadclipse_3.3.0.jar
  4. Put this plugin into the plugins directory
  5. Reoot eclipse
  6. Modify window -> Preferences -> Java -> JadClipse ->Path to decompiler to the directory including jad.exe
  7. Modify the .class associations in Windows -> Perference -> General -> Editors -> File Associations  to “JadClipse Class File Viewer”
Good luck!

TrackBack URL:http://jum.appspot.com/feeds/trackBack/2042/

开发语言互相调用

2008-09-12 14:26:58   Category:Java   Comments:0   Reference:0   Tags: delphi , java , c++ , 调用

最近完成了一个项目,用到了多种开发语言间的相互调用,在此做一个总结,希望对大家有所帮助。
1 Java调用C++
Java调用C++的方法是在Java中声明native方法,而在C++动态链接库中实现该方法。
1) 在Java中把方法声明为native,传入参数和返回值建议采用简单类型,否则处理会比较麻烦;
2) 编译Java文件;
3) 用javah根据编译后的文件生成C++需要的头文件;
4) 在C++中实现该方法;
5) 编译C++的实现为动态链接库;
6) 在Java中用System.loadLibrary()方法加载生成的动态链接库文件。
我们就象调用一般的Java类一样调用该包含了本地方法的类了。
[注意]:
在使用过程中,发现有些API调用会失败,反复调用几次就成功了,没有找到很好的解决方法。
2 C++调用Java
在C++中调用Java的方法一般分为五个步骤:初始化虚拟机、获取类、创建类对象、调用方法和退出虚拟机。
1) 初始化虚拟机。
JNIEnv *env;
JavaVM *jvm;
JavaVMInitArgs vm_args;
JavaVMOption options[3];
int res;
//设置参数
options[0].optionString = "-Djava.compiler=NONE";
options[1].optionString = "-Djava.class.path=.";
options[2].optionString = "-verbose:jni";

vm_args.version = JNI_VERSION_1_4;
vm_args.nOptions = 3;
vm_args.options = options;
vm_args.ignoreUnrecognized = JNI_TRUE;
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if (res >= 0)
{
//创建虚拟机成功
}
一个应用程序只需要一个虚拟机,但是每个线程需要自己的虚拟机运行环境。我们从一个虚拟机获取多个当前线程的运行环境,代码如下:
int result=0;
result=jvm->AttachCurrentThread( reinterpret_cast( &env ), 0 );
if(result>=0)
{
//获取运行环境成功
}
当线程退出时,需要释放本线程使用的运行环境。
jvm->DetachCurrentThread();
2) 获取类
在进行方法调用之前,需要先获取相应的类,类名称必须包括包名,其中的“.”用“/”代替。
jclass JavaClass;
JavaClass = env->FindClass("com/test/TestInterface");
if(JavaClass != 0)
{
//获取成功
}
3) 创建类对象
如果需要调用的方法静态方法,则可以跳过本步骤。反之,则需要构造该对象。构造对象是通过调用类的构造函数来实现的,构咱函数的方法声明为, GetMethodID方法的参数在下一步骤详细说明。
jobject obj;
jmethodID ctor;
ctor = env->GetMethodID(JavaClass,"","()V");
if(ctor != 0)//获取方法成功
{
obj = env->NewObject(JavaClass, ctor);
}
4) 调用方法
调用一个方法需要两个步骤:获取方法句柄和调用方法。
jmethodID methodID = env->GetMethodID( JavaClass, "setTest","(I)V");
if(methodID!=0)//获取方法成功
{
env->CallVoidMethod( obj, methodID,12);
}
GetStaticMethodID是用来获取静态方法的定义,GetMethodID则是获取非静态的方法定义。他们传入参数的参数依次为:类定义、方法名称和方法的定义,方法的定义可以用jdk中带的javap工具反编译class文件获取,其格式如下:
public void setTest(int inTest);
Signature: (I)V
Signature后面的内容就是方法的定义。
CallVoidMethod 是对获取的方法进行调用,JNI接口中提供了一系列的同类方法,包括静态方法的调用函数(如:CallStaticXXXMethod)和非静态的方法 (如:CallXXXMethod),其中XXX表示的不同方法返回类型,包括int、object等等。
5) 退出虚拟机
退出虚拟机调用方法如下:
jvm->DestroyJavaVM();
在JNI接口定义和众多文档中都说,只有最后一个线程退出时,该方法才会返回,但是我只用一个线程,调用该方法也无法返回。故此建议系统退出时执行该方法,或者整个程序退出时,让虚拟机自己释放。
[注意]:
Ø 在处理中文字符串时,需要注意Java的char是双字节的,采用Unicode编码,在和C++中的char转换时,需要用到系统API:WideCharToMultiByte和MultiByteToWideChar。
Ø 注意对运行环境中对象引用时的释放,以免引起内存泄漏。
jstring str;
wchar_t *w_buffer =(wchar_t *)env->GetStringChars(str,0);
env->ReleaseStringChars(str,(const unsigned short *)w_buffer);
3 Delphi调用C++
Delphi可以直接调用C++开发的动态链接库中的函数,但是主要调用时方法需要申明为stdcall,否则可能会引起传入的参数压栈顺序不正确。
在实际应用中我们,我们很可能会需要传递类对象或者返回类对象,我们可以通过一种变通的方式来实现。我们通过五个步骤完成这个调用过程:定义C++接口、实现C++类、编译、定义Delphi接口和调用接口。
1) 定义C++接口
接口中需要被Delphi的方法必须声明为纯虚方法,该类需要声明为导出类。
class _declspec(dllexport) BaseTest
{
public:
virtual void __stdcall seTest(char * inData)=0;
}
2) 实现C++类
class Test:public BaseTest
{
public :
void __stdcall seTest(char * inData);
}
3) 编译
在动态库中声明一个导出的函数,由该方法生成对象,返回给动态链接库调用程序。
extern "C" _declspec(dllexport) void * __stdcall CreateObject();
编译C++实现的动态链接库,以备Delphi调用。
4) 定义Delphi接口
声明与C++中定义的相同的接口,方法也需要声明为纯虚方法。
type
MyTest=class
Procedure seTest (inData:PChar); virtual;stdcall;abstract;
5) 调用接口
在Delphi中调用动态链接库有两种方式,一种是在应用程序装载时调用,另一种是在应用程序运行时调用。比较简单的方式是应用程序装载时调用,在Delphi源文件中如下声明:
function CreateObject:MyTest ; stdcall; external 'Test.dll';
调用就比较简单了了。
MyTest test:=CreateObject();
Test.seTest(‘test String’);
[注意]:
Ø 传递参数的参数最好是简单类型,Delphi的string可以用PChar类型来传递,用户需要注意字符串空间的释放。
Ø 在Delphi中释放该对象调用free会失败,所以建议在定义接口时定义一个对象释放的方法,当然也必须是纯虚的方法。

TrackBack URL:http://jum.appspot.com/feeds/trackBack/1458/

Stripes

2008-09-12 14:24:14   Category:Java   Comments:0   Reference:0   Tags: stipes , Java

Stripe implements a MVC patern, but it is very simple. There is no config xml, no form and so on. It is easy to develop a page.

TrackBack URL:http://jum.appspot.com/feeds/trackBack/1456/

Weblogic for Eclipse plugin

2008-09-12 14:12:14   Category:Java   Comments:0   Reference:0   Tags: Eclipse , Weblogic

ECLIPSE的
help->software update->find and install..

输入
https://eclipse-plugin.projects.dev2dev.bea.com/update

TrackBack URL:http://jum.appspot.com/feeds/trackBack/1444/