Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mmt-errorView
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Maeder
mmt-errorView
Commits
fcc9ec12
Commit
fcc9ec12
authored
Jan 27, 2015
by
cmaeder
Browse files
Options
Downloads
Patches
Plain Diff
separated static content server
parent
02be9048
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/Table.scala
+2
-3
2 additions, 3 deletions
src/main/scala/Table.scala
src/test/scala/CamelTest.scala
+13
-29
13 additions, 29 deletions
src/test/scala/CamelTest.scala
with
15 additions
and
32 deletions
src/main/scala/Table.scala
+
2
−
3
View file @
fcc9ec12
import
org.apache.camel.CamelContext
import
org.apache.camel.component.sql.SqlComponent
import
org.apache.camel.component.sql.SqlComponent
import
org.apache.camel.impl.DefaultCamelContext
import
org.apache.camel.impl.DefaultCamelContext
import
org.sqlite.SQLiteDataSource
import
org.sqlite.SQLiteDataSource
...
@@ -7,7 +6,7 @@ object Table {
...
@@ -7,7 +6,7 @@ object Table {
val
columns
=
List
(
"fileName"
,
"errType"
,
"shortMsg"
,
"errLevel"
,
"longMsg"
)
val
columns
=
List
(
"fileName"
,
"errType"
,
"shortMsg"
,
"errLevel"
,
"longMsg"
)
val
name
=
"errors"
val
name
=
"errors"
def
initArgs
(
args
:
scala.Array
[
String
])
:
(
CamelContext
,
String
)
=
{
def
initArgs
(
args
:
scala.Array
[
String
])
:
(
Default
CamelContext
,
String
)
=
{
val
sqlComponent
:
SqlComponent
=
new
SqlComponent
()
val
sqlComponent
:
SqlComponent
=
new
SqlComponent
()
val
ds
:
SQLiteDataSource
=
new
SQLiteDataSource
()
val
ds
:
SQLiteDataSource
=
new
SQLiteDataSource
()
val
name
=
if
(
args
.
isEmpty
)
Table
.
name
else
args
(
0
)
val
name
=
if
(
args
.
isEmpty
)
Table
.
name
else
args
(
0
)
...
@@ -15,7 +14,7 @@ object Table {
...
@@ -15,7 +14,7 @@ object Table {
ds
.
setDatabaseName
(
dbName
)
ds
.
setDatabaseName
(
dbName
)
ds
.
setUrl
(
"jdbc:sqlite:"
+
dbName
)
ds
.
setUrl
(
"jdbc:sqlite:"
+
dbName
)
sqlComponent
.
setDataSource
(
ds
)
sqlComponent
.
setDataSource
(
ds
)
val
context
:
CamelContext
=
new
DefaultCamelContext
()
val
context
=
new
DefaultCamelContext
()
context
.
addComponent
(
"db"
,
sqlComponent
)
context
.
addComponent
(
"db"
,
sqlComponent
)
val
dir
=
if
(
args
.
length
>
1
)
args
(
1
)
else
System
.
getProperty
(
"user.dir"
)
val
dir
=
if
(
args
.
length
>
1
)
args
(
1
)
else
System
.
getProperty
(
"user.dir"
)
(
context
,
dir
)
(
context
,
dir
)
...
...
This diff is collapsed.
Click to expand it.
src/test/scala/CamelTest.scala
+
13
−
29
View file @
fcc9ec12
import
org.apache.camel.component.sql.SqlComponent
import
org.apache.camel.Exchange
import
org.apache.camel.impl.DefaultCamelContext
import
org.apache.camel.scala.dsl.builder.RouteBuilder
import
org.apache.camel.scala.dsl.builder.RouteBuilder
import
org.apache.camel.
{
CamelContext
,
Exchange
}
import
org.apache.camel.
util.jndi.JndiContext
import
org.
sqlite.SQLiteDataSource
import
org.
eclipse.jetty.server.handler.ResourceHandler
import
scala.collection.
{
JavaConversions
,
mutable
}
import
scala.collection.
{
JavaConversions
,
mutable
}
...
@@ -22,36 +21,21 @@ object CamelTest {
...
@@ -22,36 +21,21 @@ object CamelTest {
exchange
.
out
=
JavaConversions
.
asJavaDictionary
(
result
)
exchange
.
out
=
JavaConversions
.
asJavaDictionary
(
result
)
}
}
"jetty:http://localhost:8383/sally
/test
"
process
myProcessor
to
"freemarker:file:src/main/resource
s
/index.html"
"jetty:http://localhost:8383/sally"
process
myProcessor
to
"freemarker:file:src/main/resource/index.html"
"jetty:http://localhost:8383/sally/test/insert"
-->
"log:a?showHeaders=true"
"jetty:http://localhost:8383/sally/test/insert"
-->
"log:a?showHeaders=true"
"jetty:http://localhost:8383/static?matchOnUriPrefix=true&handlers=#staticHandler"
-->
"log:b"
"direct:insertValues"
-->
"db:insert into person values(1, 'leo')"
-->
"db:insert into person values(2, 'yui')"
"direct:createTables"
-->
"db:drop table if exists person"
-->
"db:create table person (id integer, name string)"
"direct:listValues"
-->
"db:select count(*) from person"
-->
"log:a"
}
}
def
main
(
args
:
scala.Array
[
String
])
{
def
main
(
args
:
scala.Array
[
String
])
{
val
(
context
,
_
)
=
Table
.
initArgs
(
args
)
// init SQLite connection
val
resHandler
=
new
ResourceHandler
()
// Class.forName("org.sqlite.JDBC")
resHandler
.
setResourceBase
(
"src/main/resource"
)
val
sqlComponent
:
SqlComponent
=
new
SqlComponent
()
val
jdni
=
new
JndiContext
()
val
ds
:
SQLiteDataSource
=
new
SQLiteDataSource
()
jdni
.
bind
(
"staticHandler"
,
resHandler
)
ds
.
setDatabaseName
(
"test.db"
)
context
.
setJndiContext
(
jdni
)
ds
.
setUrl
(
"jdbc:sqlite:test.db"
)
context
.
addRoutes
(
new
MyRouteBuilder
())
sqlComponent
.
setDataSource
(
ds
)
val
errStore
=
new
SQLiteStore
()
val
context
:
CamelContext
=
new
DefaultCamelContext
()
context
.
addRoutes
(
errStore
)
context
.
addComponent
(
"db"
,
sqlComponent
)
context
.
start
()
context
.
start
()
errStore
.
initTable
()
val
pa
=
new
ParseXML
(
errStore
)
pa
.
parseDir
(
"/local/maeder/tptp/Distribution/errors"
)
errStore
.
queryValues
(
false
,
"skipped"
,
"shortMsg"
)
errStore
.
queryValues
(
false
,
""
,
"errType"
)
errStore
.
queryValues
(
true
,
"LocalError"
,
"errType"
)
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment