Giter Site home page Giter Site logo

scala-io-exercise-4's Introduction

Exercise 4

In this exercise we continue with the end result of exercise 3. So far we've hardcoded a couple of things like the host and port of the HTTP listener. In this exercise we want to use the Akka application.conf configuration file for configuring our application. We are going to expose this configuration using an Akka "extension".

We're adding another actor for our string manipulation business for supporting a version of Leetspeak. This actor needs some configuration values. The L33tActor 'leetifies' incoming text in a different style according to two configuration values:

uppercase (true/false)
use-shift (true/false)

As en example, in this dialect of Leet akka would end up as 4KK4 with uppercase set to true and use-shift set to false. With use-shift set to true it would end up as $KK$. We're going to use a Settings extension and the application.conf file to make the L33tActor configurable.

###Objective

The objective of this exercise is to learn how to create your own Settings Akka extension which is accessible from any actor in the actor system. a Settings can be referenced anywhere by using:

val settings = Settings(context)

From an Actor or:

val settings = Settings(system)

From anywhere where you have access to the actor system.

###What is already prepared

The end result of exercise 3 is the starting point of this exercise. A Settings class and object are already provided which have to be filled in for the l33t configuratin section. A l33t route is added to the Receptionist, which creates the L33tAactor. The L33tActor needs to be modified to use the configuration.

###The Exercise

  • Use the Settings to configure the HTTP host and port in the Main class
  • Add your own l33t configuration to the application.conf file (uppercase and use-shift)
  • Create a val for the settings in L33tActor
  • Get 'uppercase' boolean from the Settings L33t object in the L33tActor
  • Get 'useShift' boolean from the Settings L33t object in the L33tActor
  • Create a L33t object that contains the uppercase and useShift values in the Settings class
  • Read the uppercase and useshift from your configuration in the Settings class
  • Review the Settings Extension on the particulars of building an Akka Extension
  • Review the test for L33tActor on how to modify the configuration in a test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.