Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Eventbus available from Filters #179

Closed
timmarsha11 opened this issue Feb 17, 2021 · 6 comments
Closed

Make Eventbus available from Filters #179

timmarsha11 opened this issue Feb 17, 2021 · 6 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@timmarsha11
Copy link

At present the eventbus is only available for logging errors in filters. It has private access in the AbstractFilter class.

Proposed to make the eventbus available for general events (especially logging) when the filter is activated i.e making it protected access.

@FrankHossfeld FrankHossfeld self-assigned this Feb 17, 2021
@FrankHossfeld
Copy link
Collaborator

I do not see any reason why the event bus should not have protected access.

@FrankHossfeld FrankHossfeld added the enhancement New feature or request label Feb 26, 2021
@FrankHossfeld FrankHossfeld added this to the 2.2.1 milestone Mar 28, 2021
@timmarsha11
Copy link
Author

timmarsha11 commented Apr 6, 2021

Hi, it seems that the eventBus is not populated in the filter (its null when I try and use it).

My project setup uses a LoginModule. In the LoginFilter class, I try and send a message to the eventBus but the eventBus is null.
....
@OverRide
public boolean filter(String route, String... parms) {
if (!LoginModuleRoutes.LOGIN_ROUTE.equals(route)) {
if (!this.context.isLoggedIn()) {
this.eventBus.fireEvent(LogEvent.create().addMessage("User is not logged in! Redirect to Login screen!"));

			return false;
		}
	}
	return true;
}

...

In the generated LoginModuleModuleImpl class, I suspect the eventbus needs to be set in this method, when the context is set???

@OverRide
public void loadFilters(RouterConfiguration routerConfiguration) {
LoginFilter client_module_login_filter_LoginFilter = new LoginFilter();
client_module_login_filter_LoginFilter.setContext(super.moduleContext);
client_module_login_filter_LoginFilter.setEventBus(super.eventBus)<-- this need to be generated
routerConfiguration.getFilters().add(client_module_login_filter_LoginFilter);
}

@FrankHossfeld
Copy link
Collaborator

FrankHossfeld commented Apr 6, 2021

Mmmh, I checked the filters of my project. and in all filters the event bus is set.
I am pretty sure, you are using an old version. ATM this feature is only available inside the latest SNAPSHOT.

Please, retry using the latest SNAPSHOT.

@FrankHossfeld
Copy link
Collaborator

Oh, I missed the module generator ... please try again

FrankHossfeld added a commit that referenced this issue Apr 6, 2021
@timmarsha11
Copy link
Author

Oh, I missed the module generator ... please try again

yep this is now working in HEAD-SNAPSHOT

@FrankHossfeld
Copy link
Collaborator

Thanks for confirming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants