use of org.aspectj.lang.annotation.After in project entando-core by entando.
the class PreviewWidgetExecutorAspect method checkContentPreview.
@After("execution(* org.entando.entando.aps.system.services.controller.executor.WidgetExecutorService.service(..)) && args(reqCtx)")
public void checkContentPreview(RequestContext reqCtx) {
HttpServletRequest request = reqCtx.getRequest();
String contentOnSessionMarker = (String) request.getAttribute("contentOnSessionMarker");
if (null == contentOnSessionMarker || contentOnSessionMarker.trim().length() == 0) {
contentOnSessionMarker = request.getParameter("contentOnSessionMarker");
}
if (null == contentOnSessionMarker) {
return;
}
Content contentOnSession = (Content) request.getSession().getAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker);
if (null == contentOnSession) {
return;
}
try {
IPage currentPage = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
Widget[] widgets = currentPage.getWidgets();
for (int frame = 0; frame < widgets.length; frame++) {
Widget widget = widgets[frame];
if (widget != null && "viewerConfig".equals(widget.getType().getAction())) {
if ((currentPage.getCode().equals(contentOnSession.getViewPage()) && (widget.getConfig() == null || widget.getConfig().size() == 0)) || (widget.getConfig() != null && widget.getConfig().get("contentId") != null && widget.getConfig().get("contentId").equals(contentOnSession.getId()))) {
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME, new Integer(frame));
String output = super.extractJspOutput(reqCtx, CONTENT_VIEWER_JSP);
String[] widgetOutput = (String[]) reqCtx.getExtraParam("ShowletOutput");
widgetOutput[frame] = output;
return;
}
}
}
} catch (Throwable t) {
String msg = "Error detected while include content preview";
_logger.error(msg, t);
throw new RuntimeException(msg, t);
}
}
use of org.aspectj.lang.annotation.After in project incubator-pulsar by apache.
the class ZooKeeperServerAspect method zkServerConstructor.
@After("zkServerConstructorPointCut()")
public void zkServerConstructor(JoinPoint joinPoint) throws Throwable {
// ZooKeeperServer instance was created
ZooKeeperServer zkServer = (ZooKeeperServer) joinPoint.getThis();
synchronized (ZooKeeperServerAspect.class) {
if (metricsRegistered) {
// We can only register the metrics a single time for the process
return;
}
metricsRegistered = true;
}
Gauge.build().name("zookeeper_server_znode_count").help("Number of z-nodes stored").create().setChild(new Gauge.Child() {
@Override
public double get() {
return zkServer.getZKDatabase().getNodeCount();
}
}).register();
Gauge.build().name("zookeeper_server_data_size_bytes").help("Size of all of z-nodes stored (bytes)").create().setChild(new Gauge.Child() {
@Override
public double get() {
return zkServer.getZKDatabase().getDataTree().approximateDataSize();
}
}).register();
Gauge.build().name("zookeeper_server_connections").help("Number of currently opened connections").create().setChild(new Gauge.Child() {
@Override
public double get() {
return zkServer.serverStats().getNumAliveClientConnections();
}
}).register();
Gauge.build().name("zookeeper_server_watches_count").help("Number of watches").create().setChild(new Gauge.Child() {
@Override
public double get() {
return zkServer.getZKDatabase().getDataTree().getWatchCount();
}
}).register();
Gauge.build().name("zookeeper_server_ephemerals_count").help("Number of ephemerals z-nodes").create().setChild(new Gauge.Child() {
@Override
public double get() {
return zkServer.getZKDatabase().getDataTree().getEphemeralsCount();
}
}).register();
}
use of org.aspectj.lang.annotation.After in project trainning by fernandotomasio.
the class MatriculasLoggerAdvice method logCreateMatricula.
@After("create()")
public void logCreateMatricula(JoinPoint joinPoint) {
MatriculaDTO[] matriculas = (MatriculaDTO[]) joinPoint.getArgs()[0];
if (matriculas != null && matriculas.length > 0) {
try {
LogDTO log = new LogDTO();
log.setDataCriacao(new Date());
log.setUser(getUser());
for (MatriculaDTO matriculaDTO : matriculas) {
String texto = "CRIAÇÃO DE MATRÍCULA " + getDetails(matriculaDTO);
log.setTexto(texto);
logger.create(log);
}
} catch (DAOException ex) {
Logger.getLogger(MatriculasLoggerAdvice.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
use of org.aspectj.lang.annotation.After in project trainning by fernandotomasio.
the class TrainningServiceLoggerAdvice method logUpdateCurso.
@After("update()")
public void logUpdateCurso(JoinPoint joinPoint) {
CursoDAO dao = factory.getCursoDAO();
CursoDTO curso = (CursoDTO) joinPoint.getArgs()[0];
if (curso != null) {
try {
curso = dao.find(curso.getId()).createDTO();
LogDTO log = new LogDTO();
log.setDataCriacao(new Date());
log.setUser(getUser());
log.setObjectId(curso.getObjectId());
String texto = "ATUALIZADO O CURSO " + getDetails(curso);
log.setTexto(texto);
logger.create(log);
} catch (DAOException ex) {
Logger.getLogger(TrainningServiceLoggerAdvice.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
use of org.aspectj.lang.annotation.After in project PhotoNoter by yydcdut.
the class PermissionAspect method afterPermissionRequestBack.
@After("execution(* android.support.v4.app.FragmentActivity.onRequestPermissionsResult(..))")
public void afterPermissionRequestBack(JoinPoint joinPoint) {
YLog.i(TAG, "afterPermissionRequestBack");
Object[] objects = joinPoint.getArgs();
Object object = joinPoint.getTarget();
if (objects.length >= 1 && objects[0] instanceof Integer && object != null && object instanceof IView && ((IView) object).getPresenter() != null) {
int requestCode = (int) objects[0];
invokeMethod(((IView) object).getPresenter(), requestCode);
} else {
YLog.i(TAG, "afterPermissionRequestBack --> bad");
}
}
Aggregations