Ignore:
Timestamp:
09/30/06 22:27:30 (6 years ago)
Author:
sys
Message:

Suppression de l'instanciation du ContenuMgr 'fs' de la v1 par défaut

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Jav_CO/com/scenari/m/co/univers/WUnivers.java

    r2647 r6700  
    4747import com.scenari.m.co.service.HServicesMgr; 
    4848import com.scenari.m.co.service.IWService; 
    49 import com.scenari.m.co.univers.fs.XInstancesMgr; 
     49import com.scenari.m.co.univers.wsp.WContenuMgrWsp; 
    5050import com.scenari.m.co.univespace.HEspaceUnivers; 
    5151import com.scenari.m.co.user.IWUser; 
     
    6060public class WUnivers implements IWUnivers { 
    6161 
    62     /** Code de l'univers. */ 
    63     protected String fCode = null; 
    64  
    65     /** Liste des doc serveurs de l'univers. */ 
    66     protected HEspaceUnivers fEspaceSource = null; 
    67  
    68     protected HEspaceUnivers fEspaceComposants = null; 
    69  
    70     protected HEspaceUnivers fEspacePublication = null; 
    71  
    72     protected HEspaceUnivers fEspaceFormations = null; 
    73  
    74     protected HEspaceUnivers fEspaceUnivers = null; 
    75  
    76     protected HashMap fEspaces = new HashMap(); 
    77  
    78     /** Manager des acteurs. */ 
    79     protected IWUserMgr fActeursMgr = null; 
    80  
    81     /** Liste des Classes de composants déclarés principaux. */ 
    82     //sprotected HashMap fClasseComposantsPrinc = new HashMap(); 
    83     /** Liste des Classes de composants. */ 
    84     protected HashMap fClasseComposants = new HashMap(); 
    85  
    86     /** Liste des services de l'univers. */ 
    87     protected HashMap fServices = new HashMap(); 
    88  
    89     /** Contextes d'execution de l'univers de type HttpServlet. */ 
    90     protected HContextExecHttpServlet fContextExecHttpServlet = null; 
    91  
    92     /** Contextes d'execution de l'univers. */ 
    93     protected IWContextExec[] fContextsExecs = null; 
    94  
    95     /** Manager d'instances. */ 
    96     protected IWInstancesMgr fInstancesMgr = null; 
    97  
    98     /** Manager des contenus. */ 
    99     protected IWContenuMgr fContenuMgr = null; 
    100  
    101     /** Intitule de l'univers. */ 
    102     protected String fIntitule = null; 
    103  
    104     /** Factory de templates XSL. */ 
    105     //protected Stack fTransformerFactoryStack = null; 
    106     protected TransformerFactory fTransformerFactory = null; 
    107  
    108     static { 
    109         //Ajout des services de base 
    110         HServicesMgr.hAddServiceLoader("Libre", com.scenari.m.co.service.libre.HServiceLoaderLibre.class); 
    111         HServicesMgr.hAddServiceLoader("Quit", com.scenari.m.co.service.quit.HServiceLoaderQuit.class); 
    112     } 
    113  
    114     /** 
    115      * WUnivers constructor comment. 
    116      */ 
    117     public WUnivers(String pCode) { 
    118         super(); 
    119         fCode = pCode; 
    120         fIntitule = pCode; 
    121     } 
    122  
    123     /** 
    124      * Met à jour l'univers et les prescriptions chargées en mémoire. 
    125      */ 
    126     public void hCheckUpdate(HUpdates pUpdates) throws Exception { 
    127         if (fContenuMgr != null) { 
    128             fContenuMgr.hCheckUpdate(pUpdates); 
    129         } 
    130     } 
    131  
    132     /** 
    133      * Reourne l'acteur de compte pCompte. Si pCompte == IWUser.COMPTE_INVITE, un acteur "invité" est retourné. 
    134      *  
    135      * @return com.scenari.m.co.acteur.IWUser 
    136      * @param pCompte 
    137      *            java.lang.String 
    138      */ 
    139     public final IWUser hGetUser(String pCompte) throws Exception { 
    140         return fActeursMgr.hGetUser(pCompte); 
    141     } 
    142  
    143     /** 
    144      *  
    145      */ 
    146     public com.scenari.m.co.user.IWUserMgr hGetUserMgr() { 
    147         return fActeursMgr; 
    148     } 
    149  
    150     /** 
    151      * Renvoit la classe de composant correspondant à l'URN. 
    152      *  
    153      * @return Classe de composant. 
    154      */ 
    155     public final IWClasseComposant hGetClasseComposantByUrn(String pUrn) throws Exception { 
    156         /* 
    157          * IWClasseComposant vResult = null; StringTokenizer vTok = new StringTokenizer(pUrn, "/"); if 
    158          * (vTok.hasMoreElements()) { vResult = (IWClasseComposant)fClasseComposants.get(vTok.nextToken()); while 
    159          * (vTok.hasMoreElements() && vResult != null) { vResult = vResult.hGetClasseCompAssoc(vTok.nextToken()); } } 
    160          * return vResult; 
    161          */ 
    162         return (IWClasseComposant) fClasseComposants.get(pUrn); 
    163     } 
    164  
    165     /** 
    166      * Renvoit la classe de composant déclarée comme principale de code pCode. 
    167      *  
    168      * @return Classe de composant. 
    169      */ 
    170     public final IWClasseComposant hGetClasseComposantPrincByCode(String pCode) throws Exception { 
    171         return (IWClasseComposant) fClasseComposants.get(pCode); 
    172     } 
    173  
    174     /** 
    175      * @return String Code 
    176      */ 
    177     public final String hGetCode() { 
    178         return fCode; 
    179     } 
    180  
    181     /** 
    182      * @return com.scenari.m.co.univers.IWInstancesMgr 
    183      */ 
    184     public final IWContenuMgr hGetContenuMgr() throws Exception { 
    185         return fContenuMgr; 
    186     } 
    187  
    188     /** 
    189      * Renvoit le cotexte d'execution de type pType. 
    190      *  
    191      * @return com.scenari.m.co.univers.IWContextExec 
    192      * @param pType 
    193      *            java.lang.String 
    194      */ 
    195     public final IWContextExec hGetContextExec(java.lang.String pType) { 
    196  
    197         IWContextExec vResult = null; 
    198  
    199         if (fContextsExecs != null) { 
    200             for (int i = 0; i < fContextsExecs.length; i++) { 
    201                 if (fContextsExecs[i].hGetType().equals(pType)) { 
    202                     vResult = fContextsExecs[i]; 
    203                     break; 
    204                 } 
    205             } 
    206         } 
    207  
    208         return vResult; 
    209     } 
    210  
    211     /** 
    212      * Renvoit le contexte d'execution de type HttpServlet. 
    213      *  
    214      * @return com.scenari.m.co.univers.HContextExecHttpServlet 
    215      */ 
    216     public final HContextExecHttpServlet hGetContextExecHttpServlet() { 
    217         return fContextExecHttpServlet; 
    218     } 
    219  
    220     /** 
    221      *  
    222      */ 
    223     public final IHSource hGetEspace(String pCodeEspace) { 
    224         HEspaceUnivers vEspace = (HEspaceUnivers) fEspaces.get(pCodeEspace); 
    225         if (vEspace != null) { 
    226             return vEspace.hGetRoot(); 
    227         } 
    228         return null; 
    229     } 
    230  
    231     /* 
    232      * (non-Javadoc) 
    233      *  
    234      * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceComposants() 
    235      */ 
    236     public final IHSource hGetEspaceComposants() { 
    237         return fEspaceComposants.hGetRoot(); 
    238     } 
    239  
    240     /* 
    241      * (non-Javadoc) 
    242      *  
    243      * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceFormations() 
    244      */ 
    245     public final IHSource hGetEspaceFormations() { 
    246         return fEspaceFormations.hGetRoot(); 
    247     } 
    248  
    249     /* 
    250      * (non-Javadoc) 
    251      *  
    252      * @see com.scenari.m.co.univers.IWUnivers#hGetEspacePublications() 
    253      */ 
    254     public final IHSource hGetEspacePublications() { 
    255         return fEspacePublication.hGetRoot(); 
    256     } 
    257  
    258     /* 
    259      * (non-Javadoc) 
    260      *  
    261      * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceSources() 
    262      */ 
    263     public final IHSource hGetEspaceSources() { 
    264         return fEspaceSource.hGetRoot(); 
    265     } 
    266  
    267     /* 
    268      * (non-Javadoc) 
    269      *  
    270      * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceUnivers() 
    271      */ 
    272     public final IHSource hGetEspaceUnivers() { 
    273         return fEspaceUnivers.hGetRoot(); 
    274     } 
    275  
    276     /** 
    277      *  
    278      */ 
    279     public final IWInstancesMgr hGetInstancesMgr() throws Exception { 
    280         return fInstancesMgr; 
    281     } 
    282  
    283     /** 
    284      *  
    285      */ 
    286     public final java.lang.String hGetIntitule() { 
    287         return fIntitule; 
    288     } 
    289  
    290     /** 
    291      * Retourne le service de l'univers de code pCode. 
    292      *  
    293      * @return Service de l'univers. 
    294      * @param pCode 
    295      *            Code du service. 
    296      */ 
    297     public final IWService hGetService(String pCode) { 
    298         return (IWService) fServices.get(pCode); 
    299     } 
    300  
    301     /** 
    302      * Retourne le service par défaut de l'univers ("home page" de l'univers). 
    303      */ 
    304     public final IWService hGetServiceAccueil() throws Exception { 
    305         IWService vService = hGetService("accueil"); 
    306         if (vService == null) { 
    307             vService = hGetService("acceuil"); //Faute d'orthographe historique (!) maintenu pour la compatibilité avec 
    308                                                // l'IHM2 et le projet Espass. 
    309             if (vService == null) { 
    310                 throw HLogMgr.hNewException("Erreur de paramétrage de l'univers : il n'existe aucun service d'univers avec le code 'accueil' (ou 'acceuil')."); 
    311             } 
    312         } 
    313         return vService; 
    314     } 
    315  
    316     /** 
    317      *  
    318      */ 
    319     public boolean hHaveService(java.lang.String pCode) { 
    320         return fServices.get(pCode) != null; 
    321     } 
    322  
    323     /** 
    324      *  
    325      */ 
    326     public final void hSetEspace(HEspaceUnivers pEspace) { 
    327         String vCode = pEspace.hGetCodeEspace(); 
    328         if (ESPACE_COMPOSANT.equals(vCode)) { 
    329             fEspaceComposants = pEspace; 
    330         } else if (ESPACE_FORMATION.equals(vCode)) { 
    331             fEspaceFormations = pEspace; 
    332         } else if (ESPACE_PUBLICATION.equals(vCode)) { 
    333             fEspacePublication = pEspace; 
    334         } else if (ESPACE_SOURCE.equals(vCode)) { 
    335             fEspaceSource = pEspace; 
    336         } else if (ESPACE_UNIVERS.equals(vCode)) { 
    337             fEspaceUnivers = pEspace; 
    338         } 
    339         fEspaces.put(vCode, pEspace); 
    340     } 
    341  
    342     /** 
    343      *  
    344      */ 
    345     public final void hSetIntitule(java.lang.String pIntitule) { 
    346         fIntitule = pIntitule; 
    347     } 
    348  
    349     /** 
    350      *  
    351      */ 
    352     public String toString() { 
    353         return "<univers code=\"" + fCode + "\"/>"; 
    354     } 
    355  
    356     /** 
    357      * Ajoute une classe de composant à l'univers. 
    358      *  
    359      * @param pClasseComp 
    360      *            Classe de composant principal 
    361      */ 
    362     public final void wAddClasseComposant(IWClasseComposant pClasseComp) { 
    363         fClasseComposants.put(pClasseComp.hGetUrn(), pClasseComp); 
    364     } 
    365  
    366     /** 
    367      * Ajoute une classe de composant principal à l'univers. 
    368      *  
    369      * @param pClasseComp 
    370      *            Classe de composant principal 
    371      */ 
    372     public final void wAddClasseComposantPrincipal(IWClasseComposant pClasseComp) { 
    373         fClasseComposants.put(pClasseComp.hGetCode(), pClasseComp); 
    374         fClasseComposants.put(pClasseComp.hGetUrn(), pClasseComp); 
    375     } 
    376  
    377     /** 
    378      * Ajoute un contexte d'execution à l'univers. Si un contexte du même type existait déjà, ce contexte est remplacé 
    379      * par le nouveau. 
    380      *  
    381      * @param pContextExec 
    382      *            com.scenari.m.co.univers.IWContextExec 
    383      */ 
    384     public final synchronized void wAddContextExec(IWContextExec pContextExec) { 
    385  
    386         if (fContextsExecs == null) { 
    387             //Aucun contexte d'associe, on ajoute ce 1er contexte. 
    388             fContextsExecs = new IWContextExec[1]; 
    389             fContextsExecs[0] = pContextExec; 
    390         } else { 
    391  
    392             //On cherche un contexte du même type. 
    393             for (int i = 0; i < fContextsExecs.length; i++) { 
    394                 if (fContextsExecs[i].hGetType().equals(pContextExec.hGetType())) { 
    395                     //On a trouvé un ancien context du même type, on le remplace. 
    396                     fContextsExecs[i] = pContextExec; 
    397                     return; 
    398                 } 
    399             } 
    400  
    401             //Aucun contexte du meme type, on l'ajoute. 
    402             IWContextExec[] vNewTab = new IWContextExec[fContextsExecs.length + 1]; 
    403             System.arraycopy(fContextsExecs, 0, vNewTab, 0, fContextsExecs.length); 
    404             vNewTab[fContextsExecs.length] = pContextExec; 
    405             fContextsExecs = vNewTab; 
    406  
    407         } 
    408  
    409         //Traitement spécifique du context HttpServlet 
    410         if (IWContextExec.TYPE_HTTP_SERVLET.equals(pContextExec.hGetType())) { 
    411             fContextExecHttpServlet = (HContextExecHttpServlet) pContextExec; 
    412         } 
    413  
    414     } 
    415  
    416     /** 
    417      * Ajoute un service à l'univers. 
    418      *  
    419      * @param pService 
    420      *            Service de l'univers. 
    421      */ 
    422     public synchronized final void wAddService(IWService pService) throws Exception { 
    423         fServices.put(pService.hGetCode(), pService); 
    424         hGetContenuMgr().hInitServiceUnivers(pService); 
    425     } 
    426  
    427     /** 
    428      * Supprime définitivement l'univers. 
    429      */ 
    430     public final void wRemove() throws Exception { 
    431  
    432         //Suppression des univers. 
    433         if (fServices != null) { 
    434             Iterator vIt = fServices.values().iterator(); 
    435             while (vIt.hasNext()) { 
    436                 try { 
    437                     ((IWService) vIt.next()).wRemoveService(); 
    438                 } catch (Exception e) { 
    439                     HLogMgr.hPublishException(e, "Echec à la suprression d'un service de l'univers " + this); 
    440                 } 
    441             } 
    442         } 
    443  
    444         fActeursMgr = new HUserMgrFs(this); 
    445  
    446         // Manager d'instances 
    447         if (fInstancesMgr != null) { 
    448             fInstancesMgr.wRemoveUnivers(); 
    449         } 
    450  
    451         //On supprime tous les fichiers de l'espace publications 
    452         if (hGetEspacePublications() != null) { 
    453             hGetEspacePublications().hFindElemByPath(null).hRemove(); 
    454         } 
    455  
    456         //On supprime tous les fichiers de l'espace composants 
    457         if (hGetEspaceComposants() != null) { 
    458             hGetEspaceComposants().hFindElemByPath(null).hRemove(); 
    459         } 
    460         //On supprime tous les fichiers de l'espace Formations (instances) 
    461         if (hGetEspaceFormations() != null) { 
    462             hGetEspaceFormations().hFindElemByPath(null).hRemove(); 
    463         } 
    464         //On supprime tous les fichiers de l'espace Formations (instances) 
    465         if (hGetEspaceUnivers() != null) { 
    466             hGetEspaceUnivers().hFindElemByPath(null).hRemove(); 
    467         } 
    468     } 
    469  
    470     /** 
    471      * @see com.scenari.m.co.univers.IWUnivers#wSetContenuMgr(com.scenari.m.co.univers.IWContenuMgr) 
    472      */ 
    473     public final void wSetContenuMgr(IWContenuMgr pContenuMgr) throws Exception { 
    474         fContenuMgr = pContenuMgr; 
    475         fContenuMgr.wInitBegin(this); 
    476     } 
    477  
    478     /** 
    479      * @see com.scenari.m.co.univers.IWUnivers#wSetInstancesMgr(com.scenari.m.co.univers.IWInstancesMgr) 
    480      */ 
    481     public final void wSetInstancesMgr(IWInstancesMgr pInstancesMgr) throws Exception { 
    482         fInstancesMgr = pInstancesMgr; 
    483         fInstancesMgr.wInitBegin(this); 
    484     } 
    485  
    486     /** 
    487      * Désactive et décharge l'univers de la mémoire. 
    488      *  
    489      */ 
    490     public final void wUnload() throws Exception { 
    491  
    492         //On laisse le garbage collector faire le ménage. On ne tue rien pour laisser le tratiement en cours 
    493         //s'exécuter correctement. 
    494  
    495         //###### Envisager fonction Unload des services, etc. 
    496  
    497         /* 
    498          fEspaceSource = null; 
    499          fEspaceComposants = null; 
    500          fEspacePublication = null; 
    501          fEspaceFormations = null; 
    502          fEspaceActeurs = null; 
    503          fEspaceUnivers = null; 
    504          fPrescFormations = null; 
    505          fActeurs = null; 
    506          fClasseComposants = null; 
    507          fServices = null; 
    508          fContextExecHttpServlet = null; 
    509          fContextsExecs = null; 
    510          fInstancesMgr = null; 
    511          fPrefixResolverDefault = null; 
    512          */ 
    513         try { 
    514             if(fContenuMgr!=null) fContenuMgr.wUnloadUnivers(); 
    515         } catch (Exception e) { 
    516             HLogMgr.hPublishException(e); 
    517         } 
    518         try { 
    519             if(fInstancesMgr!=null) fInstancesMgr.wUnloadUnivers(); 
    520         } catch (Exception e) { 
    521             HLogMgr.hPublishException(e); 
    522         } 
    523         if(fServices != null){ 
    524             for (Iterator vIt = fServices.values().iterator(); vIt.hasNext();) { 
    525                 IWService vService = (IWService) vIt.next(); 
    526                 try { 
    527                     vService.wRemoveService(); 
    528                 } catch (Exception e) { 
    529                     HLogMgr.hPublishException(e); 
    530                 } 
    531             } 
    532         } 
    533     } 
    534  
    535     /** 
    536      * Initialisation de l'univers. 
    537      * Appelé juste après l'instanciation de l'objet. 
    538      *  
    539      */ 
    540     public final void xInitBegin() throws Exception { 
    541  
    542         fActeursMgr = new HUserMgrFs(this); 
    543  
    544         //fContenuMgr = new com.scenari.m.co.univers.fs.WContenuMgrFs(); 
    545         //fContenuMgr.wInitBegin(this); 
    546     } 
    547  
    548     /** 
    549      * Fin de l'Initialisation de l'univers. 
    550      * Appelé après le parsing du fichier d'init. 
    551      *  
    552      */ 
    553     public final void xInitEnd() throws Exception { 
    554  
    555         if (fContenuMgr == null) { 
    556             //Pas de ContenuMgr déclaré, on en crée un par défaut. 
    557             fContenuMgr = new com.scenari.m.co.univers.fs.WContenuMgrFs(); 
    558             fContenuMgr.wInitBegin(this); 
    559         } 
    560         fContenuMgr.wInitEnd(this); 
    561  
    562         if (fInstancesMgr == null) { 
    563             //Pas d'instance Mgr de paramétré = Donc on crée l'IntanceMgr par défaut. 
    564             fInstancesMgr = XInstancesMgr.wGetInstancesMgr(this); 
    565             fInstancesMgr.wInitBegin(this); 
    566         } 
    567         fInstancesMgr.wInitEnd(this); 
    568     } 
     62        /** Code de l'univers. */ 
     63        protected String fCode = null; 
     64 
     65        /** Liste des doc serveurs de l'univers. */ 
     66        protected HEspaceUnivers fEspaceSource = null; 
     67 
     68        protected HEspaceUnivers fEspaceComposants = null; 
     69 
     70        protected HEspaceUnivers fEspacePublication = null; 
     71 
     72        protected HEspaceUnivers fEspaceFormations = null; 
     73 
     74        protected HEspaceUnivers fEspaceUnivers = null; 
     75 
     76        protected HashMap fEspaces = new HashMap(); 
     77 
     78        /** Manager des acteurs. */ 
     79        protected IWUserMgr fActeursMgr = null; 
     80 
     81        /** Liste des Classes de composants déclarés principaux. */ 
     82        // sprotected HashMap fClasseComposantsPrinc = new HashMap(); 
     83        /** Liste des Classes de composants. */ 
     84        protected HashMap fClasseComposants = new HashMap(); 
     85 
     86        /** Liste des services de l'univers. */ 
     87        protected HashMap fServices = new HashMap(); 
     88 
     89        /** Contextes d'execution de l'univers de type HttpServlet. */ 
     90        protected HContextExecHttpServlet fContextExecHttpServlet = null; 
     91 
     92        /** Contextes d'execution de l'univers. */ 
     93        protected IWContextExec[] fContextsExecs = null; 
     94 
     95        /** Manager d'instances. */ 
     96        protected IWInstancesMgr fInstancesMgr = null; 
     97 
     98        /** Manager des contenus. */ 
     99        protected IWContenuMgr fContenuMgr = null; 
     100 
     101        /** Intitule de l'univers. */ 
     102        protected String fIntitule = null; 
     103 
     104        /** Factory de templates XSL. */ 
     105        // protected Stack fTransformerFactoryStack = null; 
     106        protected TransformerFactory fTransformerFactory = null; 
     107 
     108        static { 
     109                // Ajout des services de base 
     110                HServicesMgr.hAddServiceLoader("Libre", com.scenari.m.co.service.libre.HServiceLoaderLibre.class); 
     111                HServicesMgr.hAddServiceLoader("Quit", com.scenari.m.co.service.quit.HServiceLoaderQuit.class); 
     112        } 
     113 
     114        /** 
     115         * WUnivers constructor comment. 
     116         */ 
     117        public WUnivers(String pCode) { 
     118                super(); 
     119                fCode = pCode; 
     120                fIntitule = pCode; 
     121        } 
     122 
     123        /** 
     124         * Met à jour l'univers et les prescriptions chargées en mémoire. 
     125         */ 
     126        public void hCheckUpdate(HUpdates pUpdates) throws Exception { 
     127                if (fContenuMgr != null) { 
     128                        fContenuMgr.hCheckUpdate(pUpdates); 
     129                } 
     130        } 
     131 
     132        /** 
     133         * Reourne l'acteur de compte pCompte. Si pCompte == IWUser.COMPTE_INVITE, 
     134         * un acteur "invité" est retourné. 
     135         *  
     136         * @return com.scenari.m.co.acteur.IWUser 
     137         * @param pCompte 
     138         *            java.lang.String 
     139         */ 
     140        public final IWUser hGetUser(String pCompte) throws Exception { 
     141                return fActeursMgr.hGetUser(pCompte); 
     142        } 
     143 
     144        /** 
     145         *  
     146         */ 
     147        public com.scenari.m.co.user.IWUserMgr hGetUserMgr() { 
     148                return fActeursMgr; 
     149        } 
     150 
     151        /** 
     152         * Renvoit la classe de composant correspondant à l'URN. 
     153         *  
     154         * @return Classe de composant. 
     155         */ 
     156        public final IWClasseComposant hGetClasseComposantByUrn(String pUrn) throws Exception { 
     157                /* 
     158                 * IWClasseComposant vResult = null; StringTokenizer vTok = new 
     159                 * StringTokenizer(pUrn, "/"); if (vTok.hasMoreElements()) { vResult = 
     160                 * (IWClasseComposant)fClasseComposants.get(vTok.nextToken()); while 
     161                 * (vTok.hasMoreElements() && vResult != null) { vResult = 
     162                 * vResult.hGetClasseCompAssoc(vTok.nextToken()); } } return vResult; 
     163                 */ 
     164                return (IWClasseComposant) fClasseComposants.get(pUrn); 
     165        } 
     166 
     167        /** 
     168         * Renvoit la classe de composant déclarée comme principale de code pCode. 
     169         *  
     170         * @return Classe de composant. 
     171         */ 
     172        public final IWClasseComposant hGetClasseComposantPrincByCode(String pCode) throws Exception { 
     173                return (IWClasseComposant) fClasseComposants.get(pCode); 
     174        } 
     175 
     176        /** 
     177         * @return String Code 
     178         */ 
     179        public final String hGetCode() { 
     180                return fCode; 
     181        } 
     182 
     183        /** 
     184         * @return com.scenari.m.co.univers.IWInstancesMgr 
     185         */ 
     186        public final IWContenuMgr hGetContenuMgr() throws Exception { 
     187                return fContenuMgr; 
     188        } 
     189 
     190        /** 
     191         * Renvoit le cotexte d'execution de type pType. 
     192         *  
     193         * @return com.scenari.m.co.univers.IWContextExec 
     194         * @param pType 
     195         *            java.lang.String 
     196         */ 
     197        public final IWContextExec hGetContextExec(java.lang.String pType) { 
     198 
     199                IWContextExec vResult = null; 
     200 
     201                if (fContextsExecs != null) { 
     202                        for (int i = 0; i < fContextsExecs.length; i++) { 
     203                                if (fContextsExecs[i].hGetType().equals(pType)) { 
     204                                        vResult = fContextsExecs[i]; 
     205                                        break; 
     206                                } 
     207                        } 
     208                } 
     209 
     210                return vResult; 
     211        } 
     212 
     213        /** 
     214         * Renvoit le contexte d'execution de type HttpServlet. 
     215         *  
     216         * @return com.scenari.m.co.univers.HContextExecHttpServlet 
     217         */ 
     218        public final HContextExecHttpServlet hGetContextExecHttpServlet() { 
     219                return fContextExecHttpServlet; 
     220        } 
     221 
     222        /** 
     223         *  
     224         */ 
     225        public final IHSource hGetEspace(String pCodeEspace) { 
     226                HEspaceUnivers vEspace = (HEspaceUnivers) fEspaces.get(pCodeEspace); 
     227                if (vEspace != null) { return vEspace.hGetRoot(); } 
     228                return null; 
     229        } 
     230 
     231        /* 
     232         * (non-Javadoc) 
     233         *  
     234         * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceComposants() 
     235         */ 
     236        public final IHSource hGetEspaceComposants() { 
     237                return fEspaceComposants.hGetRoot(); 
     238        } 
     239 
     240        /* 
     241         * (non-Javadoc) 
     242         *  
     243         * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceFormations() 
     244         */ 
     245        public final IHSource hGetEspaceFormations() { 
     246                return fEspaceFormations.hGetRoot(); 
     247        } 
     248 
     249        /* 
     250         * (non-Javadoc) 
     251         *  
     252         * @see com.scenari.m.co.univers.IWUnivers#hGetEspacePublications() 
     253         */ 
     254        public final IHSource hGetEspacePublications() { 
     255                return fEspacePublication.hGetRoot(); 
     256        } 
     257 
     258        /* 
     259         * (non-Javadoc) 
     260         *  
     261         * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceSources() 
     262         */ 
     263        public final IHSource hGetEspaceSources() { 
     264                return fEspaceSource.hGetRoot(); 
     265        } 
     266 
     267        /* 
     268         * (non-Javadoc) 
     269         *  
     270         * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceUnivers() 
     271         */ 
     272        public final IHSource hGetEspaceUnivers() { 
     273                return fEspaceUnivers.hGetRoot(); 
     274        } 
     275 
     276        /** 
     277         *  
     278         */ 
     279        public final IWInstancesMgr hGetInstancesMgr() throws Exception { 
     280                return fInstancesMgr; 
     281        } 
     282 
     283        /** 
     284         *  
     285         */ 
     286        public final java.lang.String hGetIntitule() { 
     287                return fIntitule; 
     288        } 
     289 
     290        /** 
     291         * Retourne le service de l'univers de code pCode. 
     292         *  
     293         * @return Service de l'univers. 
     294         * @param pCode 
     295         *            Code du service. 
     296         */ 
     297        public final IWService hGetService(String pCode) { 
     298                return (IWService) fServices.get(pCode); 
     299        } 
     300 
     301        /** 
     302         * Retourne le service par défaut de l'univers ("home page" de l'univers). 
     303         */ 
     304        public final IWService hGetServiceAccueil() throws Exception { 
     305                IWService vService = hGetService("accueil"); 
     306                if (vService == null) { 
     307                        vService = hGetService("acceuil"); // Faute d'orthographe 
     308                                                                                                // historique (!) maintenu pour 
     309                                                                                                // la compatibilité avec 
     310                        // l'IHM2 et le projet Espass. 
     311                        if (vService == null) { throw HLogMgr.hNewException("Erreur de paramétrage de l'univers : il n'existe aucun service d'univers avec le code 'accueil' (ou 'acceuil')."); } 
     312                } 
     313                return vService; 
     314        } 
     315 
     316        /** 
     317         *  
     318         */ 
     319        public boolean hHaveService(java.lang.String pCode) { 
     320                return fServices.get(pCode) != null; 
     321        } 
     322 
     323        /** 
     324         *  
     325         */ 
     326        public final void hSetEspace(HEspaceUnivers pEspace) { 
     327                String vCode = pEspace.hGetCodeEspace(); 
     328                if (ESPACE_COMPOSANT.equals(vCode)) { 
     329                        fEspaceComposants = pEspace; 
     330                } else if (ESPACE_FORMATION.equals(vCode)) { 
     331                        fEspaceFormations = pEspace; 
     332                } else if (ESPACE_PUBLICATION.equals(vCode)) { 
     333                        fEspacePublication = pEspace; 
     334                } else if (ESPACE_SOURCE.equals(vCode)) { 
     335                        fEspaceSource = pEspace; 
     336                } else if (ESPACE_UNIVERS.equals(vCode)) { 
     337                        fEspaceUnivers = pEspace; 
     338                } 
     339                fEspaces.put(vCode, pEspace); 
     340        } 
     341 
     342        /** 
     343         *  
     344         */ 
     345        public final void hSetIntitule(java.lang.String pIntitule) { 
     346                fIntitule = pIntitule; 
     347        } 
     348 
     349        /** 
     350         *  
     351         */ 
     352        public String toString() { 
     353                return "<univers code=\"" + fCode + "\"/>"; 
     354        } 
     355 
     356        /** 
     357         * Ajoute une classe de composant à l'univers. 
     358         *  
     359         * @param pClasseComp 
     360         *            Classe de composant principal 
     361         */ 
     362        public final void wAddClasseComposant(IWClasseComposant pClasseComp) { 
     363                fClasseComposants.put(pClasseComp.hGetUrn(), pClasseComp); 
     364        } 
     365 
     366        /** 
     367         * Ajoute une classe de composant principal à l'univers. 
     368         *  
     369         * @param pClasseComp 
     370         *            Classe de composant principal 
     371         */ 
     372        public final void wAddClasseComposantPrincipal(IWClasseComposant pClasseComp) { 
     373                fClasseComposants.put(pClasseComp.hGetCode(), pClasseComp); 
     374                fClasseComposants.put(pClasseComp.hGetUrn(), pClasseComp); 
     375        } 
     376 
     377        /** 
     378         * Ajoute un contexte d'execution à l'univers. Si un contexte du même type 
     379         * existait déjà, ce contexte est remplacé par le nouveau. 
     380         *  
     381         * @param pContextExec 
     382         *            com.scenari.m.co.univers.IWContextExec 
     383         */ 
     384        public final synchronized void wAddContextExec(IWContextExec pContextExec) { 
     385 
     386                if (fContextsExecs == null) { 
     387                        // Aucun contexte d'associe, on ajoute ce 1er contexte. 
     388                        fContextsExecs = new IWContextExec[1]; 
     389                        fContextsExecs[0] = pContextExec; 
     390                } else { 
     391 
     392                        // On cherche un contexte du même type. 
     393                        for (int i = 0; i < fContextsExecs.length; i++) { 
     394                                if (fContextsExecs[i].hGetType().equals(pContextExec.hGetType())) { 
     395                                        // On a trouvé un ancien context du même type, on le 
     396                                        // remplace. 
     397                                        fContextsExecs[i] = pContextExec; 
     398                                        return; 
     399                                } 
     400                        } 
     401 
     402                        // Aucun contexte du meme type, on l'ajoute. 
     403                        IWContextExec[] vNewTab = new IWContextExec[fContextsExecs.length + 1]; 
     404                        System.arraycopy(fContextsExecs, 0, vNewTab, 0, fContextsExecs.length); 
     405                        vNewTab[fContextsExecs.length] = pContextExec; 
     406                        fContextsExecs = vNewTab; 
     407 
     408                } 
     409 
     410                // Traitement spécifique du context HttpServlet 
     411                if (IWContextExec.TYPE_HTTP_SERVLET.equals(pContextExec.hGetType())) { 
     412                        fContextExecHttpServlet = (HContextExecHttpServlet) pContextExec; 
     413                } 
     414 
     415        } 
     416 
     417        /** 
     418         * Ajoute un service à l'univers. 
     419         *  
     420         * @param pService 
     421         *            Service de l'univers. 
     422         */ 
     423        public synchronized final void wAddService(IWService pService) throws Exception { 
     424                fServices.put(pService.hGetCode(), pService); 
     425                hGetContenuMgr().hInitServiceUnivers(pService); 
     426        } 
     427 
     428        /** 
     429         * Supprime définitivement l'univers. 
     430         */ 
     431        public final void wRemove() throws Exception { 
     432 
     433                // Suppression des univers. 
     434                if (fServices != null) { 
     435                        Iterator vIt = fServices.values().iterator(); 
     436                        while (vIt.hasNext()) { 
     437                                try { 
     438                                        ((IWService) vIt.next()).wRemoveService(); 
     439                                } catch (Exception e) { 
     440                                        HLogMgr.hPublishException(e, "Echec à la suprression d'un service de l'univers " + this); 
     441                                } 
     442                        } 
     443                } 
     444 
     445                fActeursMgr = new HUserMgrFs(this); 
     446 
     447                // Manager d'instances 
     448                if (fInstancesMgr != null) { 
     449                        fInstancesMgr.wRemoveUnivers(); 
     450                } 
     451 
     452                // On supprime tous les fichiers de l'espace publications 
     453                if (hGetEspacePublications() != null) { 
     454                        hGetEspacePublications().hFindElemByPath(null).hRemove(); 
     455                } 
     456 
     457                // On supprime tous les fichiers de l'espace composants 
     458                if (hGetEspaceComposants() != null) { 
     459                        hGetEspaceComposants().hFindElemByPath(null).hRemove(); 
     460                } 
     461                // On supprime tous les fichiers de l'espace Formations (instances) 
     462                if (hGetEspaceFormations() != null) { 
     463                        hGetEspaceFormations().hFindElemByPath(null).hRemove(); 
     464                } 
     465                // On supprime tous les fichiers de l'espace Formations (instances) 
     466                if (hGetEspaceUnivers() != null) { 
     467                        hGetEspaceUnivers().hFindElemByPath(null).hRemove(); 
     468                } 
     469        } 
     470 
     471        /** 
     472         * @see com.scenari.m.co.univers.IWUnivers#wSetContenuMgr(com.scenari.m.co.univers.IWContenuMgr) 
     473         */ 
     474        public final void wSetContenuMgr(IWContenuMgr pContenuMgr) throws Exception { 
     475                fContenuMgr = pContenuMgr; 
     476                fContenuMgr.wInitBegin(this); 
     477        } 
     478 
     479        /** 
     480         * @see com.scenari.m.co.univers.IWUnivers#wSetInstancesMgr(com.scenari.m.co.univers.IWInstancesMgr) 
     481         */ 
     482        public final void wSetInstancesMgr(IWInstancesMgr pInstancesMgr) throws Exception { 
     483                fInstancesMgr = pInstancesMgr; 
     484                fInstancesMgr.wInitBegin(this); 
     485        } 
     486 
     487        /** 
     488         * Désactive et décharge l'univers de la mémoire. 
     489         *  
     490         */ 
     491        public final void wUnload() throws Exception { 
     492 
     493                // On laisse le garbage collector faire le ménage. On ne tue rien pour 
     494                // laisser le tratiement en cours 
     495                // s'exécuter correctement. 
     496 
     497                // ###### Envisager fonction Unload des services, etc. 
     498 
     499                /* 
     500                 * fEspaceSource = null; fEspaceComposants = null; fEspacePublication = 
     501                 * null; fEspaceFormations = null; fEspaceActeurs = null; fEspaceUnivers = 
     502                 * null; fPrescFormations = null; fActeurs = null; fClasseComposants = 
     503                 * null; fServices = null; fContextExecHttpServlet = null; 
     504                 * fContextsExecs = null; fInstancesMgr = null; fPrefixResolverDefault = 
     505                 * null; 
     506                 */ 
     507                try { 
     508                        if (fContenuMgr != null) fContenuMgr.wUnloadUnivers(); 
     509                } catch (Exception e) { 
     510                        HLogMgr.hPublishException(e); 
     511                } 
     512                try { 
     513                        if (fInstancesMgr != null) fInstancesMgr.wUnloadUnivers(); 
     514                } catch (Exception e) { 
     515                        HLogMgr.hPublishException(e); 
     516                } 
     517                if (fServices != null) { 
     518                        for (Iterator vIt = fServices.values().iterator(); vIt.hasNext();) { 
     519                                IWService vService = (IWService) vIt.next(); 
     520                                try { 
     521                                        vService.wRemoveService(); 
     522                                } catch (Exception e) { 
     523                                        HLogMgr.hPublishException(e); 
     524                                } 
     525                        } 
     526                } 
     527        } 
     528 
     529        /** 
     530         * Initialisation de l'univers. Appelé juste après l'instanciation de 
     531         * l'objet. 
     532         *  
     533         */ 
     534        public final void xInitBegin() throws Exception { 
     535 
     536                fActeursMgr = new HUserMgrFs(this); 
     537 
     538                // fContenuMgr = new com.scenari.m.co.univers.fs.WContenuMgrFs(); 
     539                // fContenuMgr.wInitBegin(this); 
     540        } 
     541 
     542        /** 
     543         * Fin de l'Initialisation de l'univers. Appelé après le parsing du fichier 
     544         * d'init. 
     545         *  
     546         */ 
     547        public final void xInitEnd() throws Exception { 
     548 
     549                if (fContenuMgr == null) { 
     550                        // Pas de ContenuMgr déclaré, on en crée un par défaut. 
     551                        fContenuMgr = new WContenuMgrWsp(); 
     552                        fContenuMgr.wInitBegin(this); 
     553                } 
     554                fContenuMgr.wInitEnd(this); 
     555 
     556                if (fInstancesMgr == null) { 
     557                        // Pas d'instance Mgr de paramétré = Donc on crée l'IntanceMgr par 
     558                        // défaut. 
     559                        throw HLogMgr.hNewException("No instancemgr defined in universe " + fCode); 
     560                } 
     561                fInstancesMgr.wInitEnd(this); 
     562        } 
    569563} 
Note: See TracChangeset for help on using the changeset viewer.