
org.objectweb.fractal.bf.connectors.BasicServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fixtures Show documentation
Show all versions of fixtures Show documentation
Integration tests fixtures
The newest version!
package org.objectweb.fractal.bf.connectors;
import java.util.GregorianCalendar;
import java.util.logging.Logger;
import javax.xml.datatype.XMLGregorianCalendar;
import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl;
public class BasicServiceImpl implements Service {
Logger log = Logger.getLogger(BasicServiceImpl.class.getCanonicalName());
public static final String SERVICE_REPLY = "Congratulations, Binding Factory Hello World up&running!";
public void print() {
log.info("Server will print: " + SERVICE_REPLY);
}
public String printAndAnswer() {
log.info("Server will print and return " + SERVICE_REPLY);
return SERVICE_REPLY;
}
/**
* return the current date
*
* @see org.objectweb.fractal.bf.connectors.Service#getCurrentDate()
*/
public XMLGregorianCalendar getCurrentDate() {
final XMLGregorianCalendarImpl result = new XMLGregorianCalendarImpl(
new GregorianCalendar());
log.info("The date sent by the server is: " + result);
return result;
}
/**
* @see org.objectweb.fractal.bf.connectors.Service#getPojo()
*/
public Pojo getPojo() {
Pojo p1 = new Pojo();
p1.setId(1);
p1.setDate(getCurrentDate());
p1.setName("pojo-1");
Pojo p2 = new Pojo();
p2.setId(2);
p2.setDate(getCurrentDate());
p2.setName("pojo-2");
p2.setParent(p1);
return p2;
}
/**
* @see org.objectweb.fractal.bf.connectors.Service#child(org.objectweb.fractal.bf.connectors.Pojo)
*/
public Pojo child(Pojo p) {
log.fine("Requesting child of pojo obj: " + p);
Pojo parent = new Pojo();
parent.setParent(p);
parent.setId(p.getId() + 1);
parent.setName("child-of-" + p.getName());
int parentYear = p.getDate().getYear() - 1;
XMLGregorianCalendar parentDate = p.getDate();
parentDate.setYear(parentYear);
parent.setDate(parentDate);
log.fine("Returning parent pojo: " + parent);
return parent;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy