- Eclipse 3.5 M1 - New and Noteworthy
- Eclipse 3.5 M2 - New and Noteworthy
- Eclipse 3.5 M3 - New and Noteworthy
- Eclipse 3.5 M4 - New and Noteworthy
- Eclipse 3.5 M5 - New and Noteworthy
- Eclipse 3.5 M6 - New and Noteworthy
- Eclipse 3.5 M7 - New and Noteworthy
/WEB-INF/web.xml
file which defines the configuration of the servlet. This file is typically a pointer to 2 other files. The first is named /WEB-INF/myproj-webapp-config.xml
and the second is named /WEB-INF/myproj-servlet-config.xml
.
Lets take a look at the /WEB-INF/web.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID"
version="2.5"
>
<display-name>My Project</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/myproj-webapp-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>myproject</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/myproj-servlet-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myproj</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
After the Java EE header and standard configuration comes the first of the 2 file pointers. The contextConfigLocation
is described in the /WEB-INF/myproj-webapp-config.xml
. This file contains the beans for the application. These are the Java beans that in the most part “do all the work". This file is laid out in a way that separates the business logic from the live application infrastructure.
Below is a typical example to help explain this:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- Configuration -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:C:/Data/conf/bigsoft.properties</value>
</property>
</bean>
<!-- application beans -->
<import resource="classpath:uk/co/bigsoft/myproj/config/application-config.xml"/>
<!-- Data source Access -->
<import resource="classpath:uk/co/bigsoft/myproj/config/database.xml"/>
<!-- Real Dao -->
<import resource="classpath:uk/co/bigsoft/myproj/config/dao.live.xml"/>
<!-- Transaction support -->
<import resource="classpath:uk/co/bigsoft/myproj/config/tx.xml"/>
<!-- JMS support -->
<import resource="classpath:uk/co/bigsoft/myproj/config/jms.xml"/>
</beans>
The header says that this is a file containing spring beans. It is split into several sections.
The first bean (PropertyPlaceholderConfigurer
) is a configuration post-processor which substitutes variables given as part of the definition of other beans, and is really handy because this properties file can exist anywhere.
The application-config.xml
file contains the business logic. This is the logic of the application that remains the same in the live and the development system, because it has been abstracted away from the infrastructure which follows. Each import
pulls in a configuration file containing beans which take care of an infrastructural aspect of the application while it runs in the live environment. In the case above I have split them up by technologies. Using database.xml
as an example, I may have one file which uses MySQL and another that uses Oracle depending on my deployment strategy at that location.
The second file pointer from /WEB-INF/web.xml
points to the Servlet Dispatcher which is in charge of routing web traffic (or web services) to beans within my application. There is not much in here really. The file is the interface layer which utilizes the servlet container. The configuration file would change (somewhat) depending on what servlet container (or application server) you were using.
/WEB-INF/myproj-servlet-config.xml
is included for completeness
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd"
>
<context:component-scan base-package="uk.co.bigsoft.myproj" />
<!-- Resolves logical view names to JSP views -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!-- Returns messages based on a resource bundle -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/messages/validation" />
</bean>
</beans>
The main idea behind this layout is to promote the separation of concerns. The application-config.xml
file will almost certainly be split into several other files, to allow a more modular test approach. As you can see the components relating to the database, transaction model, JMS and other infrastructural aspects of the application are split away from the business logic. The business beans are not concerned with these behaviours, in fact the more decoupled from the rest of the system the better.
Now that infrastructure is split from business the test environment can take full advantage of Spring’s Inversion of Control mechanism by faking up (or mocking) the infrastructural components and injecting them into the business beans. The mocks implement the same interfaces as the real beans and so test harnesses can be easily written.- Log into Hotmail
- Click Options (on the right), select More options
- From the Manage your account section, click View and edit your personal information
- Find the account you want and click Registered information
- The first option is Name, so click Change
- Enter First name and Last name, then click Save
Plesk generates web statistics using awstats. The "Select Period" drop down box is created with all the month dates in a random order which is not very helpful! It makes selecting the month you want tricky.
The following code checks which domains are using awstats and will re-jig their nav.html
files to put them all in the correct order. Place the following program into your cron to run after awstats has completed.
The simplest way to find out when awstats completes, is to check the creation time of the nav.html
file and add 30 minutes to be safe.
I've called mine: **plesk-awstats-nav-fixer.sh**
#!/bin/bash
#
# This code was written by BigSoft Limited.
# Please include this message when you use the code in any form.
# Code comes as is and without warrenty
#
# David Newcomb (c) BigSoft Limited 2008
#
# Get MySQL's admin password
PSA_PW=`cat /etc/psa/.psa.shadow`
PSA_USER=admin
# Location of webstats folders
VHOST=/var/www/vhosts
STATS=statistics/webstat
# Find enabled domain names that use awstats statistics.
# When a client is deactivated the status of a domain
# becomes non-zero, so there is no need to join on the
# client's table.
SQL=" SELECT d.name"
SQL="$SQL FROM domains d, hosting h"
SQL="$SQL WHERE d.id = h.dom_id"
SQL="$SQL AND d.status = 0"
SQL="$SQL AND h.webstat = 'awstats'"
# Run SQL
DOMAINS=`mysql --skip-column-names -u$PSA_USER -p$PSA_PW -e"$SQL" psa`
for DOMAIN in $DOMAINS
do
AWSTATS_DIR=$VHOST/$DOMAIN/$STATS
echo "Checking $AWSTATS_DIR"
if [ ! -d "$AWSTATS_DIR" ]
then
echo "Sorry awstats folder does not exist: $AWSTATS_DIR"
continue
fi
cd $AWSTATS_DIR
grep '^<option value="' nav.html | sort -r > nav_options.html
grep -v '<option value="' nav.html > nav_nooptions.html
ed nav_nooptions.html << EOF
/^<\/select>
-1r nav_options.html
wq
EOF
rm -f nav_options.html
rm -f nav.html
mv nav_nooptions.html nav.html
done
You have to love ed! It is (as far as I know) the only editor that is described as WYGIWYG (What You Get Is What You Get - wikipedia deleted my entry because no one else seems to have heard of this expression apart from me!).
This is the second problem with Plesk and awstats I have documented. Here's another: Plesk Awstat forgets the monthly statistics.
OpenSessionInViewInterceptor
. There wasn’t much out there. I needed to narrow my search to just the Spring Reference. So here comes the first tip:
site:static.springframework.org OpenSessionInViewInterceptorThis limits all the results to entries which are at the website http://static.springframework.org/. The search was throwing back loads of links to the API documentation so, I needed to restrict the results again to the reference section:
site:static.springframework.org inurl:reference OpenSessionInViewInterceptorThis was now giving me results for all the versions. Next I needed to reduce the search down to include the version number. Google only lets you have 1 colon’ed option per type, so:
site:static.springframework.org inurl:reference inurl:2.5 OpenSessionInViewInterceptorreturns nothing! You must join them together:
site:static.springframework.org inurl:(reference and 2.5) OpenSessionInViewInterceptor