Spring passing Class through constructor from xml file

Is it possible to inject Class param through constructor from xml file? How is it done? For example

public Server(Class<?>... configuration) {}

This is class with param to inject

This is my xml file

<constructor-arg index="0"></constructor-arg>

But what shall I do next?

-------------Problems Reply------------

If your parameter was of type Class<?>, then all you would need is to provide the fully qualified class name

<constructor-arg index="0">java.lang.String</constructor-arg>

But since you have a varargs, you need to add an <array> with values

<constructor-arg index="0">
<array>
<value>
java.lang.String
</value>
</array>
</constructor-arg>

since args is an array of Object you can use :

<bean name="myBean" class="MyClass"> <constructor-arg> <list> <value>111</value> <value>222</value> <value>333</value> <value>444</value> </list> </constructor-arg> </bean>

Category:java Views:6 Time:2019-03-12

Related post

  • passing the attribute values from xml file to java file in android 2011-05-23

    If we pass the Url of the xml file to the .java file,then how to get the attribute values into the .java file --------------Solutions------------- Hope this helps: SAX Parsing in Android Programming

  • C# Class (source code) Generator from XML file 2010-06-04

    What tools have you used to create class source code from xml files? Is this an edge case that I need to roll my own? I have need to create DTOs from some XML files, but the XML files are subject to change (add/remove attributes) so I need to be able

  • How to register Spring @Configuration annotated class instead of applicationContext.xml file in web.xml? 2011-11-10

    I am using jsf and spring together in web application. I have configured datasource and session factory in one configuration class which uses annotations like @Configuration, @ComponentScan etc. I don't have any applicationContext.xml file in my proj

  • Generating Java classes from XML file 2010-03-15

    How can I get java classes from an xml file? In this situation, I don't have an XML schema and this way I can't use JAXB, Castor or other xml binding API as far as I know. --------------Solutions------------- You can generate schema from XML file usi

  • suppose there is a class which contains 4 data fields.i have to read these value from xml file and set that value to data fields 2010-05-27

    suppose there is a class which contains 4 fields.i have to read these value from xml file and set that value to fields the xml file is like that <Root> <Application > <AppName>somevalue</AppName> <IdMark>somevalue</Id

  • How create a serializable C# class from XML file 2010-12-02

    I am fairly new to XML in .net. As part of my task i need to create the class which can be serialized to XML. I have an sample XML file with all the tags(the class should produce XML similar to the sample XML file ). what would be best approach to cr

  • Embedding data from xml file into metadata of a pdf 2013-02-28

    Hi All I'm wanting to do the following, but struggling to figure the right way to go about it. I want to embedded data from my MIS into a pdf's metadata (as scrnshot). I can create a standalone xml file with all the data I require, but I'm unsure how

  • How to load AnimationDrawable from xml file 2010-01-25

    I have some custom class BitmapStorage, not attached to any View or whatever - an utility one. And I have born_animation.xml file which contains <animation-list> with animation frames: <animation-list oneshot="true" > <item drawable="@

  • Problems populating UITableView with data from XML file 2010-02-01

    I will try to explain shortly what my problem is... I'm loading an XML file (using touchXML) to populate a UITableView with data. expositions = [[NSMutableArray alloc] init]; // Get XML string from XML document. NSString *xmlURL = EXPOSITION_XML_DOC;

  • Reading from XML file 2010-06-29

    I have a XML file like this: <students> <student rollNo="1" Name ="A" Grade="A"/> <student rollNo="2" Name ="B" Grade="A"/> <student rollNo="3" Name ="C" Grade="A"/> <student rollNo="4" Name ="D" Grade="A"/> </student

  • if XML file has "xmlns",how can I get Text from XML file using XPath 2010-08-16

    I get a XML file from website (http://www.abc.com/), URL is: http://www.abc.com/api/api.xml content is: <?xml version="1.0" encoding="utf-8"?> <root xmlns="http://www.abc.com/"> <name>Hello!</name> </root> it has xmlns="

  • DataGridView with images from XML file 2011-02-06

    say that I was to store image paths in an xml file. What I want to do is display the image in a DataGridView depending on the status stored in my sql server database table. Therefore, if I was to add a new project, I would store 'IN PROGRESS' in my P

  • Retrive Value automatically from XML file with Javascript and respond 2011-04-21

    I have following code in HTML, and I would like to retrieve "[email protected]" from XML file called "XMLSMAPLE.XML" automatically. In coding, the flow should be like : Select "[email protected]" in XML files automatically and get values from attributes

  • selecting data from xml file in javascript 2011-05-20

    i want to select just two items from xml file with itemno and quantity that have less prices.can anybody help me how to do this in javascript. items.xml: <?xml version="1.0"?> <items> <item> <itemno>1</itemno> <unitpr

  • Building side navigation menu from XML file in Rails 3 2011-07-07

    i am newbie to RoR previously working on .NET platform. We have requirement to build a home page from xml file. The xml file cantains the 3 category and under each category we have 4 menu items. The XML file looks like: <menu id="mnusermgmt" capti

  • How to change fragment class name tag in xml file? 2011-07-16

    I want to change the fragment class by other fragment class.. on click event of Listview --------------Solutions------------- How to change fragment class name tag in xml file? You open up your editor and type in a new value. I want to change the fra

  • extracting nearest stores based on coordinates from xml file 2011-08-17

    I am making store locator application. In my application i am showing nearest store to given latitude and longitude. i am getting my current lan. and lot. I have xml file on server containing all information of stores and latitude and longitude. What

  • action script 3 read values from XML file 2011-09-13

    I have a problem while reading from XML file in action script 3. This is my XML-file: <config> <production> <app_id>123</app_id> <server_path>http://someLinktoAccess</server_path> <assets_server>http://someLi

  • Extracting Data From XML File Using C# 2012-01-10

    I have some XML file sitting in my /bin folder (using vs2010). I would like to extract some data (attributes, element values) from this xml. What is the best way to do this using C#? do I need to use XMLTextReader or would it be better to create an x

  • Except function doesn't work on a list that I got from xml file 2012-02-01

    I am trying to use IEnumerable.Except function in c# 4.0 to get the difference between two lists like this: //Function to get only available rooms out of all rooms of the hotel... public IEnumerable<Room> GetAvailableRooms(DateTime arrival, Dat

  • Read array from xml file in android 2012-02-06

    We can read a string array from xml file in android like mentioned here. But this can only read simple string array. My question is that can we read array containing some other type of objects. xml file is like this: <?xml version="1.0" encoding="

  • Django MemoryError Importing Lots of Data from XML Files 2012-02-22

    I am importing records from XML files, and it is chewing up memory. I've gone through the XML ElementTree that is created and deleted all of the elements and subelements to clear memory, but it still just piles up. I finally found a solution, and wan

  • Configure Windsor IoC from XML file - special chatracters in value of XML element 2012-03-04

    I use Castle Windsor IoC. I would like configure object in IoC from XML file. Class is only POCO with some properties. My problem is that value of property is string which contain special characters. For example here is XML which I use for configure

  • visiops automatic diagram building from xml file 2012-04-11

    I have found that VisioPS is able to draw diagram in xml from xml file using COM. Nice feature I can construct xml file and build diagram in visio. However for class diagram I need to add operations and attributes for classes. Is it possible to speci

  • android get nodelist attribute from xml file 2012-04-16

    I make listview from xml file http://view-source:http://www.macetlagi.com/maps/st/canvaser/3/tb/tb123.I will get element from "segment" tag.When i run and debug my code,i get this error java.lang.NullPointerException.Please correct my code if i do my

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.205 (s). 11 q(s)