java - What does it mean to "proxy a bean"? -



java - What does it mean to "proxy a bean"? -

at work , online maintain hearing term "proxy" respect enterprise java development. example, metrics-spring uses phrase:

this module next things:

creates metrics , proxies beans contain methods annotated @timed, @metered, @exceptionmetered, , @counted [emphasis mine]

i'm unfamiliar lot of language in java ecosystem of frameworks , libraries. sense have understanding of what bean is, i'm still not clear how 1 proxy bean.

what mean proxy bean?

typically, have bean like

bean bean = new bean(); // created context

with this, can bean class declares behavior (invoke methods).

there times nice if could, example, track how long method invocation takes.

you do

long start = .. // start time bean.invoke(); long end = .. // end time // end - start

but doing each method invocation sucks. so, instead, patterns, architectures, , styles aspect oriented programming exist.

instead of bean above, you'd have

bean bean = new timingbean(new bean()); // 1 time again done context

where timingbean proxy type extends , implements types bean extends , implements. intents , purposes is bean, adds bunch of additional behavior before delegating each invocation bean object. in case, track how long each of bean's method's took execute.

basic spring uses jdk proxies , cglib proxies. here differences between them.

it uses scheduling , asynchronous invocations. uses transactional back upwards databases. uses caching. uses java based container configuration.

java spring proxy

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -