elizarov
01/06/2019, 6:29 PMnfrankel
01/06/2019, 7:20 PMcedric
01/06/2019, 9:31 PMAOP is very popular... mmmmh
elizarov
01/06/2019, 9:55 PMirus
01/06/2019, 10:53 PMfor example, aop lets you apply logging/authorization to code outside your scopeAnd you very limited here (in case of runtime AOP without java agent), since only top-level objects can be processed. Like you have 3rd party class
Foo
with method doThings
, and doThings
creates new instance of Bar
inside, so Bar
methods will not be interceptedCzar
01/06/2019, 11:11 PMcedric
01/07/2019, 5:01 AMjanvladimirmostert
01/07/2019, 7:45 AMnfrankel
01/07/2019, 8:02 AMjanvladimirmostert
01/07/2019, 8:21 AMnfrankel
01/07/2019, 8:23 AMclass Application {
private val httpHandler: HttpHandler
private val server: HttpServer
private var nettyContext: BlockingNettyContext? = null
constructor(port: Int = 8080) {
val context = GenericApplicationContext().apply {
beans().initialize(this)
refresh()
}
server = HttpServer.create(port)
httpHandler = WebHttpHandlerBuilder.applicationContext(context).build()
}
fun start() {
nettyContext = server.start(ReactorHttpHandlerAdapter(httpHandler))
}
fun startAndAwait() {
server.startAndAwait(ReactorHttpHandlerAdapter(httpHandler),
{ nettyContext = it })
}
fun stop() {
nettyContext?.shutdown()
}
}
fun main(args: Array<String>) {
Application().startAndAwait()
}
not a single annotation
but everything needs to be declared
ref: https://spring.io/blog/2017/08/01/spring-framework-5-kotlin-apis-the-functional-wayjanvladimirmostert
01/07/2019, 8:26 AMnfrankel
01/07/2019, 8:27 AMSpring Boot is horriblearguments?
InternalViewResolver
)janvladimirmostert
01/07/2019, 8:33 AMnfrankel
01/07/2019, 8:40 AM@Service
function transactional as well?
using aop, it’s a no-brainer
setting it explicitly, not that much - whether by annotation or by calling it through a function
you want to measure the execution time of a function call chain?
aop
dynatrace, introscope, etc.
they are all based on aopelizarov
01/07/2019, 8:44 AMjanvladimirmostert
01/07/2019, 8:50 AM@Transactional
, that code ended up deadlocking the database since developers weren't aware that the service calls were all transactional. I can see limited use for it in Java, in Kotlin for the majority of use-cases, there's a more elegant way of doing it that doesn't hide code.
@elizarov does Hibernate use AOP or is that just regular annotation scanning?nfrankel
01/07/2019, 8:52 AMdoesn’t hide codeit’s very trendy now but the balance shifts every now and then
elizarov
01/07/2019, 9:24 AMcedric
01/07/2019, 6:51 PMjtravis
01/07/2019, 10:19 PM@Transactional
vs transactional{}
is not a super strong argument IMO. Most people do not annotate each method, they annotate their Repo or Service classes. The advantage with annotating the class is that your developers always know the default transactional behavior by which layer the class lives in.Sql*Repo
classes have a @Transactional
on the class which requires a Tx has already been setup. And the Service classes which call into them create those Tx if they are not already created.wakingrufus
01/09/2019, 12:07 PMnfrankel
01/09/2019, 12:46 PMwakingrufus
01/09/2019, 1:40 PMDavid
01/10/2019, 12:03 AM@Transactional
(as someone mentions above - yes - it is AOP), but also method tracing for ID'ing frozen frames (ever tried actioning those frozen frame metrics in Android Vitals? You're gonna need to get you logging on... everywhere and report the Framemetrics in via something like Firebase Perf). And most recently, Analytics! Much of my event based analytics code is now woven in via Aspects...I'm not sure still how I feel about this. I've never liked seeing Analytics code in the mainline and I've had problems in the past of events going missing in releases which were annoying. Aspects kind of help here and I can unit test by asserting the class/method meta-data which is awesome... especially when adding events to legacy (read: hard to test) code@Override
@Event(type = Tags.Event.Type.Spot.SELECT_CONTENT,
paramKeys = {
CommonTags.Event.Params.REQUEST_CODE,
CommonTags.Event.Params.RESULT_CODE
})
public void onActivityResult(int requestCode, int resultCode, Intent data) { ... }
@Event
annotation which logs image selection results to my analytics providers. The constants (cf. CommonTags
and Tags
abstract constants from the analytics providers. SELECT_CONTENT
is derived from the Firebase EventType IIRC when my app is targeting Google Android.