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
object Color { | |
def create(r: Int, g: Int, b: Int): Color = { | |
new Color(r, g, b) | |
} | |
} | |
class Color(r: Int, g: Int, b: Int) { |
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
object ApplicationMain extends App { | |
val system = ActorSystem("MyActorSystem") | |
val pongActor = system.actorOf(Pong.props, "pongActor") | |
pongActor ! PongMessage("Initial message") | |
// waiting for JMX "end" message to terminate | |
system.awaitTermination() | |
} |
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
class Pong extends ActorWithJMXSupport with ActorLogging with PongMBean{ | |
import Pong._ | |
var lastReceivedMessage = "UNKNOWN" | |
def receive = { | |
case PongMessage(text) => | |
log.info("In PongActor - received message: {}", text) | |
lastReceivedMessage = text | |
} |
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
trait PongMBean { | |
def lastReceivedMessage(): String | |
def sendMessage(p1: String): Unit | |
} |
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
trait ActorWithJMXSupport extends Actor { | |
val mBeanServer = ManagementFactory.getPlatformMBeanServer(); | |
val objName = new ObjectName("hdbandit", { | |
import scala.collection.JavaConverters._ | |
new java.util.Hashtable( | |
Map( | |
"name" -> self.path.toStringWithoutAddress, | |
"type" -> getMXTypeName |
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
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-actuator</artifactId> | |
</dependency> |
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 | |
@RequestMapping("/example") | |
@RefreshScope | |
public class ExampleService { | |
@Value("${message.hello}") | |
private String message; | |
@RequestMapping(method = RequestMethod.GET) | |
public String getExample() { |
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
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-actuator</artifactId> | |
</dependency> |
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 | |
@RequestMapping("/example") | |
@RefreshScope | |
public class ExampleService { | |
@Value("${message.hello}") | |
private String message; | |
@RequestMapping(method = RequestMethod.GET) | |
public String getExample() { |
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
@EnableConfigServer | |
@SpringBootApplication | |
public class ConfigServerApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(ConfigServerApplication.class, args); | |
} | |
} |