首页 \ 问答 \ 继承和聚合UML(Inheritance and aggregation UML)

继承和聚合UML(Inheritance and aggregation UML)

想知道UML是否合理且可以接受?

请不要根据类的名称质疑组合或聚合的必要性。

只需按原样处理它们,如UML所示。

另外,我实际上是使用GoodArticle与报纸进行通信而不是实际编码中的父类文章。 但是在表示UML方面,我仍然应该将父类(Article)连接到报纸,即使它实际上是GoodArticle?

这也可以说与GoodArticle与BadArticle的构图连接的情况类似。 BadArticle应该连接到父类文章吗? 然而,我实际上是使用GoodArticle在编码中连接BadArticle。

继承和聚合


Would like to know if the UML is reasonable and acceptable?

Please do not question the need for composition or aggregation based on the names of the classes.

Just treat them as they are as shown on the UML.

Also, I am actually using GoodArticle to communicate with Newspaper and not the parent class Article in actual coding. But in terms of representing UML, I should still connect the parent class (Article) to newspaper even though it is actually GoodArticle?

This is also arguably similar to the case where GoodArticle connects with BadArticle for composition. Should BadArticle connect to parent class Article instead? However I am actually using GoodArticle to connect with BadArticle in coding.

Inheritance and aggregation


原文:
更新时间:2022-08-10 08:08

最满意答案

一般来说回答你的问题:Akka创建了一个用于进行异步消息处理的线程池。 因此,如果你编写如下代码,你的应用程序永远不会终止,因为Akka继续运行。

class Root extends Actor {

  // create some child actors to do some work

  override def receive: Receive = Actor.emptyBehavior
}

object Main {

  def main(args: Array[String]): Unit = {
    val system = ActorSystem("main")
    system.actorOf(Props(new Root))
  }
}

因此,通常如果您需要终止应用程序,您将定义一条消息,表明已完成所有工作并将此消息发送给您的根执行者。 然后,根actor可以调用context.system.terminate()来终止系统。

回到你的问题,我不明白你为什么要把Akka和Spring Boot结合起来。 你的线程转储,我不确定问题是否与Akka有关。 看起来线程挂在HttpClient中。 您确定已释放并关闭所有打开的连接吗?


To answer your question generally: Akka creates a thread pool which is used to do asynchronous message processing. So if you write code like the following, your application would never terminate since Akka keeps on running.

class Root extends Actor {

  // create some child actors to do some work

  override def receive: Receive = Actor.emptyBehavior
}

object Main {

  def main(args: Array[String]): Unit = {
    val system = ActorSystem("main")
    system.actorOf(Props(new Root))
  }
}

So usually if you need to terminate your application you would define a message which signals that all work has been done and send this message to your root actor. The root actor can then call context.system.terminate() to terminate the system.

Coming back to your question, I don't understand why you would want to combine Akka with Spring Boot. Your thread dump, I'm not sure whether the problem is related to Akka at all. It looks like the threads are hanging inside HttpClient. Are you sure you have freed and closed all open connections?

相关问答

更多
  • 在Play 2.0中,Play委托所有请求通过演员。 它严重依赖于Akka未来的API和其他部分。 在Play 2.1中,随着Akka未来的API移动到Scala 2.10,Play开始依赖于Akka。 它从Akka获得所有的执行上下文,并提供与Akka的集成,但这是关于它的程度。 在Play 2.3中,我们正在添加新的功能来帮助Akka集成,特别是在WebSockets周围。 在Play 2.4中,Play将被移植到新的akka-http(以前称为喷雾),在这一点上,Play将像Akka一样建成。 有什么 ...
  • 您可以在akka引导文件或您自己的ServletContextListener中启动您的actor,以便它们在不与servlet绑定的情况下启动。 然后你可以用akka注册表查找它们。 Actor.registry.actorFor[MyActor] foreach { _ !! (("Run",id), 10000) } 除此之外,目前还没有真正整合akka与scalatra。 因此,到目前为止,您可以做的最好的事情是对一堆演员使用阻止请求。 我不确定,但我不需要为每个请求生成一个actor,而是有一个 ...
  • 正如@SRI 指出你应该使用scala.concurrent.Await而不是akka.dispatch.Await 。 价值? 不是akka.actor.ActorSelection的成员 在版本2.1.4没有对ActorSelection ask模式支持。 看到这个提交 。 支持ActorSelection仅在版本2.2之后可用。 As @S.R.I noted you should use scala.concurrent.Await instead of akka.dispatch.Await. v ...
  • 我不知道什么是错的,但你可以做到以下几点: 检查你的logback.xml是否在jar文件中 尝试使用java -Dlogback.configurationFile = / path / to / logback.xml -jar event-assembly-0.1.1-SNAPSHOT.jar启动应用程序 So, how I found out, the sbt-assembly removed some logback-binaries from the result jar (it was set ...
  • 我解决了这两个问题,并将代码迁移到了最新的Akka 2.2-M3版本。 第一个问题的解决方案是让MapReduce远程MasterActor一收到所有消息发出后从客户端发送的TaskInfo通知就立即发回ShutdownInfo通知。 TaskInfo包含MapReduce任务有多少个子任务的信息,例如在这种情况下,文本文件中有多少行。 解决第二个问题的方法是向TaskInfo发送子任务总数。 在这里,AggregatorActor计算它已处理的子任务的数量,并将其与TaskInfo进行比较,并表示作业在匹 ...
  • 在Scala中,任何实现apply方法的对象都可以在没有new关键字的情况下调用,只需调用MyObject() ,它将自动查找它的apply 。 如果您查看Props的伴随对象 ,则会看到以下方法定义: /** * Scala API: Returns a Props that has default values except for "creator" * which will be a function that creates an instance * of the supplied typ ...
  • Akka Streams是比演员更高层次的抽象。 它是Reactive Streams的一个实现,它构建在 actor模型之上。 它利用了所有actor的功能,因为它使用了actor。 您甚至可以直接在流的任何部分使用actor。 看看ActorPublisher和ActorSubscriber。 Akka Streams is a higher level abstraction than actors. It's an implementation of Reactive Streams which b ...
  • chunjef的答案是正确的。如果您确实要清除警告,请将以下代码添加到build.sbt中。 conflictManager := ConflictManager.strict dependencyOverrides += "com.typesafe.akka" %% "akka-actor" % "2.5.4" dependencyOverrides += "com.typesafe.akka" %% "akka-stream" % "2.5.4" dependencyOverrides += "o ...
  • 一般来说回答你的问题:Akka创建了一个用于进行异步消息处理的线程池。 因此,如果你编写如下代码,你的应用程序永远不会终止,因为Akka继续运行。 class Root extends Actor { // create some child actors to do some work override def receive: Receive = Actor.emptyBehavior } object Main { def main(args: Array[String]): Un ...
  • 你可能想让你的Actor扩展ActorPublisher。 然后,您可以从中创建一个源并将其集成到您的流中。 请参阅此处有关ActorPublisher的文档: http ://doc.akka.io/docs/akka-stream-and-http-experimental/2.0.3/scala/stream-integrations.html You probably want to make your Actor extend ActorPublisher. Then you can create ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)