diff options
author | Vitaly Takmazov | 2019-03-29 16:21:42 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-03-29 16:21:42 +0300 |
commit | 1ae03ea2f7866b30796d7f8ae925c53d7d98c1b3 (patch) | |
tree | 5afd7cd6ae015708a921c5076291dd24443b9514 /src/main/java/com/juick/server/api | |
parent | c2dc3c4e839805ae010cc01541f2d26631c0862e (diff) |
Using @Resource where possible
Diffstat (limited to 'src/main/java/com/juick/server/api')
-rw-r--r-- | src/main/java/com/juick/server/api/Messages.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/java/com/juick/server/api/Messages.java b/src/main/java/com/juick/server/api/Messages.java index 5c791df4..5a4d8c31 100644 --- a/src/main/java/com/juick/server/api/Messages.java +++ b/src/main/java/com/juick/server/api/Messages.java @@ -31,7 +31,9 @@ import com.juick.service.MessagesService; import com.juick.service.TagService; import com.juick.service.UserService; import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.core.io.Resource; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -67,6 +69,8 @@ public class Messages { private ApplicationEventPublisher applicationEventPublisher; @Inject private WebApp webApp; + @Value("classpath:Transparent.gif") + private Resource invisiblePixel; // TODO: serialize image urls @@ -204,8 +208,7 @@ public class Messages { userService.updateLastSeen(visitor); applicationEventPublisher.publishEvent( new MessageReadEvent(this, visitor, msg)); - return IOUtils.toByteArray( - Objects.requireNonNull(getClass().getClassLoader().getResource("Transparent.gif"))); + return IOUtils.toByteArray(invisiblePixel.getInputStream()); } throw new HttpBadRequestException(); } |