30.04.08

Php for Visual Studio (Php4VS)

posted by Nicolas Penin

Morning everyone,

Some days ago, I've published a project on codeplex : php4vs. Currently, it provides basic functions, but I intend to implement intellisense. Though, we could have a great php IDE, but it would also have made me understand a bit more how to implement Language Service in VS, and how to work with MPF (Managed Package Framework). Once intellisense works, I will publish a post to let you know, how I made it work.

04/29/08

TOOLS EUROPE 2008, ETH Zurich, Switzerland 30 June-4 July 2008

posted by Agusti Canals

TOOLS EUROPE 2008, 46th International Conference: Objects, Models, Components, Patterns. Co-located with "International Conference on Model Transformation 2008"

28.04.08

La 6è édition pour UML par la pratique !

posted by Pascal Roques

J'ai le plaisir de vous annoncer la sortie de la (déjà) 6è édition d'UML par la pratique ! 88|

Quelques compléments et corrections mineures pour ce livre qui va bientôt atteindre les 17.000 ex. vendus. :D

Merci à tous mes lecteurs et n'hésitez pas à m'envoyer vos commentaires, critiques et suggestions pour la future 7è édition ...

25.04.08

UML&FORMAL METHODS,Kitakyushu-City, Japan, October 27, 2008

posted by Agusti Canals

CALL FOR PAPERS:UML&FM’2008

FIRST INTERNATIONAL WORKSHOP ON UML&FORMAL METHODS
Workshop held in conjunction with ICFEM 2008 The 10th International Conference on Formal Engineering Methods

24.04.08

Lucene Persistence Engine Sample

posted by Nicolas Penin

Due to my preceding post, I had to publish a sample on how to use this Lucene Persistence Engine. And since a picture is worth a thousand words, I let try it. The sample is a small application that looks for content in an articles library.

You may find the sample here.

04/23/08

CALL FOR PAPERS ACES-MB'08, Toulouse, September 28th, 29th or 30th (TBD)

posted by Agusti Canals

1st International Workshop on Model Based Architecting and Construction of Embedded Systems (ACES-MB 2008. Organized and funded by ARTIST Network of Excellence in Embedded Systems Design. In conjunction with MODELS 2008.

21.04.08

Systems Engineering for the Planet, The Netherlands, 15-19 June 2008

posted by Agusti Canals


Theme: “Systems Engineering for the Planet

The symposium theme “Systems Engineering for the Planet”, addressing the expanding scope of Systems Engineering application and responsibility. Examples of this expanding scope are Safety & Security, Disaster control, Resource efficiency, Infrastructure, Transportation systems, Climate impact, Water Management, Education & Government, Sustainable developments... you name it.

20.04.08

Lucene Persistence Engine for Euss

posted by Nicolas Penin

I have been working with EUSS for some time now. For the one who don't know it yet, I would suggest you to have a look at it. During my free time, I've developed a Persistence Engine based on Lucene. If you know EUSS or have taken some time to read the overview, you know that to request objects to EUSS, you use the OPath language, or with the .NET framework 3.5, you can use Linq. My persistence engine enables you use these languages with Lucene. Imagine the power of Linq combined with the Lucene ! I know, a LinqToLucene already exists, but my persistence engine goes further, since it enables to use aggregate functions (not in constraints). For instance, you may get the number of objects satisfying a condition with one single query. For those who have been reading so far, I guess you're impatient to test it, then here is the dlls to use, and there an example of an app.config/web.config :

<configuration>
    <configSections>
        <section name="euss" type="Evaluant.Uss.Configuration.EussConfiguration, Evaluant.Uss"/>
    </configSections>
    <connectionStrings>
        <add name="MsSQL" connectionString="Data Source=.;Initial Catalog=EUSS;Integrated Security=true"/>
    </connectionStrings>
    <system.diagnostics>
        <switches>
            <add name="Evaluant.Uss.SqlMapper.Sql" value="1"/>
            <add name="Evaluant.Uss.Lucene" value="1"/>
        </switches>
    </system.diagnostics>
    <euss>
        <engines defaultEngine="myIndexer">
            <engine name="myIndexer" factory="Evaluant.Uss.Lucene.IndexerProvider, Evaluant.Uss.Lucene">
                <add name="delegator" value="Lucene,SqlMapper" />
                <add name="DefaultEngineIndex" value="1" />
                <add name="IndexerDefaultIndex" value="0"/>
            </engine>
            <engine name="SqlMapper" factory="Evaluant.Uss.SqlMapper.SqlMapperProvider" connectionStringName="MsSQL">
                <add name="Dialect" value="Evaluant.Uss.SqlMapper.MsSqlDialect" />
                <add name="Driver" value="Evaluant.Uss.SqlMapper.MsSqlDriver" />
                <add name="MappingFileName" value="~/mapping.xml" />
                <metadata>
                    <add type="assembly" value="LucenePersistenceEngineSample.Domain" />
                </metadata>
            </engine>
            <engine name="Lucene" factory="Evaluant.Uss.Lucene.LuceneProvider, Evaluant.Uss.Lucene">
                <add name="Path" value="Index" />
                <add name="StoreAttributes" value="True" />
                <metadata>
                    <add type="assembly" value="LucenePersistenceEngineSample.Domain" />
                </metadata>
            </engine>
        </engines>
    </euss>
</configuration>

04/17/08

BlazeDS: Use hibernate4gwt as Hibernate adapter

posted by Bruno Marchesson

Foreword

I am currently working on a EJB3 / Flex3 project and face a very familiar issue.
BlazeDS is an open-source library, published by Adobe, to send messages from Flex code to java one (and vice-versa). The source code is an extract of LiveCycle Data Services, its commercial ancestor, still alive and handling more functionalities.
One of the most missing features of BlazeDS is an adapter to send Hibernate beans from a Java server to the Flex/Action Script client side, whereas this adapter is available in LiveCycle DataService (but it costs a lot of $$$, including runtime fees).

Hibernate4GWT ?
Hibernate4GWT is a open-source library I am working on since more than one year now to allow sharing Hibernate beans from server to GWT client side. But, despites of its name, the core of the library is really independent of GWT (don’t worry, you won’t have to add GWT libraries to your Flex project ;) ):

  • The ‘clone’ operation consists of converting Hibernate beans to pure, regular beans. Proxies are removed, and Persistent collections converted to their classic counterparts. Of course, persistence information handled by proxies and persistent collections are stored to be reused when the POJO comes back.
  • The ‘merge’ operation takes the neutral bean and merges it back to a Hibernate bean. Proxies and persistent collections are regenerated accordingly to what was undone by the clone operation.

Defining your own adapter
It is pretty simple, and well documented here.
So here is the code:

/**
* Hibernate adapter for BlazeDS
* It is based on hibernate4gwt core and delegates Hibernate beans management to it.
* @author bruno.marchesson
*
*/
public class HibernateAdapter extends JavaAdapter
{
/**
* The Hibernate bean manager
*/
private HibernateBeanManager _beanManager;

//-------------------------------------------------------------------------
// Java adapter override
//-------------------------------------------------------------------------
/**
* Adapter initialisation
*/
@Override
public void initialize(String name, ConfigMap config)
{
// Call base method
//
super.start();

// Get EntityManagerFactory
//
Object entityManagerFactory = getEntityManagerFactory();

// Create hibernate bean manager
//
_beanManager = new HibernateBeanManager();
_beanManager.setEntityManagerFactory(entityManagerFactory);
}

/**
* Invoke adapter
*/
@Override
public Object invoke(Message message)
{
RemotingMessage remotingMessage = (RemotingMessage) message;

// Merge input arguments
//
List mergedParameters = (List) _beanManager.merge(remotingMessage.getParameters());
remotingMessage.setParameters(mergedParameters);

// Call Java adapter
//
Object result = super.invoke(message);

// Clone result
//
return _beanManager.clone(result);
}

//-------------------------------------------------------------------------
// Internal methods
//-------------------------------------------------------------------------
/**
* @return the Entity Manager Factory
*/
protected Object getEntityManagerFactory()
{
// JNDI Lookup for Entity Manager Factory
//
Context context = new InitialContext();

Object entityManagerFactory = context.lookup("your_emf_jndi_name");
if (entityManagerFactory == null)
{
throw new RuntimeException("Unable to find EntityManagerFactory");
}
return entityManagerFactory;
}
}

It is pretty straightforward: the only difficulty is to set the Hibernate session factory or the entityManagerFactory to the HibernateBeanManager. In our case, we use the JNDI name of the EntityManagerFactory (declared in the EJB3 “persistence.xml” file), but you can inject easily it in another way depending on your code.
The “invoke” method is the heart of the adapter: before server call, the input arguments are merged to Hibernate entities, and the result of the process call is cloned before going to the server side.

Stateful/Stateless mode
Previously, I mentioned that the persistence information hold by proxies and collections is stored in the ‘clone’ operation and reused in the ‘merge’ one.
Basically, Hibernate4GWT provides 2 ways of storing such information: on the server (the stateful mode) or on the pojo (stateless mode).

Stateful mode:
The proxy is stored in the HTTP session. As a consequence, your entity beans do not have any technical inheritance. Magic, isn’t it B)?

To make it work, just edit the Hibernate Adapter below as follows :

  • In the ‘init’ method, add the following line:
    _beanManager.setPojoStore(new HttpSessionPojoStore());
  • At the very beginning of the ‘invoke’ method, put the following line :
    HttpSessionPojoStore.setHttpSession(FlexContext.getHttpRequest().getSession(true));

Stateless mode:
The entity beans store minimal persistence information, by inheriting from LazyPojo abstract class. No information is stored on server, which can be very helpful in clustered environments.

First, your entities must inherit from net.sf.hibernate4gwt.pojo.LazyPojo:
public class MyPojo extends LazyPojo
{…}

And here is the LazyPojo class in ActionScript (your value objects have to inherits from it, in a symmetric way to your entity hierarchy) :

package com.mypackage.client.vo
{
import com.adobe.cairngorm.vo.IValueObject;
import mx.collections.ArrayCollection;

[RemoteClass(alias="net.sf.hibernate4gwt.pojo.LazyPojo")]
public class LazyPojo implements IValueObject
{
/**
* The internal lazy properties collection
*/
private var _lazyProperties:ArrayCollection;

/**
* Constructor of Lazy Pojo abstract class.
*/
public function LazyPojo()
{
_lazyProperties = new ArrayCollection();
}

/**
* Getter for lazy properties collection
*/
public function get lazyProperties():ArrayCollection
{
return _lazyProperties;
}

/**
* Setter for lazy properties collection
*/
public function set lazyProperties(value:ArrayCollection):void
{
_lazyProperties = value;
}
}
}

The future
BlazeDS is not currently supported by Hibernate4GWT : it means that it as not been tested in different configurations (remoting, messaging, etc…), and there is no dedicated distribution or documentation for Flex applications.
Nevertheless, Hibernate4GWT is currently under heavy refactoring : the code has been split in different jars, and an official new distribution and documentation is scheduled for the end of Q2. It will include GWT new tutorial, some more functionality… and probably BlazeDS support :D

Stay tuned !

17.04.08

Acceleo: Good news ...

posted by Agusti Canals

Acceleo development team announce the start of new works for bringing Acceleo compatible with the OMG standard MOF Model-to-text Transformation Language.

More informations on:
- http://wiki.eclipse.org/M2T/MTL_Relaunch_Plan
- http://www.acceleo.org/pages/roadmap/en

OpenEmbeDD: The MDE platform

posted by Agusti Canals

OpenEmbeDD is THE open source platform for Model Driven Engineering.
The OpenEmbeDD project intends to produce, collect and package open source MDE software for Real Time & Embedded (RT&E) systems...

see: http://openembedd.org/MDE

15.04.08

École Systèmes de systèmes: Paris, 22 et 23 avril

posted by Agusti Canals

L'édition 2008 de l'École Systèmes de systèmes se déroulera à Paris du 22 au 23 avril 2008. Vous pouvez vous inscrire sur le site de l'École SdS

14.04.08

SysML et Génie Logiciel (Mars 2008, Numéro 84)

posted by Agusti Canals

A noter deux papiers très intéressants sur l'Ingénierie de systèmes publiés par Génie Logiciel. Le langage de modélisation de systèmes, SysML par Y.Pollet et Modélisation SysML par l'exemple par P.Leblanc. A lire sans modération !!!

13.04.08

IDM'2008: Mulhouse, 5 et 6 juin

posted by Agusti Canals

Le programme des 4ièmes journées IDM est désormais disponible. Cette année c'est Mulhouse qui reçoit. Ces journées essentiellement orientées recherche sont complémentaires aux journées NEPTUNE qui mixent la recherche et l'industrie. Ne manquez pas cet évènement !!!

11.04.08

Dany la malice m'a écrit!

posted by amethyste

Que ce soit sur mon blog ou par mail privé, je reçois régulièrement des questions. Malheureusement je n'y réponds pas toujours faute de temps.

Alors je vais essayer de me rattraper au cours des prochains blogs à commencer par un mail privé reçu cette semaine de la part d'un certain "dany la malice".

Que disait-il?

… je voulais savoir si vous pourriez m aider car je suis débutant en dotnet et je dois réaliser un projet qui gère une base de données qui elle même doit pouvoir comporter une table dont un champ qui reçoit des photos
le pb c est que je ne vois pas comment je peut faire cela
j ai déjà créé la base et la table
je travail sur vs2005 en c#...

Il y a deux façons de stocker des images dans une application:

• Dans une base de données
• Dans le système de fichier

Vous avez apparemment fait le premier choix. Avant de l'analyser je voudrai tout de même dire un mot du deuxième. Les deux choix sont tout aussi valides, mais le contexte de l'application peut parfois en préférer un plutôt que l'autre.

Par exemple si on parle d'une application Web, personnellement je pense que le système de fichier est le meilleurs choix, à condition de l'inclure dans un répertoire virtuel, c'est-à-dire accessible via une url.
C'est très simple à faire, vous créez un site Web qui ne contient que des répertoires dans lequel vous positionnez vos images.
Un autre avantage de ce choix est que s'il s'agit d'un site à fort trafic les images pourront être mises en cache très facilement. Il existe des sociétés spécialisées comme Akamai[1] qui louent de l'espace mémoire sur de gros serveurs pour cela justement.

Par expérience, un répertoire contenant de très nombreux fichiers est difficile à gérer et ralentit les performances. Il est donc important de le structurer en petits sous répertoires.

Avoir une règle de nommage précise peut vous simplifier la vie.
Supposons par exemple que le site affiche un catalogue de vêtements représentés par un identifiant. Vous pouvez nommer les images par l'identifiant et l'arborescence des répertoires selon une norme du genre:
/Hommes/Chemise/12345_red_XXL.gif

Côté code c'est facile de reconstituer dynamiquement l'url qui pointe vers l'image.
A titre d'exercice, essayez de vous renseigner pour savoir quelle est la taille maxi d'une url, s'il y en a une. Déduisez en quelques règles simples pour mettre au point votre architecture de répertoire.

Le choix est donc une base de données. Il s'agit de Sql Server 2005.
Sachez déjà que les champs de type image sont considérés comme dépréciés au profit de varbinary(max). Vous trouverez en bibliographie des informations sur le genre de problèmes résolus par varbinary [2].
Varbinary(max) fonctionne comme un champ normal. On peut donc le lire avec les objets ADO usuels sans grandes difficultés.

Côté Dal, on s'en sort comment?

Personnellement j'ai dans la majorité des cas un faible pour les DataReader, les performances sont en général meilleures. Il va vous renvoyer un tableau d'octet. Vous allez donc avoir du code qui ressemble à ceci:

long imgTaille = dr.GetBytes(0, 0, null, 0, 0);
byte[] tabOct = new byte[imgTaille];
dr.GetBytes(0, 0, tabOct, 0, (int)imgTaille); // charge l'image

dr étant l'instance du DataReader.

Ensuite vous pouvez insérer l'image dans un flux http:

HttpContext.Current.Response.OutputStream.Write(tabOct, 0, tabOct.Length);

Où la charger en mémoire, par exemple:

using (MemoryStream reader = new MemoryStream(ImageProperty.Image))
{
    using (Bitmap bitmap = new Bitmap(reader))
    {
        // traitement ici
    }
}

Voilà de quoi vous occuper. J'ai testé ces deux méthodes dans des applications et elles fonctionnent très bien.

Bibliographie

[1] Pour en savoir plus sur Akamai:
http://www.01net.com/article/283899.html

[2] Information sur les champs de type blobs

http://www.teratrax.com/articles/varchar_max.html
http://blog.sqlauthority.com/2007/06/01/sql-server-2005-constraint-on-varcharmax-field-to-limit-it-certain-length/

:: Page suivante >>

Publicité

powered by
b2evolution