incorporate Viktor’s review

- rename instance() to getInstance()
- add ScalaDoc
- some formatting
This commit is contained in:
Roland 2012-04-10 16:49:29 +02:00
parent b6db48818a
commit 201885d125
6 changed files with 61 additions and 21 deletions

View file

@ -32,18 +32,18 @@ public class JavaAPI {
// compilation tests // compilation tests
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void mustCompile() { public void mustCompile() {
final Kill kill = Kill.instance(); final Kill kill = Kill.getInstance();
final PoisonPill pill = PoisonPill.instance(); final PoisonPill pill = PoisonPill.getInstance();
final ReceiveTimeout t = ReceiveTimeout.instance(); final ReceiveTimeout t = ReceiveTimeout.getInstance();
final LocalScope ls = LocalScope.instance(); final LocalScope ls = LocalScope.getInstance();
final NoScopeGiven noscope = NoScopeGiven.instance(); final NoScopeGiven noscope = NoScopeGiven.getInstance();
final LoggerInitialized x = Logging.loggerInitialized(); final LoggerInitialized x = Logging.loggerInitialized();
final CurrentRoutees r = CurrentRoutees.instance(); final CurrentRoutees r = CurrentRoutees.getInstance();
final NoRouter nr = NoRouter.instance(); final NoRouter nr = NoRouter.getInstance();
final FromConfig fc = FromConfig.instance(); final FromConfig fc = FromConfig.getInstance();
} }
@Test @Test

View file

@ -30,19 +30,28 @@ case class Failed(cause: Throwable) extends AutoReceivedMessage with PossiblyHar
abstract class PoisonPill extends AutoReceivedMessage with PossiblyHarmful abstract class PoisonPill extends AutoReceivedMessage with PossiblyHarmful
case object PoisonPill extends PoisonPill { case object PoisonPill extends PoisonPill {
def instance = this /**
* Java API: get the singleton instance
*/
def getInstance = this
} }
abstract class Kill extends AutoReceivedMessage with PossiblyHarmful abstract class Kill extends AutoReceivedMessage with PossiblyHarmful
case object Kill extends Kill { case object Kill extends Kill {
def instance = this /**
* Java API: get the singleton instance
*/
def getInstance = this
} }
case class Terminated(@BeanProperty actor: ActorRef) extends PossiblyHarmful case class Terminated(@BeanProperty actor: ActorRef) extends PossiblyHarmful
abstract class ReceiveTimeout extends PossiblyHarmful abstract class ReceiveTimeout extends PossiblyHarmful
case object ReceiveTimeout extends ReceiveTimeout { case object ReceiveTimeout extends ReceiveTimeout {
def instance = this /**
* Java API: get the singleton instance
*/
def getInstance = this
} }
/** /**

View file

@ -71,7 +71,10 @@ case object LocalScope extends LocalScope {
@deprecated("use instance() method instead", "2.0.1") @deprecated("use instance() method instead", "2.0.1")
def scope: Scope = this def scope: Scope = this
def instance = this /**
* Java API: get the singleton instance
*/
def getInstance = this
def withFallback(other: Scope): Scope = this def withFallback(other: Scope): Scope = this
} }
@ -84,7 +87,10 @@ abstract class NoScopeGiven extends Scope
case object NoScopeGiven extends NoScopeGiven { case object NoScopeGiven extends NoScopeGiven {
def withFallback(other: Scope): Scope = other def withFallback(other: Scope): Scope = other
def instance = this /**
* Java API: get the singleton instance
*/
def getInstance = this
} }
/** /**

View file

@ -590,7 +590,10 @@ object Logging {
*/ */
abstract class LoggerInitialized abstract class LoggerInitialized
case object LoggerInitialized extends LoggerInitialized { case object LoggerInitialized extends LoggerInitialized {
def instance = this /**
* Java API: get the singleton instance
*/
def getInstance = this
} }
/** /**

View file

@ -346,7 +346,10 @@ case class Broadcast(message: Any)
*/ */
abstract class CurrentRoutees abstract class CurrentRoutees
case object CurrentRoutees extends CurrentRoutees { case object CurrentRoutees extends CurrentRoutees {
def instance = this /**
* Java API: get the singleton instance
*/
def getInstance = this
} }
/** /**
@ -376,16 +379,22 @@ case object NoRouter extends NoRouter {
def supervisorStrategy = null def supervisorStrategy = null
override def withFallback(other: RouterConfig): RouterConfig = other override def withFallback(other: RouterConfig): RouterConfig = other
def instance = this /**
* Java API: get the singleton instance
*/
def getInstance = this
} }
/** /**
* Router configuration which has no default, i.e. external configuration is required. * Router configuration which has no default, i.e. external configuration is required.
*/ */
case object FromConfig extends FromConfig { case object FromConfig extends FromConfig {
def instance = this /**
def apply(routerDispatcher: String = Dispatchers.DefaultDispatcherId) = new FromConfig(routerDispatcher) * Java API: get the singleton instance
def unapply(fc: FromConfig): Option[String] = Some(fc.routerDispatcher) */
def getInstance = this
@inline final def apply(routerDispatcher: String = Dispatchers.DefaultDispatcherId) = new FromConfig(routerDispatcher)
@inline final def unapply(fc: FromConfig): Option[String] = Some(fc.routerDispatcher)
} }
/** /**
@ -411,21 +420,28 @@ class FromConfig(val routerDispatcher: String = Dispatchers.DefaultDispatcherId)
// open-coded case class to preserve binary compatibility, all deprecated for 2.1 // open-coded case class to preserve binary compatibility, all deprecated for 2.1
@deprecated("FromConfig does not make sense as case class", "2.0.1") @deprecated("FromConfig does not make sense as case class", "2.0.1")
override def productPrefix = "FromConfig" override def productPrefix = "FromConfig"
@deprecated("FromConfig does not make sense as case class", "2.0.1") @deprecated("FromConfig does not make sense as case class", "2.0.1")
def productArity = 1 def productArity = 1
@deprecated("FromConfig does not make sense as case class", "2.0.1") @deprecated("FromConfig does not make sense as case class", "2.0.1")
def productElement(x: Int) = x match { def productElement(x: Int) = x match {
case 0 routerDispatcher case 0 routerDispatcher
case _ throw new IndexOutOfBoundsException(x.toString) case _ throw new IndexOutOfBoundsException(x.toString)
} }
@deprecated("FromConfig does not make sense as case class", "2.0.1") @deprecated("FromConfig does not make sense as case class", "2.0.1")
def copy(d: String = Dispatchers.DefaultDispatcherId): FromConfig = new FromConfig(d) def copy(d: String = Dispatchers.DefaultDispatcherId): FromConfig = new FromConfig(d)
@deprecated("FromConfig does not make sense as case class", "2.0.1") @deprecated("FromConfig does not make sense as case class", "2.0.1")
def canEqual(o: Any) = o.isInstanceOf[FromConfig] def canEqual(o: Any) = o.isInstanceOf[FromConfig]
@deprecated("FromConfig does not make sense as case class", "2.0.1") @deprecated("FromConfig does not make sense as case class", "2.0.1")
override def hashCode = ScalaRunTime._hashCode(this) override def hashCode = ScalaRunTime._hashCode(this)
@deprecated("FromConfig does not make sense as case class", "2.0.1") @deprecated("FromConfig does not make sense as case class", "2.0.1")
override def toString = "FromConfig(" + routerDispatcher + ")" override def toString = "FromConfig(" + routerDispatcher + ")"
@deprecated("FromConfig does not make sense as case class", "2.0.1") @deprecated("FromConfig does not make sense as case class", "2.0.1")
override def equals(other: Any): Boolean = other match { override def equals(other: Any): Boolean = other match {
case FromConfig(x) x == routerDispatcher case FromConfig(x) x == routerDispatcher

View file

@ -12,11 +12,17 @@ sealed trait Response
* When the ZeroMQ socket connects it sends this message to a listener * When the ZeroMQ socket connects it sends this message to a listener
*/ */
case object Connecting extends Response { case object Connecting extends Response {
def instance = this /**
* Java API: get the singleton instance
*/
def getInstance = this
} }
/** /**
* When the ZeroMQ socket disconnects it sends this message to a listener * When the ZeroMQ socket disconnects it sends this message to a listener
*/ */
case object Closed extends Response { case object Closed extends Response {
def instance = this /**
* Java API: get the singleton instance
*/
def getInstance = this
} }