最快最省构建漂亮合理的Java程序

王朝java/jsp·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

一、编译运行示例:

javac -classpath ..\..\libnakedobjects.jar;..\..\liblog4j.jar;..\..libxerces.jar;classes;. Run.java

二、示例程序(地址簿):

// Address.java

import org.nakedobjects.object.*;

public class Address extends NakedObject {

private final TextString name = new TextString();

private final TextString address = new TextString();

private final TextString telephone = new TextString();

private final TextString mobile = new TextString();

private final TextString email = new TextString();

public TextString getName() {

return name;

}

public TextString getAddress() {

return address;

}

public TextString getTelephone() {

return telephone;

}

public TextString getMobile() {

return mobile;

}

public TextString getEmail() {

return email;

}

public Title title() {

return name.title();

}

}

// Run.java

import org.nakedobjects.*;

import org.nakedobjects.object.ClassSet;

import org.nakedobjects.utility.ConfigurationException;

import org.nakedobjects.object.ObjectStore;

import org.nakedobjects.xmlpersistence.XMLObjectStore;

import org.apache.log4j.Category;

import org.apache.log4j.Priority;

public class Run extends DefaultApplication {

public static void main(String args[]){

new Run();

}

public void classSet(ClassSet set){

set.addClass(Address.class);

}

protected void configureLogging() throws ConfigurationException {

super.configureLogging();

Category.getDefaultHierarchy().disable(Priority.INFO);

}

protected ObjectStore installObjectStore() throws ConfigurationException {

return new XMLObjectStore();

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航