This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Objeto4{ | |
public void metodoD(){ | |
// ano e mes são recuperados do Contexto, cujo está guardado na Thread local | |
final Integer ano = GerenciadorContexto.getParametros().getAno(); | |
final Integer mes= GerenciadorContexto.getParametros().getMes(); | |
} | |
public void metodoE(){ | |
// cnpj são recuperados do Contexto, cujo está guardado na Thread local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring.mail.host=smtp.gmail.com | |
spring.mail.port=587 | |
spring.mail.protocol=smtp | |
spring.mail.username=<seu_email>@gmail.com | |
spring.mail.password=<chave de 16 digitos gerada pelo Google Account> | |
spring.mail.properties.mail.smtp.auth=true | |
spring.mail.properties.mail.smtp.starttls.enable=true | |
spring.mail.properties.mail.smtp.starttls.required=true | |
spring.mail.properties.mail.smtp.quitwait=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
# ... outras configurações | |
mail: | |
host: smtp.gmail.com | |
port: 587 | |
protocol: smtp | |
username: <seu_email>@gmail.com | |
password: <chave de 16 digitos gerada pelo Google Account> | |
properties: | |
mail: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class SenderMailService { | |
@Autowired | |
private JavaMailSender mailSender; | |
private void enviar() { | |
SimpleMailMessage email = new SimpleMailMessage(); | |
email.setTo("teste@gmail.com"); | |
email.setSubject("Teste envio de e-mail"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringRunner.class) | |
@SpringBootTest | |
public class SenderMailServiceTest { | |
@Autowired | |
SenderMailService senderMailService; | |
@Test | |
public void testEnvioEmail() { | |
senderMailService.enviar(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-mail</artifactId> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
compile('org.springframework.boot:spring-boot-starter-mail') | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ProxyMapHandler implements MethodHandler { | |
private Map<String, Object> mapaRegistro; | |
public ProxyMapHandler(final Map<String, Object> pMapaRegistro) { | |
mapaRegistro = pMapaRegistro; | |
} | |
public Object invoke(final Object self, final Method thisMethod, final Method proceed, final Object[] args) throws Throwable { | |
// -> getAlgumaPropriedade - algumaPropriedade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> T criarProxyBaseadoNoMapa(final Class<T> pTipoDoProxy, final Map<String, Object> pMapaRegistro) { | |
final ProxyFactory factory = new ProxyFactory(); | |
if (pTipoDoProxy.isInterface()) { | |
factory.setInterfaces(new Class[] { pTipoDoProxy }); | |
} else { | |
factory.setSuperclass(pTipoDoProxy); | |
} | |
Object newProxyInstance = null; | |
try { | |
newProxyInstance = factory.create(new Class<?>[0], new Object[0], new ProxyMapHandler(pMapaRegistro)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Object invoke(final Object self, final Method thisMethod, final Method proceed, final Object[] args) throws Throwable { | |
Object retorno = null; | |
final String methodName = thisMethod.getName(); | |
if (self instanceof FacesContext) { | |
if ("addMessage".equals(methodName)) { | |
final FacesMessage facesMessage = (FacesMessage) args[1]; | |
listaMensagensJsf.add(facesMessage); | |
} else if ("getMessages".equals(methodName)) { | |
retorno = listaMensagensJsf.iterator(); | |
} else if ("getExternalContext".equals(methodName)) { |