This file contains hidden or 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
package br.com.casadocodigo.loja.infra.spring; | |
import org.springframework.beans.BeansException; | |
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; | |
import org.springframework.beans.factory.config.BeanDefinition; | |
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; | |
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.core.type.AnnotationMetadata; | |
import org.springframework.stereotype.Controller; |
This file contains hidden or 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
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> | |
<c:forEach var="transacao" items="${transacoes}"> | |
${transacao}<br/> | |
</c:forEach> |
This file contains hidden or 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
@Controller | |
@RequestMapping("/connect") | |
public class CustomConnectController extends ConnectController { | |
@Autowired | |
public CustomConnectController(ConnectionFactoryLocator connectionFactoryLocator, | |
ConnectionRepository connectionRepository) { | |
super(connectionFactoryLocator, connectionRepository); | |
} |
This file contains hidden or 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
@Controller | |
@Transactional | |
public class FacebookLoginController { | |
@Autowired | |
private Facebook facebook; | |
@RequestMapping(value = "/facebook/login", method = RequestMethod.GET) | |
public ModelAndView handleFacebookLogin(HttpServletResponse response) { | |
User profile = facebook.fetchObject("me", User.class, "id", "name", "link", "email"); |
This file contains hidden or 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
<form action="/connect/facebook" method="POST"> | |
<input type="hidden" name="scope" value="email" /> | |
<p> | |
<button type="submit">Connect to Facebook</button> | |
</p> | |
</form> |
This file contains hidden or 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
<Form onSubmit={handleSubmit} subscription={{ submitting: true }} validate={validate}> | |
{({ handleSubmit2, submitting }) => ( | |
<form onSubmit={handleSubmit2} className={classes.form} noValidate> | |
<Field | |
autoComplete="email" | |
autoFocus | |
component={RFTextField} | |
disabled={submitting || sent} | |
fullWidth | |
label="Email" |
This file contains hidden or 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 void main(String[] args) { | |
Team team = new Team("instrutores"); | |
Cycle cycle = new Cycle("novo ciclo", LocalDate.now().minusDays(60), LocalDate.now()); | |
ArrayList<SupportStrategy> strategies = new ArrayList<>(); | |
strategies.add(new SupportStrategy("descricao")); | |
TeamCycle teamCycle = new TeamCycle(cycle, team, strategies); | |
System.out.println(DataView.of(teamCycle) | |
.add(TeamCycle :: getId) |
This file contains hidden or 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 DataView<T> { | |
private T proxy; | |
private Trace trace; | |
private T original; | |
private Map<String, Object> complexValues = new HashMap<>(); | |
private DataView(T instance) { | |
Enhancer enhancer = new Enhancer(); | |
enhancer.setSuperclass(instance.getClass()); |
This file contains hidden or 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
@RestController | |
public class TeamController { | |
@Autowired | |
private FormFlow formFlow; | |
@PostMapping(...) | |
public void save(@Valid NewTeamForm newTeamForm){ | |
formFlow.transform(newTeamForm).save().andThen(savedObject -> { |
This file contains hidden or 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
//exemplo mexendo nas referências que não deveria | |
public class PagamentoController { | |
@Post("/pagamento/usuario/{usuarioId}") | |
public void aceita(@PathVariable("usuarioId") Long usuarioId,@Valid NovoPagamentoForm dadosPagamento) { | |
Usuario novoCliente = usuarioRepository.findyId(usuarioId); | |
//novoCliente.getPagamento() => Optional.empty aqui | |
novoPagamentoService.executa(novoCliente,dadosPagamento); | |
//novoCliente.getPagamento() => Optional(pagamento) | |
//como você ia saber que o estado foi alterado? |