Skip to content

Commit 9340f01

Browse files
committed
Framework integrated
1 parent 4133bdf commit 9340f01

File tree

12 files changed

+117
-49
lines changed

12 files changed

+117
-49
lines changed

build.gradle

+4-41
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ buildscript {
22
apply from: project.rootProject.relativePath('buildscript.gradle'), to: buildscript
33
}
44

5-
defaultTasks = ['clean', 'createOsgiContainer']
6-
75
apply plugin: 'neva.osgi-container'
86

7+
defaultTasks = ['clean', 'createOsgiContainer']
8+
description = "OSGi based, written in Kotlin, MVC framework for web artisans from Java community"
9+
910
allprojects {
1011
group 'com.neva.javarel'
1112
version "1.0.0.ALPHA"
@@ -21,22 +22,7 @@ allprojects {
2122

2223
dependencies {
2324
osgiMain 'org.apache.felix:org.apache.felix.main:5.6.0'
24-
osgiBundle 'org.apache.felix:org.apache.felix.fileinstall:3.5.4'
25-
osgiBundle 'org.apache.felix:org.apache.felix.configadmin:1.8.10'
26-
osgiBundle 'org.apache.felix:org.apache.felix.eventadmin:1.4.8'
27-
osgiBundle 'org.apache.felix:org.apache.felix.metatype:1.1.2'
28-
osgiBundle 'org.apache.felix:org.apache.felix.webconsole:4.2.16'
29-
osgiBundle 'org.ops4j.pax.logging:pax-logging-service:1.9.0'
30-
31-
osgiModule project(':foundation')
32-
osgiModule project(':resource')
33-
osgiModule project(':communication:rest')
34-
osgiModule project(':presentation:asset')
35-
osgiModule project(':presentation:view')
36-
osgiModule project(':presentation:view:pebble')
37-
osgiModule project(':storage')
38-
osgiModule project(':processing:scheduler')
39-
osgiModule project(':security:auth')
25+
osgiModule project(':integration')
4026
}
4127

4228
osgiContainer {
@@ -49,7 +35,6 @@ osgiContainer {
4935
'xml-apis-1.3*',
5036
'antlr',
5137
'animal-sniffer-annotations',
52-
'grizzly-httpservice-bundle*',
5338
'kxml2',
5439
'xmlpull',
5540
])
@@ -58,8 +43,6 @@ osgiContainer {
5843
subprojects { subProject ->
5944

6045
plugins.withId 'kotlin', {
61-
// testCompile group: 'junit', name: 'junit', version: '4.11'
62-
6346
jar.baseName = "javarel-${subProject.path.substring(1).replace(':', '-')}"
6447

6548
sourceCompatibility = 1.7
@@ -91,26 +74,6 @@ subprojects { subProject ->
9174
instruction 'Bundle-Category', 'javarel'
9275
}
9376
}
94-
95-
dependencies {
96-
osgiBundle 'org.jetbrains.kotlin:kotlin-osgi-bundle:1.0.4'
97-
98-
osgiBundle 'org.osgi:org.osgi.enterprise:5.0.0'
99-
osgiBundle 'org.osgi:org.osgi.core:5.0.0'
100-
101-
osgiBundle 'org.apache.felix:org.apache.felix.scr:2.0.6'
102-
compile 'org.apache.felix:org.apache.felix.scr.annotations:1.11.0'
103-
104-
osgiBundle 'javax.servlet:javax.servlet-api:3.0.1'
105-
osgiBundle 'com.google.guava:guava:19.0'
106-
osgiBundle 'com.google.code.gson:gson:2.6.2'
107-
osgiBundle 'commons-io:commons-io:2.4'
108-
osgiBundle 'commons-fileupload:commons-fileupload:1.3.1'
109-
osgiBundle 'org.json:json:20160212'
110-
osgiBundle 'org.apache.commons:commons-lang3:3.4'
111-
osgiBundle 'org.slf4j:slf4j-api:1.7.6'
112-
osgiBundle 'org.slf4j:slf4j-log4j12:1.7.6'
113-
}
11477
}
11578

11679
}

buildscript.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dependencies {
22
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.4"
33

44
//classpath "gradle.plugin.com.neva.gradle.plugin:osgi:1.0.1"
5-
classpath "com.neva.gradle.plugin:osgi:1.0.1"
5+
classpath "com.neva.gradle.plugin:osgi:1.0.1", { changing = true }
66

77
classpath "gradle.plugin.com.neva.gradle.plugin:openjpa:1.0.0"
88
classpath "gradle.plugin.com.neva.gradle.plugin:scr:1.0.0"

communication/rest/src/main/kotlin/com/neva/javarel/communication/rest/impl/JerseyRestApplication.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.glassfish.jersey.servlet.ServletContainer
1111
import org.glassfish.jersey.servlet.ServletProperties
1212
import org.osgi.framework.BundleEvent
1313
import org.slf4j.LoggerFactory
14+
import java.util.*
1415

1516
@Component(immediate = true)
1617
@Service
@@ -57,10 +58,9 @@ class JerseyRestApplication : RestApplication, BundleWatcher {
5758
val components = bundleScanner.scan(COMPONENT_FILTER)
5859
val resourceConfig = OsgiResourceConfig(components)
5960
resourceConfig.properties = mapOf(ServletProperties.FILTER_CONTEXT_PATH to "/")
60-
6161
this.filter = JerseyFilter(restConfig, resourceConfig)
6262

63-
http.registerFilter(filter, ".*", null, JerseyFilter.RANKING, null)
63+
http.registerFilter(filter, ".*", filterProps, JerseyFilter.RANKING, null)
6464
router.configure(components)
6565
started = true
6666
} catch (e: Throwable) {
@@ -80,6 +80,14 @@ class JerseyRestApplication : RestApplication, BundleWatcher {
8080
}
8181
}
8282

83+
private val filterProps: Dictionary<String, Any>
84+
get() {
85+
val props = Hashtable<String, Any>()
86+
props.put("jersey.config.servlet.filter.contextPath", "")
87+
88+
return props
89+
}
90+
8391
@Synchronized
8492
override fun toggle(start: Boolean) {
8593
if (ready) {

foundation/build.gradle

+20-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ buildscript {
22
apply from: rootProject.file('buildscript.gradle'), to: buildscript
33
}
44

5-
description = 'Javarel :: Foundation Utilities'
5+
description = 'Javarel :: Foundation'
66

77
apply plugin: 'kotlin'
88
apply plugin: 'maven-publish'
@@ -17,13 +17,31 @@ jar {
1717
}
1818

1919
dependencies {
20+
compile 'org.apache.felix:org.apache.felix.main:5.6.0'
21+
compile 'org.apache.felix:org.apache.felix.scr.annotations:1.11.0'
22+
23+
osgiBundle 'org.jetbrains.kotlin:kotlin-osgi-bundle:1.0.4'
24+
25+
osgiBundle 'org.osgi:org.osgi.enterprise:5.0.0'
26+
osgiBundle 'org.osgi:org.osgi.core:5.0.0'
27+
2028
osgiBundle 'org.apache.felix:org.apache.felix.fileinstall:3.5.4'
2129
osgiBundle 'org.apache.felix:org.apache.felix.configadmin:1.8.10'
2230
osgiBundle 'org.apache.felix:org.apache.felix.eventadmin:1.4.8'
2331
osgiBundle 'org.apache.felix:org.apache.felix.metatype:1.1.2'
2432
osgiBundle 'org.apache.felix:org.apache.felix.webconsole:4.2.16'
33+
osgiBundle 'org.apache.felix:org.apache.felix.scr:2.0.6'
2534
osgiBundle 'org.ops4j.pax.logging:pax-logging-service:1.9.0'
2635

27-
osgiBundle 'org.ow2.asm:asm:5.1'
36+
osgiBundle 'javax.servlet:javax.servlet-api:3.0.1'
37+
osgiBundle 'com.google.guava:guava:19.0'
38+
osgiBundle 'com.google.code.gson:gson:2.6.2'
39+
osgiBundle 'commons-io:commons-io:2.4'
40+
osgiBundle 'commons-fileupload:commons-fileupload:1.3.1'
41+
osgiBundle 'org.json:json:20160212'
42+
osgiBundle 'org.apache.commons:commons-lang3:3.4'
43+
osgiBundle 'org.slf4j:slf4j-api:1.7.6'
44+
osgiBundle 'org.slf4j:slf4j-log4j12:1.7.6'
2845

46+
osgiBundle 'org.ow2.asm:asm:5.1'
2947
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Oct 22 13:37:43 CEST 2016
1+
#Sat Oct 22 15:13:58 CEST 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-all.zip

integration/build.gradle

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
buildscript {
2+
apply from: rootProject.file('buildscript.gradle'), to: buildscript
3+
}
4+
5+
description = 'Javarel :: Integration'
6+
7+
apply plugin: 'kotlin'
8+
apply plugin: 'maven-publish'
9+
apply plugin: 'neva.osgi-module'
10+
apply plugin: 'neva.scr'
11+
12+
jar {
13+
manifest {
14+
name project.description
15+
instruction 'Export-Package', "com.neva.javarel.integration.api.*;version=${project.version}"
16+
}
17+
}
18+
19+
dependencies {
20+
compile project(':foundation')
21+
22+
osgiBundle project(':foundation')
23+
osgiBundle project(':resource')
24+
osgiBundle project(':communication:rest')
25+
osgiBundle project(':presentation:asset')
26+
osgiBundle project(':presentation:view')
27+
osgiBundle project(':presentation:view:pebble')
28+
osgiBundle project(':storage')
29+
osgiBundle project(':processing:scheduler')
30+
osgiBundle project(':security:auth')
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.neva.javarel.integration.api.rest
2+
3+
import com.neva.javarel.communication.rest.api.RestRequest
4+
import com.neva.javarel.communication.rest.api.UrlGenerator
5+
import com.neva.javarel.communication.rest.api.Uses
6+
import com.neva.javarel.presentation.view.api.View
7+
import com.neva.javarel.resource.api.ResourceResolver
8+
import com.neva.javarel.security.auth.api.Guard
9+
import com.neva.javarel.storage.api.DatabaseAdmin
10+
import javax.ws.rs.core.Context
11+
12+
abstract class Controller {
13+
14+
@Context
15+
protected lateinit var request: RestRequest
16+
17+
@Uses
18+
protected lateinit var guard: Guard
19+
20+
@Uses
21+
protected lateinit var db: DatabaseAdmin
22+
23+
@Uses
24+
protected lateinit var urlGenerator: UrlGenerator
25+
26+
@Uses
27+
protected lateinit var resourceResolver: ResourceResolver
28+
29+
protected fun view(resourceUri: String): View {
30+
return resourceResolver.findOrFail(resourceUri).adaptTo(View::class).with(viewGlobals())
31+
}
32+
33+
protected fun viewGlobals(): Map<String, Any> {
34+
return mapOf(
35+
"request" to request,
36+
"guard" to guard
37+
)
38+
}
39+
40+
}

presentation/asset/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jar {
1717
}
1818

1919
dependencies {
20+
compile project(':foundation')
2021
compile project(':resource')
2122
compile project(':communication:rest')
2223

presentation/view/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ jar {
1818
dependencies {
1919
compile project(':resource')
2020
}
21+
}
22+
23+
dependencies {
24+
compile project(':foundation')
2125
}

processing/scheduler/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ jar {
1717
}
1818

1919
dependencies {
20+
compile project(':foundation')
21+
2022
osgiBundle 'org.quartz-scheduler:quartz:2.2.2'
2123
}

security/auth/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ jar {
1818
}
1919

2020
dependencies {
21+
compile project(':foundation')
2122
compile project(':communication:rest')
2223
}

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ include ':presentation:view:pebble'
99
include ':processing:scheduler'
1010
include ':security:auth'
1111
include ':storage'
12-
12+
include ':integration'

0 commit comments

Comments
 (0)