mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 11:27:05 +00:00
Refactor/Disable Lift-specific schedulers and actor systems in Boot.scala; update pom.xml to upgrade classutil to 1.5.1 and configure maven-war-plugin with attachClasses; replace scala.jdk.CollectionConverters with scala.collection.JavaConverters for compatibility; add obp-http4s-runner module with fat JAR assembly configuration; update ClassScanUtils to handle UnsupportedOperationException from old ASM versions
This commit is contained in:
parent
21f6314e4d
commit
e3e32458c4
@ -42,6 +42,19 @@
|
|||||||
<descriptorRefs>
|
<descriptorRefs>
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
</descriptorRefs>
|
</descriptorRefs>
|
||||||
|
<dependencySets>
|
||||||
|
<dependencySet>
|
||||||
|
<outputDirectory>/</outputDirectory>
|
||||||
|
<unpack>true</unpack>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependencySet>
|
||||||
|
</dependencySets>
|
||||||
|
<fileSets>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.build.outputDirectory}</directory>
|
||||||
|
<outputDirectory>/</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
@ -388,7 +401,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.clapper</groupId>
|
<groupId>org.clapper</groupId>
|
||||||
<artifactId>classutil_${scala.version}</artifactId>
|
<artifactId>classutil_${scala.version}</artifactId>
|
||||||
<version>1.4.0</version>
|
<version>1.5.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.grumlimited</groupId>
|
<groupId>com.github.grumlimited</groupId>
|
||||||
@ -666,6 +679,8 @@
|
|||||||
<version>3.4.0</version>
|
<version>3.4.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<webXml>${webXmlPath}</webXml>
|
<webXml>${webXmlPath}</webXml>
|
||||||
|
<attachClasses>true</attachClasses>
|
||||||
|
<classesClassifier>classes</classesClassifier>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import code.UserRefreshes.MappedUserRefreshes
|
|||||||
import code.accountapplication.MappedAccountApplication
|
import code.accountapplication.MappedAccountApplication
|
||||||
import code.accountattribute.MappedAccountAttribute
|
import code.accountattribute.MappedAccountAttribute
|
||||||
import code.accountholders.MapperAccountHolders
|
import code.accountholders.MapperAccountHolders
|
||||||
import code.actorsystem.ObpActorSystem
|
//import code.actorsystem.ObpActorSystem
|
||||||
import code.api.Constant._
|
import code.api.Constant._
|
||||||
import code.api.ResourceDocs1_4_0.ResourceDocs300.{ResourceDocs310, ResourceDocs400, ResourceDocs500, ResourceDocs510, ResourceDocs600}
|
import code.api.ResourceDocs1_4_0.ResourceDocs300.{ResourceDocs310, ResourceDocs400, ResourceDocs500, ResourceDocs510, ResourceDocs600}
|
||||||
import code.api.ResourceDocs1_4_0._
|
import code.api.ResourceDocs1_4_0._
|
||||||
@ -328,7 +328,7 @@ class Boot extends MdcLoggable {
|
|||||||
createBootstrapSuperUser()
|
createBootstrapSuperUser()
|
||||||
|
|
||||||
//launch the scheduler to clean the database from the expired tokens and nonces, 1 hour
|
//launch the scheduler to clean the database from the expired tokens and nonces, 1 hour
|
||||||
DataBaseCleanerScheduler.start(intervalInSeconds = 60*60)
|
// DataBaseCleanerScheduler.start(intervalInSeconds = 60*60)
|
||||||
|
|
||||||
// if (Props.devMode || Props.testMode) {
|
// if (Props.devMode || Props.testMode) {
|
||||||
// StoredProceduresMockedData.createOrDropMockedPostgresStoredProcedures()
|
// StoredProceduresMockedData.createOrDropMockedPostgresStoredProcedures()
|
||||||
@ -428,15 +428,15 @@ class Boot extends MdcLoggable {
|
|||||||
|
|
||||||
logger.debug(s"If you can read this, logging level is debug")
|
logger.debug(s"If you can read this, logging level is debug")
|
||||||
|
|
||||||
val actorSystem = ObpActorSystem.startLocalActorSystem()
|
// val actorSystem = ObpActorSystem.startLocalActorSystem()
|
||||||
connector match {
|
// connector match {
|
||||||
case "akka_vDec2018" =>
|
// case "akka_vDec2018" =>
|
||||||
// Start Actor system of Akka connector
|
// // Start Actor system of Akka connector
|
||||||
ObpActorSystem.startNorthSideAkkaConnectorActorSystem()
|
// ObpActorSystem.startNorthSideAkkaConnectorActorSystem()
|
||||||
case "star" if (APIUtil.getPropsValue("starConnector_supported_types","").split(",").contains("akka")) =>
|
// case "star" if (APIUtil.getPropsValue("starConnector_supported_types","").split(",").contains("akka")) =>
|
||||||
ObpActorSystem.startNorthSideAkkaConnectorActorSystem()
|
// ObpActorSystem.startNorthSideAkkaConnectorActorSystem()
|
||||||
case _ => // Do nothing
|
// case _ => // Do nothing
|
||||||
}
|
// }
|
||||||
|
|
||||||
// where to search snippets
|
// where to search snippets
|
||||||
LiftRules.addToPackages("code")
|
LiftRules.addToPackages("code")
|
||||||
@ -751,13 +751,13 @@ class Boot extends MdcLoggable {
|
|||||||
TransactionScheduler.startAll()
|
TransactionScheduler.startAll()
|
||||||
|
|
||||||
|
|
||||||
APIUtil.getPropsAsBoolValue("enable_metrics_scheduler", true) match {
|
// APIUtil.getPropsAsBoolValue("enable_metrics_scheduler", true) match {
|
||||||
case true =>
|
// case true =>
|
||||||
val interval =
|
// val interval =
|
||||||
APIUtil.getPropsAsIntValue("retain_metrics_scheduler_interval_in_seconds", 3600)
|
// APIUtil.getPropsAsIntValue("retain_metrics_scheduler_interval_in_seconds", 3600)
|
||||||
MetricsArchiveScheduler.start(intervalInSeconds = interval)
|
// MetricsArchiveScheduler.start(intervalInSeconds = interval)
|
||||||
case false => // Do not start it
|
// case false => // Do not start it
|
||||||
}
|
// }
|
||||||
|
|
||||||
object UsernameLockedChecker {
|
object UsernameLockedChecker {
|
||||||
def onBeginServicing(session: LiftSession, req: Req): Unit = {
|
def onBeginServicing(session: LiftSession, req: Req): Unit = {
|
||||||
|
|||||||
@ -50,7 +50,7 @@ import sh.ory.hydra.model.OAuth2TokenIntrospection
|
|||||||
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
import scala.jdk.CollectionConverters.mapAsJavaMapConverter
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This object provides the API calls necessary to third party applications
|
* This object provides the API calls necessary to third party applications
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import java.security.cert._
|
|||||||
import java.util.{Base64, Collections}
|
import java.util.{Base64, Collections}
|
||||||
import javax.net.ssl.TrustManagerFactory
|
import javax.net.ssl.TrustManagerFactory
|
||||||
import scala.io.Source
|
import scala.io.Source
|
||||||
import scala.jdk.CollectionConverters._
|
import scala.collection.JavaConverters._
|
||||||
import scala.util.{Failure, Success, Try}
|
import scala.util.{Failure, Success, Try}
|
||||||
|
|
||||||
object CertificateVerifier extends MdcLoggable {
|
object CertificateVerifier extends MdcLoggable {
|
||||||
@ -69,8 +69,8 @@ object CertificateVerifier extends MdcLoggable {
|
|||||||
trustManagerFactory.init(trustStore)
|
trustManagerFactory.init(trustStore)
|
||||||
|
|
||||||
// Get trusted CAs from the trust store
|
// Get trusted CAs from the trust store
|
||||||
val trustAnchors = trustStore.aliases().asScala
|
val trustAnchors = enumerationAsScalaIterator(trustStore.aliases())
|
||||||
.filter(trustStore.isCertificateEntry)
|
.filter(trustStore.isCertificateEntry(_))
|
||||||
.map(alias => trustStore.getCertificate(alias).asInstanceOf[X509Certificate])
|
.map(alias => trustStore.getCertificate(alias).asInstanceOf[X509Certificate])
|
||||||
.map(cert => new TrustAnchor(cert, null))
|
.map(cert => new TrustAnchor(cert, null))
|
||||||
.toSet
|
.toSet
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import java.time.format.DateTimeFormatter
|
|||||||
import java.time.{Duration, ZoneOffset, ZonedDateTime}
|
import java.time.{Duration, ZoneOffset, ZonedDateTime}
|
||||||
import java.util
|
import java.util
|
||||||
import scala.collection.immutable.{HashMap, List}
|
import scala.collection.immutable.{HashMap, List}
|
||||||
import scala.jdk.CollectionConverters.seqAsJavaListConverter
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
|
|
||||||
object JwsUtil extends MdcLoggable {
|
object JwsUtil extends MdcLoggable {
|
||||||
|
|||||||
@ -113,7 +113,7 @@ import java.util.{Calendar, Date}
|
|||||||
import scala.collection.immutable.{List, Nil}
|
import scala.collection.immutable.{List, Nil}
|
||||||
import scala.collection.mutable.ArrayBuffer
|
import scala.collection.mutable.ArrayBuffer
|
||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
import scala.jdk.CollectionConverters.collectionAsScalaIterableConverter
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
trait APIMethods400 extends MdcLoggable {
|
trait APIMethods400 extends MdcLoggable {
|
||||||
self: RestHelper =>
|
self: RestHelper =>
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import org.apache.commons.lang3.StringUtils.uncapitalize
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import scala.jdk.CollectionConverters.enumerationAsScalaIteratorConverter
|
import scala.collection.JavaConverters._
|
||||||
import scala.language.postfixOps
|
import scala.language.postfixOps
|
||||||
import scala.reflect.runtime.universe._
|
import scala.reflect.runtime.universe._
|
||||||
import scala.reflect.runtime.{universe => ru}
|
import scala.reflect.runtime.{universe => ru}
|
||||||
|
|||||||
@ -45,7 +45,7 @@ import net.liftweb.util.Helpers._
|
|||||||
import sh.ory.hydra.api.AdminApi
|
import sh.ory.hydra.api.AdminApi
|
||||||
import sh.ory.hydra.model.{AcceptConsentRequest, RejectRequest}
|
import sh.ory.hydra.model.{AcceptConsentRequest, RejectRequest}
|
||||||
|
|
||||||
import scala.jdk.CollectionConverters.seqAsJavaListConverter
|
import scala.collection.JavaConverters._
|
||||||
import scala.xml.NodeSeq
|
import scala.xml.NodeSeq
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ import org.apache.commons.lang3.StringUtils
|
|||||||
import org.codehaus.jackson.map.ObjectMapper
|
import org.codehaus.jackson.map.ObjectMapper
|
||||||
|
|
||||||
import scala.collection.immutable.{List, ListMap}
|
import scala.collection.immutable.{List, ListMap}
|
||||||
import scala.jdk.CollectionConverters.seqAsJavaListConverter
|
import scala.collection.JavaConverters._
|
||||||
import scala.xml.{Text, Unparsed}
|
import scala.xml.{Text, Unparsed}
|
||||||
|
|
||||||
class ConsumerRegistration extends MdcLoggable {
|
class ConsumerRegistration extends MdcLoggable {
|
||||||
|
|||||||
@ -35,7 +35,15 @@ object ClassScanUtils {
|
|||||||
*/
|
*/
|
||||||
def getSubTypeObjects[T:TypeTag]: List[T] = {
|
def getSubTypeObjects[T:TypeTag]: List[T] = {
|
||||||
val clazz = ReflectUtils.typeTagToClass[T]
|
val clazz = ReflectUtils.typeTagToClass[T]
|
||||||
finder.getClasses().filter(_.implements(clazz.getName)).map(_.name).map(companion[T](_)).toList
|
val classes = try {
|
||||||
|
finder.getClasses().toList
|
||||||
|
} catch {
|
||||||
|
case _: UnsupportedOperationException =>
|
||||||
|
// ASM version is too old for some class files (e.g. requires ASM7). In that case,
|
||||||
|
// skip scanned APIs instead of failing the whole application.
|
||||||
|
Seq.empty
|
||||||
|
}
|
||||||
|
classes.filter(_.implements(clazz.getName)).map(_.name).map(companion[T](_)).toList
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,14 +51,22 @@ object ClassScanUtils {
|
|||||||
* @param predict check whether include this type in the result
|
* @param predict check whether include this type in the result
|
||||||
* @return all fit type names
|
* @return all fit type names
|
||||||
*/
|
*/
|
||||||
def findTypes(predict: ClassInfo => Boolean): List[String] = finder.getClasses()
|
def findTypes(predict: ClassInfo => Boolean): List[String] = {
|
||||||
.filter(predict)
|
val classes = try {
|
||||||
.map(it => {
|
finder.getClasses().toList
|
||||||
val name = it.name
|
} catch {
|
||||||
if(name.endsWith("$")) name.substring(0, name.length - 1)
|
case _: UnsupportedOperationException =>
|
||||||
else name
|
Seq.empty
|
||||||
}) //some companion type name ends with $, it added by scalac, should remove from class name
|
}
|
||||||
.toList
|
classes
|
||||||
|
.filter(predict)
|
||||||
|
.map(it => {
|
||||||
|
val name = it.name
|
||||||
|
if(name.endsWith("$")) name.substring(0, name.length - 1)
|
||||||
|
else name
|
||||||
|
}) //some companion type name ends with $, it added by scalac, should remove from class name
|
||||||
|
.toList
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get given class exists jar Files
|
* get given class exists jar Files
|
||||||
@ -71,7 +87,13 @@ object ClassScanUtils {
|
|||||||
*/
|
*/
|
||||||
def getMappers(packageName:String = ""): Seq[ClassInfo] = {
|
def getMappers(packageName:String = ""): Seq[ClassInfo] = {
|
||||||
val mapperInterface = "net.liftweb.mapper.LongKeyedMapper"
|
val mapperInterface = "net.liftweb.mapper.LongKeyedMapper"
|
||||||
val infos = finder.getClasses().filter(it => it.interfaces.contains(mapperInterface))
|
val classes = try {
|
||||||
|
finder.getClasses().toList
|
||||||
|
} catch {
|
||||||
|
case _: UnsupportedOperationException =>
|
||||||
|
Seq.empty
|
||||||
|
}
|
||||||
|
val infos = classes.filter(it => it.interfaces.contains(mapperInterface))
|
||||||
if(StringUtils.isNoneBlank()) {
|
if(StringUtils.isNoneBlank()) {
|
||||||
infos.filter(classInfo => classInfo.name.startsWith(packageName))
|
infos.filter(classInfo => classInfo.name.startsWith(packageName))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import sh.ory.hydra.model.OAuth2Client
|
|||||||
import sh.ory.hydra.{ApiClient, Configuration}
|
import sh.ory.hydra.{ApiClient, Configuration}
|
||||||
|
|
||||||
import scala.collection.immutable.List
|
import scala.collection.immutable.List
|
||||||
import scala.jdk.CollectionConverters.{mapAsJavaMapConverter, seqAsJavaListConverter}
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
object HydraUtil extends MdcLoggable{
|
object HydraUtil extends MdcLoggable{
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import com.openbankproject.commons.model.ListResult
|
|||||||
import com.openbankproject.commons.util.{ApiVersion, ScannedApiVersion}
|
import com.openbankproject.commons.util.{ApiVersion, ScannedApiVersion}
|
||||||
import org.scalatest.Tag
|
import org.scalatest.Tag
|
||||||
|
|
||||||
import scala.jdk.CollectionConverters.collectionAsScalaIterableConverter
|
import scala.collection.JavaConverters._
|
||||||
class GetScannedApiVersionsTest extends V400ServerSetup {
|
class GetScannedApiVersionsTest extends V400ServerSetup {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
71
obp-http4s-runner/pom.xml
Normal file
71
obp-http4s-runner/pom.xml
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.tesobe</groupId>
|
||||||
|
<artifactId>obp-parent</artifactId>
|
||||||
|
<version>1.10.1</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>obp-http4s-runner</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>OBP Http4s Runner</name>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- Use obp-api compiled classes as a normal JAR -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tesobe</groupId>
|
||||||
|
<artifactId>obp-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<classifier>classes</classifier>
|
||||||
|
<type>jar</type>
|
||||||
|
<exclusions>
|
||||||
|
<!-- Exclude old classutil version if present -->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.clapper</groupId>
|
||||||
|
<artifactId>classutil_${scala.version}</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- Explicitly include classutil 1.5.1 to override any transitive dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.clapper</groupId>
|
||||||
|
<artifactId>classutil_${scala.version}</artifactId>
|
||||||
|
<version>1.5.1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<version>3.6.0</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>bootstrap.http4s.Http4sServer</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
<appendAssemblyId>false</appendAssemblyId>
|
||||||
|
<finalName>obp-http4s-runner</finalName>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>make-fat-jar</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
Loading…
Reference in New Issue
Block a user