-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into beta
- Loading branch information
Showing
44 changed files
with
1,901 additions
and
1,906 deletions.
There are no files selected for viewing
Submodule jul
updated
4 files
54 changes: 0 additions & 54 deletions
54
module/api/graphql/src/main/java/org/openbase/bco/api/graphql/BcoApiGraphQlLauncher.java
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
module/api/graphql/src/main/java/org/openbase/bco/api/graphql/BcoApiGraphQlLauncher.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.openbase.bco.api.graphql | ||
|
||
import org.openbase.bco.authentication.lib.BCO | ||
import org.openbase.bco.authentication.lib.jp.JPCredentialsDirectory | ||
import org.openbase.jps.core.JPService | ||
import org.openbase.jps.preset.JPDebugMode | ||
import org.openbase.jul.communication.jp.JPComHost | ||
import org.openbase.jul.communication.jp.JPComPort | ||
import org.openbase.jul.pattern.launch.AbstractLauncher | ||
|
||
/*- | ||
* #%L | ||
* BCO GraphQL API | ||
* %% | ||
* Copyright (C) 2020 openbase.org | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
* #L% | ||
*/ class BcoApiGraphQlLauncher : AbstractLauncher<BcoApiGraphQlSpringLaunchable>( | ||
BcoApiGraphQlLauncher::class.java, BcoApiGraphQlSpringLaunchable::class.java | ||
) { | ||
override fun loadProperties() { | ||
JPService.registerProperty(JPDebugMode::class.java) | ||
JPService.registerProperty(JPCredentialsDirectory::class.java) | ||
JPService.registerProperty(JPComHost::class.java) | ||
JPService.registerProperty(JPComPort::class.java) | ||
} | ||
|
||
companion object { | ||
/** | ||
* @param args the command line arguments | ||
*/ | ||
@JvmStatic | ||
fun main(args: Array<String>) { | ||
BCO.printLogo() | ||
main(BCO::class.java, BcoApiGraphQlLauncher::class.java, args, BcoApiGraphQlLauncher::class.java) | ||
} | ||
} | ||
} |
106 changes: 0 additions & 106 deletions
106
...api/graphql/src/main/java/org/openbase/bco/api/graphql/BcoApiGraphQlSpringLaunchable.java
This file was deleted.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
...e/api/graphql/src/main/java/org/openbase/bco/api/graphql/BcoApiGraphQlSpringLaunchable.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package org.openbase.bco.api.graphql | ||
|
||
import org.openbase.bco.api.graphql.discovery.ServiceAdvertiser | ||
import org.openbase.bco.registry.remote.Registries | ||
import org.openbase.bco.registry.remote.login.BCOLogin | ||
import org.openbase.jps.core.JPService | ||
import org.openbase.jul.exception.* | ||
import org.openbase.jul.iface.Launchable | ||
import org.openbase.jul.iface.VoidInitializable | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.boot.SpringApplication | ||
import org.springframework.context.ConfigurableApplicationContext | ||
import java.util.* | ||
import javax.jmdns.ServiceInfo | ||
|
||
/*- | ||
* #%L | ||
* BCO GraphQL API | ||
* %% | ||
* Copyright (C) 2020 openbase.org | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
* #L% | ||
*/ class BcoApiGraphQlSpringLaunchable : Launchable<Void>, VoidInitializable { | ||
private var serviceAdvertiser: ServiceAdvertiser? = null | ||
private var context: ConfigurableApplicationContext? = null | ||
|
||
@Throws(InitializationException::class) | ||
override fun init() { | ||
serviceAdvertiser = try { | ||
ServiceAdvertiser.instance | ||
} catch (ex: InstantiationException) { | ||
throw InitializationException(this, ex) | ||
} | ||
} | ||
|
||
@Throws(CouldNotPerformException::class, InterruptedException::class) | ||
override fun activate() { | ||
LOGGER.info("Connect to bco...") | ||
Registries.waitUntilReady() | ||
LOGGER.info("Login to bco...") | ||
BCOLogin.getSession().loginBCOUser() | ||
LOGGER.info("Start webserver...") | ||
context = SpringApplication.run(BcoGraphQlApiSpringBootApplication::class.java, *JPService.getArgs()) | ||
LOGGER.info("Advertise graphql service...") | ||
val qualifiedNameMap = HashMap<ServiceInfo.Fields, String>() | ||
qualifiedNameMap[ServiceInfo.Fields.Application] = "http" | ||
qualifiedNameMap[ServiceInfo.Fields.Instance] = "graphql-bco-openbase" | ||
qualifiedNameMap[ServiceInfo.Fields.Subtype] = "graphql" | ||
val propertyMap = HashMap<String, String>() | ||
propertyMap["bco-uuid"] = UUID.randomUUID().toString() | ||
propertyMap["path"] = "graphql" | ||
|
||
// lookup port | ||
context?.getEnvironment()?.getProperty("server.port")?.toInt()?.let { port -> | ||
// register service advertising | ||
serviceAdvertiser!!.register(qualifiedNameMap, port, 0, 0, false, propertyMap) | ||
} | ||
} | ||
|
||
override fun deactivate() { | ||
LOGGER.info("Logout...") | ||
serviceAdvertiser!!.shutdown() | ||
BCOLogin.getSession().logout() | ||
if (isActive) { | ||
LOGGER.info("Shutdown " + context!!.applicationName) | ||
SpringApplication.exit(context) | ||
context = null | ||
} | ||
} | ||
|
||
override fun isActive(): Boolean { | ||
return context != null && context!!.isActive | ||
} | ||
|
||
companion object { | ||
private val LOGGER = LoggerFactory.getLogger(BcoApiGraphQlSpringLaunchable::class.java) | ||
} | ||
} |
Oops, something went wrong.