메서드 호출에 인터페이스를 제공하고 싶습니다. 주어진 인터페이스에 따라 메소드는 인스턴스를 작성해야합니다. 이 목적을 위해 나는 generics를 사용하여 메소드에 다른 종류의 인터페이스를 제공합니다. 여기에 예 :메서드 매개 변수로 inteface
static <T> T createClient(T, String endpointAddress) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean()
factory.setServiceClass(T.class)
factory.setAddress(endpointAddress)
(T) factory.create() // error -> java.lang.IllegalArgumentException: java.lang.Class is not an interface
}
// AccessibleClient is an interface. call method
createClient(AccessibleClient, "http://localhost/service")
나는 내 접근 방식이 적절한 해결책이라는 것을 모른다.
shouldn' 그것은'createClient (T param, String endpointAddress)'가 될 것인가? – sanbhat
인터페이스에서 인스턴스를 어떻게 만들 계획입니까? – Apurv
'createClient (AccessibleClient.class, "http : // localhost/service")' – gontard