Created
February 1, 2017 08:41
-
-
Save nodakai/9665c9557c10f3c1820635cd38c373d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Apply the scala plugin to add support for Scala | |
apply plugin: 'scala' | |
// In this section you declare where to find the dependencies of your project | |
repositories { | |
// Use 'jcenter' for resolving your dependencies. | |
// You can declare any Maven/Ivy/file repository here. | |
jcenter() | |
maven { | |
url "http://repo.marketcetera.org/maven" | |
} | |
} | |
configurations { | |
fatJar | |
} | |
// In this section you declare the dependencies for your production and test code | |
dependencies { | |
def deps = [ 'org.scala-lang:scala-library:2.11.8', | |
'quickfixj:quickfixj-core:1.6.1', | |
'quickfixj:quickfixj-messages-fix42:1.6.1', | |
'org.slf4j:slf4j-api:1.7.19', | |
'org.slf4j:slf4j-jdk14:1.7.19', | |
'org.kaazing:mina-core:5.0.1.51', | |
] | |
compile deps | |
fatJar deps | |
// We use Scalatest for testing our library | |
testCompile 'junit:junit:4.12', | |
'org.scalatest:scalatest_2.11:2.2.6' | |
testRuntime 'org.scala-lang.modules:scala-xml_2.11:1.0.5' | |
} | |
apply plugin: 'application' | |
version = '0.1' | |
mainClassName = 'sqpt.qqj.QuickQuickFix' | |
task fatJar(type: Jar) { | |
manifest { | |
attributes 'Implementation-Title': 'QuickQuickFix', | |
'Implementation-Version': version, | |
'Main-Class': mainClassName, | |
'Implementation-Vendor': 'nodakai' | |
} | |
baseName = project.name + '-all' | |
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } | |
with jar | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/test/scala/LibrarySuite.scala | |
import org.scalatest.FunSuite | |
import org.junit.runner.RunWith | |
import org.scalatest.junit.JUnitRunner | |
@RunWith(classOf[JUnitRunner]) | |
class LibrarySuite extends FunSuite { | |
test("test01 is always true") { | |
assert(sqpt.qqj.QFAdaptor.test01) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/main/scala/Main.scala | |
package sqpt.qqj | |
class QFAdaptor extends quickfix.Application { | |
import quickfix.{SessionID, Message} | |
def ltnow = QFAdaptor.ltnow | |
def onCreate(sessionId: SessionID) { | |
println(s"${ltnow}: onCreate: ${sessionId}") | |
} | |
def onLogon(sessionId: SessionID) { | |
println(s"${ltnow}: onLogon: ${sessionId}") | |
} | |
def onLogout(sessionId: SessionID) { | |
println(s"${ltnow}: onLogout: ${sessionId}") | |
} | |
def toAdmin(message: Message, sessionId: SessionID) { | |
println(s"${ltnow}: toAdmin: ${sessionId}, ${message}") | |
} | |
def toApp(message: Message , sessionId: SessionID) { | |
println(s"${ltnow}: onApp: ${sessionId}, ${message}") | |
} | |
def fromAdmin(message: Message, sessionId: SessionID) { | |
println(s"${ltnow}: fromAdmin: ${sessionId}, ${message}") | |
} | |
def fromApp(message: Message, sessionId: SessionID) { | |
println(s"${ltnow}: fromApp: ${sessionId}, ${message}") | |
} | |
} | |
object QFAdaptor { | |
def test01 = true | |
val cal = java.util.Calendar.getInstance | |
def ltnow = cal.getTime | |
} | |
object QuickQuickFix extends App { | |
def ltnow = QFAdaptor.ltnow | |
{ | |
println(s"Command line: [${args.mkString(",")}]") | |
val fileName = args(0); | |
val settings = new quickfix.SessionSettings(new java.io.FileInputStream(fileName)); | |
println(s"${ltnow}: parameters read from ${fileName}:") | |
println(settings) | |
val conn = new quickfix.SocketInitiator(new QFAdaptor, | |
new quickfix.FileStoreFactory(settings), | |
settings, | |
new quickfix.ScreenLogFactory(settings), | |
new quickfix.DefaultMessageFactory()) | |
println(s"${ltnow}: starting...") | |
conn.start() | |
println(s"${ltnow}: started.") | |
System.in.read | |
println(s"${ltnow}: shutting down...") | |
conn.stop() | |
println(s"${ltnow}: shut down.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment