JAVA Adoptions

Tags:

Java EE 5 Adoption
J2SE 5.0 Adoption
Mustang (Java SE 6) Snapshot Releases

Java EE 5는 썩 괜찮군요.. (라고는 하지만 기존의 코드와 현재의 코드를 비교해보면 옛날이 너무 엉망이었던거야라는 생각밖에 안드네요.) 특히 새로운 Persistence model을 쓰면 코드가 다음과 같이 변한다고 하는군요.

@Entity

public class Employee implements Serializable {

    private String id;
    private String name;
    private Department department;

    // Every entity must have a no-arg public/protected constructor.
    public Employee(){ }
    public Employee(String name, Department dept)
        { this.name = name;
        this.department = dept;
    }

    @Id // Every entity must have an identity.
    public String getId() { return id; }
    public void setId(String id) { this.id = id; }
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }

    @ManyToOne
    public Department getDepartment() { return department; }
    public void setDepartment(Department department) {
        this.department = department; }

    }
@Entity
public class Department {
    private String name;
    private Set<Employee> employees;
    public Department() { } 

    @Id
    public String getName() { return name; }
    public void setName(String name) {
        this.name = name; }

   @OneToMany(mappedBy="department")
   public Set<Employee> getEmployees() { return employees; }
   public void setEmployees(Set<Employee> employees) { 
       this.employees = employees; 
   }
    ...
}

한데 문제는 이놈의 Entity Bean 이 너무나 느리다고 악명이 높아서 어찌될런지는.

JAX-WS 2.0을 볼까요?

@WebService(name="CreditRatingService",

            targetNamespace="http://example.org")
@Stateless
public class CreditRating {

   @WebMethod(operationName="getCreditScore")
   public Score getCredit(@WebParam(name="customer")
                          Customer c) { ... }
}

이걸 보니 문득 이곳에서 아래와 같은 코드를 퍼오고 싶더군요.

[WebServiceBinding(Namespace = "http://example.org/weather")]
public interface IWeatherService
{
    [WebMethod]
    string GetForecast(string zip);

    [WebMethod]
    string GetForecastByDate(string zip, DateTime forecastDate);
}

Java EE 5라….