Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • delight delight
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Commits
Collapse sidebar
  • delight
  • delightdelight
  • Wiki
  • Xmlrpc
  • ExampleUsingOwnInterfaceTypes

ExampleUsingOwnInterfaceTypes · Changes

Page history
started documentation of json-over-http delight authored Mar 05, 2019 by Andreas Lauer's avatar Andreas Lauer
Hide whitespace changes
Inline Side-by-side
xmlrpc/ExampleUsingOwnInterfaceTypes.md 0 → 100644
View page @ 91ec85b6
## [Home](https://git.opendfki.de/delight/delight/wikis/Home) | [Documentation](https://git.opendfki.de/delight/delight/wikis/Documentation) | [People / Contact](https://git.opendfki.de/delight/delight/wikis/people)
---
### Using Interface Types and Abstract Classes
The API is defined the same way as in the [preceeding use case](ExampleUsingOwnConceteTypes).
```java
public interface Api
{
Param returnParam();
void passAsParameter( Param p );
}
public class Impl implements Api
{
public Param returnParam() { return createParam( ... ); }
void passAsParameter( Param p ) { doSomethingWith( p ); }
}
```
Since Param is an interface, the runtime system cannot create instances of this type without further information.
We use the concrete attribute of the @XmlRpc annotation to tell the Delight runtime-system what concrete type to use to create instances of type Param.
In this case we use the concete class ''ParamImpl'' to create instances of type Param (note that ''ParamImpl'' has to be a Convertable and also has to implement ''Param''):
```java
@XmlRpc( type=Type.STRING,
concrete=ParamImpl.class )
public interface Param
{
public String printContent() { ... }
}
public class ParamImpl implements Param,
Convertable<String>
{
public ParamImpl( String xmlRpcRepresentation ) { processXmlRpc( xmlRpcRepresentation ); }
public String toXmlRpc() { return( createXmlRpcRep() ); }
}
```
#### Client side
The client can be created and used without further actions to take. No factories to register. No configuration files to load. Just like a local call to the API.
```java
Api remote_api = XmlRpc.createClient( Api.class, "handlerId", host, port );
Param p = remote_api.returnParam();
System.out.println( p.printContent() );
Param asParam = new ParamImpl(...);
remote_api.passAsParameter( asParam );
...
```
See also [Using own concrete types in your API](ExampleUsingOwnConceteTypes).
Examples in source code: [here](https://git.opendfki.de/delight/delight/tree/master/example-delight-webapp)
Clone repository
  • DocuFeature
  • ExampleServer
  • ExampleWebApp
  • Home
  • ServerSentEventsFeature
  • StatsFeature
  • people
  • xmlrpc
    • Documentation
    • ExampleUsingConverterRegistry
    • ExampleUsingOwnConceteTypes
    • ExampleUsingOwnInterfaceTypes
    • ExampleUsingThirdPartyTypes
    • ExampleUsingXmlRpcBeans
    • ExampleUsingXmlRpcCompliantTypes

Legal Notice, Imprint, Privacy Policy