• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala Autowired类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中org.springframework.beans.factory.annotation.Autowired的典型用法代码示例。如果您正苦于以下问题:Scala Autowired类的具体用法?Scala Autowired怎么用?Scala Autowired使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Autowired类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: ScalajHttpAdapter

//设置package包名称以及导入依赖的类
package com.piotrglazar.receiptlottery.utils

import org.springframework.beans.factory.annotation.{Autowired, Value}
import org.springframework.stereotype.Component

import scala.concurrent.{ExecutionContext, Future}
import scalaj.http.Http

@Component
class ScalajHttpAdapter @Autowired()(@Value("${http.timeouts:2000}") private val timeouts: Int) extends HttpAdapter {

  override def request(url: String, params: Map[String, String]): String =
    Http(url)
      .params(params)
      .timeout(timeouts, timeouts)
      .asString
      .body

  override def asyncRequest(url: String, params: Map[String, String])
                           (implicit executionContext: ExecutionContext): Future[String] =
    Future(request(url, params))
} 
开发者ID:piotrglazar,项目名称:receipt-lottery,代码行数:23,代码来源:ScalajHttpAdapter.scala


示例2: CustomerController

//设置package包名称以及导入依赖的类
package fr.sysf.sample.service


import java.net.HttpURLConnection
import javax.validation.Valid

import fr.sysf.sample.domain.Customer
import io.swagger.annotations.{Api, ApiOperation, ApiResponse, ApiResponses}
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.{HttpStatus, MediaType, ResponseEntity}
import org.springframework.web.bind.annotation._


@Api(value = "Customers service", consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
@RestController
@RequestMapping(Array("/customers"))
class CustomerController {

  @Autowired
  private val customerRepository: CustomerRepository = null

  @ApiOperation(value = "Put_Customers", notes = "method to create new Customer or update customer")
  @ApiResponses(value = Array(
    new ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "Bad Request"),
    new ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found"),
    new ApiResponse(code = HttpURLConnection.HTTP_ACCEPTED, response = classOf[Customer], message = "Success PUT")
  ))
  @RequestMapping(
    value = Array("/"),
    method = Array(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH),
    produces = Array(MediaType.APPLICATION_JSON_UTF8_VALUE))
  def setCustomer(
                   @Valid @RequestBody customer: Customer
                 ): ResponseEntity[Customer] = {

    val customerExisted = customerRepository.findByEmail(customer.email)
    if (customerExisted != null) {
      customer.id = customerExisted.id
      customer.version = customerExisted.version
    }
    val customerSaved = customerRepository.save(customer)

    new ResponseEntity[Customer](customerSaved, HttpStatus.ACCEPTED)
  }

} 
开发者ID:fpeyron,项目名称:sample-scala-mongo-rest,代码行数:47,代码来源:CustomerController.scala


示例3: es

//设置package包名称以及导入依赖的类
package fr.sysf.sample

import java.time.LocalDate

import fr.sysf.sample.domain.Customer
import fr.sysf.sample.service.CustomerRepository
import org.assertj.core.api.Assertions
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner


@RunWith(classOf[SpringJUnit4ClassRunner])
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = Array(classOf[ApplicationConfig]))
//@ContextConfiguration(classes = Array(classOf[ApplicationConfig]))
class CustomerDataTest {

  @Autowired
  private val customerRepository: CustomerRepository = null

  @Test
  def getHello {

    val customer = new Customer()
    customer.firstName = "Anna"
    customer.lastName = "Blum"
    customer.birthDate = LocalDate.of(1965, 2, 7)

    var request = customerRepository.save(customer)

    // getAll before insert
    assertThat(request).isNotNull
    assertThat(request.createdDate).isNotNull
    assertThat(request.updatedDate).isEqualTo(request.createdDate)
    Assertions.assertThat(request.version).isEqualTo(0l)

    request.city = "Paris"
    request = customerRepository.save(request)

    assertThat(request).isNotNull
    Assertions.assertThat(request.createdDate).isNotNull
    Assertions.assertThat(request.city).isEqualTo("Paris")
    Assertions.assertThat(request.version).isEqualTo(1l)


  }
} 
开发者ID:fpeyron,项目名称:sample-scala-mongo-rest,代码行数:52,代码来源:CustomerDataTest.scala


示例4: es

//设置package包名称以及导入依赖的类
package fr.sysf.sample

import org.junit.runner.RunWith
import org.junit.{Ignore, Test}
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner


@RunWith(classOf[SpringJUnit4ClassRunner])
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = Array(classOf[ApplicationConfig]))
class ApiRestTest {

  @Autowired
  private val restTemplate: TestRestTemplate = null


  // todo: to complete
  @Ignore
  @Test
  def should_put_customer_when_it_does_not_exits {

  }
} 
开发者ID:fpeyron,项目名称:sample-scala-mongo-rest,代码行数:27,代码来源:ApiRestTest.scala


示例5: AppConfiguration

//设置package包名称以及导入依赖的类
package com.piotrglazar.receiptlottery.extension

import akka.actor.ActorSystem
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.{Bean, Configuration}

import scala.concurrent.ExecutionContext

@Configuration
class AppConfiguration {

  @Autowired
  var applicationContext: ApplicationContext = _

  @Bean
  def actorSystem(): ActorSystem = {
    val sys = ActorSystem()
    SpringExtension.provider.get(sys).initialize(applicationContext)
    sys
  }

  @Bean
  def executionContext(actorSystem: ActorSystem): ExecutionContext =
    actorSystem.dispatcher
} 
开发者ID:piotrglazar,项目名称:receipt-lottery,代码行数:27,代码来源:AppConfiguration.scala


示例6: ResultFetcher

//设置package包名称以及导入依赖的类
package com.piotrglazar.receiptlottery.core

import com.piotrglazar.receiptlottery.Token
import com.piotrglazar.receiptlottery.utils.HttpAdapter
import org.htmlcleaner.{HtmlCleaner, TagNode}
import org.springframework.beans.factory.annotation.{Autowired, Value}
import org.springframework.stereotype.Component

import scala.concurrent.{ExecutionContext, Future}

@Component
class ResultFetcher @Autowired()(@Value("${results.page}") private val pageAddress: String, private val httpAdapter: HttpAdapter,
                                 implicit private val executionContext: ExecutionContext) {

  def hasResult(token: Token): Future[Boolean] = {
    val rawContentFuture = httpAdapter.asyncRequest(pageAddress, Map("code" -> token.value))
    rawContentFuture.map { rawContent =>
      val cleanContent: TagNode = new HtmlCleaner().clean(rawContent)

      !getResultTables(cleanContent)
        .flatMap(getResultTableBody)
        .flatMap(getResultTableRows)
        .isEmpty
    }
  }

  private def getResultTables(page: TagNode): Array[TagNode] =
    page.getElementsByAttValue("class", "results-table", true, true)

  private def getResultTableBody(table: TagNode): Array[TagNode] =
    table.getElementsByName("tbody", true)

  private def getResultTableRows(tableBody: TagNode): Array[TagNode] =
    tableBody.getElementsByName("tr", true)
} 
开发者ID:piotrglazar,项目名称:receipt-lottery,代码行数:36,代码来源:ResultFetcher.scala


示例7: WorkingActor

//设置package包名称以及导入依赖的类
package com.piotrglazar.receiptlottery.core

import akka.actor.Actor
import com.piotrglazar.receiptlottery.{Token, VerifiedToken}
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component

@Component("workingActor")
@Scope("prototype")
class WorkingActor @Autowired()(private val resultFetcher: ResultFetcher) extends Actor {

  implicit private val executionContext = context.system.dispatcher

  override def receive: Receive = {
    case token: Token =>
      val requester = sender()
      val resultFuture = resultFetcher.hasResult(token)
      resultFuture.onSuccess { case result => requester ! VerifiedToken(token, result) }
  }
} 
开发者ID:piotrglazar,项目名称:receipt-lottery,代码行数:22,代码来源:WorkingActor.scala


示例8: TokenReader

//设置package包名称以及导入依赖的类
package com.piotrglazar.receiptlottery.core

import com.piotrglazar.receiptlottery.Token
import org.springframework.beans.factory.annotation.{Value, Autowired}
import org.springframework.stereotype.Component
import rx.lang.scala.Observable

import scala.io.Source
import scala.util.{Failure, Success, Try}

@Component
class TokenReader @Autowired()(@Value("${token.file}") private val path: String) {

  def readTokens(): Observable[Token] = {
    readContent() match {
      case Success(items) => Observable.from(items)
      case Failure(e) => Observable.error(e)
    }
  }

  private def readContent(): Try[List[Token]] =
    Try {
      Source.fromInputStream(getClass.getResourceAsStream(path))
        .getLines()
        .filter(!_.isEmpty)
        .map(Token)
        .toList
    }
} 
开发者ID:piotrglazar,项目名称:receipt-lottery,代码行数:30,代码来源:TokenReader.scala


示例9: ReceiptLotteryTest

//设置package包名称以及导入依赖的类
package com.piotrglazar.receiptlottery

import akka.actor.ActorSystem
import org.springframework.beans.factory.annotation.{Qualifier, Autowired}
import org.springframework.test.context.ContextConfiguration

@ContextConfiguration(classes = Array[Class[_]](classOf[ReceiptLottery]))
class ReceiptLotteryTest extends BaseContextTest  {

  override def beforeAll(): Unit = {
    System.setProperty("token.file", "/testTokens.txt")
    System.setProperty("results.page", "https://loteriaparagonowa.gov.pl/wyniki")
    super.beforeAll()
  }

  @Autowired
  @Qualifier("actorSystem")
  var actorSystem: ActorSystem = _

  "ReceiptLottery" should "use actors to verify tokens" in {
    // given
    // context loaded

    // when
    new ReceiptLottery().runActors_=(actorSystem)

    // then
    System.setProperty("token.file", "")
  }
} 
开发者ID:piotrglazar,项目名称:receipt-lottery,代码行数:31,代码来源:ReceiptLotteryTest.scala


示例10: MyApp

//设置package包名称以及导入依赖的类
package com.kemalates.demo02

import com.kemalates.demo02.service.MyService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.{CommandLineRunner, SpringApplication}
import org.springframework.boot.autoconfigure.SpringBootApplication


@SpringBootApplication
class MyApp extends CommandLineRunner {

  @Autowired
  val myService: MyService = null

  override def run(args: String*) = {
    myService.sayHello()
  }
}

object MyApp extends App {
  SpringApplication run classOf[MyApp]
} 
开发者ID:kemalates,项目名称:scala-spring-boot-skeleton,代码行数:23,代码来源:MyApp.scala


示例11: ActuatorConfig

//设置package包名称以及导入依赖的类
package k8sslbnginxing.actuator
import akka.actor.ActorSystem
import com.google.common.base.Stopwatch
import io.fabric8.kubernetes.client.KubernetesClient
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.actuate.health.{Health, HealthIndicator}
import org.springframework.context.annotation.{Bean, Configuration}

@Configuration
class ActuatorConfig {

  @Autowired
  private var actorSystem: ActorSystem = _

  @Autowired
  private var kubernetesClient: KubernetesClient = _

  @Bean
  def kubernetesHealthIndicator: HealthIndicator = () => {
    try {
      val watch = Stopwatch.createStarted()
      kubernetesClient.services().inNamespace("default").withName("kubernetes").get()
      watch.stop()
      Health.up()
          .withDetail("get", "GET Service [email protected] in " + watch.toString)
          .build()
    } catch {
      case e: Exception =>
        Health.down(e).build()
    }
  }
} 
开发者ID:ferdinandhuebner,项目名称:k8s-slb-nginx-ing,代码行数:33,代码来源:ActuatorConfig.scala


示例12: ItalianInvoiceIDFinderTest

//设置package包名称以及导入依赖的类
package org.pdfextractor.algorithm.finder.it

import org.pdfextractor.algorithm.finder.AbstractFinderTest
import org.slf4j.{Logger, LoggerFactory}
import org.springframework.beans.factory.annotation.Autowired
import org.pdfextractor.algorithm.phrase.PhraseTypesStore

class ItalianInvoiceIDFinderTest extends AbstractFinderTest {

  val log: Logger = LoggerFactory.getLogger(classOf[PhraseTypesStore])

  @Autowired var italianInvoiceIDFinder: ItalianInvoiceIDFinder = _

  "Italian invoice ID finder" should "parse" in {
    val idText = "Numero fattura: 3816442625428252-20"
    val parsed = italianInvoiceIDFinder.parseValue(idText).asInstanceOf[String]
    assert("3816442625428252-20" == parsed)
  }

  "Italian invoice ID finder" should "find from start" in {
    assert(italianInvoiceIDFinder.searchPattern.get.findFirstIn("Fattura n.6 del 23.02.2016").nonEmpty)
  }

  "Italian invoice ID finder" should "find from line" in {
    assert(italianInvoiceIDFinder.getValuePattern.findFirstIn("Fattura n.6 del 23.02.2016").nonEmpty)
    assert("Fattura n.6" == italianInvoiceIDFinder.getValuePattern.findFirstIn("Fattura n.6 del 23.02.2016").get)
    assert("Fattura n.654343-3s" == italianInvoiceIDFinder.getValuePattern.findFirstIn("Fattura n.654343-3s del 23.02.2016").get)
    assert("654343-3s" == italianInvoiceIDFinder.StartR.replaceFirstIn("Fattura n.654343-3s", ""))
  }

} 
开发者ID:kveskimae,项目名称:pdfalg,代码行数:32,代码来源:ItalianInvoiceIDFinderTest.scala


示例13: EstonianInvoiceIDFinderTest

//设置package包名称以及导入依赖的类
package org.pdfextractor.algorithm.finder.et

import org.pdfextractor.algorithm.candidate.Candidate
import org.pdfextractor.algorithm.finder.{AbstractFinderTest, AbstractInvoiceFileReader}
import org.pdfextractor.algorithm.io._
import org.slf4j.{Logger, LoggerFactory}
import org.springframework.beans.factory.annotation.Autowired
import org.pdfextractor.algorithm.parser.{PDFFileParser, ParseResult, Phrase}
import org.pdfextractor.algorithm.phrase.PhraseTypesStore

import scala.collection.LinearSeq

class EstonianInvoiceIDFinderTest extends AbstractFinderTest {

  val log: Logger = LoggerFactory.getLogger(classOf[PhraseTypesStore])

  @Autowired var estonianInvoiceIDFinder: EstonianInvoiceIDFinder = _

  "Estonian invoice ID finder" should "find from phrase" in {
    val invoiceAsString = getStringFromFile("EestiEnergia.txt")
    val phrase: Phrase = new Phrase(1, 1, 1, 1, 1, invoiceAsString, false)
    val phrases: LinearSeq[Phrase] = LinearSeq(phrase)
    val parseResult: ParseResult = new ParseResult("", phrases)

    val candidates: Seq[Candidate] = estonianInvoiceIDFinder.findCandidates(parseResult)

    assert(candidates.nonEmpty)

    val foundValues: Seq[String] = candidates.map(_.getValue.asInstanceOf[String])

    assert(foundValues.head == "Arve nr 12345")
  }

  "Estonian invoice ID finder" should "find from real PDF" in {
    val inputStream = getInputStreamFromFile(AbstractInvoiceFileReader.Starman)
    val parseResult = PDFFileParser.parse(inputStream)
    val candidates = estonianInvoiceIDFinder.findCandidates(parseResult)

    assert(candidates.nonEmpty)
    assert(candidates.size == 1)

    val firstCandidate = candidates.head

    assert(Option(firstCandidate.value).isDefined)
    assert(Option(firstCandidate.x).isDefined)
    assert(Option(firstCandidate.y).isDefined)
    assert(firstCandidate.value == "Arve number A-123456")
    assert(330 == firstCandidate.x)
    assert(94 == firstCandidate.y)
  }

} 
开发者ID:kveskimae,项目名称:pdfalg,代码行数:53,代码来源:EstonianInvoiceIDFinderTest.scala


示例14: EstonianTotalFinderTest

//设置package包名称以及导入依赖的类
package org.pdfextractor.algorithm.finder.et

import org.pdfextractor.algorithm.candidate.{IsDouble, HasEuroSign}
import org.pdfextractor.algorithm.finder.{AbstractFinderTest, AbstractInvoiceFileReader}
import org.pdfextractor.algorithm.io._
import org.slf4j.{Logger, LoggerFactory}
import org.springframework.beans.factory.annotation.Autowired
import org.pdfextractor.algorithm.parser.PDFFileParser
import org.pdfextractor.algorithm.phrase.PhraseTypesStore
class EstonianTotalFinderTest extends AbstractFinderTest {

  val log: Logger = LoggerFactory.getLogger(classOf[PhraseTypesStore])

  @Autowired var estonianTotalFinder: EstonianTotalFinder = _

  "Estonian total finder" should "find from real invoice and have additional info present" in {
    val inputStream = getInputStreamFromFile(AbstractInvoiceFileReader.Starman)
    val parseResult = PDFFileParser.parse(inputStream)
    val candidates = estonianTotalFinder.findCandidates(parseResult)

    assert(candidates.nonEmpty)

    val firstCandidate = candidates.head

    assert(Option(firstCandidate.value).isDefined)
    assert(Option(firstCandidate.x).isDefined)
    assert(Option(firstCandidate.y).isDefined)
    assert(firstCandidate.value == 16.87d)
    assert(35 == firstCandidate.x)
    assert(414 == firstCandidate.y)
    assert(firstCandidate.properties.get(IsDouble).get.asInstanceOf[Boolean])
    assert(!firstCandidate.properties.get(HasEuroSign).get.asInstanceOf[Boolean])
  }

} 
开发者ID:kveskimae,项目名称:pdfalg,代码行数:36,代码来源:EstonianTotalFinderTest.scala


示例15: EstonianAccountNumberFinderTest

//设置package包名称以及导入依赖的类
package org.pdfextractor.algorithm.finder.et

import org.pdfextractor.algorithm.candidate.Candidate
import org.pdfextractor.algorithm.finder.{AbstractFinderTest, AbstractInvoiceFileReader}
import org.pdfextractor.algorithm.io._
import org.slf4j.{Logger, LoggerFactory}
import org.springframework.beans.factory.annotation.Autowired
import org.pdfextractor.algorithm.parser.{PDFFileParser, ParseResult}
import org.pdfextractor.algorithm.phrase.PhraseTypesStore

import scala.collection.LinearSeq

class EstonianAccountNumberFinderTest extends AbstractFinderTest {

  val log: Logger = LoggerFactory.getLogger(classOf[PhraseTypesStore])

  @Autowired var estonianAccountNumberFinder: EstonianAccountNumberFinder = _

  "Estonian account finder" should "find from real PDF" in {
    val inputStream = getInputStreamFromFile(AbstractInvoiceFileReader.Starman)
    val parseResult = PDFFileParser.parse(inputStream)
    val candidates = estonianAccountNumberFinder.findCandidates(parseResult)
    assert(candidates.nonEmpty)
    assert(4 == candidates.size)
    val foundValues: Seq[String] = candidates.map(_.getValue.asInstanceOf[String])
    assert(foundValues.contains("EE882200001180000796"))
    assert(foundValues.contains("EE921010002046022001"))
    assert(foundValues.contains("EE103300332097940003"))
    assert(foundValues.contains("EE561700017000030979"))
  }

  "Estonian account finder" should "find from invoice as a string" in {
    val invoiceAsString = getStringFromFile("EestiEnergia.txt")
    val candidates: Seq[Candidate] = estonianAccountNumberFinder.findCandidates(new ParseResult(invoiceAsString, LinearSeq.empty))
    val foundValues: Seq[String] = candidates.map(_.getValue.asInstanceOf[String])
    assert(foundValues.nonEmpty)
    assert(foundValues.contains("EE232200001180005555"))
    assert(foundValues.contains("EE081010002059413005"))
    assert(foundValues.contains("EE703300332099000006"))
    assert(foundValues.contains("EE431700017000115797"))
  }

  "Estonian account finder" should "discard invalid accounts" in {
    val invoiceAsString = getStringFromFile("RiggedInvoice.txt")
    val candidates: Seq[Candidate] = estonianAccountNumberFinder.findCandidates(new ParseResult(invoiceAsString, LinearSeq.empty))
    assert(candidates.isEmpty)
  }

} 
开发者ID:kveskimae,项目名称:pdfalg,代码行数:50,代码来源:EstonianAccountNumberFinderTest.scala


示例16: AdminSettingsDao

//设置package包名称以及导入依赖的类
package ch.mibex.bamboo.shipit.settings

import ch.mibex.bamboo.shipit.Logging
import com.atlassian.activeobjects.external.ActiveObjects
import com.atlassian.bamboo.security.EncryptionService
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport
import com.atlassian.sal.api.transaction.TransactionCallback
import net.java.ao.DBParam
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
class AdminSettingsDao @Autowired()(@ComponentImport ao: ActiveObjects,
                                    @ComponentImport encryptionService: EncryptionService) extends Logging {

  import AoAdminSettings._

  // we cannot use @Transactional annotations but instead have to wrap our DB code into executeInTransaction
  // because this annotation cannot be used on Bamboo remote agents
  def createOrUpdate(vendorName: String, vendorPassword: String): AoAdminSettings =
    executeInTransaction(() => {
      ao.find[AoAdminSettings, Integer](classOf[AoAdminSettings]).headOption match {
        case Some(credentials) =>
          credentials.setVendorUserName(vendorName)
          credentials.setVendorPassword(encryptionService.encrypt(vendorPassword))
          credentials.save()
          credentials
        case None =>
          ao.create[AoAdminSettings, Integer](
            classOf[AoAdminSettings],
            new DBParam(VENDOR_USERNAME_COLUMN, vendorName),
            new DBParam(VENDOR_PASSWORD_COLUMN, encryptionService.encrypt(vendorPassword))
          )
      }
    })

  def find(): Option[AoAdminSettings] =
    executeInTransaction(() => ao.find[AoAdminSettings, Integer](classOf[AoAdminSettings]).headOption)

  private def executeInTransaction[T](fun: () => T) =
    ao.executeInTransaction(new TransactionCallback[T]() {
      override def doInTransaction(): T = fun()
    })

} 
开发者ID:mibexsoftware,项目名称:shipit2marketplace,代码行数:46,代码来源:AdminSettingsDao.scala


示例17: ShipItResultsLinkPanel

//设置package包名称以及导入依赖的类
package ch.mibex.bamboo.shipit.task

import java.util
import java.util.{Map => JMap}

import ch.mibex.bamboo.shipit.{Constants, Logging}
import com.atlassian.bamboo.chains.ChainResultsSummary
import com.atlassian.plugin.PluginAccessor
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport
import com.atlassian.plugin.web.model.AbstractWebPanel
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

import scala.collection.JavaConverters._


@Component
class ShipItResultsLinkPanel @Autowired()(@ComponentImport pluginAccessor: PluginAccessor)
  extends AbstractWebPanel(pluginAccessor) with Logging {

  private val MpacLogoBase64Encoded =
    """<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAZABkAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQICAQECAQEBAgICAgICAgICAQICAgICAgICAgL/2wBDAQEBAQEBAQEBAQECAQEBAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgL/wAARCABGACUDAREAAhEBAxEB/8QAHAAAAgICAwAAAAAAAAAAAAAAAAoICQYHAwUL/8QANRAAAAYCAQMCBAMGBwAAAAAAAQIDBAUGBwgJABESChMUFSFBFiJhFxgjJVFxMTI0YoGx8P/EABwBAAIDAQEBAQAAAAAAAAAAAAAHBQYIBAEDAv/EADsRAAIBAwMDAgEHCQkAAAAAAAECAwQFEQAGEgcTISIxQRQVMkJxkZIWI1FhcoKywcIzNUNEUoGhs8P/2gAMAwEAAhEDEQA/AH+OjRo6NGjo0aOjRo6NGuB06bMmzh48cItWjVFVy5cuVU0G7dugQyq666ypgKiiRMpjHMYQKUpRERAA69ALEKoLMxwAPJJPsAP068JCgsxwo8knwAB8TpQHZPnS2+3D2oPpbw10WFnnKD6RjH2wM/BR8+eURiFyNp27wLW0pnhKTi9koYQCXmmr9aSBZuLRs2WXat3T5s/TWw2Cy/lD1BqWiBAIpVYpxLDKxsU/OSTMP8OMqEweRYAkJW69QL3e7ubFsanWQgkGpZQ2Qpw0ih/RHEv+uQMW8cQCVBsMoukPNvWcfSV1n+WqAsmeCRfzKJxbIa4Y2lcFO5pECrGq87cFYJpLhEuex0Bko+GYLtPd94jZfw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J9fMDYrxC1MgVu6c0amQkLMyaRQKH86sLdp8fOKD4F7qPHK6hhKAiYRDpaXO+Xm8v3LrdJ69s5AlkZlX9lCeC/YqjTBt1mtNpThbbdDRL7HtxqrH9pgOTfvE6kN1Fak9HRo0dGjR0aNHRo0dGjX//2Q=="/>"""

  // currently, there is no way to show a web panel on the environment of the deployment project,
  // see https://jira.atlassian.com/browse/BAM-13280
  override def getHtml(context: util.Map[String, AnyRef]): String = createMpacSubmissionLink(context)

  private def createMpacSubmissionLink(context: JMap[String, AnyRef]): String =
    context.get("resultSummary") match {
      case crs: ChainResultsSummary =>
        val pluginInfos = for {
          jobSummaries <- crs.getOrderedJobResultSummaries.asScala
          (key, pluginBinaryUrl) <- jobSummaries.getCustomBuildData.asScala if key == Constants.ResultLinkPluginBinaryUrl
          (key, pluginVersion) <- jobSummaries.getCustomBuildData.asScala if key == Constants.ResultLinkPluginVersion
        } yield (pluginBinaryUrl, pluginVersion)
        pluginInfos.toList match {
          case Nil => ""
          case (binaryUrl, version) :: _ =>
            s"""<p>$MpacLogoBase64Encoded <a href="$binaryUrl">Atlassian Marketplace version $version</a></p>"""
        }
      case _ => ""
    }

} 
开发者ID:mibexsoftware,项目名称:shipit2marketplace,代码行数:45,代码来源:ShipItResultsLinkPanel.scala


示例18: SubscribedArtifactCollector

//设置package包名称以及导入依赖的类
package ch.mibex.bamboo.shipit.task.artifacts

import java.io.File

import ch.mibex.bamboo.shipit.Utils
import com.atlassian.bamboo.plan.cache.ImmutableJob
import com.atlassian.bamboo.task.{CommonTaskContext, TaskContext}
import com.atlassian.bamboo.util.Narrow
import com.atlassian.bamboo.webwork.util.WwSelectOption
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport
import com.atlassian.sal.api.message.I18nResolver
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

import scala.collection.JavaConverters._


@Component
class SubscribedArtifactCollector @Autowired() (@ComponentImport i18nResolver: I18nResolver) {

  def buildArtifactUiList(job: ImmutableJob): Seq[WwSelectOption] =
    job.getArtifactSubscriptions.asScala map { as =>
      val selectedValue = ArtifactSubscriptionId(as.getArtifactDefinition)
      val groupName = i18nResolver.getText("shipit.task.config.subscribed.artifacts")
      new WwSelectOption(as.getName, groupName, selectedValue.toString)
    }

  def findArtifactInSubscriptions(taskContext: CommonTaskContext, artifactId: Long): Option[File] = {
    val rootDir = taskContext.getWorkingDirectory
    val buildTaskContext = Narrow.downTo(taskContext, classOf[TaskContext])
    Option(buildTaskContext) flatMap { btc =>
      (btc.getBuildContext.getArtifactContext.getSubscriptionContexts.asScala collectFirst {
        case asc if asc.getArtifactDefinitionContext.getId == artifactId =>
          Utils.findMostRecentMatchingFile(asc.getArtifactDefinitionContext.getCopyPattern, rootDir)
      }).flatten
    }
  }

} 
开发者ID:mibexsoftware,项目名称:shipit2marketplace,代码行数:40,代码来源:SubscribedArtifactCollector.scala


示例19: InfoService

//设置package包名称以及导入依赖的类
package com.github.swwjf.ws

import com.github.swwjf.errorhandling.WSException
import org.springframework.beans.BeanUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.dao.DataIntegrityViolationException
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

import scala.collection.JavaConversions._
import scala.compat.java8.OptionConverters.RichOptionalGeneric

@Service
class InfoService @Autowired()(infoRepository: InfoRepository) {

  def fetchAllInformation(): List[InfoResponseDTO] = {
    def jpaToResponse(jpa: InfoJPA): InfoResponseDTO = {
      val response = InfoResponseDTO(
        createdDate = jpa.createdData.toString,
        updatedDate = Option(jpa.updatedDate).map(_.toString).orNull
      )
      BeanUtils.copyProperties(jpa, response)
      response
    }

    infoRepository
      .findAll()
      .map(jpaToResponse)
      .toList
  }

  def saveInfo(infoRequestDTO: InfoRequestDTO): Unit = {
    def requestToJPA(request: InfoRequestDTO): InfoJPA = {
      val jpa = new InfoJPA
      BeanUtils.copyProperties(request, jpa)
      jpa
    }

    try {
      infoRepository.save(requestToJPA(infoRequestDTO))
    } catch {
      case e: DataIntegrityViolationException => throw new WSException("Invalid/duplicate label")
    }
  }

  @Transactional
  def updateInfo(info: InfoRequestDTO): Unit = {
    val infoJPA = infoRepository
      .findOneByLabel(info.label)
      .asScala
      .getOrElse(throw new WSException(s"Failed to find info by label ${info.label}"))
    infoJPA.setMainDetails(info.mainDetails)
    infoJPA.setComments(info.comments)
  }

} 
开发者ID:andrei-l,项目名称:scala-webapp-with-java-frameworks,代码行数:57,代码来源:InfoService.scala


示例20: DBConfig

//设置package包名称以及导入依赖的类
package com.github.swwjf.config

import javax.persistence.EntityManagerFactory
import javax.sql.DataSource

import org.apache.commons.dbcp2.BasicDataSource
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties
import org.springframework.boot.context.properties.{ConfigurationProperties, EnableConfigurationProperties}
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder
import org.springframework.context.annotation.{Bean, Configuration, Primary}
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.orm.jpa.{JpaTransactionManager, LocalContainerEntityManagerFactoryBean}
import org.springframework.transaction.PlatformTransactionManager
import org.springframework.transaction.annotation.EnableTransactionManagement

@Configuration
@EnableJpaRepositories(basePackages = Array(DBConfig.RootPackage))
@EnableTransactionManagement
@EnableConfigurationProperties(Array(classOf[JpaProperties]))
private class DBConfig {
  @Bean
  @ConfigurationProperties(prefix = "jdbc.datasource.ws")
  @Primary
  def wsDataSource(): DataSource =
    DataSourceBuilder
      .create()
      .`type`(classOf[BasicDataSource])
      .build()

  @Bean
  @Autowired
  def entityManagerFactory(builder: EntityManagerFactoryBuilder): LocalContainerEntityManagerFactoryBean =
    builder
      .dataSource(wsDataSource())
      .persistenceUnit("ws")
      .packages(DBConfig.RootPackage)
      .build()

  @Bean
  def transactionManager(entityManagerFactory: EntityManagerFactory): PlatformTransactionManager = {
    val txManager = new JpaTransactionManager()
    txManager.setEntityManagerFactory(entityManagerFactory)
    txManager
  }
}

private object DBConfig extends DBConstants

private sealed trait DBConstants {
  final val RootPackage = "com.github.swwjf"
} 
开发者ID:andrei-l,项目名称:scala-webapp-with-java-frameworks,代码行数:54,代码来源:DBConfig.scala



注:本文中的org.springframework.beans.factory.annotation.Autowired类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala ActorNotFound类代码示例发布时间:2022-05-23
下一篇:
Scala PrimaryStage类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap