SPRNET-1324 - Add namespace parser for WCF integration
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -224,26 +224,21 @@
|
||||
<title>Creating client side proxies declaratively</title>
|
||||
|
||||
<para>To create a client side proxy based on the use of
|
||||
ChannelFactory<T>, 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<T>, 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"> <!-- returns ChannelFactory<ICalculator>("calculatorEndpoint").CreateChannel() -->
|
||||
<programlisting language="myxml"><objects xmlns="http://www.springframework.net"
|
||||
xmlns:wcf="http://www.springframework.net/wcf">
|
||||
|
||||
<object id="serverAppCalculator" type="Spring.WcfQuickStart.ICalculator, Spring.WcfQuickStart.ClientApp"
|
||||
factory-object="serverAppCalculatorChannelFactory"
|
||||
factory-method="CreateChannel" />
|
||||
<!-- returns ChannelFactory<ICalculator>("calculatorEndpoint").CreateChannel() -->
|
||||
|
||||
<object id="serverAppCalculatorChannelFactory"
|
||||
type="System.ServiceModel.ChannelFactory&lt;Spring.WcfQuickStart.ICalculator>, System.ServiceModel">
|
||||
|
||||
<constructor-arg name="endpointConfigurationName" value="serverAppCalculatorEndpoint" />
|
||||
|
||||
</object></programlisting>
|
||||
|
||||
<note>
|
||||
<para>This will be shortened using a custom namespce in a future release</para>
|
||||
</note>
|
||||
<wcf:channelFactory id="serverAppCalculator"
|
||||
channelType="Spring.WcfQuickStart.ICalculator, Spring.WcfQuickStart.Contracts"
|
||||
endpointConfigurationName="serverAppCalculatorEndpoint" />
|
||||
|
||||
</objects></programlisting>
|
||||
|
||||
<para>The value 'serverAppCalculatorEndpoint' refers to the name of an
|
||||
enpoints in the <client> section of the standard WCF configuration
|
||||
|
||||
@@ -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"><configuration>
|
||||
@@ -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"><configuration>
|
||||
@@ -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"><configuration>
|
||||
@@ -262,6 +266,54 @@
|
||||
</parsers>
|
||||
</spring>
|
||||
|
||||
</configuration></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<ICalculator>("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"><configuration>
|
||||
|
||||
<configSections>
|
||||
<sectionGroup name="spring">
|
||||
<!-- other Spring config sections handler like context, typeAliases, etc not shown for brevity -->
|
||||
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<spring>
|
||||
<parsers>
|
||||
<parser type="Spring.ServiceModel.Config.WcfNamespaceParser, Spring.Services" />
|
||||
</parsers>
|
||||
</spring>
|
||||
|
||||
</configuration></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"><configuration>
|
||||
@@ -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"><configuration>
|
||||
@@ -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"><configuration>
|
||||
@@ -437,4 +489,4 @@
|
||||
url="http://community.sharpdevelop.net/blogs/mattward/articles/FeatureTourEditingXml.aspx">Editing
|
||||
XML</ulink>" product documentation.</para>
|
||||
</section>
|
||||
</appendix>
|
||||
</appendix>
|
||||
|
||||
Reference in New Issue
Block a user