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 1086331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:47:59+00:00 2026-05-16T22:47:59+00:00

I have Java classes like this: public class Config { public Config1 getConfigOpt1(); public

  • 0

I have Java classes like this:

public class Config {
    public Config1 getConfigOpt1();
    public Config2 getConfigOpt2();
}

public class SomeBean {
    public Config getEntireConfig();
}

public class BeanToConstruct {

    public static BeanToConstruct createAndStart( Config1 config1, Config2 config2 )
}

Given SomeBean, I would construct BeanToConstruct like this:

SomeBean someBean = ....
BeanToConstruct bean = BeanToConstruct.createAndStart( 
    someBean.getEntireConfig().getConfigOpt1(),
    someBean.getEntireConfig().getConfigOpt2() )

How can I do this inside my applicationContext.xml? This is basically what I want to do, but it obviously doesn’t work. I could pull the entire Config object out into its own bean, but I don’t want to have this extra bean around that is really only needed to make constructing BeanToConstruct possible.

<bean class="com.example.SomeBean" id="someBean"/>
<bean class="com.example.BeanToConstruct" factory-method="createAndStart" id="myBean">
    <constructor-arg>
        <bean factory-bean="someBean" factory-method="getEntireConfig().getConfigOpt1()"/>
    </constructor-arg>
    <constructor-arg>
        <bean factory-bean="someBean" factory-method="getEntireConfig().getConfigOpt2()"/>
    </constructor-arg>
</bean> 
  • 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-16T22:48:00+00:00Added an answer on May 16, 2026 at 10:48 pm

    In Spring 3.x you may use expression language:

    <bean class="com.example.BeanToConstruct" factory-method="createAndStart" id="myBean"> 
        <constructor-arg value = "#{someBean.entireConfig.configOpt1}" /> 
        <constructor-arg value = "#{someBean.entireConfig.configOpt2}" /> 
    </bean> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java class that looks like this: public class My_ABC { int
I have some java classes like, Class User { String email; String name; String
I have a package with logic classes(like CheckAuthenticationDataLogic.java, GetVocabulariesLogic.java). And another class - ApiService.java
I'm looking at some Java classes that have the following form: public abstract class
I have a number of classes that look like this: class Foo(val:BasicData) extends Bar(val)
I've got a problem with generic classes in java. I've got this class: public
I have a Java problem with nested classes. My first class structure looked like
I'd like to have functor class like this: public class Functor<T, R> { public
I have a java web project containing JAX-RS resource classes like this: @Stateless @Path(user)
I have Servlet that looks something like this: public class MyServlet extends Servlet {

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.