Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sisu-users] enforcing component scope nesting

Thank you for the information, Stuart.

I've looked at ProvisionListener and I am not sure I understand how to
find specific injection-point-injected-provider wirings, which I think I
need to decide if scope nesting rules are violated or not. In other
words, ProvisionListener gets invoked for each @Inject and @Named
separately, but not @Inject/@Named wiring.

I also looked at TypeEncounter and InjectionListener, which give
information about "injectees" and classes they are injected into, but do
not tell specific injection point. This gives enough information to
detect invalid injections, I think, but not enough information to
provide meaningful error message. I also don't know how much overhead
InjectionListeners have, because implementation would need to listen on
all types from inner scopes.

Did I miss anything? Any other ideas or suggestions?

--
Regards,
Igor

On 2015-02-15 19:23, Stuart McCulloch wrote:
You might be able to use a ProvisionListener to do this as it gives
access to the dependency chain leading up to each injection as well as
the binding (which includes the scope)

http://google.github.io/guice/api-docs/latest/javadoc/index.html?com/google/inject/spi/ProvisionListenerBinding.html

--
Cheers, Stuart

On Monday, 9 February 2015 at 13:01, Igor Fedorenko wrote:

In Maven, there are several relatively clearly nested component scopes
that have different lifespan. There are components that can last as long
as Maven runtime instance is running, there are components that are
created and disposed of together with MavenProject instances (think of
Maven plugins) and there are also components with lifespan of individual
mojo executions.

Direct injection of components from shorter-lived scopes into components
from longer-lived scopes is not desirable (or outright wrong?) but from
what I can tell is currently allowed.

I am looking for a way to detect and report such injections. Some sort
of listener that gets notified whenever @Inject Component or
@Requirement Component is injected so the listener can analyze
classloaders of source and target components to decide if the injection
is legal or not. Is there anything is Sisu or Guice to do this?

--
Regards,
Igor
_______________________________________________
sisu-users mailing list
sisu-users@xxxxxxxxxxx <mailto:sisu-users@xxxxxxxxxxx>
To change your delivery options, retrieve your password, or
unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/sisu-users



_______________________________________________
sisu-users mailing list
sisu-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/sisu-users



Back to the top