Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [e4-dev] Question for the template code from the e4 wizard

Anyone with a example why these @Named tags are useful in a handler? Otherwise I remove them.


2013/9/12 Lars Vogel <lars.vogel@xxxxxxxxx>
Hello,

The example code from the e4 wizard uses  @Named(ServiceConstants.ACTIVE_*) regulary. For example:

@Execute
public void execute(
IEclipseContext context,
@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
@Named(IServiceConstants.ACTIVE_PART) final MContribution contribution)
throws InvocationTargetException, InterruptedException {
............
}

AFAIK these service constants are useless in a handler, as the handler is always executed in the active context.

Is anyone aware of a situation in which @Inject MPart would fail (in a handler class) and the usage of  @Named(IServiceConstants.ACTIVE_PART) would return the correct part?

I'm unable to construct one, so I'm thinking about changing the template code.

I understand that the constants are useful somewhere else, e.g. another part but IMHO not in a handler.

Best regards, Lars






Back to the top