geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r453113 - /geronimo/xbean/site/editing-custom-xml.html
Date Thu, 05 Oct 2006 06:41:24 GMT
Author: chirino
Date: Wed Oct  4 23:41:24 2006
New Revision: 453113

URL: http://svn.apache.org/viewvc?view=rev&rev=453113
Log:
Latest export from confluence

Modified:
    geronimo/xbean/site/editing-custom-xml.html

Modified: geronimo/xbean/site/editing-custom-xml.html
URL: http://svn.apache.org/viewvc/geronimo/xbean/site/editing-custom-xml.html?view=diff&rev=453113&r1=453112&r2=453113
==============================================================================
--- geronimo/xbean/site/editing-custom-xml.html (original)
+++ geronimo/xbean/site/editing-custom-xml.html Wed Oct  4 23:41:24 2006
@@ -100,11 +100,11 @@
                     <FONT color="#003366" face="Verdana, Helvetica, Arial">
                             
                 
-                                                                                        
                                                       
+                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                     
                                                 
                         
             <A href="download.html" title="Download">Download</A> | <SPAN
class="nobr"><A href="http://geronimo.apache.org/xbean/dist/xbean-2.4/site/" title="Visit
page outside Confluence" rel="nofollow">JavaDocs<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif"
height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN>
| <A href="source.html" title="Source">Source</A> | <SPAN class="nobr"><A
href="http://goopen.org/confluence/pages/listpages.action?key=XB" title="Visit page outside
Confluence" rel="nofollow">Wiki<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif"
height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN>
| <A href="lists.html" title="Lists">Mailing Lists</A> | <SPAN class="nobr"><A
href="http://issues.apache.org/jira/browse/XBEAN" title="Visit page outside Confluence" rel="nofollow">Support<SUP><IMG
class="rendericon" src="http://goopen.org/confluenc
 e/images/icons/linkext7.gif" height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN>
-                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                 </FONT>
+                                                                                        
                                                   </FONT>
                         <IMG src="http://geronimo.apache.org/images/spacer.gif" width="4"
height="1" border="0">
                 </DIV>
             </TD>
@@ -214,7 +214,7 @@
                                     <TD>&nbsp;</TD>
                                     <TD class="sideNavSectionContent" align="left">
   
                 
-                                                                                        
       
+                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                       
                                                 
                         
             <A href="home.html" title="Home">Home</A><BR>
@@ -222,7 +222,7 @@
 <A href="site.html" title="Site">Site</A><BR>
 <A href="faq.html" title="FAQ">FAQ</A><BR>
 <A href="download.html" title="Download">Download</A>
-                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                   </TD>
+                                                            </TD>
                                 </TR>
                             </TABLE>
                         </TD>
@@ -253,7 +253,7 @@
                                     <TD>&nbsp;</TD>
                                     <TD class="sideNavSectionContent" align="left">
   
                 
-                                                                                        
                   
+                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                               
                                                 
                         
             <A href="custom-xml.html" title="Custom XML">Custom XML</A><BR>
@@ -261,7 +261,7 @@
 <A href="xbean-ant-task.html" title="XBean Ant Task">XBean Ant Task</A><BR>
 <A href="jaxb-jndi.html" title="A JNDI provider using JAXB2">JAXB JNDI</A><BR>
 <A href="annotation-based-dependency-injection.html" title="Annotation based Dependency
Injection">AnDI</A>
-                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                         
       </TD>
+                                                                                    </TD>
                                 </TR>
                             </TABLE>
                         </TD>
@@ -292,7 +292,7 @@
                                     <TD>&nbsp;</TD>
                                     <TD class="sideNavSectionContent" align="left">
   
                 
-                                                                                    
+                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                   
                                                 
                         
             <SPAN class="nobr"><A href="http://www.springframework.org/" title="Visit
page outside Confluence" rel="nofollow">Spring<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif"
height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN><BR>
@@ -301,7 +301,7 @@
 <SPAN class="nobr"><A href="http://openejb.org/" title="Visit page outside Confluence"
rel="nofollow">OpenEJB<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif"
height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN><BR>
 <SPAN class="nobr"><A href="http://jencks.org/" title="Visit page outside Confluence"
rel="nofollow">Jencks<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif"
height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN><BR>
 <SPAN class="nobr"><A href="http://servicemix.org/" title="Visit page outside Confluence"
rel="nofollow">ServiceMix<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif"
height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN>
-                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                               </TD>
+                                                </TD>
                                 </TR>
                             </TABLE>
                         </TD>
@@ -332,13 +332,13 @@
                                     <TD>&nbsp;</TD>
                                     <TD class="sideNavSectionContent" align="left">
   
                 
-                                                                        
+                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                           
                                                 
                         
             <SPAN class="nobr"><A href="http://issues.apache.org/jira/browse/XBEAN"
title="Visit page outside Confluence" rel="nofollow">Issues<SUP><IMG class="rendericon"
src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle"
alt="" border="0"></SUP></A></SPAN><BR>
 <SPAN class="nobr"><A href="http://issues.apache.org/jira/browse/XBEAN?report=com.atlassian.jira.plugin.system.project:roadmap-panel"
title="Visit page outside Confluence" rel="nofollow">Roadmap<SUP><IMG class="rendericon"
src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle"
alt="" border="0"></SUP></A></SPAN><BR>
 <SPAN class="nobr"><A href="http://issues.apache.org/jira/browse/XBEAN?report=com.atlassian.jira.plugin.system.project:changelog-panel"
title="Visit page outside Confluence" rel="nofollow">Change log<SUP><IMG class="rendericon"
src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle"
alt="" border="0"></SUP></A></SPAN>
-                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                           </TD>
+                                                                        </TD>
                                 </TR>
                             </TABLE>
                         </TD>
@@ -369,14 +369,14 @@
                                     <TD>&nbsp;</TD>
                                     <TD class="sideNavSectionContent" align="left">
   
                 
-                                                                                        
                                           
+                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                         
       
                                                 
                         
             <SPAN class="nobr"><A href="http://goopen.org/confluence/pages/listpages.action?key=XB"
title="Visit page outside Confluence" rel="nofollow">Wiki<SUP><IMG class="rendericon"
src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle"
alt="" border="0"></SUP></A></SPAN><BR>
 <A href="lists.html" title="Lists">Mailing Lists</A><BR>
 <A href="contributor.html" title="Contributor">Who We Are</A><BR>
 <A href="contributing.html" title="Contributing">Contributing</A>
-                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                         </TD>
+                                                                                        
                   </TD>
                                 </TR>
                             </TABLE>
                         </TD>
@@ -407,7 +407,7 @@
                                     <TD>&nbsp;</TD>
                                     <TD class="sideNavSectionContent" align="left">
   
                 
-                                                                                        
                               
+                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                   
                                                 
                         
             <A href="source.html" title="Source">Source Code</A><BR>
@@ -415,7 +415,7 @@
 <SPAN class="nobr"><A href="http://geronimo.apache.org/xbean/dist/xbean-2.4/site/"
title="Visit page outside Confluence" rel="nofollow">Source XRef<SUP><IMG class="rendericon"
src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle"
alt="" border="0"></SUP></A></SPAN><BR>
 <SPAN class="nobr"><A href="http://geronimo.apache.org/xbean/dist/xbean-2.4/site/"
title="Visit page outside Confluence" rel="nofollow">Test Source XRef<SUP><IMG
class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0"
width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN><BR>
 <A href="release-procedure.html" title="Release Procedure">Release Procedure</A>
-                                                                                        
                                                                                         
                                                                                         
                                                                                         
                                                                                     </TD>
+                                                                                        
       </TD>
                                 </TR>
                             </TABLE>
                         </TD>
@@ -445,7 +445,19 @@
 
 <P>e.g. consider this example</P>
 
+<DIV class="code"><DIV class="codeContent">
+<PRE class="code-xml"><SPAN class="code-tag">&lt;beans <SPAN class="code-keyword">xmlns:p</SPAN>=<SPAN
class="code-quote">&quot;http://xbean.apache.org/schemas/pizza&quot;</SPAN>&gt;</SPAN>
 
+  <SPAN class="code-tag">&lt;bean id=<SPAN class="code-quote">&quot;topping&quot;</SPAN>
class=<SPAN class="code-quote">&quot;java.lang.String&quot;</SPAN>&gt;</SPAN>
+    <SPAN class="code-tag">&lt;constructor-arg&gt;</SPAN>
+      <SPAN class="code-tag">&lt;value&gt;</SPAN>Salami<SPAN class="code-tag">&lt;/value&gt;</SPAN>
+    <SPAN class="code-tag">&lt;/constructor-arg&gt;</SPAN>
+  <SPAN class="code-tag">&lt;/bean&gt;</SPAN>
+
+  <SPAN class="code-tag">&lt;p:pizza id=<SPAN class="code-quote">&quot;pizzaService&quot;</SPAN>
myTopping=<SPAN class="code-quote">&quot;#topping&quot;</SPAN> cheese=<SPAN
class="code-quote">&quot;##Edam&quot;</SPAN> size=<SPAN class="code-quote">&quot;17&quot;</SPAN>/&gt;</SPAN>
+  
+<SPAN class="code-tag">&lt;/beans&gt;</SPAN></PRE>
+</DIV></DIV>
 
 <P>The topping bean is configured using the regular Spring way; the pizza bean is configured
using XBean XML; however notice that the pizza bean is configured via the reference #topping.
If you really do want to configure a property with a string which starts with # then escape
it as ## as we are doing with the cheese property in this example. i.e. the cheese property
will be set to the string &quot;#Edam&quot;</P>
 
@@ -455,15 +467,102 @@
 
 <P>Here&apos;s an example of what the user would configure:</P>
 
+<DIV class="code"><DIV class="codeContent">
+<PRE class="code-xml"><SPAN class="code-tag">&lt;beans <SPAN class="code-keyword">xmlns:x</SPAN>=<SPAN
class="code-quote">&quot;http://xbean.apache.org/schemas/pizza&quot;</SPAN>&gt;</SPAN>
 
+  <SPAN class="code-tag">&lt;x:keg id=<SPAN class="code-quote">&quot;ml1000&quot;</SPAN>
remaining=<SPAN class="code-quote">&quot;1000 ml&quot;</SPAN>/&gt;</SPAN>
+  <SPAN class="code-tag">&lt;x:keg id=<SPAN class="code-quote">&quot;pints5&quot;</SPAN>
remaining=<SPAN class="code-quote">&quot;5 pints&quot;</SPAN>/&gt;</SPAN>
+  <SPAN class="code-tag">&lt;x:keg id=<SPAN class="code-quote">&quot;liter20&quot;</SPAN>
remaining=<SPAN class="code-quote">&quot;20 liter&quot;</SPAN>/&gt;</SPAN>
+  <SPAN class="code-tag">&lt;x:keg id=<SPAN class="code-quote">&quot;empty&quot;</SPAN>
remaining=<SPAN class="code-quote">&quot;0&quot;</SPAN>/&gt;</SPAN>
+
+<SPAN class="code-tag">&lt;/beans&gt;</SPAN></PRE>
+</DIV></DIV>
 
 <P>Here&apos;s how the bean developer would setup the PropertyEditor for the &quot;remaining&quot;
property:</P>
 
+<DIV class="code"><DIV class="codeContent">
+<PRE class="code-java">/**
+ * @org.apache.xbean.XBean element=<SPAN class="code-quote">&quot;keg&quot;</SPAN>

+ * 
+ * Used to verify that property PropertyEditors work correctly.
+ * 
+ * @author chirino
+ */
+<SPAN class="code-keyword">public</SPAN> class KegService {
+	
+    <SPAN class="code-keyword">private</SPAN> <SPAN class="code-object">long</SPAN>
remaining;
+
+	/**
+	 * Gets the amount of beer remaining in the keg (in ml)
+	 * 
+	 * @param remaining
+	 */
+	<SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">long</SPAN>
getRemaining() {
+		<SPAN class="code-keyword">return</SPAN> remaining;
+	}
+
+	/**
+	 * Sets the amount of beer remaining in the keg (in ml)
+	 * 
+     * @org.apache.xbean.Property propertyEditor=<SPAN class="code-quote">&quot;org.apache.xbean.spring.example.MilliLittersPropertyEditor&quot;</SPAN>
+	 * @param remaining
+	 */
+	<SPAN class="code-keyword">public</SPAN> void setRemaining(<SPAN class="code-object">long</SPAN>
remaining) {
+		<SPAN class="code-keyword">this</SPAN>.remaining = remaining;
+	}
+	
+	<SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">long</SPAN>
dispense( <SPAN class="code-object">long</SPAN> amount ) {
+		<SPAN class="code-keyword">this</SPAN>.remaining -= amount;
+		<SPAN class="code-keyword">return</SPAN> <SPAN class="code-keyword">this</SPAN>.remaining;
+	}
 
+}</PRE>
+</DIV></DIV>
 
 <P>And here is how the PropertyEditor was implemented:</P>
 
-
+<DIV class="code"><DIV class="codeContent">
+<PRE class="code-java">/**
+ * 
+ * Used to verify that per property PropertyEditors work correctly.
+ * 
+ * @author chirino
+ */
+<SPAN class="code-keyword">public</SPAN> class MilliLittersPropertyEditor <SPAN
class="code-keyword">extends</SPAN> PropertyEditorSupport {
+
+	<SPAN class="code-keyword">public</SPAN> void setAsText(<SPAN class="code-object">String</SPAN>
text) <SPAN class="code-keyword">throws</SPAN> IllegalArgumentException {
+
+		Pattern p = Pattern.compile(<SPAN class="code-quote">&quot;^(\\d+)\\s*(l(iter)?)?$&quot;</SPAN>,
Pattern.CASE_INSENSITIVE);
+		Matcher m = p.matcher(text);
+		<SPAN class="code-keyword">if</SPAN>( m.matches() ) {
+			setValue(<SPAN class="code-keyword">new</SPAN> <SPAN class="code-object">Long</SPAN>(<SPAN
class="code-object">Long</SPAN>.parseLong(m.group(1))*1000));
+			<SPAN class="code-keyword">return</SPAN>;
+		}
+		
+		p = Pattern.compile(<SPAN class="code-quote">&quot;^(\\d+)\\s*(ml)?$&quot;</SPAN>,
Pattern.CASE_INSENSITIVE);
+		m = p.matcher(text);
+		<SPAN class="code-keyword">if</SPAN>( m.matches() ) {
+			setValue(<SPAN class="code-keyword">new</SPAN> <SPAN class="code-object">Long</SPAN>(<SPAN
class="code-object">Long</SPAN>.parseLong(m.group(1))));
+			<SPAN class="code-keyword">return</SPAN>;
+		}
+
+		p = Pattern.compile(<SPAN class="code-quote">&quot;^(\\d+)\\s*pints?$&quot;</SPAN>,
Pattern.CASE_INSENSITIVE);
+	    m = p.matcher(text);
+		<SPAN class="code-keyword">if</SPAN>( m.matches() ) {
+			<SPAN class="code-object">long</SPAN> pints = <SPAN class="code-object">Long</SPAN>.parseLong(m.group(1));
+			setValue(<SPAN class="code-keyword">new</SPAN> <SPAN class="code-object">Long</SPAN>(
(<SPAN class="code-object">long</SPAN>)(pints * 1750) ));
+			<SPAN class="code-keyword">return</SPAN>;
+		}
+		
+		<SPAN class="code-keyword">throw</SPAN> <SPAN class="code-keyword">new</SPAN>
IllegalArgumentException(<SPAN class="code-quote">&quot;Could convert not to <SPAN
class="code-object">long</SPAN> (in ml) <SPAN class="code-keyword">for</SPAN>
&quot;</SPAN>+ text);		
+	}
+
+	<SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN>
getAsText() {
+		<SPAN class="code-object">Long</SPAN> value = (<SPAN class="code-object">Long</SPAN>)
getValue();
+		<SPAN class="code-keyword">return</SPAN> (value != <SPAN class="code-keyword">null</SPAN>
? value.toString() : &quot;&quot;);
+	}
+}</PRE>
+</DIV></DIV>
 
 
 



Mime
View raw message