WEB开发网
开发学院WEB开发Jsp 最快最省构建漂亮合理的Java程序 阅读

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

 2008-01-05 09:47:08 来源:WEB开发网   
核心提示:一、编译运行示例:>javac -classpath ..\..\libnakedobjects.jar;..\..\liblog4j.jar;..\..libxerces.jar;classes;. Run.java二、示例程序(地址簿):// Address.javaimport org.nakedobjec

  一、编译运行示例:
  
  >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();
  }
  }

Tags:最快 构建 漂亮

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接