Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6678617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:15:51+00:00 2026-05-26T04:15:51+00:00

This can be done using a converter wrapper: import scala.collection.JavaConversions._ object ListConverter { def

  • 0

This can be done using a converter wrapper:

import scala.collection.JavaConversions._

object ListConverter {

  def toScalaList( jlist: java.util.List[AnyRef] ) = {
    jlist.toList
  }
}

which uses a implicit def asScalaBuffer in JavaConversions to return a Scala List. Then I can make the list injectable as:

<bean id="someItems" class="my.package.ListConverter" factory-method="toScalaList">
    <constructor-arg type="java.util.List">
        <util:list>
            <ref bean="itemOne"/>
            <ref bean="itemTwo"/>
        </util:list>
    </constructor-arg>
</bean>

I would like to find a cleaner way to do this

I can’t really use JavaConversions directly as a static factory call:

<bean id="someItems" class="scala.collection.JavaConversions" factory-method="asScalaBuffer">...</bean>

Since an implicit def is not really a static method in a Java universe.

P.S. To get it out of the way.. I know there are a lot of annotation driven config lovers, but I am not one of them, and that is not a solution I am looking for: I like my XML for Spring configs, and I like Spring to DI Scala

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:15:52+00:00Added an answer on May 26, 2026 at 4:15 am

    If you want to convert a java.util.List to a scala List you will have to provide your own conversion/factory method as no such method exists.

    JavaConversions.asScalaBuffer could be referenced exactly as you did in your XML definition as the Scala compiler generates static forwarder methods to the object instance unless you tell it not to do so.
    The problem here is actually actually that this method returns a scala.collection.mutable.Buffer which you still have to convert into a List.

    An alternative is to accept an instance of Seq[A] to be injected. This would work as Buffer[A] extends Seq[A] – but you have to be aware that you are injecting a wrapper around the (possibly mutable) java.util.List<A> instance then.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this can be done and i have seen it done using some
I know that this can be easily done by using if(i%5 == 0 OR
I don't think this can be done cleanly, but I'll ask anyway. I have
I am wondering if this can be done easily. I am doing some paypal
Simple question. Just wondering if this can be done without me having to enforce
Can this be done by setting a property? I'd prefer that approach then to
Can this be done w/ linqtosql? SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP
Can this be done? It seems like this should be possible. In general, I
Can this be done in JavaScript? type == 1 ? function1() : function2();
How can this be done more elegant and without creating new objects? List<Move> playerMoves

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.