You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Suneet Shah <su...@gmail.com> on 2009/08/11 21:30:27 UTC
Working with Interfaces using JAX-WS
Hello:
How do you deal with or annotate interfaces in JAX-WS? I have the class
below that has a variable of type "Credential". Credential in this case
is an interface and is set using Spring's dependency injection. I have
pasted below the code for the interface and the implementation classes.
I am not sure what I should be annotating and how.:
public class AuthenticationContextImpl implements Serializable,
AuthenticationContext {
private String authenticationType;
private String resourceId;
private Credential credential;
private String domainId;
private String principal;
private String password;
@XmlJavaTypeAdapter(ObjectMapAdapter.class)
private Map<String,Object> authParam = new HashMap();
Above Credential is an interface. I have an implement to the interface,
but I am not sure how to deal with this.
public interface Credential {
}
public abstract class BaseCredential implements Credential {
public BaseCredential() {
}
}
XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PasswordCredential", propOrder = {
"domainId",
"principal",
"password"
})
public class PasswordCredential extends BaseCredential {
String domainId;
String principal;
String password;
public PasswordCredential() {
}
Thanks
Suneet
Re: Working with Interfaces using JAX-WS
Posted by Daniel Kulp <dk...@apache.org>.
It's done the same way as what you are going for the Map below. You need to
write a @XmlJavaTypeAdapter thing to map the Credential to/from a concrete
class.
Most likely, in your case, the adapter would map Credential <-->
BaseCredential and you would then use XmlSeeAlso annotations to register the
concrete subtypes (PasswordCredential plus others).
Dan
On Tue August 11 2009 3:30:27 pm Suneet Shah wrote:
> Hello:
>
> How do you deal with or annotate interfaces in JAX-WS? I have the class
> below that has a variable of type "Credential". Credential in this case
> is an interface and is set using Spring's dependency injection. I have
> pasted below the code for the interface and the implementation classes.
> I am not sure what I should be annotating and how.:
>
> public class AuthenticationContextImpl implements Serializable,
> AuthenticationContext {
>
> private String authenticationType;
> private String resourceId;
> private Credential credential;
> private String domainId;
> private String principal;
> private String password;
> @XmlJavaTypeAdapter(ObjectMapAdapter.class)
> private Map<String,Object> authParam = new HashMap();
>
>
> Above Credential is an interface. I have an implement to the interface,
> but I am not sure how to deal with this.
>
> public interface Credential {
>
> }
>
> public abstract class BaseCredential implements Credential {
>
> public BaseCredential() {
>
> }
> }
>
>
> XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "PasswordCredential", propOrder = {
> "domainId",
> "principal",
> "password"
> })
> public class PasswordCredential extends BaseCredential {
>
> String domainId;
> String principal;
> String password;
>
> public PasswordCredential() {
>
> }
>
>
> Thanks
> Suneet
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog