Property Editor Bean : IoC Factory Beans « Spring « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » Spring » IoC Factory BeansScreenshots 
Property Editor Bean

/*
Pro Spring
By Rob Harrop
Jan Machacek
ISBN: 1-59059-461-4
Publisher: Apress
*/



///////////////////////////////////////////////////////////////////////////////////////
//File: builtin.xml
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="builtInSample" class="PropertyEditorBean">
        <property name="class">
            <value>java.lang.String</value>
        </property>
        <property name="file">
            <value>c:/test.txt</value>
        </property>
        <property name="locale">
            <value> en-GB </value>
        </property>
        <property name="url">
            <value>http://www.springframework.org</value>
        </property>
        <property name="properties">
            <value> 
                name=foo 
                age=19 
            </value>
        </property>
        <property name="strings">
            <value>rob,jan,rod,jurgen,alef</value>
        </property>
        <property name="bytes">
            <value>Hello World</value>
        </property>
    </bean>
</beans>


///////////////////////////////////////////////////////////////////////////////////////
import java.io.File;
import java.net.URL;
import java.util.Locale;
import java.util.Properties;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

public class PropertyEditorBean {

    private Class cls;

    private File file;

    private URL url;

    private Locale locale;

    private Properties properties;

    private String[] strings;

    private byte[] bytes;

    public void setClass(Class cls) {
        System.out.println("Setting class: " + cls.getName());
        this.cls = cls;
    }

    public void setFile(File file) {
        System.out.println("Setting file: " + file.getName());
        this.file = file;
    }

    public void setLocale(Locale locale) {
        System.out.println("Setting locale: " + locale.getDisplayName());
        this.locale = locale;
    }

    public void setProperties(Properties properties) {
        System.out.println("Loaded " + properties.size() " properties");
        this.properties = properties;
    }

    public void setStrings(String[] strings) {
        System.out.println("Loaded " + strings.length + " Strings");
        this.strings = strings;
    }

    public void setUrl(URL url) {
        System.out.println("Setting URL: " + url.toExternalForm());
        this.url = url;
    }

    public void setBytes(byte[] bytes) {
        System.out.println("Adding " + bytes.length + " bytes");
        this.bytes = bytes;
    }

    public static void main(String[] args) {
        BeanFactory factory = new XmlBeanFactory(new FileSystemResource(
                "build/builtin.xml"));
        PropertyEditorBean bean = (PropertyEditorBeanfactory
                .getBean("builtInSample");
    }
}

           
       
PropertyEditorBean.zip( 1,476 k)
Related examples in the same category
1. Hierarchical Bean Factory Usage
2. Message Digest Example
3. Method Replacement Example
4. Logging Bean Example
5. Custom Editor Example
6. Accessing Factory Beans
ww___w.___j___a__v__a_2__s___._c_o_m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.