SPRNET-1109, SPRNET-1095

This commit is contained in:
eeichinger
2008-11-14 18:53:16 +00:00
parent 238a44da8f
commit eb3dae49b5
13 changed files with 150 additions and 132 deletions

View File

@@ -33,7 +33,6 @@ namespace Spring.Aspects.Logging
/// Basic implementation of a logging aspect using Common.Logging library.
/// </summary>
/// <author>Bruno Baia</author>
/// <version>$Id: CommonLoggingAroundAdvice.cs,v 1.2 2007/06/27 16:00:42 bbaia Exp $</version>
public class CommonLoggingAroundAdvice : IMethodInterceptor
{
#region Logging

View File

@@ -34,7 +34,7 @@
<!-- ================================== -->
<!-- In process (local) implementations -->
<!-- ================================== -->
<!-- resource uri="assembly://Spring.Calculator.ClientApp/Spring.Calculator.ClientApp.Config.InProcess/inProcess.xml" /-->
<resource uri="assembly://Spring.Calculator.ClientApp/Spring.Calculator.ClientApp.Config.InProcess/inProcess.xml" />
<!-- ======================== -->
<!-- Remoting implementations -->

View File

@@ -49,6 +49,7 @@
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>

View File

@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<common>
<logging>
@@ -20,12 +20,89 @@
</common>
<spring>
<context>
<resource uri="Config/services.xml" />
<resource uri="assembly://Spring.Calculator.RegisterComponentServices/Spring.Calculator.RegisterComponentServices.Config/enterpriseServices.xml" />
</context>
</spring>
<context>
<resource uri="Config/services.xml" />
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springframework.net">
<description>Contains definitions how to export objects defined in ~/Config/services.xml</description>
<!-- Define the component for exporting 'calculatorService' -->
<object id="calculatorComponent" type="Spring.EnterpriseServices.ServicedComponentExporter, Spring.Services">
<property name="TargetName" value="calculatorService" />
<property name="TypeAttributes">
<list>
<object type="System.EnterpriseServices.TransactionAttribute, System.EnterpriseServices" />
</list>
</property>
<property name="MemberAttributes">
<dictionary>
<entry key="*">
<list>
<object type="System.EnterpriseServices.AutoCompleteAttribute, System.EnterpriseServices" />
</list>
</entry>
</dictionary>
</property>
</object>
<!-- Define the component for exporting 'simpleCalculatorService' -->
<object id="simpleCalculatorComponent" type="Spring.EnterpriseServices.ServicedComponentExporter, Spring.Services">
<property name="TargetName" value="simpleCalculatorService" />
</object>
<!-- Export components into assembly and autoregister with COM+ -->
<object type="Spring.EnterpriseServices.EnterpriseServicesExporter, Spring.Services">
<!-- assembly name to generated - will generate 'Spring.Calculator.EnterpriseServices.dll' -->
<property name="Assembly" value="Spring.Calculator.EnterpriseServices" />
<!--
use Spring's ContextRegistry for managing services. If true, requires a file
'Spring.Calculator.EnterpriseServices.dll.spring-context.xml' containing a
<spring/context /> section placed next to the generated assembly.
-->
<property name="UseSpring" value="true" />
<property name="ApplicationName" value="Spring Calculator Application" />
<property name="ActivationMode" value="Library" />
<property name="Description" value="Spring Calculator application" />
<property name="Components">
<list>
<ref object="calculatorComponent" />
<ref object="simpleCalculatorComponent" />
</list>
</property>
<property name="AccessControl">
<object type="System.EnterpriseServices.ApplicationAccessControlAttribute, System.EnterpriseServices">
<property name="Value">
<value>false</value>
</property>
</object>
</property>
<!--
<property name="AccessControl">
<object type="System.EnterpriseServices.ApplicationAccessControlAttribute, System.EnterpriseServices">
<property name="Value">
<value>true</value>
</property>
<property name="AccessChecksLevel">
<value>ApplicationComponent</value>
</property>
</object>
</property>
<property name="Roles">
<list>
<value>Admin : Administrator role</value>
<value>User : User role</value>
<value>Manager : Administrator role</value>
</list>
</property>
-->
</object>
</objects>
</spring>
</configuration>

View File

@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<description>enterpriseService</description>
<object id="calculatorComponent" type="Spring.EnterpriseServices.ServicedComponentExporter, Spring.Services">
<property name="TargetName" value="calculatorService" />
<property name="TypeAttributes">
<list>
<object type="System.EnterpriseServices.TransactionAttribute, System.EnterpriseServices" />
</list>
</property>
<property name="MemberAttributes">
<dictionary>
<entry key="*">
<list>
<object type="System.EnterpriseServices.AutoCompleteAttribute, System.EnterpriseServices" />
</list>
</entry>
</dictionary>
</property>
</object>
<object id="simpleCalculatorComponent" type="Spring.EnterpriseServices.ServicedComponentExporter, Spring.Services">
<property name="TargetName" value="simpleCalculatorService" />
</object>
<object type="Spring.EnterpriseServices.EnterpriseServicesExporter, Spring.Services">
<!-- assembly name to generated - will generate 'Spring.Calculator.EnterpriseServices.dll' -->
<property name="Assembly" value="Spring.Calculator.EnterpriseServices" />
<!--
use Spring's ContextRegistry for managing services. if true,
requires a file 'Spring.Calculator.EnterpriseServices.dll.spring-context.xml'
containing a <context /> section placed next to the generated assembly
-->
<property name="UseSpring" value="true" />
<property name="ApplicationName" value="Spring Calculator Application" />
<property name="ActivationMode" value="Library" />
<property name="Description" value="Spring Calculator application" />
<property name="Components">
<list>
<ref object="calculatorComponent" />
<ref object="simpleCalculatorComponent" />
</list>
</property>
<property name="AccessControl">
<object type="System.EnterpriseServices.ApplicationAccessControlAttribute, System.EnterpriseServices">
<property name="Value">
<value>false</value>
</property>
</object>
</property>
<!--
<property name="AccessControl">
<object type="System.EnterpriseServices.ApplicationAccessControlAttribute, System.EnterpriseServices">
<property name="Value">
<value>true</value>
</property>
<property name="AccessChecksLevel">
<value>ApplicationComponent</value>
</property>
</object>
</property>
<property name="Roles">
<list>
<value>Admin : Administrator role</value>
<value>User : User role</value>
<value>Manager : Administrator role</value>
</list>
</property>
-->
</object>
</objects>

View File

@@ -2,7 +2,27 @@
<objects xmlns="http://www.springframework.net">
<description>Definitions of objects to be registered.</description>
<object id="calculatorService" type="Spring.Calculator.Services.AdvancedCalculator, Spring.Calculator.Services" />
<!-- Aspect -->
<object id="CommonLoggingAroundAdvice" type="Spring.Aspects.Logging.CommonLoggingAroundAdvice, Spring.Aspects">
<property name="Level" value="Debug"/>
</object>
<object type="Spring.Aop.Framework.AutoProxy.ObjectNameAutoProxyCreator, Spring.Aop">
<property name="objectNames">
<list>
<idref local="simpleCalculatorService"/>
<idref local="calculatorService"/>
</list>
</property>
<property name="interceptorNames">
<list>
<value>CommonLoggingAroundAdvice</value>
</list>
</property>
</object>
<!-- Service -->
<object id="simpleCalculatorService" type="Spring.Calculator.Services.Calculator, Spring.Calculator.Services" />
<object id="calculatorService" type="Spring.Calculator.Services.AdvancedCalculator, Spring.Calculator.Services" />
</objects>

View File

@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<context>
<resource uri="Config/services.xml" />
</context>
<spring>
<context>
<resource uri="Config/services.xml" />
</context>
</spring>

View File

@@ -84,6 +84,11 @@
AssemblyName = "Spring.Core"
HintPath = "..\..\..\..\..\bin\net\1.1\debug\Spring.Core.dll"
/>
<Reference
Name = "Spring.Aspects.2003"
Project = "{6B34626E-8D2A-4387-BBB6-CB352D4DBDEC}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
</References>
</Build>
<Files>
@@ -106,10 +111,6 @@
RelPath = "Spring.Calculator.EnterpriseServices.dll.spring-context.xml"
BuildAction = "Content"
/>
<File
RelPath = "Config\enterpriseServices.xml"
BuildAction = "EmbeddedResource"
/>
<File
RelPath = "Config\services.xml"
BuildAction = "Content"

View File

@@ -49,6 +49,7 @@
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
@@ -81,9 +82,12 @@
<Compile Include="Program.cs">
<SubType>Code</SubType>
</Compile>
<EmbeddedResource Include="Config\enterpriseServices.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spring.Aspects\Spring.Aspects.2005.csproj">
<Project>{6B34626E-8D2A-4387-BBB6-CB352D4DBDEC}</Project>
<Name>Spring.Aspects.2005</Name>
</ProjectReference>
<ProjectReference Include="..\Spring.Calculator.Contract\Spring.Calculator.Contract.2005.csproj">
<Project>{284C0873-BBB4-4399-B6F7-CB7EDBD001C7}</Project>
<Name>Spring.Calculator.Contract.2005</Name>
@@ -103,6 +107,14 @@
<HintPath>..\..\..\..\..\bin\net\2.0\debug\Spring.Services.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="Config\services.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Spring.Calculator.EnterpriseServices.dll.spring-context.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>

View File

@@ -20,9 +20,6 @@
#region Imports
using System;
using System.Reflection;
using Common.Logging;
using Spring.Calculator.Interfaces;
#endregion
@@ -58,25 +55,22 @@ namespace Spring.Calculator.Services
public int GetMemory()
{
Log.Debug(string.Format("GetMemory: IsInTransaction={0}, at {1}", System.EnterpriseServices.ContextUtil.IsInTransaction, new System.Diagnostics.StackTrace()));
// Log.Debug(string.Format("GetMemory: IsInTransaction={0}, at {1}", System.EnterpriseServices.ContextUtil.IsInTransaction, new System.Diagnostics.StackTrace()));
return memoryStore;
}
public void SetMemory(int memoryValue)
{
Log.Debug("SetMemory");
memoryStore = memoryValue;
}
public void MemoryClear()
{
Log.Debug("MemoryClear");
memoryStore = 0;
}
public void MemoryAdd(int num)
{
Log.Debug("MemoryAdd");
memoryStore += num;
}

View File

@@ -20,10 +20,6 @@
#region Imports
using System;
using System.Diagnostics;
using System.Reflection;
using Common.Logging;
using Spring.Calculator.Domain;
using Spring.Calculator.Interfaces;
@@ -43,25 +39,25 @@ namespace Spring.Calculator.Services
static Calculator()
{
instanceCount = 0;
ILog log = LogManager.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType);
log.Debug(
string.Format("Initialized Type in AppDomain {0}, ConfigFile={1}, BaseDirectory={2}, CurrentDirectory={3}, ExecutingAssembly={4}, EntryAssembly={5}"
, AppDomain.CurrentDomain.GetHashCode()
, AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
, AppDomain.CurrentDomain.BaseDirectory
, Environment.CurrentDirectory
, Assembly.GetExecutingAssembly().Location
, Assembly.GetEntryAssembly().Location
));
// Common.Logging.ILog log = Common.Logging.LogManager.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType);
// log.Debug(
// string.Format("Initialized Type in AppDomain {0}, ConfigFile={1}, BaseDirectory={2}, CurrentDirectory={3}, ExecutingAssembly={4}, EntryAssembly={5}"
// , AppDomain.CurrentDomain.GetHashCode()
// , AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
// , AppDomain.CurrentDomain.BaseDirectory
// , Environment.CurrentDirectory
// , Assembly.GetExecutingAssembly().Location
// , Assembly.GetEntryAssembly().Location
// ));
}
#region ICalculator Members
protected readonly ILog Log = LogManager.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType);
// protected readonly Common.Logging.ILog Log = Common.Logging.LogManager.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType);
public Calculator()
{
Log.Debug(string.Format("Initialized Instance in AppDomain {0}, #{0} at {1}", AppDomain.CurrentDomain.GetHashCode(), instanceCount, new System.Diagnostics.StackTrace()));
// Common.Logging.Log.Debug(string.Format("Initialized Instance in AppDomain {0}, #{0} at {1}", AppDomain.CurrentDomain.GetHashCode(), instanceCount, new System.Diagnostics.StackTrace()));
instanceCount++;
}

View File

@@ -69,16 +69,6 @@
Project = "{284C0873-BBB4-4399-B6F7-CB7EDBD001C7}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
<Reference
Name = "Common.Logging"
AssemblyName = "Common.Logging"
HintPath = "..\..\..\..\..\lib\Net\1.1\Common.Logging.dll"
/>
<Reference
Name = "System.EnterpriseServices"
AssemblyName = "System.EnterpriseServices"
HintPath = "..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.EnterpriseServices.dll"
/>
</References>
</Build>
<Files>

View File

@@ -25,7 +25,7 @@
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<SignAssembly>true</SignAssembly>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>