Scala Days tomorrow !
In a few hours, I'm going to take the TGV for Lausanne, to attend first Scala Days !
There seems to be a lots of really good conferences, and it will be the opportunity to finally met a lot of irc/mailing list names !
Personal stuff. Obviously.
In a few hours, I'm going to take the TGV for Lausanne, to attend first Scala Days !
There seems to be a lots of really good conferences, and it will be the opportunity to finally met a lot of irc/mailing list names !
Posted by Fanf at 14:47 1 comments
I just created a github project that shows what one has to do to configure and start OpenDS LDAP directory from a Java application, for example to run unit tests.
Most of the code is a direct transcription of information found on OpenDS wiki[1].
Along the commits, I tried to remove most of the unused configuration for the proposed goal, and I ended to replace the Berkeley DB backend by a memory one.
The source code is here: http://github.com/fanf/opends-simple-config
Feel free to remove even more unused configuration, or propose things to make OpenDS start time even faster.
Enjoy !
[1] https://www.opends.org/wiki/page/CreatingAnOpenDSInstanceForEmbeddedUse
https://www.opends.org/wiki/page/ControllingOpenDSFromAnotherApplication
Posted by Fanf at 19:15 3 comments
Scala native DSL capabilities are astonishing. I just created some Scala object to mimic Unix file permission representation and "chmod" interaction, and I'm rather pleased of the result
Only user", "group" and "other" permission are managed - so no setuid, setgid or sticky bit.
scala> val p:Perm = wx scala> w.toString // "-wx" scala> w.octal // 3You can combine permission to obtain new permissions:
scala> w+r // rw- scala> rwx-w // r-w
scala> val perms = FilePerms(777)
scala> val perms = FilePerms(rw,rw,r)Like Perm, they have nice string and octal representation:
scala> val perms = FilePerms(777) scala> perms.toString //rwxrwxrwx scala> perms.octal // 777
scala> val perms = FilePerms(77) //rwxrwx--- scala> val perms = FilePerms(rw) //rw-------
scala> val perms = FilePerms(77) //rwxrwx--- scala> perms.g-wx // rwxr---- scala> perms.ugo+x // rwxr-x--x scala> perms.a-wx // r--r-----The binding of theses objects with Java IO with the goal to actually set file permissions is let as an exercise for the reader ;)
scala> object p { [enter]
| [here, past the content of the file]
.....
| }
defined module p
scala> import p._
import p._
scala> FilePerms(644)
res0: Option[p.FilePerms] = Some(rw-r--r--)
chmod( ug(_)+rw, filePerms)Not really nice.
Posted by Fanf at 23:43 2 comments
Labels: dsl, scala, unix file permissions
Today, the first official "Scala 2.8 Beta" was released. It was awaited, and for really good reasons !
Just look at the announcement summary to see all the goodness available: http://www.scala-lang.org/node/4587
I would like to thanks all the people at EPFL and all other contributors around the world to provide us with such a good language and awesome libraries/tools for our daily work - both production ready thanks to Java existing ecosystem and Start-up friendly (ok, no argument here, I just like that language :)
Downloads are available here: http://www.scala-lang.org/downloads
Posted by Fanf at 17:48 0 comments
Scala, Spring 3, Actor, REST, IoC configuration by code...
... and well, I should be able to put some other buzz words in that title, perhaps agile and Scrum ?
I wanted to test Spring 3 "configuration via code" new feature, and especially how well it works with Scala.
As a Tapestry 5 (former) user, I'm a great fan of IoC configuration done in Java (or Scala). From a developer point of view, it's so much more easy and robust (especially refactoring prone) to have access to a real, type safe language in place of an ersatz like XML... and most of the time, it's also much less verbose.
The application
I needed a pretext and decided to build a trivial web
application that allows to upload files to some URL, and post-process
them - a rather usual need in a web-application. That will allow to test Spring 3 new "REST"
features, a bit of Expression Language, and put in a little Scala Actor
to let the (long) processing be done asynchronously.
I also used maven, and Slf4j with NoCommonsLogging to be able to use Slf4j with Spring.
What exactly does the application:
- wait uploads on a REST endpoint URL;
- when an upload comes, save it into a temporary file;
- signal the file's availability to a "file processor". That processing may take a looooooong time to process (for example, it's a big XML report, with a lot of parsing, input validation, graphs generation, etc), and so, the processing should be done in a side process.
Results
Everything comes along really well, and the result is available on github.
To test it, you will need a JVM and Maven (if you haven't done it yet and are not limited by production constrains, just go download the last 1.6 JVM (1.6.0_18), the performances improvements with the last two releases are impressive)
% git clone git://github.com/fanf/scala-spring3-upload.git
% cd scala-spring3-upload
% mvn jetty:run
You should have a Jetty server up and running on localhost.% curl -F FileToUploadName=@/path/to/the/file/to/upload http://localhost:8080/upload/
© Blogger template 'Minimalist G' by Ourblogtemplates.com 2008
Back to TOP