com.github.panchitoboy.common.ecb.Boundary Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-rest Show documentation
Show all versions of common-rest Show documentation
Libreria de ayuda la generacion de servicios REST
package com.github.panchitoboy.common.ecb;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.util.List;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
import javax.validation.Valid;
import org.slf4j.Logger;
public abstract class Boundary {
@Inject
public Boundary(InjectionPoint ip) {
ParameterizedType type = (ParameterizedType) ip.getType();
Class clazz = (Class) type.getActualTypeArguments()[0];
this.entityClass = clazz;
}
@Inject
protected Logger logger;
protected final Class entityClass;
protected Logger getLogger() {
return logger;
}
public abstract Control getControl();
public T find(Serializable id) {
return getControl().findBy(id);
}
public List findAll() {
return getControl().findAll();
}
public void create(@Valid T entity) {
getControl().save(entity);
}
public void update(@Valid T entity) {
getControl().save(entity);
}
public void remove(Serializable id) {
T instance = find(id);
getControl().attachAndRemove(instance);
}
public void remove(T instance) {
getControl().attachAndRemove(instance);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy