--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="XEMELIOS-api-plugin" default="usage" basedir=".">
+ <import file="../../common-tasks.xml"/>
+ <description>Builds, tests, and runs the project XEMELIOS api-plugin</description>
+ <property file="${user.home}/.ant.properties"/>
+ <property name="compile.debug" value="true"/>
+ <xmlproperty file="component-definition-properties.xml"/>
+
+ <target name="usage">
+ <echo> Using ${ant.version} These are targets supported by this ANT build script: compile -
+ compile all .java files, except thoses in ./tmp folder. clean - deletes all compiled and
+ generated files and resources. jars - build jar files. Do not call this script directly,
+ use the one located at root of projet (in ../..) instead. </echo>
+ </target>
+
+ <target name="compile" depends="mk-output-dirs,define-compile-debug,prepare">
+ <javac srcdir="java" destdir="build/classes" debug="${compile.debug}" encoding="ISO-8859-1">
+ </javac>
+ <copy todir="build/classes">
+ <fileset dir="java">
+ <include name="**/*"/>
+ <exclude name="**/*.java"/>
+ <exclude name="**/CVS/*"/>
+ <exclude name="**/*.form"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="jars" depends="prepare">
+ <copy file="manifest/manifest.txt" tofile="build/manifest.txt">
+ <filterset>
+ <filter token="version" value="${component.release}"/>
+ <filter token="name" value="${component.name}"/>
+ </filterset>
+ </copy>
+ <jar destfile="build/jars/${component.name}.jar" basedir="build/classes"
+ manifest="build/manifest.txt"/>
+ </target>
+
+ <target name="clean">
+ <delete dir="build"/>
+ </target>
+
+
+ <target name="mk-output-dirs">
+ <mkdir dir="build/classes"/>
+ <mkdir dir="build/jars"/>
+ </target>
+
+ <target name="config" description="Genere l'arborescence de mise a jour"
+ depends="get-configuration,prepare">
+ <property name="component.dir"
+ value="build/config/source/${component.name}/${component.release}"/>
+ <copy file="component-definition-properties.xml"
+ tofile="build/config/source/component-definition-properties.xml"/>
+ <mkdir dir="${component.dir}"/>
+ <copy todir="${component.dir}">
+ <!--fileset dir="lib" includes="*.jar"/-->
+ <fileset dir="build/jars" includes="*.jar"/>
+ </copy>
+ <antcall target="generate-update"/>
+ </target>
+
+ <target name="setup">
+ <copy todir="../../build/setup/root/lib">
+ <fileset dir="build/jars" includes="*.jar"/>
+ </copy>
+ <copy todir="../../build/setup/root/lib">
+ <fileset dir="lib" includes="*.jar"/>
+ </copy>
+ </target>
+
+ <target name="javadoc">
+ <mkdir dir="build/javadoc"/>
+ <javadoc destdir="build/javadoc" access="private" encoding="iso-8859-1" splitindex="yes" windowtitle="Xemelios Javadoc" charset="UTF-8" docencoding="UTF-8">
+ <fileset dir="java" includes="**/*.java"/>
+ </javadoc>
+ </target>
+
+</project>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="../../defs/technical-component-definition.xsd">
+ <name>api-plugin</name>
+ <description>Brique pour l'intégration des outils compagnons</description>
+ <release>5.0.0.2+</release>
+ <url>http://xemelios.org/updatesV5/api-plugin</url>
+ <type>COMPOSANT</type>
+ <destination>
+ <base>${xemelios.root}/lib</base>
+ </destination>
+ <release-notes>
+ <note visibility="dev">Ajouté des logs dans la factory pour identifier la méthode de chargement</note>
+ <release v="5.0.0.2">
+ <note visibility="dev">Ajout de la factory, avec une implémentation de base, qui renvoie un service vide. La spécification de l'instanciation de la Factory est complète.</note>
+ </release>
+ <release v="5.0.0.1">
+ <note visibility="dev">Ajout du manifeste</note>
+ </release>
+ <release v="5.0.0.0">
+ <note>Création de l'api</note>
+ </release>
+ </release-notes>
+</component>
--- /dev/null
+/*
+ * Copyright
+ * 2005 axYus - www.axyus.com
+ * 2005 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package fr.gouv.finances.dgfip.xemelios.tools;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.net.URL;
+import javax.swing.JFrame;
+
+/**
+ * Each Xemelios Plugin entry-point class must :
+ * <ul>
+ * <li>extend this class</li>
+ * </ul>
+ * @author chm
+ */
+public abstract class AbstractTool {
+
+ public AbstractTool() {
+ super();
+ }
+
+ /**
+ * <b>Deprecated</b> : Depuis la V5, il est de la responsabilité du plugin de
+ * savoir si il a été lancé dans Xemelios, ou en dehors.<br/>
+ * Vérifie si l'execution se fait ou non dans Xemelios
+ * @return true if Xemelios is running in the same JVM.
+ * @deprecated
+ */
+ public static boolean isInXemelios() {
+ boolean ret = true;
+ URL url = AbstractTool.class.getClassLoader().getResource("fr/gouv/finances/cp/xemelios/ui/MainWindow.class");
+ if(url!=null) {
+ // la classe est dans le Class-Path
+ // on essaie de la charger sans la referencer
+ try {
+ Class clazz = Class.forName("fr.gouv.finances.cp.xemelios.ui.MainWindow");
+ Field fld = clazz.getDeclaredField("instance");
+ if((fld.getModifiers() & Modifier.STATIC) >0) {
+ Object value = fld.get(null);
+ ret = (value!=null);
+ }
+ } catch(Throwable t) {
+ ret = false;
+ }
+ } else {
+ ret = false;
+ }
+ return ret;
+ }
+
+ /**
+ * Defines the parent window.
+ * @param parentWindow
+ */
+ public abstract void setParentWindow(JFrame parentWindow);
+ /**
+ * Runs this plugin.
+ */
+ public abstract void run();
+
+}
--- /dev/null
+/*
+ * Copyright
+ * 2008 axYus - www.axyus.com
+ * 2008 C. Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package fr.gouv.finances.dgfip.xemelios.tools;
+
+import java.lang.annotation.*;
+
+@Retention(value=RetentionPolicy.RUNTIME)
+@Target(value=ElementType.TYPE)
+public @interface MenuTitle {
+ String value();
+}
--- /dev/null
+/*
+ * Copyright
+ * 2011 axYus - http://www.axyus.com
+ * 2011 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS_NB.
+ *
+ * XEMELIOS_NB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS_NB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with XEMELIOS_NB; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+package fr.gouv.finances.dgfip.xemelios.tools;
+
+/**
+ * Exception jetée par le service provider
+ * @author cmarchand
+ */
+public class ServiceException extends Exception {
+ public ServiceException() { super(); }
+ public ServiceException(String msg) { super(msg); }
+ public ServiceException(String msg, Throwable cause) { super(msg,cause); }
+ public ServiceException(Throwable cause) { super(cause); }
+}
--- /dev/null
+/*
+ * Copyright
+ * 2005 axYus - www.axyus.com
+ * 2005 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package fr.gouv.finances.dgfip.xemelios.tools;
+
+/**
+ *
+ * @author chm
+ */
+public interface ToolConstants {
+ public final String TOOL_CLASS = "Tool-Class";
+ public final String TOOL_REQUIRES = "Tool-Requires";
+ public final String TOOL_DESC = "Tool-Description";
+ public final String TOOL_ICON = "Tool-Icon";
+}
--- /dev/null
+/*
+ * Copyright
+ * 2011 axYus - http://www.axyus.com
+ * 2011 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS_NB.
+ *
+ * XEMELIOS_NB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS_NB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with XEMELIOS_NB; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+package fr.gouv.finances.dgfip.xemelios.tools;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Renvoie
+ * @author cmarchand
+ */
+public class ToolServiceProviderFactory {
+
+ /**
+ * Instancie une nouvelle Factory.
+ * L'ordre de recherche est le suivant :
+ * <ol>
+ * <li>cherche une propriété système <tt>fr.gouv.finances.dgfip.xemelios.tools.ToolServiceProviderFactory</tt> Si elle existe, elle contient alors le nom de la classe à instancier.</li>
+ * <li>sinon, cherche un service nommé <tt>fr.gouv.finances.dgfip.xemelios.tools.ToolServiceProviderFactory</tt> Si le service existe, la ressource associée ne contient que le nom de la classe à instancier</li>
+ * <li>sinon, instancie <tt>fr.gouv.finances.dgfip.xemelios.tools.ToolServiceProviderFactory</tt></li>
+ * </ol>
+ * @return La factory
+ */
+ public static ToolServiceProviderFactory newInstance() {
+ String className = getClassName();
+ ToolServiceProviderFactory factory = null;
+ try {
+ Class clazz = Class.forName(className);
+ Constructor<? extends ToolServiceProviderFactory> cc = clazz.getConstructor(new Class[0]);
+ factory = cc.newInstance(new Object[0]);
+ } catch(Exception ex) {
+ // pour le moment, on ignore tout
+ factory = new ToolServiceProviderFactory();
+ }
+ return factory;
+ }
+
+ public XemeliosToolServiceProvider getServiceProvider() {
+ return new XemeliosToolServiceProvider() {
+
+ @Override
+ public List<String> getAvailableDocumentsConfigurations() {
+ return new ArrayList<String>();
+ }
+
+ @Override
+ public List<String> getSearchableDocumentsConfigurations() {
+ return new ArrayList<String>();
+ }
+
+ @Override
+ public List<String> getImportableDocumentsConfigurations() {
+ return new ArrayList<String>();
+ }
+
+ @Override
+ public List<String> getBrowsableDocumentsConfigurations() {
+ return new ArrayList<String>();
+ }
+
+ @Override
+ public String getDocumentConfigurationTitle(String documentId) {
+ return null;
+ }
+
+ @Override
+ public void importFile(File fileToImport, String documentId) throws ServiceException {
+ throw new ServiceException("Service unavailable");
+ }
+
+ @Override
+ public void importFiles(List<ImportContent> filesToImport) throws ServiceException {
+ throw new ServiceException("Service unavailable");
+ }
+
+ @Override
+ public XemeliosProperties getApplicationProperties() {
+ return new XemeliosPropertiesImpl(System.getProperties());
+ }
+ };
+ }
+
+ private static String getClassName() {
+ String className = null;
+ className = System.getProperty(ToolServiceProviderFactory.class.getName());
+ if(className!=null) {
+ System.out.println("found system property "+ToolServiceProviderFactory.class.getName()+"="+className);
+ }
+ if(className==null) {
+ String uri = "META-INF/services/"+ToolServiceProviderFactory.class.getName();
+ InputStream is = ToolServiceProviderFactory.class.getClassLoader().getResourceAsStream(uri);
+ if(is!=null) {
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ className = br.readLine();
+ } catch(IOException ioEx) {
+ ioEx.printStackTrace();
+ }
+ }
+ if(className!=null) {
+ System.out.println("found service uri="+className);
+ }
+ }
+ if(className==null) {
+ className = ToolServiceProviderFactory.class.getName();
+ System.out.println("using default factory: "+className);
+ }
+ return className;
+ }
+
+ public class XemeliosPropertiesImpl implements XemeliosToolServiceProvider.XemeliosProperties {
+ private Properties props;
+
+ public XemeliosPropertiesImpl(java.util.Properties props) {
+ super();
+ this.props = props;
+ }
+
+ @Override
+ public String getProperty(String key) {
+ return props.getProperty(key);
+ }
+
+ @Override
+ public Enumeration<Object> keys() {
+ return props.keys();
+ }
+
+ @Override
+ public Set<Object> keySet() {
+ return props.keySet();
+ }
+
+ }
+}
--- /dev/null
+/*
+ * Copyright
+ * 2011 axYus - http://www.axyus.com
+ * 2011 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS_NB.
+ *
+ * XEMELIOS_NB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS_NB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with XEMELIOS_NB; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+package fr.gouv.finances.dgfip.xemelios.tools;
+
+import java.io.File;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * This interface defines the service contract that Xemelios offers to plugins.
+ * @author cmarchand
+ */
+public interface XemeliosToolServiceProvider {
+
+ /**
+ * Returns all the available configurations documents id.
+ * @return
+ */
+ public List<String> getAvailableDocumentsConfigurations();
+ /**
+ * Returns all the searchable documents id, as they appears in the 'Search' Xemelios menu.
+ * @return
+ */
+ public List<String> getSearchableDocumentsConfigurations();
+ /**
+ * Returns all the importable documents id, as they appears in the 'Import' Xemelios menu. Archive id is not returned.
+ * @return
+ */
+ public List<String> getImportableDocumentsConfigurations();
+ /**
+ * Returns all the browsable documents id, as they appears in the 'browse' Xemelios menu.
+ * @return
+ */
+ public List<String> getBrowsableDocumentsConfigurations();
+ /**
+ * Returns the document configuration title.
+ * @param documentId
+ * @return
+ */
+ public String getDocumentConfigurationTitle(String documentId);
+ /**
+ * Imports the provided <tt>fileToImport</tt>, as it belongs to the configuration denoted by <tt>documentId</tt>
+ * @param fileToImport
+ * @param documentId
+ * @throws Exception
+ */
+ public void importFile(File fileToImport, String documentId) throws Exception;
+ /**
+ * Imports the provided <tt>filesToImport</tt> {@link ImportContent}
+ * @param filesToImport
+ */
+ public void importFiles(List<ImportContent> filesToImport) throws Exception;
+ /**
+ * Returns all the Xemelios configuration properties.
+ * @return
+ */
+ public XemeliosProperties getApplicationProperties();
+
+ /**
+ * A wrapper around a file to import.
+ */
+ public interface ImportContent {
+ /**
+ * Returns the file to import
+ * @return
+ */
+ public File getFile();
+ /**
+ * Returns the document id the file is
+ * @return
+ */
+ public String getDocumentId();
+ /**
+ * Returns the archive name fhe file is in. It may return <tt>null</tt>.
+ * @return
+ */
+ public String getArchiveName();
+ }
+
+
+ /**
+ * A read-only version of {@link java.util.Properties}
+ */
+ public interface XemeliosProperties {
+ /**
+ * Searches for the property with the specified key in this property list.
+ * The method returns null if the property is not found.
+ * @param key
+ * @return the value in this property list with the specified key value.
+ */
+ public String getProperty(String key);
+ /**
+ * Returns an enumeration of the keys in this map.
+ * @return an enumeration view of the keys contained in this map.
+ */
+ public Enumeration<Object> keys();
+ /**
+ * Returns a Set view of the keys contained in this map.
+ * The set is not backed by the map, so changes to the map are not reflected in the set, and vice-versa.
+ * @return a set view of the keys contained in the map.
+ */
+ public Set<Object> keySet();
+ }
+}
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <p>Provide service contract between Xemelios and external plugins - market name is "Outil Compagnon".
+ Each plugin to be loaded into Xemelios must provide :</p>
+ <ul>
+ <li>A single jar with a manifest</li>
+ <li>the manifest must contain :<ul>
+ <li>a <tt>Tool-Class</tt> attribute that denotes the start class while the tool is loaded into Xemelios</li>
+ </ul>
+ </li>
+ <li>the manifest may contain :<ul>
+ <li>a <tt>Tool-Requires</tt> attribute. This attribute is a ';' separated list of components the tool rely on.
+ <br/>A component is <tt>component-url</tt>,<tt>component-release</tt> string</li>
+ <li>a <tt>Tool-Description</tt> attribute that describes the plugin</li>
+ <li>a <tt>Tool-Icon</tt> attribute that references an icon. Icon must be provided into the jar, and described by a {@link ClassLoader.getResource(String)} parameter</li>
+ </ul>
+ </li>
+ <li>the <tt>Tool-Class</tt> must extend {@link fr.gouv.finances.dgfip.xemelios.tools.AbstractTool} and provide a constructor with one {@link fr.gouv.finances.dgfip.xemelios.tools.XemeliosToolServiceProvider} parameter</li>
+ <li>the <tt>Tool-Class</tt> must provide the {@link fr.gouv.finances.dgfip.xemelios.tools.MenuTitle} annotation</li>
+ <li>the manifest must not :<ul>
+ <li>provide this API</li>
+ <li>provide classes already provided by Xemelios</li>
+ </ul>
+ </li>
+ <li>the META-INF directory must not define services (<a href="http://download.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#The%20META-INF%20directory">See jar specification</a>)</li>
+ </ul>
+ </body>
+</html>
--- /dev/null
+Manifest-version: 1.0
+Jar-Version: @version@
+Jar-Content: @name@
\ No newline at end of file