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
| if(java.awt.Desktop.isDesktopSupported) { | |
| val desktop = java.awt.Desktop.getDesktop | |
| if(desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { | |
| new Thread(new Runnable { def run() { | |
| try { | |
| val waitTimeBeforeLaunchingBrowser = 3000 // give web server some time to start up | |
| Thread.sleep(waitTimeBeforeLaunchingBrowser) | |
| desktop.browse(new java.net.URI(browserUiUrl_IpAddress)) | |
| } catch { | |
| case t: Throwable => if (verbose) System.err.println("warning: failed to open browser (for convenience only)") |
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
| import akka.actor.ActorDSL._ | |
| val a = actor(new Act { | |
| become { | |
| case "hello" => sender() ! "hi" | |
| } | |
| }) |
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 WrongWayActor extends Actor { | |
| override def receive: Receive = { | |
| case _ => Future { | |
| val result = doSomeHeavyComputation | |
| sender() ! result // if you reacive other message in meantime, it will send the response to WRONG actor | |
| } | |
| } | |
| } | |
| class GoodWayActor extends Actor { |
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 FooActor { | |
| case object FooMessage | |
| } | |
| class FooActor extends Actor { | |
| import FooActor._ | |
| override def receive: Receive = { | |
| case FooMessage => ??? | |
| case BarActor.BarMessage => ??? | |
| } | |
| } |
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 ClassMain { | |
| private val mainVar = "Main" | |
| showMeTheMain() | |
| protected def showMeTheMain() { | |
| println(mainVar) | |
| } | |
| } | |
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
| <bean id="fruit" class="Fruits" factory-method="createFruit"> | |
| <constructor-arg value="sliwka"></constructor-arg> | |
| </bean> |
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
| <bean id="fruit" class="Fruits" factory-method="newPlum"> | |
| <constructor-arg value="sliwka"></constructor-arg> | |
| </bean> |
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 interface Fruit { | |
| void eat(); | |
| String getName(); | |
| } |
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 Test { | |
| private String type; | |
| private String password; | |
| public Test(String type, String password) { | |
| this.type = type; | |
| this.password = password; | |
| } | |
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 interface Fruit { | |
| void eat(); | |
| String getName(); | |
| } | |
| public interface Peelable { | |
| void peel(); | |
| } | |
| public class Apple implements Fruit, Peelable { |