Skip to content

Instantly share code, notes, and snippets.

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)")
import akka.actor.ActorDSL._
val a = actor(new Act {
become {
case "hello" => sender() ! "hi"
}
})
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 {
object FooActor {
case object FooMessage
}
class FooActor extends Actor {
import FooActor._
override def receive: Receive = {
case FooMessage => ???
case BarActor.BarMessage => ???
}
}
class ClassMain {
private val mainVar = "Main"
showMeTheMain()
protected def showMeTheMain() {
println(mainVar)
}
}
<bean id="fruit" class="Fruits" factory-method="createFruit">
<constructor-arg value="sliwka"></constructor-arg>
</bean>
<bean id="fruit" class="Fruits" factory-method="newPlum">
<constructor-arg value="sliwka"></constructor-arg>
</bean>
public interface Fruit {
void eat();
String getName();
}
public class Test {
private String type;
private String password;
public Test(String type, String password) {
this.type = type;
this.password = password;
}
public interface Fruit {
void eat();
String getName();
}
public interface Peelable {
void peel();
}
public class Apple implements Fruit, Peelable {