-
Notifications
You must be signed in to change notification settings - Fork 151
Index sync job #79
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
Index sync job #79
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt possible to use the environment inside of the frequency method of the controller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, no. This appears to be called by the vRaptor-quartz library entirely outside of the CDI. All @Injected fields are null when this is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-(
I think its because vraptor-quartzjob is building the task instance through
reflection in this class:
https://github.com/caelum/vraptor-quartzjob/blob/master/src/main/java/br/com/caelum/vraptor/quartzjob/QuartzScheduler.java#L108
.
But I think it should be possible to get the controller instance using
CDI's api. I'll take at the plugin later.
For now your solution is fine, then.
Chico Sokol
On Mon, Sep 29, 2014 at 2:52 PM, monitorjbl [email protected]
wrote:
In src/main/java/org/mamute/search/IndexSyncJob.java:
- public void onStartup(@observes InterceptorsReady init) {
if (Boolean.parseBoolean(environment.get("solr.syncOnStartup"))) {execute();}- }
- /**
- * Grabs the frequency of the job (bit of a hack to get things in the
- * correct scope)
- */
- @ApplicationScoped
- static class FrequencyInit {
@Inject private Environment environment;
public void onStartup(@Observes VRaptorInitialized init) {frequency = environment.get("solr.syncJob", DEFAULT_SYNC);Sadly, no. This appears to be called by the vRaptor-quartz library
entirely outside of the CDI. All @injected fields are null when this is
called.—
Reply to this email directly or view it on GitHub
https://github.com/caelum/mamute/pull/79/files#r18186341.
|
I pulled the |
06c9ed9 to
88698d8
Compare
|
Hard-coded the frequency to get around the scoping issues with Quartz for now. I think the rest of the design is what's intended with vRaptor: a request-scoped controller for Quartz and an application-scoped singleton with the job execution logic. |
|
Removed |
|
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing the field visibility (private)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added :)
Fix for #75. Got rid of the controller and made it into a Quartz job with a configurable frequency. Also added an option to make the index sync on startup.