Skip to content

Commit

Permalink
Merge branch 'AspectJ'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
#	comrueda-back-aspect/src/main/java/comrueda/back/aspect/Log.java
#	comrueda-back-aspect/src/main/java/comrueda/back/aspect/LoggerAspect.aj
#	comrueda-back-aspectos/src/main/java/comrueda/aspect/Log.java
#	comrueda-back-aspectos/src/main/java/comrueda/aspect/LoggerAspect.aj
#	comrueda-back/pom.xml
#	comrueda-back/src/main/java/comrueda/aspect/Log.java
#	comrueda-back/src/main/java/comrueda/aspect/LoggerAspect.aj
#	comrueda-back/target/maven-archiver/pom.properties
#	comrueda-front/src/main/java/comrueda/eventos/salidas/resources/SalidaResource.java
  • Loading branch information
camilo-tangarife committed May 22, 2018
2 parents fc98583 + e49f65a commit cc204bb
Show file tree
Hide file tree
Showing 29 changed files with 936 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ comrueda-back/target/
comrueda-front/target/
*iml/
.idea/
/comrueda-back-aspectos/target/
/comrueda-back-aspect/target/
12 changes: 12 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions comrueda-back-aspect/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.comrueda</groupId>
<artifactId>comrueda</artifactId>
<version>1.0</version>
</parent>

<artifactId>comrueda-back-aspect</artifactId>
<packaging>jar</packaging>

<dependencies>

<dependency>
<groupId>com.comrueda</groupId>
<artifactId>comrueda-back</artifactId>
<version>1.0</version>
</dependency>

<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.13</version>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- IMPORTANT -->
<useIncrementalCompilation>false</useIncrementalCompilation>
<warn>constructorName,packageDefaultMethod,deprecation,maskedCatchBlocks,unusedLocals,unusedArguments,unusedImport</warn>
</configuration>
</plugin>

<!-- AspectJ: weave aspects -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<Xlint>ignore</Xlint>
<encoding>UTF-8 </encoding>
<weaveDependencies>
<weaveDependency>
<groupId>com.comrueda</groupId>
<artifactId>comrueda-back</artifactId>
</weaveDependency>
</weaveDependencies>
</configuration>
<executions>
<execution>
<!-- Compile and weave aspects after all classes compiled by javac -->
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
</plugin>

</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package comrueda.aspect;
package comrueda.back.aspect;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
package comrueda.aspect;
import java.io.IOException;
import util.*;


import comrueda.usuarios.miembros.*;
package comrueda.back.aspect;

public aspect LoggerAspect {


// todos los métodos en los paquetes comrueda.*.ejb.*
pointcut logger():
call(public * MiembroLogic.*(. .));
execution(* comrueda..ejb..*(..)) ;

before():logger(){
System.out.println("Inicio de ejecucion del metodo: " + thisJoinPoint);
Log.DebugLog("Inicio de ejecucion del metodo: " + thisJoinPoint);
// Log.DebugLog("Inicio de ejecucion del metodo: " + thisJoinPoint);
}

after() returning(Object r):logger(){
System.out.println("Metodo " + r + " Retorno correctamente");
Log.DebugLog("Metodo " + r + " Retorno correctamente");
// Log.DebugLog("Metodo " + r + " Retorno correctamente");
}

after() throwing(Throwable e):logger(){
System.out.println("Excepcion en el metodo: " + e);
Log.DebugLog("Excepcion en el metodo: " + e);
// Log.DebugLog("Excepcion en el metodo: " + e);
}
}
5 changes: 5 additions & 0 deletions comrueda-back-aspect/src/main/resources/META-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
35 changes: 7 additions & 28 deletions comrueda-back/pom.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.comrueda</groupId>
<artifactId>comrueda</artifactId>
<version>1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>comrueda-back</artifactId>
<packaging>jar</packaging>
<name>comrueda-back</name>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.2</version>
</dependency>

<dependencies>

<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
Expand All @@ -34,18 +29,11 @@
<scope>test</scope>
<type>jar</type>
</dependency>
<!-- <dependency> <groupId>uk.co.jemos.podam</groupId> <artifactId>podam</artifactId>
<version>6.0.2.RELEASE</version> <type>jar</type> </dependency> -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>uk.co.jemos.podam</groupId>
<artifactId>podam</artifactId>
<version>6.0.2.RELEASE</version>
<scope>provided</scope>
<type>jar</type>
</dependency>
<dependency>
Expand All @@ -54,15 +42,6 @@
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<type>jar</type>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package comrueda.eventos.encuentros.ejb;

import comrueda.eventos.encuentros.ejb.*;
import comrueda.eventos.encuentros.entities.EncuentroEntity;
import comrueda.eventos.encuentros.persistance.EncuentroPersistance;

import javax.ejb.Stateless;
import javax.inject.Inject;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

@Stateless
public class EncuentroLogic {

private static final Logger LOGGER = Logger.getLogger(EncuentroLogic.class.getName());

@Inject
private EncuentroPersistance persistence;

public EncuentroEntity crearEncuentro(EncuentroEntity entity) {
LOGGER.info("Inicia proceso de creación de salida");
persistence.crear(entity);
LOGGER.info("Termina proceso de creación de salida");
return entity;
}

public List<EncuentroEntity> listarEncuentros() {
LOGGER.info("Inicia proceso de consultar todos los encuentros");
List<EncuentroEntity> encuentros = persistence.listarEncuentros();
LOGGER.info("Termina proceso de consultar todos los encuentros");
return encuentros;
}

public EncuentroEntity buscar(Long id) {
return persistence.buscar(id);
}

public EncuentroEntity actualizar(EncuentroEntity entity) {
return persistence.actualizar(entity);
}

public void borrar(EncuentroEntity entity) {
LOGGER.log(Level.INFO, "Inicia proceso de borrar salida con id={0}", entity.getId());
persistence.borrar(entity);
LOGGER.log(Level.INFO, "Termina proceso de borrar salida con id={0}", entity.getId());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package comrueda.eventos.encuentros.entities;


import comrueda.eventos.entities.EventoEntity;
import comrueda.common.podam.DateStrategy;
import uk.co.jemos.podam.common.PodamStrategyValue;

import javax.persistence.Entity;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.io.Serializable;
import java.util.Date;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@XmlRootElement
public class EncuentroEntity extends EventoEntity implements Serializable {
private static final long serialVersionUID = 5141657634228477191L;

private String direccion;


public String getDireccion() {
return direccion;
}

public void setDireccion(String direccion) {
this.direccion = direccion;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package comrueda.eventos.encuentros.persistance;



import comrueda.eventos.encuentros.entities.EncuentroEntity;
import comrueda.usuarios.miembros.persistance.MiembroPersistance;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import java.util.List;
import java.util.logging.Logger;

@Stateless
public class EncuentroPersistance {
private static final Logger LOGGER = Logger.getLogger(MiembroPersistance.class.getName());

@PersistenceContext(unitName = "ComruedaPU")
protected EntityManager em;

public EncuentroEntity crear(EncuentroEntity entity) {
LOGGER.info("Creando una encuentro nuevo");
em.persist(entity);
LOGGER.info("Nuevo encuentro creado");
return entity;
}

public List<EncuentroEntity> listarEncuentros(){
LOGGER.info("Consultando todos los encuentros");
TypedQuery<EncuentroEntity> query = em.createQuery("select u from EncuentroEntity u", EncuentroEntity.class);
return query.getResultList();
}

public EncuentroEntity buscar(Long id) {
return em.find(EncuentroEntity.class, id);
}

public EncuentroEntity actualizar(EncuentroEntity entity) {
return em.merge(entity);
}

public void borrar(EncuentroEntity entity) {
em.remove(entity);
}
}
Loading

0 comments on commit cc204bb

Please sign in to comment.