@Documented
@Inherited
@Target(value=TYPE)
@Retention(value=CLASS)
public @interface SonicPOJO
Annotation attributes describe UI rendering, global settings of the ESB service type implemented by this POJO class.
Sonic POJO(Plain Old Java Object) Services allow Sonic services to be developed and unit tested without the need for Sonic API expertise. Unit testing does not require a running domain, or, complex mocks for the Sonic APIs. Similar to Spring, service initialization parameters translate to Java bean properties "injected" by the environment at initialization time(InitParameter ). POJOs that implement com.sonicsw.xq.XQServiceLifecycle can be informed on service lifecycle methods through this interface.
@SonicPOJO ESB Service:
Example usage:
import com.aurea.sonic.esb.pojo.annotation.InitParameter;
import com.aurea.sonic.esb.pojo.annotation.Operation;
import com.aurea.sonic.esb.pojo.annotation.Parameter;
import com.aurea.sonic.esb.pojo.annotation.SonicPOJO;
import org.apache.log4j.Logger;
@SonicPOJO(description = "ConverterService POJO service")
public class ConverterService{
private final Logger log = Logger.getLogger(this.getClass());
@InitParameter(description = "Log operation calls", defaultValue = "false")
private boolean verbose;
public void setVerbose(final boolean verbose) {
this.verbose = verbose;
}
public boolean isVerbose() {
return verbose;
}
@Operation(description = "Concatenate strings")
public String concatenate(final String strList[], final String delimiter) {
if (isVerbose()) {
log.info("concatenate called with parameters strList={"+strList+"} and delimiter={"+delimiter+"}");
}
if (strList == null) {
return "";
}
final StringBuffer sb = new StringBuffer();
for (int i = 0; i < strList.length; i++) {
sb.append(strList[i]);
if (i < strList.length - 1) {
sb.append(delimiter);
}
}
return sb.toString();
}
@Operation(description = "Split string")
public String[] split(final String str, final String delimiter) {
if (isVerbose()) {
log.info("split called with parameters str={"+str+"} delimiter={"+delimiter+"}");
}
if (str == null) {
return new String[0];
}
return str.split(delimiter);
}
@Operation(description = "Convert Fahrenheit To Celcius")
public float convert(@Parameter(contentType = "text/xml") final float fahrenheit) {
if (isVerbose()) {
log.info("convert called with parameter fahrenheitr={"+fahrenheit+"}");
}
return (fahrenheit - 32) * 5 / 9;
}
}
| Modifier and Type | Optional Element and Description |
|---|---|
java.lang.String |
description
Service description(default: "")
|
java.lang.String |
displayName
Service type display name(default: service name)
|
java.lang.String |
instanceName
Name of default service instance created by upload(default: service name suffixed by "Instance")
|
java.lang.String |
name
Service type name(default: the class simple name)
|
public abstract java.lang.String name
public abstract java.lang.String displayName
public abstract java.lang.String instanceName
public abstract java.lang.String description