Skip to content

Commit c45bf31

Browse files
Mikhail42ihostage
authored andcommitted
Support for Scala 3
1 parent 367d1d3 commit c45bf31

6 files changed

Lines changed: 18 additions & 21 deletions

File tree

build.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ lazy val client = project
3131
.settings(
3232
name := "play-soap-client",
3333
description := "Play SOAP client",
34-
crossScalaVersions := Seq(scala213),
34+
crossScalaVersions := Seq(scala213, scala3),
3535
Dependencies.`play-client`,
3636
)
3737

@@ -87,7 +87,7 @@ lazy val testJava = project
8787
.settings(
8888
name := "play-soap-test-java",
8989
description := "Play SOAP integration tests for Java",
90-
crossScalaVersions := Seq(scala213),
90+
crossScalaVersions := Seq(scala213, scala3),
9191
scalaVersion := scala213,
9292
publish / skip := true,
9393
Compile / doc / sources := Seq.empty,
@@ -121,7 +121,7 @@ lazy val testScala = project
121121
.settings(
122122
name := "play-soap-test-scala",
123123
description := "Play SOAP integration tests for Scala",
124-
crossScalaVersions := Seq(scala213),
124+
crossScalaVersions := Seq(scala213, scala3),
125125
scalaVersion := scala213,
126126
publish / skip := true,
127127
Compile / doc / sources := Seq.empty,

client/src/main/scala/play/soap/PlayJaxWsProxyFactoryBean.scala

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private[soap] class PlayJaxWsProxyFactoryBean extends ClientProxyFactoryBean(new
8282
* @param h
8383
* a <code>List</code> of <code>Handler</code> objects
8484
*/
85-
def setHandlers(h: JList[Handler[_ <: MessageContext]]) {
85+
def setHandlers(h: JList[Handler[_ <: MessageContext]]): Unit = {
8686
handlers.clear()
8787
handlers.addAll(h)
8888
}
@@ -97,7 +97,7 @@ private[soap] class PlayJaxWsProxyFactoryBean extends ClientProxyFactoryBean(new
9797
handlers
9898
}
9999

100-
def setLoadHandlers(b: Boolean) {
100+
def setLoadHandlers(b: Boolean): Unit = {
101101
loadHandlers = b
102102
}
103103

@@ -123,7 +123,7 @@ private[soap] class PlayJaxWsProxyFactoryBean extends ClientProxyFactoryBean(new
123123
* @return
124124
* the proxy. You must cast the returned object to the approriate class before making remote calls
125125
*/
126-
override def create: AnyRef = {
126+
override def create(): AnyRef = {
127127
var orig: ClassLoaderUtils.ClassLoaderHolder = null
128128
try {
129129
if (getBus != null) {
@@ -132,7 +132,7 @@ private[soap] class PlayJaxWsProxyFactoryBean extends ClientProxyFactoryBean(new
132132
orig = ClassLoaderUtils.setThreadContextClassloader(loader)
133133
}
134134
}
135-
val obj: AnyRef = super.create
135+
val obj: AnyRef = super.create()
136136

137137
val service: Service = getServiceFactory.getService
138138
if (needWrapperClassInterceptor(service.getServiceInfos.get(0))) {
@@ -156,13 +156,10 @@ private[soap] class PlayJaxWsProxyFactoryBean extends ClientProxyFactoryBean(new
156156
if (serviceInfo == null) {
157157
return false
158158
}
159-
import scala.collection.JavaConverters._
160-
for (opInfo <- serviceInfo.getInterface.getOperations.asScala) {
161-
if (opInfo.isUnwrappedCapable && opInfo.getProperty(ReflectionServiceFactoryBean.WRAPPERGEN_NEEDED) != null) {
162-
return true
163-
}
164-
}
165-
return false
159+
import scala.jdk.CollectionConverters._
160+
serviceInfo.getInterface.getOperations.asScala.exists(opInfo =>
161+
opInfo.isUnwrappedCapable && opInfo.getProperty(ReflectionServiceFactoryBean.WRAPPERGEN_NEEDED) != null
162+
)
166163
}
167164

168165
private def buildHandlerChain(cp: PlayJaxWsClientProxy): Unit = {
@@ -185,7 +182,7 @@ private[soap] class PlayJaxWsProxyFactoryBean extends ClientProxyFactoryBean(new
185182
resourceManager = new DefaultResourceManager(resolvers)
186183
resourceManager.addResourceResolver(new WebServiceContextResourceResolver)
187184
val injector: ResourceInjector = new ResourceInjector(resourceManager)
188-
import scala.collection.JavaConverters._
185+
import scala.jdk.CollectionConverters._
189186
for (h <- chain.asScala) {
190187
if (Proxy.isProxyClass(h.getClass) && getServiceClass != null) {
191188
injector.inject(h, getServiceClass)

client/src/main/scala/play/soap/PlaySoapPlugin.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import org.apache.cxf.transport.http.asyncclient.AsyncHttpTransportFactory
2020
import play.api._
2121
import play.api.inject.ApplicationLifecycle
2222

23-
import scala.collection.JavaConverters._
23+
import scala.jdk.CollectionConverters._
2424
import scala.concurrent.Future
2525
import scala.reflect.ClassTag
2626

@@ -59,7 +59,7 @@ abstract class PlaySoapClient @Inject() (apacheCxfBus: ApacheCxfBus, configurati
5959
defaultAddress: String,
6060
handlers: Handler[_ <: MessageContext]*
6161
)(implicit ct: ClassTag[T]): T = {
62-
val factory = createFactory
62+
val factory: PlayJaxWsProxyFactoryBean = createFactory
6363

6464
if (readConfig(portName, _.getOptional[Boolean]("debugLog"), false)) {
6565
factory.getInInterceptors.add(new LoggingInInterceptor)
@@ -79,7 +79,7 @@ abstract class PlaySoapClient @Inject() (apacheCxfBus: ApacheCxfBus, configurati
7979
port.asInstanceOf[T]
8080
}
8181

82-
private def createFactory = {
82+
private def createFactory: PlayJaxWsProxyFactoryBean = {
8383
val factory = new PlayJaxWsProxyFactoryBean
8484
factory.setBus(apacheCxfBus.bus)
8585
factory

project/Common.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ object Common extends AutoPlugin {
5050
)
5151
),
5252
headerMappings ++= Map(
53-
// TODO: use `FileType.xml.firstLinePattern` instead after release https://github.com/sbt/sbt-header/issues/310
54-
FileType("wsdl", Some("(<\\?xml.*\\?>(?:\\s+))([\\S\\s]*)".r)) -> HeaderCommentStyle.xmlStyleBlockComment
53+
FileType("wsdl", FileType.xml.firstLinePattern) -> HeaderCommentStyle.xmlStyleBlockComment
5554
)
5655
)
5756
}

project/Dependencies.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ object Dependencies {
99

1010
object ScalaVersions {
1111
val scala213 = "2.13.16"
12+
val scala3 = "3.3.5"
1213
}
1314

1415
object Versions {

test/scala/src/test/scala/play/soap/test/PrimitivesSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PrimitivesSpec extends AsyncWordSpec with BeforeAndAfterAll with AsyncTime
3838
factory.setServiceClass(classOf[Primitives])
3939
// noinspection HttpUrlsUsage
4040
factory.setAddress(s"http://${container.containerIpAddress}:${container.mappedPort(8080)}/primitives")
41-
client = factory.create.asInstanceOf[Primitives]
41+
client = factory.create().asInstanceOf[Primitives]
4242
}
4343

4444
"SOAP service that uses primitives" should {

0 commit comments

Comments
 (0)