Skip to content

Commit be02a49

Browse files
committedJun 27, 2013
Initial commit - licensed under ASF v2
1 parent 0584cb5 commit be02a49

19 files changed

+1797
-1
lines changed
 

‎README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
spring-custom-namespaces
22
========================
33

4-
Spring Custom Namespaces code by Vlad Untu
4+
Spring Custom Namespaces code by Vlad Untu - released under Apache Software License V2
5+
http://www.apache.org/licenses/LICENSE-2.0.html
6+
7+
<a href="http://www.bjug.ro/editii/12.html">link to presentation</a>
8+

‎build.xml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- You may freely edit this file. See commented blocks below for -->
3+
<!-- some examples of how to customize the build. -->
4+
<!-- (If you delete it and reopen the project it will be recreated.) -->
5+
<!-- By default, only the Clean and Build commands use this build script. -->
6+
<!-- Commands such as Run, Debug, and Test only use this build script if -->
7+
<!-- the Compile on Save feature is turned off for the project. -->
8+
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
9+
<!-- in the project's Project Properties dialog box.-->
10+
<project name="SpringCustomNs" default="default" basedir=".">
11+
<description>Builds, tests, and runs the project SpringCustomNs.</description>
12+
<import file="nbproject/build-impl.xml"/>
13+
<!--
14+
15+
There exist several targets which are by default empty and which can be
16+
used for execution of your tasks. These targets are usually executed
17+
before and after some main targets. They are:
18+
19+
-pre-init: called before initialization of project properties
20+
-post-init: called after initialization of project properties
21+
-pre-compile: called before javac compilation
22+
-post-compile: called after javac compilation
23+
-pre-compile-single: called before javac compilation of single file
24+
-post-compile-single: called after javac compilation of single file
25+
-pre-compile-test: called before javac compilation of JUnit tests
26+
-post-compile-test: called after javac compilation of JUnit tests
27+
-pre-compile-test-single: called before javac compilation of single JUnit test
28+
-post-compile-test-single: called after javac compilation of single JUunit test
29+
-pre-jar: called before JAR building
30+
-post-jar: called after JAR building
31+
-post-clean: called after cleaning build products
32+
33+
(Targets beginning with '-' are not intended to be called on their own.)
34+
35+
Example of inserting an obfuscator after compilation could look like this:
36+
37+
<target name="-post-compile">
38+
<obfuscate>
39+
<fileset dir="${build.classes.dir}"/>
40+
</obfuscate>
41+
</target>
42+
43+
For list of available properties check the imported
44+
nbproject/build-impl.xml file.
45+
46+
47+
Another way to customize the build is by overriding existing main targets.
48+
The targets of interest are:
49+
50+
-init-macrodef-javac: defines macro for javac compilation
51+
-init-macrodef-junit: defines macro for junit execution
52+
-init-macrodef-debug: defines macro for class debugging
53+
-init-macrodef-java: defines macro for class execution
54+
-do-jar-with-manifest: JAR building (if you are using a manifest)
55+
-do-jar-without-manifest: JAR building (if you are not using a manifest)
56+
run: execution of project
57+
-javadoc-build: Javadoc generation
58+
test-report: JUnit report generation
59+
60+
An example of overriding the target for project execution could look like this:
61+
62+
<target name="run" depends="SpringCustomNs-impl.jar">
63+
<exec dir="bin" executable="launcher.exe">
64+
<arg file="${dist.jar}"/>
65+
</exec>
66+
</target>
67+
68+
Notice that the overridden target depends on the jar target and not only on
69+
the compile target as the regular run target does. Again, for a list of available
70+
properties which you can use, check the target you are overriding in the
71+
nbproject/build-impl.xml file.
72+
73+
-->
74+
</project>

‎manifest.mf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
X-COMMENT: Main-Class will be added automatically by build
3+

‎nbproject/build-impl.xml

+1,411
Large diffs are not rendered by default.

‎nbproject/genfiles.properties

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build.xml.data.CRC32=e3a4b6fc
2+
build.xml.script.CRC32=d4a30df7
3+
build.xml.stylesheet.CRC32=28e38971@1.56.1.46
4+
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5+
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6+
nbproject/build-impl.xml.data.CRC32=e3a4b6fc
7+
nbproject/build-impl.xml.script.CRC32=f20f30d4
8+
nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46

‎nbproject/private/private.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
compile.on.save=true
2+
user.properties.file=C:\\Users\\Vlad Untu\\AppData\\Roaming\\NetBeans\\7.3\\build.properties

‎nbproject/private/private.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
3+
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
4+
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
5+
<file>file:/C:/Users/Vlad%20Untu/Documents/NetBeansProjects/SpringNms/src/ro/bjug/spring/customns/applicationContext.xml</file>
6+
<file>file:/C:/Users/Vlad%20Untu/Documents/NetBeansProjects/SpringNms/src/META-INF/spring.handlers</file>
7+
<file>file:/C:/Users/Vlad%20Untu/Documents/NetBeansProjects/SpringNms/src/META-INF/spring.schemas</file>
8+
<file>file:/C:/Users/Vlad%20Untu/Documents/NetBeansProjects/SpringNms/src/ro/bjug/spring/customns/SpringNms.java</file>
9+
</open-files>
10+
</project-private>
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
3+
<system systemId="http://www.springframework.org/schema/beans" uri="www.springframework.org/schema/beans/index"/>
4+
</catalog>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2+
<html>
3+
<head>
4+
<title>Index of /schema/beans</title>
5+
</head>
6+
<body>
7+
<h1>Index of /schema/beans</h1>
8+
<ul><li><a href="/schema/"> Parent Directory</a></li>
9+
<li><a href="spring-beans-2.0.xsd"> spring-beans-2.0.xsd</a></li>
10+
<li><a href="spring-beans-2.5.xsd"> spring-beans-2.5.xsd</a></li>
11+
<li><a href="spring-beans-3.0.xsd"> spring-beans-3.0.xsd</a></li>
12+
<li><a href="spring-beans-3.1.xsd"> spring-beans-3.1.xsd</a></li>
13+
<li><a href="spring-beans-3.2.xsd"> spring-beans-3.2.xsd</a></li>
14+
<li><a href="spring-beans.xsd"> spring-beans.xsd</a></li>
15+
</ul>
16+
<address>Apache/2.2.3 (CentOS) Server at www.springframework.org Port 80</address>
17+
</body></html>

‎nbproject/project.properties

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
annotation.processing.enabled=true
2+
annotation.processing.enabled.in.editor=false
3+
annotation.processing.processor.options=
4+
annotation.processing.processors.list=
5+
annotation.processing.run.all.processors=true
6+
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7+
build.classes.dir=${build.dir}/classes
8+
build.classes.excludes=**/*.java,**/*.form
9+
# This directory is removed when the project is cleaned:
10+
build.dir=build
11+
build.generated.dir=${build.dir}/generated
12+
build.generated.sources.dir=${build.dir}/generated-sources
13+
# Only compile against the classpath explicitly listed here:
14+
build.sysclasspath=ignore
15+
build.test.classes.dir=${build.dir}/test/classes
16+
build.test.results.dir=${build.dir}/test/results
17+
# Uncomment to specify the preferred debugger connection transport:
18+
#debug.transport=dt_socket
19+
debug.classpath=\
20+
${run.classpath}
21+
debug.test.classpath=\
22+
${run.test.classpath}
23+
# This directory is removed when the project is cleaned:
24+
dist.dir=dist
25+
dist.jar=${dist.dir}/SpringCustomNs.jar
26+
dist.javadoc.dir=${dist.dir}/javadoc
27+
excludes=
28+
includes=**
29+
jar.compress=false
30+
javac.classpath=\
31+
${libs.spring-framework300.classpath}
32+
# Space-separated list of extra javac options
33+
javac.compilerargs=
34+
javac.deprecation=false
35+
javac.processorpath=\
36+
${javac.classpath}
37+
javac.source=1.6
38+
javac.target=1.6
39+
javac.test.classpath=\
40+
${javac.classpath}:\
41+
${build.classes.dir}
42+
javac.test.processorpath=\
43+
${javac.test.classpath}
44+
javadoc.additionalparam=
45+
javadoc.author=false
46+
javadoc.encoding=${source.encoding}
47+
javadoc.noindex=false
48+
javadoc.nonavbar=false
49+
javadoc.notree=false
50+
javadoc.private=false
51+
javadoc.splitindex=true
52+
javadoc.use=true
53+
javadoc.version=false
54+
javadoc.windowtitle=
55+
main.class=ro.bjug.spring.customns.SpringNms
56+
manifest.file=manifest.mf
57+
meta.inf.dir=${src.dir}/META-INF
58+
mkdist.disabled=false
59+
platform.active=default_platform
60+
run.classpath=\
61+
${javac.classpath}:\
62+
${build.classes.dir}
63+
# Space-separated list of JVM arguments used when running the project.
64+
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
65+
# To set system properties for unit tests define test-sys-prop.name=value:
66+
run.jvmargs=
67+
run.test.classpath=\
68+
${javac.test.classpath}:\
69+
${build.test.classes.dir}
70+
source.encoding=UTF-8
71+
src.dir=src
72+
test.src.dir=test

‎nbproject/project.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://www.netbeans.org/ns/project/1">
3+
<type>org.netbeans.modules.java.j2seproject</type>
4+
<configuration>
5+
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
6+
<name>SpringCustomNs</name>
7+
<source-roots>
8+
<root id="src.dir"/>
9+
</source-roots>
10+
<test-roots>
11+
<root id="test.src.dir"/>
12+
</test-roots>
13+
</data>
14+
</configuration>
15+
</project>

‎src/META-INF/spring.handlers

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
http\://www.bjug.ro/schema/customns=ro.bjug.spring.customns.CustomNsHandler

‎src/META-INF/spring.schemas

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
http\://www.bjug.ro/schema/customns.xsd=ro/bjug/spring/customns/customns.xsd
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package ro.bjug.spring.customns;
6+
7+
/**
8+
*
9+
* @author Vlad Untu
10+
*/
11+
public class Configuration {
12+
private String user;
13+
private String password;
14+
private String server;
15+
16+
/**
17+
* @return the user
18+
*/
19+
public String getUser() {
20+
return user;
21+
}
22+
23+
/**
24+
* @param user the user to set
25+
*/
26+
public void setUser(String user) {
27+
this.user = user;
28+
}
29+
30+
/**
31+
* @return the password
32+
*/
33+
public String getPassword() {
34+
return password;
35+
}
36+
37+
/**
38+
* @param password the password to set
39+
*/
40+
public void setPassword(String password) {
41+
this.password = password;
42+
}
43+
44+
/**
45+
* @return the server
46+
*/
47+
public String getServer() {
48+
return server;
49+
}
50+
51+
/**
52+
* @param server the server to set
53+
*/
54+
public void setServer(String server) {
55+
this.server = server;
56+
}
57+
58+
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package ro.bjug.spring.customns;
6+
7+
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
8+
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
9+
import org.w3c.dom.Element;
10+
11+
/**
12+
*
13+
* @author Vlad Untu
14+
*/
15+
class ConfigurationDefinitionParser extends AbstractSingleBeanDefinitionParser {
16+
17+
@Override
18+
protected Class<?> getBeanClass(Element element) {
19+
return Configuration.class;
20+
}
21+
22+
@Override
23+
protected void doParse(Element element, BeanDefinitionBuilder builder) {
24+
builder.addPropertyValue("user", element.getAttribute("user"));
25+
builder.addPropertyValue("password", element.getAttribute("password"));
26+
builder.addPropertyValue("server", element.getAttribute("server"));
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package ro.bjug.spring.customns;
6+
7+
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
8+
9+
/**
10+
*
11+
* @author Vlad Untu
12+
*/
13+
public class CustomNsHandler extends NamespaceHandlerSupport {
14+
15+
@Override
16+
public void init() {
17+
registerBeanDefinitionParser("configuration", new ConfigurationDefinitionParser());
18+
}
19+
20+
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package ro.bjug.spring.customns;
6+
7+
import org.springframework.context.ApplicationContext;
8+
import org.springframework.context.support.ClassPathXmlApplicationContext;
9+
10+
/**
11+
*
12+
* @author Vlad Untu
13+
*/
14+
public class SpringNms {
15+
16+
/**
17+
* @param args the command line arguments
18+
*/
19+
public static void main(String[] args) {
20+
ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"ro/bjug/spring/customns/applicationContext.xml"} );
21+
22+
Configuration config1 = context.getBean("config1", Configuration.class);
23+
24+
Configuration config2 = context.getBean("config2", Configuration.class);
25+
26+
System.out.println("User: " + config1.getUser());
27+
System.out.println("Password: " + config1.getPassword());
28+
System.out.println("Server: " + config1.getServer());
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:c="http://www.bjug.ro/schema/customns"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.bjug.ro/schema/customns http://www.bjug.ro/schema/customns.xsd">
6+
7+
<bean id="config1" class="ro.bjug.spring.customns.Configuration">
8+
<property name="user" value="root"/>
9+
<property name="password" value="changeit"/>
10+
<property name="server" value="127.0.0.1"/>
11+
</bean>
12+
13+
<c:configuration id="config2" user="root" password="changeit" server="127.0.0.1"/>
14+
</beans>
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsd:schema xmlns="http://www.bjug.ro/schema/customns"
3+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4+
xmlns:beans="http://www.springframework.org/schema/beans"
5+
targetNamespace="http://www.bjug.ro/schema/customns"
6+
elementFormDefault="qualified"
7+
attributeFormDefault="unqualified">
8+
9+
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
10+
11+
<xsd:element name="configuration">
12+
<xsd:complexType>
13+
<xsd:complexContent>
14+
<xsd:extension base="beans:identifiedType">
15+
<xsd:attribute name="user" type="xsd:string" use="required"/>
16+
<xsd:attribute name="password" type="xsd:string" use="required"/>
17+
<xsd:attribute name="server" type="xsd:string" use="required"/>
18+
</xsd:extension>
19+
</xsd:complexContent>
20+
</xsd:complexType>
21+
</xsd:element>
22+
23+
</xsd:schema>

0 commit comments

Comments
 (0)
Please sign in to comment.