Skip to content

Commit

Permalink
Aggiunto shutdown hook per scan pec sdi
Browse files Browse the repository at this point in the history
  • Loading branch information
mspasiano committed Sep 26, 2017
1 parent 4e94d6f commit 9791497
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import it.cnr.jada.comp.ComponentException;
import it.cnr.jada.persistency.PersistencyError;
import it.cnr.jada.persistency.PersistencyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.math.BigDecimal;
Expand All @@ -16,6 +18,7 @@

public class Configurazione_cnrComponent extends it.cnr.jada.comp.GenericComponent implements IConfigurazione_cnrMgr, Cloneable, Serializable {

private transient final static Logger logger = LoggerFactory.getLogger(Configurazione_cnrComponent.class);

public static final String ASTERISCO = "*";

Expand Down Expand Up @@ -503,4 +506,34 @@ private Optional<Boolean> findConfigurazioneOrdini(UserContext userContext, Conf
.map(Configurazione_cnrBulk.class::cast)
.map(bulk -> Boolean.valueOf(bulk.getVal01()));
}



public void shutdowHook(UserContext userContext) throws ComponentException {
logger.info("shutdow hook");
final BulkHome home = getHome(userContext, Configurazione_cnrBulk.class);
try {
Configurazione_cnrBulk configurazione_cnrBulk = new Configurazione_cnrBulk(
Configurazione_cnrBulk.PK_EMAIL_PEC,
Configurazione_cnrBulk.SK_SDI,
ASTERISCO,
new Integer(0));
Optional.ofNullable(home.findByPrimaryKey(configurazione_cnrBulk))
.filter(Configurazione_cnrBulk.class::isInstance)
.map(Configurazione_cnrBulk.class::cast)
.filter(bulk -> bulk.getVal04().equalsIgnoreCase("Y"))
.ifPresent(bulk -> {
bulk.setVal04("N");
bulk.setToBeUpdated();
try {
home.update(bulk, userContext);
} catch (PersistencyException e) {
throw new RuntimeException(e);
}
});
} catch (PersistencyException e) {
throw handleException(e);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package it.cnr.contab.config00.ejb;

import it.cnr.contab.config00.comp.Configurazione_cnrComponent;
import it.cnr.jada.UserContext;
import it.cnr.jada.action.AdminUserContext;
import it.cnr.jada.comp.ComponentException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.EJBException;
import javax.ejb.Remove;
import javax.ejb.Stateless;
import java.util.UUID;

@Stateless(name = "CNRCONFIG00_EJB_Configurazione_cnrComponentSession")
public class Configurazione_cnrComponentSessionBean extends it.cnr.jada.ejb.GenericComponentSessionBean implements Configurazione_cnrComponentSession {
private it.cnr.contab.config00.comp.Configurazione_cnrComponent componentObj;
private transient final static Logger logger = LoggerFactory.getLogger(Configurazione_cnrComponentSessionBean.class);

public static Configurazione_cnrComponentSessionBean newInstance() throws EJBException {
return new Configurazione_cnrComponentSessionBean();
Expand All @@ -23,6 +31,11 @@ public void ejbPassivate() throws EJBException {

@Remove
public void ejbRemove() throws EJBException {
try {
shutdowHook();
} catch (ComponentException e) {
logger.error("ERROR while shutdow hook", e);
}
componentObj.release();
}

Expand All @@ -31,6 +44,25 @@ public void ejbCreate() {
componentObj = new it.cnr.contab.config00.comp.Configurazione_cnrComponent();
}

public void shutdowHook() throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException{
UserContext param0 = new AdminUserContext(UUID.randomUUID().toString());
pre_component_invocation(param0, componentObj);
try {
componentObj.shutdowHook(param0);
component_invocation_succes(param0, componentObj);
} catch (it.cnr.jada.comp.NoRollbackException e) {
component_invocation_succes(param0, componentObj);
throw e;
} catch (it.cnr.jada.comp.ComponentException e) {
component_invocation_failure(param0, componentObj);
throw e;
} catch (RuntimeException e) {
throw uncaughtRuntimeException(param0, componentObj, e);
} catch (Error e) {
throw uncaughtError(param0, componentObj, e);
}
}

public it.cnr.contab.config00.bulk.Configurazione_cnrBulk getConfigurazione(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException {
pre_component_invocation(param0, componentObj);
try {
Expand Down
Loading

0 comments on commit 9791497

Please sign in to comment.