Spring.NET resource files - spring.net

<spring>
<context type="Spring.Context.Support.XmlApplicationContext, Spring.Core">
<resource uri="file://C:/config1.xml" />
<resource uri="file://C:/config2.xml" />
<resource uri="file://C:/config3.xml" />
<resource uri="config://spring/objects" />
</context>
</spring>
Instead of specifying the XML file locations in a configuration file, is there a way to programmatically specify these resource files after application start?

Yes, you can do
IApplicationContext ctx =
new XmlApplicationContext("file://C:/config1.xml","file://C:/config2.xml", ..);
See instantiating a container in the spring.net docs for more information.

Related

What is the directory for a background image in a CSS file?

I am new to Confluence. I am playing decorators and CSS.
This is my atlassian-plugin.xml:
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
<param name="plugin-icon">images/ohanaFavicon.png</param>
<param name="plugin-logo">images/ohanaPluginLogo.gif</param>
</plugin-info>
<resource type="i18n" name="i18n" location="mysite" />
<web-resource key="mysite-resources" name="mysite Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<context>mysite</context>
</web-resource>
<theme key="mysiteheme" name="Mysite Theme" class="com.atlassian.confluence.themes.BasicTheme">
<description>A theme for tests</description>
<param name="includeClassicStyles" value="false" />
<resource type="download" name="default-theme.css" location="/includes/css/default-theme.css">
<param name="source" value="webContext" />
</resource>
<resource type="download" name="mysite.css" location="/theme-mysite/css/mysite.css" />
<resource type="download" name="mysite.js" location="/theme-mysite/js/mysite.js" />
<resource type="download" key="images" name="images/" location="/theme-mysite/images"/>
<layout key="${atlassian.plugin.key}:main" />
</theme>
<layout key="main" name="Main Decorator" overrides="/decorators/main.vmd" class="com.atlassian.confluence.themes.VelocityDecorator">
<resource type="velocity" name="decorator" location="/theme-mysite/decorators/main.vmd" />
</layout>
In mysite.css, I have the following CSS rule:
background: url(images/header-bkgd.png) 5px -115px;
However, I am not able to see the display of the background image. What is missing in what I did? The "images" directory is under "theme-mysite" directory, which is under the "resources" directory.
A broader question: I have read the book <> and did quite online search. But I am still not able to find any sample or tutorial explaining how to refer background images in a CSS file. Where to acquire such knowledge?
Best.
Update
I tried this:
background: url(../images/header-bkgd.png)
When looking at the change in Confluence, Chrome shows 404 for the image and the path to it is:
http://localhost:1990/confluence/s/en_GB/6441/NOCACHE/1.0.0-SNAPSHOT/_/download/resources/images/header-bkgd.png
I also tried
background: url(../theme-mysite/images/header-bkgd.png);
The generated path in Chrome is:
http://localhost:1990/confluence/s/en_GB/6441/NOCACHE/1.0.0-SNAPSHOT/_/download/resources/theme-mysite/images/header-bkgd.png
The image does not exist either.
You try to change like this
background: url(../images/header-bkgd.png) 5px -115px;
Finally got it resolved myself. I need to add this:
<resource type="download" key="images" name="images/" location="/theme-mysite/images"/>
outside '...'

How to add servicePointManager to web config in ASP.net MVC

I am trying to add the following lines to web config
<system.net>
<settings>
<servicePointManager expect100Continue="false" />
</settings>
But it returning error Only one element allowed. It must be the first child element of the root element
Can any one please help on us?
try this in webconfig or refer MSDN for details
<configuration>
<system.net>
<settings>
<servicePointManager
checkCertificateName="false"
checkCertificateRevocationList="false"
/>
</settings>
</system.net>
</configuration>

Spring Framework basics

I'm quite new to Spring Framework. Could someone please help me understand the spring configuration below?
<?xml version="1.0"?>
<configuration>
<spring>
<context>
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springframework.net">
<object type="Test.aspx">
<property name="AService" ref="AService" />
<property name="BService" ref="BService" />
</object>
</objects>
</spring>
</configuration>
Basically questions in my mind are:
What does this line means:
<resource uri="config://spring/objects" />
and this:
<object type="Test.aspx">
<property name="AService" ref="AService" />
<property name="BService" ref="BService" />
</object>
Does config: means configuration file?
Does ref means Classes in C#?
<resource uri="config://spring/objects" /> means that the spring container should read a configuration section from an application configuration file (app.config or web.config).
<object ... is an object definition; this defines an object in your container. An object can have dependencies. In your case, the Test.aspx page has properties named AService and BService. The container will set these properties to the objects defined elsewhere in your container.
What might be a bit confusing here is the double usage of ="AService" in <property name="AService" ref="AService" />:
name=: refers to the name of the property on your class Test, there is a property defined as public IMyService AService { get; set; }
ref= : refers to another object defined in your container, there is an object definition like <object id="AService" type="MyNamespace.MyClass, MyAssembly" /> somewhere in your configuration.
The "Instantiating the container" section of the spring docs does a good job of explaining this further.

Can Spring.Net log what it's doing as it constructors objects?

Is there anyway to get Spring.Net to log what it's doing as it constructs objects? Something on the order of
Constructing Object A
Constructing Object B
etc etc.....
I need to resolve a circular dependency within my application, and seeing the order in which Spring is creating the objects could be a huge help.
This can easily be done. Spring uses Common.Logging. You can grab logging output from Spring.Objects.Factory.* classes and look for ... Creating instance of Object 'your-id-here' ... messages.
Note that you have to log at DEBUG level, which means you'll see quite a lot of other information too.
The following app.config would log creation calls to the console, using log4net:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
</layout>
</appender>
<!-- this logger will catch creation messages -->
<logger name="Spring.Objects.Factory">
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</logger>
</log4net>
</configuration>
So most of this is boiler-plate Common.Logging and log4net configuration, which is well documented on the Common.Logging website. If you want to append to a file or something else, see the log4net docs.

How do I specify typeAliases and objects in an external Spring.NET configuration file

SOLVED!!!! Thanks for your help
I'm kinda lost here, I'd like to remove all the Spring.NET configuration outside Web.Config but I cant figure out how to put my typeAliases.
I'll appreciate all the help you can give me.
Thanks.
You can register type aliases either in app.config/web.config:
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="typeAliases" type="Spring.Context.Support.TypeAliasesSectionHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<spring>
<typeAliases>
<alias name="Prog" type="MyNs.Program, MyLibrary" />
</typeAliases>
<context>
<resource uri="context.xml"/>
</context>
</spring>
Or in a spring configuration file by adding a definition for the Spring.Objects.Factory.Config.TypeAliasConfigurer object:
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<object id="program" type="Prog" />
<object id="myTypeAlias" type="Spring.Objects.Factory.Config.TypeAliasConfigurer, Spring.Core">
<property name="TypeAliases">
<dictionary>
<entry key="Prog" value="MyNs.Program, MyLibrary"/>
</dictionary>
</property>
</object>
</objects>
You will find this in the documentation.

Resources