Skip to content

Instantly share code, notes, and snippets.

<!-- Execute some random code, but disabled due to weird interaction between amven and glassfish asadmin command.
Question asked on StackOverflow : http://stackoverflow.com/questions/6942759/batch-creation-of-domain-working-in-command-line-but-not-through-exec-maven-plug -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>create start and configure domain</id>
<phase>package</phase>
@Riduidel
Riduidel / PropertySenderSet.java
Created July 7, 2011 12:22
Un Set capable d'envoyer des événements. Vous savez très bien à quoi ça va servir ....
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@Riduidel
Riduidel / Bean.java
Created June 29, 2011 13:38
Un bean tout simple avec envoi d'événements
public class Bean {
/**
* Avec le PropertyChangeSupport, vous n'avez aps besoin d'envoyer vous-même les événements,
* il s'en occupe (et il le fait mieux que vous, croyez-moi)
*/
private PropertyChangeSupport support = new PropertyChangeSupport(this);
/**
* Notre champ name ne change pas d'un iota
*/
@Riduidel
Riduidel / Bean.java
Created June 29, 2011 13:37
Un bean tout simple (mais sans révisions)
public class Bean {
private String name;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
@Riduidel
Riduidel / Bean.java
Created June 29, 2011 11:40
Un bean tout simple
public class Bean {
/**
* Avec le PropertyChangeSupport, vous n'avez aps besoin d'envoyer vous-même les événements,
* il s'en occupe (et il le fait mieux que vous, croyez-moi)
*/
private PropertyChangeSupport support = new PropertyChangeSupport(this);
/**
* Notre champ name ne change pas d'un iota
*/
@Riduidel
Riduidel / Adapting.java
Created June 27, 2011 12:13
Adapting a domain object into a JComponent (or anything else, for that matter)
if(myObject.canAdapt(JComponent.class)) {
myPanel.add(myObject.getAdapter(JComponent.class));
}
@Riduidel
Riduidel / Adapter.java
Created June 27, 2011 12:06
An example external adapter (for cases where IAdaptable won't suffice)
public interface Adapter {
/**
* Check if this adapter can adapt from source class to target one
* @param from class to adapt
* @param to class to create
* @return isn't it obvious ? true if this adapter can transform an object of "from" class into an object of "to" class
*/
public boolean canAdapt(Class<?> from, Class<?> to);
/**
@Riduidel
Riduidel / Adaptable.java
Created June 27, 2011 11:51
An example adaptable interface
/**
* Shamelessely borrowed from Eclipse concepts, as this article explains the
* interest of this approach :
* http://www.manageability.org/blog/stuff/adaptor-oriented-programming/view
* There is also an article in Eclipse site :
* http://www.eclipse.org/articles/article.php?file=Article-Adapters/index.html
* but it is a little too much Eclipse centric for me
*/
public interface Adaptable {
/**
@Riduidel
Riduidel / pom.xml
Created May 10, 2011 12:45
Build element of a flexmojos maven poom to use conditionnal compilation and produce both elements
<build>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<resourceBundlePath>${basedir}/src/main/locale/{locale}</resourceBundlePath>
<compiledLocales>
<locale>en_US</locale>
@Riduidel
Riduidel / SharedClass.as
Created May 10, 2011 12:38
an example ActionScript file with conditional compilation
ackage com.foo.bar
{
public class SharedClass
{
public function SharedClass()
{
}
CONFIG::FLEX
public function getLibFrom():String