| S2Container.NET TOP page ## S2Container Setup Requirements Distribution Files S2Container.NET Setup log4net Setup S2ADO Setup S2Unit.NET Setup Seasar.DynamicProxy Setup Examples ## Requirements Microsoft .NET Framework 1.1 or 2.0 NUnit (required only if modifying s2dotnet and to test the modified version) ## Distribution Files Following files and folders are created with s2container.net-version.zip is extracted.
Folder | Description
--- | ---
s2container.net/build | S2Container.NET release build assembly
s2container.net/data | DDL necessary to run examples
s2container.net/lib | Assembly referenced by S2Container.NET
s2container.net/source | S2Container.NET source code
www | Document
## S2Container.NET Setup When using S2Container.NET, following files (assembly) must be added to referenced files. Furthermore, make Seasar.dll in build directory as ja-JP directory. s2container.net/build/Seasar.dll s2container.net/lib/log4net.dll Next, set configuration in application configuration file (app.config) if necessary. Refer to the following page to set this configuration file. S2Container.NET Reference - Application Configuration File ## log4net Setup S2Container.NET uses Apache Logging Services project log4net. Thus, it is necessary to set log4net to log S2Container.NET. Following is an example of log4net configuration. ### Specifying log4net Configuration File Following attributes are specified in the AssemblyInfo. This will set application configuration file (app.config) in log4net. C#
    [assembly: log4net.Config.XmlConfigurator(Watch=true)]
VB.NET
    <Assembly: log4net.Config.XmlConfigurator(Watch:=True)>
### Add log4net configuration in application configuration file (app.config). Below is an example using TraceAdapter.
    <configuration>

        <configSections>
            <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
            <section name="seasar" type="Seasar.Framework.Xml.S2SectionHandler, Seasar" />
        </configSections>

        <log4net>
            <appender name="TraceAppender" type="log4net.Appender.TraceAppender">
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%-5p %d [%t] %m%n" />
                </layout>
            </appender>

            <root>
                <level value="DEBUG" />
                <appender-ref ref="TraceAppender" />
            </root>

        </log4net>

        <seasar>
            <!-- omitted -->
        </seasar>

    </configuration>
That ends log4net setup. When an application configuration file that is configured with log4net does not log using log4net, however, log will not be outputted. As an example, if Seasar assembly tries to log an output, log4net tries to find log4net configuration in a Seasar assembly and will not output a log. To properly output a log, therefore, output a log from the application configured in log4net configuration, or add a step to read application configuration file when the program starts. C#
    System.IO.FileInfo info = new System.IO.FileInfo(
       log4net.Util.SystemInfo.AssemblyShortName(
       System.Reflection.Assembly.GetExecutingAssembly())
       + ".exe.config"); // if an assembly is a dll, use ".dll.config"

    log4net.Config.XmlConfigurator.Configure(
       log4net.LogManager.GetRepository(), info);
VB.NET
    Dim info As New System.IO.FileInfo( _
       log4net.Util.SystemInfo.AssemblyShortName( _
       System.Reflection.Assembly.GetExecutingAssembly()) _
       + ".exe.config") ' if an assembly is a dll, use ".dll.config"

    log4net.Config.XmlConfigurator.Configure( _
       log4net.LogManager.GetRepository(), info)
## S2ADO Setup When using S2ADO, following files (assembly) must be added to referenced files. s2container.net/lib/Nullables.dll Next, set configuration in application configuration file (app.config) if necessary. Refer to the following page to set this configuration file. S2Container.NET Reference - Application Configuration File ## S2Unit.NET Setup S2Unit.NET is a testing framework to make testing with S2Container easier. Download and install MbUnit 2.3.0 to use S2Unit.NET. The current release of S2Unit.NET requires MbUnit version 2.3.0 - it does not run properly with any other version. Test class extends Seasar.Extension.Unit.S2TestCase. S2TestCase class is included in Seasar.Unit.dll. Thus, a project with test codes should reference this Seasar.Unit.dll. Refer to S2Unit.NET for further information. ## Seasar.DynamicProxy Setup By default, S2AOP.NET implements System.Runtime.Remoting.Proxies.RealProxy, but it is possible to use Castle.DynamicProxy. Refer to the following document for further information on Seasar.DynamicProxy. AOP - Seasar.DynamicProxy To use Seasar.DynamicProxy, add references to the following files: s2container.net/build/Seasar.DynamicProxy.dll s2container.net/lib/Castle.DynamicProxy.dll (It is not necessary to add reference to this dll, if Seasar.DynamicProxy.dll is placed in a folder that is visible from the project) Add [Seasar.DynamicProxy] assembly to application configuration file (App.config) as below:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>

        <configSections>
            <section name="seasar" type="Seasar.Framework.Xml.S2SectionHandler, Seasar" />
        </configSections>

        <seasar>
            <configPath>App.dicon</configPath>
            <assemblys>
                <assembly>Seasar.DynamicProxy</assembly>
            </assemblys>
        </seasar>

    </configuration>
Add Seasar.Framework.Aop.Impl.DynamicAopProxyAspectWeaver class to the dicon file as below. Use caution on row placement so DynamicAopProxyAspectWeaver will be resolved before an aspect is applied to a component.
    <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container//EN"
    "http://www.seasar.org/dtd/components.dtd">
    <components>

        <component class="Seasar.Framework.Aop.Impl.DynamicAopProxyAspectWeaver" />

        ...

    </components>
That ends Seasar.DynamicProxy setup. ## Examples To run examples, open s2container.net/source/Seasar.sln from Visual Studio and set Seasar.Examples project as a startup project. When the example is executed, ExamplesExplorer should start. Some of the examples require SQL Server 2000 (or MSDE 2000). Before running these examples, execute s2container.net/data/setUpDemo.bat to create the necessary tables and set database connection string in Tx.dicon and DTCTx.dicon files in Seasar.Examples folder. |
Trans. by H.Ozawa | Copyright© 2004-2007, The Seasar Foundation and the others. All rights reserved.