|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface ServiceChannel
Factory that creates Cinnamon client proxies. In a usual deployment scenario Cinnamon will be used with Flex/Flash clients. But if you need to invoke the same services that you exposed to Flex clients from a Java client, this facility comes in handy, since you do not need to bother with exposing the same service for a second protocol.
Cinnamon comes with two implementations of this interface. One uses Cinnamons own XML configuration format, the other uses a Spring ApplicationContext to assemble the configuration artifacts from.
An example: Let's assume you want to invoke a method on a service with the following interface:
public interface EchoService {
public String echo (String str);
}
The code needed for the invocation would look like this (assuming that you load the configuration from the server, of course you could also load it locally):
ClientProxyFactory factory = new XmlClientProxyFactory();
factory.setConfigResource(new HttpResource("http://www.mycompany.com/service-config.xml"));
factory.setServiceUrl("http://www.mycompany.com/services/");
factory.configure();
EchoService service = factory.createService(EchoService.class, "echoService");
String result = service.echo("Hello World");
System.out.println("The result was: " + result);
| Method Summary | ||
|---|---|---|
void |
configure()
Method that should be called once after all properties have been set on this instance but before any service instances will be created. |
|
|
createService(Class<T> serviceInterface,
String serviceName)
Creates a client service proxy that implements the specified service interface. |
|
CinnamonConfig |
getConfig()
Returns the Cinnamon configuration. |
|
Set<String> |
getHeaderNames()
Returns an unmodifiable Set containing all header names for this message. |
|
Object |
getHeaderValue(String name)
Returns the header value for the given name. |
|
String |
getServiceUrl()
Returns the service URL that client proxies should connect to. |
|
void |
removeHeader(String name)
Removes the header for the given name. |
|
void |
setConfigResource(Resource resource)
Sets the resource to load the Cinnamonn configuration from. |
|
void |
setHeader(String name,
Object value)
Sets a header for this message. |
|
void |
setServiceUrl(String serviceUrl)
Sets the service URL that client proxies should connect to. |
|
| Method Detail |
|---|
void setConfigResource(Resource resource)
resource - the resource to load the Cinnamonn configuration fromvoid setServiceUrl(String serviceUrl)
serviceUrl - the service URL that client proxies should connect toString getServiceUrl()
CinnamonConfig getConfig()
void configure()
<T> T createService(Class<T> serviceInterface,
String serviceName)
serviceInterface - the service interfaceserviceName - the name of the service as specified in the Cinnamon configuration
void setHeader(String name,
Object value)
name - value - void removeHeader(String name)
name - the name of the header to removeSet<String> getHeaderNames()
Object getHeaderValue(String name)
name - the name of the header
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||