SPRNET-1324 - Add namespace parser for WCF integration

This commit is contained in:
markpollack
2010-08-03 18:28:15 +00:00
parent 904167ec0f
commit c756336427
3 changed files with 99 additions and 52 deletions

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 2002-2008 the original author or authors.
@@ -2783,16 +2783,16 @@ source.OnClick(); // First eventListener1.HandleEvent is invoked, then eventList
<title>Method injection</title>
<para>In most application scenarios, most object in the container are
singletons. When a singleton object needs to collaborate with (use)
another singleton object, or a non-singleton object needs to collaborate
with another non-singleton object, you typically handle the dependency
by defining one object as a property of the other. A problem arrises
when the object lifecycles are different. Suppose singleton object A
needs to use a non-singleton (prototype) object B, perhaps on each
method invocation on A. The container only creates the singleton object
A once, and thus only get the opportunity to set the properties. The
container cannot provide object A with a new instance of object B every
time one is needed.</para>
singletons. When a singleton object needs to collaborate with another
singleton object, or a non-singleton object needs to collaborate with
another non-singleton object, you typically handle the dependency by
defining one object as a property of the other. A problem arrises when
the object lifecycles are different. Suppose singleton object A needs to
use a non-singleton (prototype) object B, perhaps on each method
invocation on A. The container only creates the singleton object A once,
and thus only gets one opportunity to set the properties. The container
cannot provide object A with a new instance of object B every time one
is needed.</para>
<para>A solution is to forego some inversion of control. You can <link
linkend="objects-factory-aware-objectfactoryaware">make object A aware

View File

@@ -224,26 +224,21 @@
<title>Creating client side proxies declaratively</title>
<para>To create a client side proxy based on the use of
ChannelFactory&lt;T&gt;, you can use this rather ugly 'boiler plate' XML
snippit that takes uses Spring's support for calling factory methods on
object instances.</para>
ChannelFactory&lt;T&gt;, you can use Spring's WCF schema to create an
instance of the interface that will communicate over a WCF channel. See
section on the <link linkend="xsd-config-body-schemas-wcf">Spring WCF
Schema</link> for more information.</para>
<programlisting language="myxml"> &lt;!-- returns ChannelFactory&lt;ICalculator&gt;("calculatorEndpoint").CreateChannel() --&gt;
<programlisting language="myxml">&lt;objects xmlns="http://www.springframework.net"
xmlns:wcf="http://www.springframework.net/wcf"&gt;
&lt;object id="serverAppCalculator" type="Spring.WcfQuickStart.ICalculator, Spring.WcfQuickStart.ClientApp"
factory-object="serverAppCalculatorChannelFactory"
factory-method="CreateChannel" /&gt;
&lt;!-- returns ChannelFactory&lt;ICalculator&gt;("calculatorEndpoint").CreateChannel() --&gt;
&lt;object id="serverAppCalculatorChannelFactory"
type="System.ServiceModel.ChannelFactory&amp;lt;Spring.WcfQuickStart.ICalculator&gt;, System.ServiceModel"&gt;
&lt;constructor-arg name="endpointConfigurationName" value="serverAppCalculatorEndpoint" /&gt;
&lt;/object&gt;</programlisting>
<note>
<para>This will be shortened using a custom namespce in a future release</para>
</note>
&lt;wcf:channelFactory id="serverAppCalculator"
channelType="Spring.WcfQuickStart.ICalculator, Spring.WcfQuickStart.Contracts"
endpointConfigurationName="serverAppCalculatorEndpoint" /&gt;
&lt;/objects&gt;</programlisting>
<para>The value 'serverAppCalculatorEndpoint' refers to the name of an
enpoints in the &lt;client&gt; section of the standard WCF configuration

View File

@@ -16,7 +16,12 @@
* limitations under the License.
*/
-->
<appendix id="xsd-config" xmlns="http://docbook.org/ns/docbook" version="5">
<appendix id="xsd-config" version="5" xmlns="http://docbook.org/ns/docbook"
xmlns:ns6="http://www.w3.org/1999/xlink"
xmlns:ns5="http://www.w3.org/1998/Math/MathML"
xmlns:ns4="http://www.w3.org/1999/xhtml"
xmlns:ns3="http://www.w3.org/2000/svg"
xmlns:ns="http://docbook.org/ns/docbook">
<title>XML Schema-based configuration</title>
<section xml:id="xsd-config-introduction">
@@ -82,11 +87,10 @@
<note>
<para>As of Spring.NET 1.2.0 it is no longer necessary to explicitly
configure the namespace parsers that come with Spring
via a custom section in App.config. You will still need to register custom namespace
parsers if you are writing your own.</para>
configure the namespace parsers that come with Spring via a custom
section in App.config. You will still need to register custom
namespace parsers if you are writing your own.</para>
</note>
</section>
<section xml:id="xsd-config-body-schemas-tx">
@@ -142,9 +146,9 @@
<note>
<para>As of Spring.NET 1.2.0 it is no longer necessary to explicitly
configure the namespace parsers that come with Spring
via a custom section in App.config. You will still need to register custom namespace
parsers if you are writing your own.</para>
configure the namespace parsers that come with Spring via a custom
section in App.config. You will still need to register custom
namespace parsers if you are writing your own.</para>
</note>
<programlisting language="myxml">&lt;configuration&gt;
@@ -194,9 +198,9 @@
<note>
<para>As of Spring.NET 1.2.0 it is no longer necessary to explicitly
configure the namespace parsers that come with Spring
via a custom section in App.config. You will still need to register custom namespace
parsers if you are writing your own.</para>
configure the namespace parsers that come with Spring via a custom
section in App.config. You will still need to register custom
namespace parsers if you are writing your own.</para>
</note>
<programlisting language="myxml">&lt;configuration&gt;
@@ -242,9 +246,9 @@
<note>
<para>As of Spring.NET 1.2.0 it is no longer necessary to explicitly
configure the namespace parsers that come with Spring
via a custom section in App.config. You will still need to register custom namespace
parsers if you are writing your own.</para>
configure the namespace parsers that come with Spring via a custom
section in App.config. You will still need to register custom
namespace parsers if you are writing your own.</para>
</note>
<programlisting language="myxml">&lt;configuration&gt;
@@ -262,6 +266,54 @@
&lt;/parsers&gt;
&lt;/spring&gt;
&lt;/configuration&gt;</programlisting>
</section>
<section xml:id="xsd-config-body-schemas-wcf">
<title>The <literal>wcf</literal> schema</title>
<para>The <literal>wcf</literal> schema is used when you would like to
create a client channel to invoke a WCF service as compared to
generating a proxy using svcutil.exe. The channel factory approach
requires that you have a known interface which describes the service.
This approach is quite common to use when you are controlling both the
client and the server code, but is not exclusive to that case. The
advantage of coding to the interface is that it can be easily replaced
with another implementation, perhaps for testing purposes to facilitate
unit testing. </para>
<para>For example, the following code can be used to create an instance
of the ICaclulator interface that invokes the remote service.</para>
<programlisting language="myxml">ICalculator calculator = ChannelFactory&lt;ICalculator&gt;("calculatorEndpoint").CreateChannel();
int result = calculator.Add(1,2);</programlisting>
<para>You need to configure the remoting namespace parser in the main
.NET application configuration file as shown below</para>
<note>
<para>As of Spring.NET 1.2.0 it is no longer necessary to explicitly
configure the namespace parsers that come with Spring via a custom
section in App.config. You will still need to register custom
namespace parsers if you are writing your own.</para>
</note>
<programlisting language="myxml">&lt;configuration&gt;
&lt;configSections&gt;
&lt;sectionGroup name="spring"&gt;
&lt;!-- other Spring config sections handler like context, typeAliases, etc not shown for brevity --&gt;
&lt;section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/&gt;
&lt;/sectionGroup&gt;
&lt;/configSections&gt;
&lt;spring&gt;
&lt;parsers&gt;
&lt;parser type="Spring.ServiceModel.Config.WcfNamespaceParser, Spring.Services" /&gt;
&lt;/parsers&gt;
&lt;/spring&gt;
&lt;/configuration&gt;</programlisting>
</section>
@@ -288,9 +340,9 @@
<note>
<para>As of Spring.NET 1.2.0 it is no longer necessary to explicitly
configure the namespace parsers that come with Spring
via a custom section in App.config. You will still need to register custom namespace
parsers if you are writing your own.</para>
configure the namespace parsers that come with Spring via a custom
section in App.config. You will still need to register custom
namespace parsers if you are writing your own.</para>
</note>
<programlisting language="myxml">&lt;configuration&gt;
@@ -333,9 +385,9 @@
<note>
<para>As of Spring.NET 1.2.0 it is no longer necessary to explicitly
configure the namespace parsers that come with Spring
via a custom section in App.config. You will still need to register custom namespace
parsers if you are writing your own.</para>
configure the namespace parsers that come with Spring via a custom
section in App.config. You will still need to register custom
namespace parsers if you are writing your own.</para>
</note>
<programlisting language="myxml">&lt;configuration&gt;
@@ -379,9 +431,9 @@
<note>
<para>As of Spring.NET 1.2.0 it is no longer necessary to explicitly
configure the namespace parsers that come with Spring
via a custom section in App.config. You will still need to register custom namespace
parsers if you are writing your own.</para>
configure the namespace parsers that come with Spring via a custom
section in App.config. You will still need to register custom
namespace parsers if you are writing your own.</para>
</note>
<programlisting language="myxml">&lt;configuration&gt;
@@ -437,4 +489,4 @@
url="http://community.sharpdevelop.net/blogs/mattward/articles/FeatureTourEditingXml.aspx">Editing
XML</ulink>" product documentation.</para>
</section>
</appendix>
</appendix>