forked from tranSMART-Foundation/Rmodules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RdcRmodulesGrailsPlugin.groovy
71 lines (62 loc) · 2.71 KB
/
RdcRmodulesGrailsPlugin.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*************************************************************************
* Copyright 2008-2012 Janssen Research & Development, LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************/
import com.google.common.collect.ImmutableMap
import jobs.misc.AnalysisQuartzJobAdapter
import org.springframework.beans.factory.config.CustomScopeConfigurer
import org.springframework.stereotype.Component
import org.transmartproject.core.users.User
class RdcRmodulesGrailsPlugin {
def version = '18.1-SNAPSHOT'
def grailsVersion = '2.3 > *'
def title = 'R Modules Plugin'
def author = 'Sai Kumar Munikuntla'
def authorEmail = '[email protected]'
def description = 'TODO'
def documentation = 'TODO'
def license = 'GPL3'
def issueManagement = [system: 'TODO', url: 'TODO']
def scm = [url: 'https://github.com/transmart/Rmodules']
def doWithSpring = {
xmlns context: 'http://www.springframework.org/schema/context'
context.'component-scan'('base-package': 'jobs') {
context.'include-filter'(type: 'annotation', expression: Component.canonicalName)
}
jobScopeConfigurer(CustomScopeConfigurer) {
scopes = ImmutableMap.of('job', ref('jobSpringScope'))
}
// these beans are actually created manually and put in the storage for the job scope
jobName(String) { bean ->
bean.scope = 'job'
}
"$AnalysisQuartzJobAdapter.BEAN_USER_IN_CONTEXT"(User) { bean ->
bean.scope = 'job'
}
// Prevent the resource plugin from handling the resources in this so that it can be served directly
def adhoc = application.config.grails.resources.adhoc
adhoc.excludes = ['/analysisFiles/**', '/images/analysisFiles/**'] + (adhoc.excludes ?: [])
}
def doWithApplicationContext = { applicationContext ->
// currentUserBean is a tranSMART bean
def currentUserBean = applicationContext.getBean('¤tUserBean')
if (!currentUserBean) {
throw new IllegalStateException(
"The context doesn't provide the bean currentUserBean. " +
"Most likely, you're using an incompatible transmartApp")
}
// allow currentUserBean to be able to find the current user inside the jobs (quartz) threads
currentUserBean.registerBeanToTry(AnalysisQuartzJobAdapter.BEAN_USER_IN_CONTEXT)
}
}