add trust all package
This commit is contained in:
parent
1381d706ed
commit
2cd3dd6549
@ -1,7 +1,7 @@
|
||||
package drills.drill07.exercise3.hello
|
||||
|
||||
import drills.drill07.exercise3.replier.ActiveMQReplier
|
||||
import drills.drill07.exercise3.replier.Replier
|
||||
import util.jms.replier.ActiveMQReplier
|
||||
import util.jms.replier.Replier
|
||||
import javax.jms.TextMessage
|
||||
|
||||
fun main() {
|
||||
|
@ -1,11 +1,12 @@
|
||||
package drills.drill07.exercise3.hello
|
||||
|
||||
import drills.drill07.exercise3.requestor.ActiveMQRequestor
|
||||
import drills.drill07.exercise3.requestor.Requestor
|
||||
import util.jms.requestor.ActiveMQRequestor
|
||||
import util.jms.requestor.Requestor
|
||||
import javax.jms.TextMessage
|
||||
|
||||
fun main() {
|
||||
val requestor: Requestor = ActiveMQRequestor("hello", shared = true)
|
||||
val requestor: Requestor =
|
||||
ActiveMQRequestor("hello", shared = true)
|
||||
|
||||
val msg = requestor.request(requestor.createTextMessage("Hello Home!")) as TextMessage
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package drills.drill07.exercise4
|
||||
|
||||
import drills.drill07.exercise3.replier.ActiveMQReplier
|
||||
import drills.drill07.exercise3.replier.Replier
|
||||
import util.jms.replier.ActiveMQReplier
|
||||
import util.jms.replier.Replier
|
||||
|
||||
fun main() {
|
||||
val replier: Replier = ActiveMQReplier("factorial", shared = true)
|
||||
|
@ -1,10 +1,11 @@
|
||||
package drills.drill07.exercise4
|
||||
|
||||
import drills.drill07.exercise3.requestor.ActiveMQRequestor
|
||||
import drills.drill07.exercise3.requestor.Requestor
|
||||
import util.jms.requestor.ActiveMQRequestor
|
||||
import util.jms.requestor.Requestor
|
||||
|
||||
fun main() {
|
||||
val requestor: Requestor = ActiveMQRequestor("factorial", shared = true)
|
||||
val requestor: Requestor =
|
||||
ActiveMQRequestor("factorial", shared = true)
|
||||
|
||||
println("Enter the number of which you want to calculate the factorial:")
|
||||
val n = readLine()?.toInt()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package drills.drill07.exercise3.replier
|
||||
package util.jms.replier
|
||||
|
||||
import java.io.Serializable
|
||||
import javax.jms.Message
|
||||
import javax.jms.Queue
|
||||
import javax.jms.QueueConnectionFactory
|
||||
@ -13,12 +14,12 @@ abstract class AbstarctReplier(
|
||||
) : Replier {
|
||||
private val factory: QueueConnectionFactory = this.getFactory()
|
||||
private val connection = factory.createQueueConnection()
|
||||
private val session = connection.createQueueSession(
|
||||
private val mainSession = connection.createQueueSession(
|
||||
false,
|
||||
Session.AUTO_ACKNOWLEDGE
|
||||
)
|
||||
private val mainQueue = session.createQueue(queueName)
|
||||
private val receiver = session.createReceiver(mainQueue)
|
||||
private val mainQueue = mainSession.createQueue(queueName)
|
||||
private val receiver = mainSession.createReceiver(mainQueue)
|
||||
private val secondarySession = connection.createQueueSession(
|
||||
false,
|
||||
Session.AUTO_ACKNOWLEDGE
|
||||
@ -37,18 +38,19 @@ abstract class AbstarctReplier(
|
||||
}
|
||||
}
|
||||
|
||||
override fun createTextMessage(text: String): TextMessage = session.createTextMessage(text)
|
||||
override fun createTextMessage(text: String): TextMessage = mainSession.createTextMessage(text)
|
||||
|
||||
override fun createObjectMessage(): ObjectMessage = session.createObjectMessage()
|
||||
override fun createObjectMessage(obj: Serializable?): ObjectMessage =
|
||||
mainSession.createObjectMessage(obj)
|
||||
|
||||
override fun createMessage(): Message = session.createMessage()
|
||||
override fun createMessage(): Message = mainSession.createMessage()
|
||||
|
||||
override fun start() {
|
||||
connection.start()
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
session.close()
|
||||
mainSession.close()
|
||||
connection.close()
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package drills.drill07.exercise3.replier
|
||||
package util.jms.replier
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory
|
||||
import javax.jms.QueueConnectionFactory
|
||||
@ -8,4 +8,5 @@ class ActiveMQReplier(
|
||||
shared: Boolean = false
|
||||
) : AbstarctReplier(queueName, shared) {
|
||||
override fun getFactory(uri: String): QueueConnectionFactory = ActiveMQConnectionFactory(uri)
|
||||
.also { it.isTrustAllPackages = true }
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package drills.drill07.exercise3.replier
|
||||
package util.jms.replier
|
||||
|
||||
import java.io.Serializable
|
||||
import javax.jms.Message
|
||||
import javax.jms.ObjectMessage
|
||||
import javax.jms.TextMessage
|
||||
@ -7,7 +8,7 @@ import javax.jms.TextMessage
|
||||
interface Replier {
|
||||
fun onRequest(buildResponse: (Message) -> Message)
|
||||
fun createTextMessage(text: String = ""): TextMessage
|
||||
fun createObjectMessage(): ObjectMessage
|
||||
fun createObjectMessage(obj: Serializable? = null): ObjectMessage
|
||||
fun createMessage(): Message
|
||||
fun start()
|
||||
fun close()
|
@ -1,5 +1,6 @@
|
||||
package drills.drill07.exercise3.requestor
|
||||
package util.jms.requestor
|
||||
|
||||
import java.io.Serializable
|
||||
import javax.jms.Message
|
||||
import javax.jms.QueueConnectionFactory
|
||||
import javax.jms.Session
|
||||
@ -42,7 +43,8 @@ abstract class AbstractRequestor(
|
||||
|
||||
override fun createTextMessage(text: String): TextMessage = mainSession.createTextMessage(text)
|
||||
|
||||
override fun createObjectMessage(): ObjectMessage = mainSession.createObjectMessage()
|
||||
override fun createObjectMessage(obj: Serializable?): ObjectMessage =
|
||||
mainSession.createObjectMessage(obj)
|
||||
|
||||
override fun createMessage(): Message = mainSession.createMessage()
|
||||
|
@ -1,4 +1,4 @@
|
||||
package drills.drill07.exercise3.requestor
|
||||
package util.jms.requestor
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory
|
||||
import javax.jms.QueueConnectionFactory
|
||||
@ -8,4 +8,5 @@ class ActiveMQRequestor(
|
||||
shared: Boolean = false
|
||||
) : AbstractRequestor(queueName, shared) {
|
||||
override fun getFactory(uri: String): QueueConnectionFactory = ActiveMQConnectionFactory(uri)
|
||||
.also { it.isTrustAllPackages = true }
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package drills.drill07.exercise3.requestor
|
||||
package util.jms.requestor
|
||||
|
||||
import java.io.Serializable
|
||||
import javax.jms.Message
|
||||
import javax.jms.ObjectMessage
|
||||
import javax.jms.TextMessage
|
||||
@ -7,7 +8,7 @@ import javax.jms.TextMessage
|
||||
interface Requestor {
|
||||
fun request(message: Message): Message
|
||||
fun createTextMessage(text: String = ""): TextMessage
|
||||
fun createObjectMessage(): ObjectMessage
|
||||
fun createObjectMessage(obj: Serializable? = null): ObjectMessage
|
||||
fun createMessage(): Message
|
||||
fun close()
|
||||
}
|
Loading…
Reference in New Issue
Block a user