Filmpje
By joost on July 29th, 2007Een aantal collega’s hebben een leuk E-id! promo filmpje gemaakt om afstudeerders te lokken.
Een aantal collega’s hebben een leuk E-id! promo filmpje gemaakt om afstudeerders te lokken.
Finally I more or less finished my new site. Unlike the old one which ran under Confluence, this site is running in Wordpress. I learned about Wordpress via my girlfriend and I really started to like it even though it’s a PHP application and not Java.
Since I wanted to change my site more into a blog anyway, I decided to install Wordpress on our sites too. Now both our main site www.claroquesi.info and this site are running Wordpress.
I have been working a lot with Adobe Flex lately and we ran into many issues. Most of them Flex Data Services (FDS) related. It seemed we were using FDS in a way Adobe hadn’t thought of yet. I’ll post these issues here soon. Meanwhile I posted some blogs I posted in my blog on my company wiki. Hope it’s usefull for someone.
Spring biedt uiteraard ondersteuning voor JPA. Echter, er zijn zoveel opties, dat het nog redelijk ingewikkeld is om dit correct te configureren.
Spring heeft een tweetal beans waaronder de LocalContainerEntityManagerFactoryBean welke de JPA persistence.xml inlezen. Groot voordeel om dit met Spring te doen is, dat je niet alles in de persistence.xml hoeft te configureren. De datasource kan je bijvoorbeeld in Spring configureren. Zie hieronder.
<bean id=”entityManagerFactory” class=”org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean”>
<property name=”persistenceUnitName” value=”dino_lic” />
<property name=”dataSource” ref=”dinoDS” />
</bean>
Als je simpel JPA gebruikt, is bovenstaand het enige wat je in Spring hoeft te configureren om met JPA te kunnen werken. Als je Spring ook je transacties laat regelen, moet je ervoor zorgen dat je de juiste EntityManager gebruikt. Je mag niet zelf de EntityManager in je methodes opvragen aan de EntityManagerFactory. Bij het starten van een transactie, zal Spring een EntityManager opvragen en de transactie daarop starten. Als je toch zelf een EntityManager maakt, is dit een andere waarop geen transactie gestart is.
Als er geen transactie gestart is, zal JPA geen update uitvoeren !
JPA biedt ook dependency injection dmv annotations.
Uit Spring reference, hoofdstuk 12.6.3:
While EntityManagerFactory instances are thread safe, EntityManager instances are not. The injected JPA EntityManager behave just like an EntityManager fetched from an application server’s JNDI environment, as defined by the JPA specification. It will delegate all calls to the current transactional EntityManager, if any; else, it will fall back to a newly created EntityManager per operation, making it thread safe.
Spring ondersteund ook de JPA injection annotations dmv de PersistenceAnnotationBeanPostProcessor. Door deze bean op te nemen in de Spring context, zal Spring het juiste object injecteren afhankelijk van de gebruikte annotation.
<!– JPA annotations bean post processor –>
<bean class=”org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor”/>
Er zijn diverse manier om Spring transactions voor JPA te laten managen. Zie hoofdstuk 12.7 in de Spring reference. Hieronder staat een manier.
Door de JpaTransactionManager bean op te nemen in de context, worden al opeens een hoop transactionele zaken geregeld. Het enige wat je nog moet configureren is wat je transactioneel wilt hebben. In onderstaand voorbeeld is dit gedaan dmv Aspects in Spring. In aop:config wordt een pointcut gedefinieerd en welke advisor voor die pointcut geldt. Met tx:advice wordt een transactioneel advies gemaakt welke gebruik zal maken van de JpaTransactionManager. Door meerdere tx:method elementen op te nemen, kan voor elke methode de gewenste propagation gedefinieerd worden.
Door onderstaande configuratie te gebruiken in combinatie met @PersistenceContext, zal Spring ervoor zorgen dat op de bean waarin @PersistenceContext staat, een EntityManager geinject wordt waarop de transactie is gestart.
<bean id=”myTxManager” class=”org.springframework.orm.jpa.JpaTransactionManager”>
<property name=”entityManagerFactory” ref=”entityManagerFactory” />
<property name=”jpaDialect” ref=”jpaDialect” />
</bean>
<bean id=”jpaDialect” class=”org.springframework.orm.jpa.vendor.HibernateJpaDialect” />
<aop:config>
<aop:pointcut id=”allDaoMethods”
expression=”execution(* nl.tno.nitg.dino.lic.dao.*Dao.*(..))” />
<aop:advisor advice-ref=”txAdvice”
pointcut-ref=”allDaoMethods” />
</aop:config>
<tx:advice id=”txAdvice” transaction-manager=”myTxManager”>
<tx:attributes>
<tx:method name=”*” propagation=”REQUIRED” />
</tx:attributes>
</tx:advice>
Door met log4j debugging aan te zetten voor org.springframework kan je percies zien wanneer Spring transacties start en commit.
With Delicious it’s possible to manager your bookmarks on 1 single place. You just need to install the Firefox extention and register on the site. Btw there are plugins for all browsers.
The big advantage is that you cannot only manage all you bookmarks on 1 place, you can also tag you bookmarks which makes it much easier to find you bookmarks again. Also with the Firefox plugin (don’t know about the others) you can have a bookmark toolbar which displays your bookmarks, your tags or your bundles (this is a collection of tags).
Furthermore you can share you bookmarks with others in a network. This would be an ideal place to share bookmarks with collegues. See the Delicious site about more information about sharing bookmarks and adding people to your network.
It’s also possible to add your bookmarks to your personalized google homepage. Just use the url http://del.icio.us/<userid> to add content to your homepage and the latest created public bookmarks will be displayed.
You can also make small scriptlets which you can include on your homepage so people can add you to their network or show people you bookmarks. These scriplets can be created on you Delicious settings page.
I started this year with a nice regular expression fight.
An expression which I used in an application to select all files which name starts with ‘IWu’ but not ends with ‘Bean’,'Local’ or ‘Home’ followed by ‘.java’ aparently did not work properly.
The expression which I used was:
.*\\IWu.*[^(Bean)|(Home)|(Local)]\.java
Somehow with this expression, filenames like ‘….\IwuRelation.java’ did not validate as true. A small test showed that the group ‘Bean’ in the expression was the cause. Why I don’t know. Maybe because ‘Bean’ and ‘Relation’ share 3 letters; ‘a’,'e’,'n’.
So aparently grouping a combination of letters this way, does not work. What than? It’s easy to create an expression using a group, but how to create one which validates ‘not group’.
After trying many different expressions, I finally found one which seems to do exactly what I wanted it to do. All tests I created were successful for this expression.
.*\\IWu.*(?<!Bean|Home|Local)\.java
This expression uses a negative-lookbehind (”?<!”) function of regular expressions. It looks back and makes sure it does not contain ‘Bean’,'Home’ or ‘Local’. If it does, validation fails.
If you need to define this expression in an XML file, like I did, you have to use CDATA because a ‘<’ is used in the expression.
<![CDATA[.*\\IWu.*(?<!Bean|Home|Local)\.java]]>
JRemoteFS is a generic framework to connect to remote filesystems. It was created for SFTP integration into JAlbum. It supports both FTP and SFTP access. JRemoteFS is only the framework. It uses FtpBean for FTP implementation and JSCH for SFTP implementation. The framework contains adapters to convert these components to the framework’s RemoteFS interface. See the design.
(Click image to enlarge)
The design is fairly simple. The framework defines a interface; RemoteFS. The adapters adapt the FtpBean and JSCH implementations to match this interface. The framework also defines a RemoteFile. This is an abstract object which defines some methods to get information about the file on the remote filesystem. Each adapter will return instances of this RemoteFile. The abstract object contains some methods which might be usefull for other implementations.
The framework also provides a bean; RemoteFSBean. This bean also implements the RemoteFS interface and works as a proxy, hiding which implementation will be used. The bean uses the RemoteFSFactory to get an implementation of RemoteFS. The bean will than use this implementation to forward all requests to. Applications can use this bean to easily integrate JRemoteFS into their application.
If you have any remarks or suggentions for JRemoteFS, please let me an email
RemoteFS defines methods for:
* Set\Get the port on which to connect to remote server
* Set\Get force UTF-8 characterset
* Set\Get passive mode (used for ftp support)
* Set\Get the remote directory
* Change to parent directory
* Create a new directory
* Remove a directory
* Connect to remote server
* Disconnect from remote server
* Check for connection to server
* Get files
* Upload a file
* Remote a file
Via RemoteFile the following info about the remote file can be obtained:
* If the file is a file
* If the file is a directory
* Name
* Creation date
* Modify date
* Size
Current version: 1.0
TODO LIST:
I plan the following improvements to the current version:
* Use a filesystem-type to determine what kind of implementation to use. This makes it possible to add other implementations than FTP to be added. For example SCP , NFS or …?.
* Have the factory use a properties file to determine which class to use for which remote filesystem type
Both binary and source downloads contain JSCH and an adapted version of FtpBean and include the Javadoc.
JRemoteFS is released under LGPL license.
Get binary or sources from sourceforge.
JAlbum - http://www.jalbum.net
JSch – Java Secure Channel - http://www.jcraft.com/jsch/index.html
FtpBean - http://www.geocities.com/SiliconValley/Code/9129/javabean/ftpbean/