<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cake Solutions Team Blog &#187; java</title>
	<atom:link href="http://www.cakesolutions.net/teamblogs/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cakesolutions.net/teamblogs</link>
	<description>void magic() { }</description>
	<lastBuildDate>Tue, 07 Feb 2012 12:02:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SBT &#8211; DocBook Plugin</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/01/20/sbt-docbook-plugin/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sbt-docbook-plugin</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/01/20/sbt-docbook-plugin/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 14:22:59 +0000</pubDate>
		<dc:creator>Ndidi</dc:creator>
				<category><![CDATA[Ndidi's Blog]]></category>
		<category><![CDATA[DocBook]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[sbt]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Specs2]]></category>
		<category><![CDATA[Specs2 Spring]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=1858</guid>
		<description><![CDATA[Hey there! I&#8217;ve recently just started working with Cake Solutions, Scala and SBT. One of my first tasks was to improve the documentation in Specs2 Spring. SBT and DocBook As part of our Specs2 Spring project, we wanted to ensure users had &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/01/20/sbt-docbook-plugin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hey there! I&#8217;ve recently just started working with <a href="http://www.cakesolutions.net/">Cake Solutions</a>, Scala and SBT. One of my first tasks was to improve the documentation in Specs2 Spring.</p>
<h2>SBT and DocBook</h2>
<p>As part of our <a href="https://github.com/janm399/specs2-spring">Specs2 Spring</a> project, we wanted to ensure users had access to Spec2 Spring&#8217;s documentation in a format they know and love, we figured we&#8217;d use <a href="http://www.docbook.org/">DocBook</a>, the multiformat-generating, markup language.</p>
<p>Fortunately a SBT plugin currently exists for DocBook, however it currently doesn&#8217;t have a few features we need.</p>
<p>We have forked the SBT DocBook plugin, because we needed to add support for XInclude, syntax highlighting, ePUB and many other improvements. Find it <a href="https://github.com/janm399/sbt-docbook-plugin">here</a>.</p>
<h2>The Setup</h2>
<p>Using it is pretty straight-forward. You should have a directory structure similar to this:</p>
<pre>MyProject
  build.sbt
  src/
    main/
      java/
      scala/
      docbook/
        main.xml
        chapter1.xml
        ...
  project/
    plugins.sbt</pre>
<p>Simply ensure all DocBook files are in the <code>src/main/docbook</code> directory. Note that if you have multiple DocBook files, the main file must be named <code>main.xml</code>. On the other hand, if there is just one file, feel free to name it anything you like.</p>
<p>Include the plugin in your <code>project/plugins.sbt</code> file as follows:</p>
<pre class="brush:[scala]">resolvers += ScalaToolsSnapshots

addSbtPlugin("de.undercouch" % "sbt-docbook-plugin" % "0.2-SNAPSHOT")</pre>
<p>That&#8217;s it!</p>
<h2>Run it!</h2>
<p>Generating documents in the format of your choice is pretty easy:</p>
<p><code><br />
$ sbt html<br />
</code></p>
<p><code><br />
$ sbt pdf<br />
</code></p>
<p><code><br />
$ sbt xhtml<br />
</code></p>
<p><code><br />
$ sbt manpage<br />
</code></p>
<p><code><br />
$ sbt eclipse-help<br />
</code></p>
<p>Checkout the readme for more options.</p>
<h2>How have we done it?</h2>
<p>Robust documentation is key to getting the community interested and involved in any project and modular documentation is key to the sanity of the project developers. An easy way to produce modular documentation is by using <a href="http://en.wikipedia.org/wiki/XInclude">XInclude</a>, sadly the plugin it uses, <a href="http://saxon.sourceforge.net/">Saxon</a> 6.5.3, for processing XSLT, cannot handle XInclude.</p>
<p>After extensive googling &amp; hacking, I eventually turned to <a href="http://xerces.apache.org/xerces2-j/">Xerces2</a> to resolve XInclude. The code looks a little something like this:</p>
<pre class="brush:[scala]">   private def transformDocBook(src: File, dst: File, styleSheet: String,
  cp: Classpath, log: Logger) {
    transform(src, dst, log) {
      //write output to temporary file. this avoids a bug in Saxon
      //that caused spaces in the output filename to be converted to
      //an escaped sequence (%20)
      val temp = File.createTempFile("sbt-docbook-plugin-", ".fo")
      val code = Fork.java(None, Seq[String](
      "-cp", cp.files.mkString(File.pathSeparator),
      "-Djavax.xml.parsers.DocumentBuilderFactory="+
        "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl",
      "-Djavax.xml.parsers.SAXParserFactory=" +
        "org.apache.xerces.jaxp.SAXParserFactoryImpl",
      "-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=" +
        "org.apache.xerces.parsers.XIncludeParserConfiguration",
      "com.icl.saxon.StyleSheet",
      "-o", temp.toString,
        src.toString, styleSheet
      ), log)

      //copy temporary file to real output file
      temp #&gt; dst !

      //delete temporary file (if this files it will be deleted on exit)
      if (!temp.delete()) {
        temp.deleteOnExit()
      }
      code
    }
  }</pre>
<p>So what&#8217;s going on here? Well <code><a href="http://harrah.github.com/xsbt/latest/api/index.html#sbt.Fork$$ForkJava">Fork.java</a></code> makes it possible for us to run a separate java process, <code>"-cp"</code> sets up it&#8217;s classpath, <code>cp.files.mkString(File.pathSeparator)</code> ensures that the correct path separator is used for your file system, the first 2 <code>-D</code> options set Xerces as Saxon&#8217;s xml parser, the last <code>-D</code> option turns on the XInclude feature and <code>-o</code> set&#8217;s Saxon&#8217;s output file or directory!</p>
<p>Maintaining Specs2 Spring and any other documentation has been made a little easier!</p>
<p>The next focus will be on improving the plugin&#8217;s output for documentation split into multiple files, in particular EPUB..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/01/20/sbt-docbook-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Why Java</title>
		<link>http://www.cakesolutions.net/teamblogs/2010/08/23/why-java/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=why-java</link>
		<comments>http://www.cakesolutions.net/teamblogs/2010/08/23/why-java/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 16:33:00 +0000</pubDate>
		<dc:creator>Jan Machacek</dc:creator>
				<category><![CDATA[Jan's Blog]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=652</guid>
		<description><![CDATA[At Cake Solutions, we have been using Java for quite a few years. Recently, I had to formulate why our customers should chose Java over other languages. It was easy to come up with geeky reasons, but purely technical reasons &#8230; <a href="http://www.cakesolutions.net/teamblogs/2010/08/23/why-java/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At Cake Solutions, we have been using Java for quite a few years. Recently, I had to formulate why our customers should chose Java over other languages. It was easy to come up with <i>geeky</i> reasons, but purely technical reasons on their own are not enough. It turns out that modern Java EE applications are successful, interesting and exciting because of all the tools we have in the Java world&#8211;it boils down to the fact that I believe that a lot of the innovation we see in contemporary computing runs on the JVM and with JDK 1.7, we should see even more exciting developments.<br />
In the meantime, <a href='http://www.cakesolutions.net/teamblogs/wp-content/uploads/2010/08/whyjvm.pdf'>download the Why Java PDF</a>, where I try to explain why you should use JVM-based platform over anything else.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2010/08/23/why-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>October North West Spring User Group Meeting</title>
		<link>http://www.cakesolutions.net/teamblogs/2009/10/19/october-sug-northwest/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=october-sug-northwest</link>
		<comments>http://www.cakesolutions.net/teamblogs/2009/10/19/october-sug-northwest/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 08:36:16 +0000</pubDate>
		<dc:creator>Andrew Chalkley</dc:creator>
				<category><![CDATA[Andrew C's Blog]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring Integration]]></category>
		<category><![CDATA[Spring User Group]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=469</guid>
		<description><![CDATA[Last Tuesday was the North West Spring User Group. I was asked to deliver my jQuery talk that I gave to the South Spring User Group back in September last year. It&#8217;s always good talking about jQuery as it&#8217;s relatively &#8230; <a href="http://www.cakesolutions.net/teamblogs/2009/10/19/october-sug-northwest/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last Tuesday was the North West Spring User Group. I was asked to deliver my jQuery talk that I gave to the South Spring User Group back in <a href="http://skillsmatter.com/podcast/java-jee/jquery">September</a> last year.</p>
<p>It&#8217;s always good talking about jQuery as it&#8217;s relatively straight forward for the audience to read and has a shallow learning curve (if you know CSS already). One of the other pleasures talking about jQuery, and other front end tech, is that you can always show interactive demos to &#8220;wow&#8221; the audience&#8230;</p>
<p>Here are my slides followed by a link to my demo code:</p>
<div style="width:425px;text-align:left" id="__ss_2273365"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/chalkley/jquery-sug-group-introduction" title="jQuery SUG Group Introduction">jQuery SUG Group Introduction</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=jquery-091019025326-phpapp02&#038;stripped_title=jquery-sug-group-introduction" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=jquery-091019025326-phpapp02&#038;stripped_title=jquery-sug-group-introduction" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/chalkley">Andrew Chalkley</a>.</div>
</div>
<p>I brought some of my demo code up to date showing examples using the <a href="http://docs.jquery.com/Events/live">live</a>, event delegation functionality with jQuery. You can view my demo <a href="http://cakesolutions.net/jquery_demo/jquery.html">here</a> or download it zipped <a href="http://cakesolutions.net/jquery_demo/jquery.zip">here</a>.</p>
<p>If you have any queries about the above or want assist you in a jQuery, Javascript and AJAX project <a href="http://www.cakesolutions.net/contact.html">contact us</a>.</p>
<h2>Spring Integration</h2>
<p>Jonas Partner from OpenCredo also gave a presentation on the evening on Spring Integration. His slides are below:</p>
<div style="width:425px;text-align:left" id="__ss_2292034"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/chalkley/spring-integration-2292034" title="Spring Integration">Spring Integration &#8211; Jonas Partner</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=nwsugspringintegration-091020075822-phpapp01&#038;stripped_title=spring-integration-2292034" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=nwsugspringintegration-091020075822-phpapp01&#038;stripped_title=spring-integration-2292034" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">documents</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/chalkley">Jonas Partner</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2009/10/19/october-sug-northwest/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>That&#8217;s what I call performance</title>
		<link>http://www.cakesolutions.net/teamblogs/2009/08/27/thats-what-i-call-performance/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=thats-what-i-call-performance</link>
		<comments>http://www.cakesolutions.net/teamblogs/2009/08/27/thats-what-i-call-performance/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 15:00:22 +0000</pubDate>
		<dc:creator>Jan Machacek</dc:creator>
				<category><![CDATA[Jan's Blog]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Performance tuning]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=445</guid>
		<description><![CDATA[We are completing work on caching and routing tier we added to a lived-in system. The performance increase is very substantial and I will write a lot more about how we achieved this next week. For now, I&#8217;ll wet your &#8230; <a href="http://www.cakesolutions.net/teamblogs/2009/08/27/thats-what-i-call-performance/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We are completing work on caching and routing tier we added to a lived-in system. The performance increase is very substantial and I will write a lot more about how we achieved this next week.<br />
For now, I&#8217;ll wet your appetite with a screenshot that says it all<br />
<div id="attachment_446" class="wp-caption alignleft" style="width: 435px"><a href="http://www.cakesolutions.net/teamblogs/wp-content/uploads/2009/08/Picture-1.png"><img src="http://www.cakesolutions.net/teamblogs/wp-content/uploads/2009/08/Picture-1.png" alt="Service node statistics" title="Service node statistics" width="425" height="631" class="size-full wp-image-446" /></a><p class="wp-caption-text">Service node statistics</p></div><br />
P.S. Yes, we&#8217;re talking about the <code>RDTSC</code> and <code>System.nanoTime()</code>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2009/08/27/thats-what-i-call-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing AsyncWorker</title>
		<link>http://www.cakesolutions.net/teamblogs/2009/06/23/introducing-asyncworker/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-asyncworker</link>
		<comments>http://www.cakesolutions.net/teamblogs/2009/06/23/introducing-asyncworker/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 07:58:29 +0000</pubDate>
		<dc:creator>Jan Machacek</dc:creator>
				<category><![CDATA[Jan's Blog]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source central]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=363</guid>
		<description><![CDATA[I have another project for the Open Source Central: AsyncWorker. I am tired of writing similar asynchronous call infrastructure from scratch in every project. This is why I am going to write the AsyncWorker. At the highest level, there will &#8230; <a href="http://www.cakesolutions.net/teamblogs/2009/06/23/introducing-asyncworker/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have another project for the Open Source Central: AsyncWorker. I am tired of writing similar asynchronous call infrastructure from scratch in every project. This is why I am going to write the AsyncWorker. At the highest level, there will be an interface (class?) <code>AsyncWorker</code> defined as </p>
<pre>
interface AsyncWorker {
    &lt;T&gt; T invoke(T t);
    &lt;T&gt; T invoke(T t, int maxWait);
    &lt;T&gt; InvocationIdentity execute(T t, AsyncCallback callback);
}
</pre>
<p>The implementation of the <code>AsyncWorker</code> will be flexible enough to use simple heap, JMS or database queues to store the invocations and the API is very easy to start using in your existing projects. For example, if you wanted to turn a synchronous call into asynchronous one with as little coding as possible, you&#8217;d write</p>
<pre>
@Controller
class ExistingController {
    private SomeService someService;
    private AsyncWorker asyncWorker;

    @RequestMapping(...)
    public void index() {
        // this.someService.doWork(1, 2, "hello");     #A
        this.asyncWorker.invoke(this.someService).     #B
            doWork(1, 2, "hello");
    }
}
</pre>
<p>That should be it! Instead of synchronous call on line #A, you will use the <code>AsyncWorker</code> on line #B. The AsyncWorker will queue the invocation of the <code>doWork</code> method of <code>SomeService</code> and will return immediately. Because of the asynchronous nature of the call, the value returned from the method call will be default for the return type (0 for <code>int</code>, <code>long</code>, 0.0 for <code>double</code>, <code>float</code>, <code>null</code> for object reference, etc.).<br />
The alternatives, as you can guess, are using the <code>invoke(T, int)</code> method, which will also invoke any method of <code>T</code> asynchronously, but will wait up to the specified timespan before returning. If the invoked method completes within the specified timespan, the returned value will be valid, otherwise it will be the default value.<br />
Finally, you can use the execute method to schedule the asynchronous call &#8212; this gives you the highest degree of control and you will get an <code>InvocationIdentity</code> object back. You will be able to use the returned <code>InvocationIdentity</code> to monitor the progress of the call.</p>
<h3>Call for comments</h3>
<p>If you think this is a good idea, please comment and add any features you&#8217;d find useful. <i>We will be releasing this project under the Open Source Central under Apache Licence.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2009/06/23/introducing-asyncworker/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Acegi Concurrent Login</title>
		<link>http://www.cakesolutions.net/teamblogs/2008/05/08/acegi-concurrent-login/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=acegi-concurrent-login</link>
		<comments>http://www.cakesolutions.net/teamblogs/2008/05/08/acegi-concurrent-login/#comments</comments>
		<pubDate>Thu, 08 May 2008 09:05:05 +0000</pubDate>
		<dc:creator>Aleksa Vukotic</dc:creator>
				<category><![CDATA[Aleksa's Blog]]></category>
		<category><![CDATA[acegi]]></category>
		<category><![CDATA[concurrent login]]></category>
		<category><![CDATA[concurrentloginexception]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/2008/05/08/acegi-concurrent-login/</guid>
		<description><![CDATA[It is a security requirement for most web sites to disable concurrent logins, so users cannot login from different machines using same login details. Let&#8217;s see how to enable this functionality with Acegi Security. Firstly, add org.acegisecurity.concurrent.SessionRegistry implementation bean to &#8230; <a href="http://www.cakesolutions.net/teamblogs/2008/05/08/acegi-concurrent-login/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It is a security requirement for most web sites to disable concurrent logins, so users cannot login from different machines using same login details.</p>
<p>Let&#8217;s see how to enable this functionality with Acegi Security.</p>
<p>Firstly, add <code>org.acegisecurity.concurrent.SessionRegistry</code> implementation bean to your security context:<br />
<code>
<pre>
&lt;bean id="sessionRegistry" class="org.acegisecurity.concurrent.SessionRegistryImpl" /&gt;
</pre>
<p></code></p>
<p>We are using default Acegi implementation <code>org.acegisecurity.concurrent.SessionRegistryImpl</code>.</p>
<p>Next, define the <code>org.acegisecurity.concurrent.SessionController bean</code>:</p>
<pre>
<code>
    &lt;bean id="sessionController" class="org.acegisecurity.
           concurrent.ConcurrentSessionControllerImpl"&gt;
        &lt;property name="exceptionIfMaximumExceeded" value="true"/&gt;
        &lt;property name="maximumSessions" value="1" /&gt;
        &lt;property name="sessionRegistry" ref="sessionRegistry"/&gt;
    &lt;/bean&gt;
</code>
</pre>
<p>As you can see, it takes <code>sessionRegistry</code> property, as well as two additional properties <code>maximumSessions</code> and <code>exceptionIfMAximumExceeded</code>.<br />
<code>maximumSessions</code> says how meny concurrent login sessions  are allowed (in our case just one)<br />
if <code>exceptionIfMAximumExceeded</code> property is set to true, exception will be thrown every time the user tries to login concurrently. You can check this exception in your login controller and display user with a message.<br />
Otherwise, if <code>exceptionIfMAximumExceeded property</code> is set to false, exception will NOT be thrown. If user tries to login concurrently, he will be allowed, but his last login session (before the concurrent one) will be invalidated.</p>
<p>Last step is to add  <code>sessionController</code> property to your <code>ProviderManager</code> bean:<br />
<code>
<pre>
     &lt;bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager"&gt;
		&lt;property name="providers"&gt;
			&lt;list&gt;
				&lt;ref local="daoAuthenticationProvider"/&gt;
			&lt;/list&gt;
		&lt;/property&gt;
        &lt;property name="sessionController" ref="sessionController"/&gt;
    &lt;/bean&gt;
</pre>
<p></code></p>
<p>And you&#8217;re ready to run.</p>
<p>Some users have encountered problems with concurrent logins: If a user logs out, and then tries to log in again, the <code>ConcurrentLoginException</code> is thrown, so user cannot log in again. This happens when Acegi logout does not remove the session data for the user that has been logout out (before his login session has expired)<br />
In order to fix this, you can manually clear the authentication session for the user that&#8217;s logged out:<br />
<code>
<pre>
public void logout() {
        SecurityContext context = SecurityContextHolder.getContext();
        if (context == null) return;
        Authentication authentication = context.getAuthentication();
        if (authentication == null) return;
        String sessionId = SessionRegistryUtils.obtainSessionIdFromAuthentication(authentication);
        this.sessionRegistry.removeSessionInformation(sessionId);
}
</pre>
<p></code><br />
You will also need this code to be run when Acegi session gets unpublished.<br />
For this implement <code>org.acegisecurity.ui.session.HttpSessionEventPublisher</code>, and configure listener for it in your web.xml:<br />
<code>
<pre>
public class MyHttpSessionEventPublisher extends HttpSessionEventPublisher {
    private static final Log logger = LogFactory.getLog(MyHttpSessionEventPublisher.class);
    private UserContext userContext;

    public void sessionDestroyed(HttpSessionEvent event) {
        logger.info("unpublishing session");
        if (userContext == null) {
            this.userContext = lookupBean(
                        WebApplicationContextUtils.
                             getWebApplicationContext(
                              event.getSession().getServletContext()),
                       "userContext",
                       UserContext.class);
        }

        this.userContext.invalidate();
        super.sessionDestroyed(event);
    }

    private  T lookupBean(final ApplicationContext applicationContext, final String beanName, final Class c) {
        //noinspection unchecked
        return (T) applicationContext.getBean(beanName, c);
    }
}
</pre>
<p></code></p>
<p>In web.xml you will have:<br />
<code>
<pre>
&lt;listener&gt;
        &lt;listener-class&gt;net.cakesolutions.service.security.acegi.BimHttpSessionEventPublisher&lt;/listener-class&gt;
&lt;/listener&gt;
</pre>
<p></code><br />
And you&#8217;re ready to go.</p>
<p>Hope this article has helped anyone in configuring concurrent logins with Acegi Security.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2008/05/08/acegi-concurrent-login/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

