Skip to content

Commit

Permalink
feat: local prod, dev 환경에서만 FCM Bean 들이 생성되도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
BGuga committed Sep 26, 2023
1 parent 5aaf339 commit 29c5c55
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import com.festago.fcm.domain.MemberFCM;
import com.festago.fcm.repository.MemberFCMRepository;
import java.util.List;
import org.springframework.context.event.EventListener;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;

@Component
@Profile({"dev", "prod"})
public class AuthEventListener {

private final MemberFCMRepository memberFCMRepository;
Expand All @@ -21,8 +22,7 @@ public AuthEventListener(MemberFCMRepository memberFCMRepository) {
this.memberFCMRepository = memberFCMRepository;
}

@Transactional
@EventListener
@TransactionalEventListener
public void saveMemberFCM(MemberLoginEvent memberLoginEvent) {
Long memberId = memberLoginEvent.memberId();
deleteFCM(memberId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;

@Profile("!test")
@Component
@Profile({"dev", "prod"})
public class FCMNotificationEventListener {

private static final Logger logger = LoggerFactory.getLogger(FCMNotificationEventListener.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
@Profile({"prod", "dev"})
public class MemberFCMService {

private static final Logger logger = LoggerFactory.getLogger(MemberFCMService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.springframework.core.io.ClassPathResource;

@Configuration
@Profile("!test")
@Profile({"prod", "dev"})
public class FCMConfig {

@Value("${fcm.key.path}")
Expand Down

0 comments on commit 29c5c55

Please sign in to comment.