IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Portails Java Discussion :

IPC entre deux war [JBoss Portal]


Sujet :

Portails Java

  1. #1
    Membre averti
    Avatar de natoine
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Décembre 2007
    Messages
    393
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chercheur en informatique

    Informations forums :
    Inscription : Décembre 2007
    Messages : 393
    Points : 343
    Points
    343
    Par défaut IPC entre deux war
    Je comprends pas.
    Je tente de faire de l'ipc entre deux portlets qui sont dans deux wars différents et ça ne marche pas.
    En fait ça marche très bien si mes events sont des String.
    Si je veux passer un objet à ma sauce, là ça ne marche plus...
    Pourtant j'ai bien mis l'annotation @XmlRootElement

    L'envoi de l'event se fait bien.
    Mais le portlet qui écoute ne fait rien du tout de son côté.
    Et je n'ai pas d'erreur remontée par jboss.

    Voilà mon code du portlet qui envoie l'event :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    ...
    UserAccount _user = new UserAccount();
    this.sendEvent("UserLog", _user, response);
    ...
    private void sendEvent(String _event_type , Serializable _event_object , ActionResponse response)
    	{
    		System.out.println("[BrowserPortlet.sendEvent] type : " + _event_type + " value : " + _event_object);
    		response.setEvent(_event_type, _event_object);
    	}
    Le code du portlet qui est censé écouter l'event :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
     public void processEvent(EventRequest request, EventResponse response)
    	{
    		Event event = request.getEvent();
    		System.out.println("[PortletCreateAnnotation.processEvent] event : " + event.getName());
    		String _event_name = event.getName() ;
    		if(_event_name.equalsIgnoreCase("UserLog"))
    		{
    			if(event.getValue() instanceof UserAccount)
    			{
    				UserAccount _current_user = (UserAccount)event.getValue() ;
    				if(_current_user.getId() != null) request.getPortletSession().setAttribute("user", _current_user);
    			}
    		}
    }
    Le descripteur portlet.xml du premier portlet :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    <?xml version="1.0" encoding="UTF-8"?>
    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
                 version="2.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
          http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
       <portlet>
          <portlet-name>PortletLogin</portlet-name>
     	<portlet-class>fr.natoine.PortletUserAccount.PortletLogin</portlet-class>
          <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>VIEW</portlet-mode>
             <portlet-mode>HELP</portlet-mode>
             <portlet-mode>EDIT</portlet-mode>
          </supports>
          <portlet-info>
             <title>Se connecter</title>
          </portlet-info> 
           <supported-publishing-event>
    		<qname>UserLog</qname>
    	  </supported-publishing-event>
    	  <supported-publishing-event>
    		<qname>UserUnLog</qname>
    	  </supported-publishing-event>
    	  <supported-publishing-event>
    		<qname>newApplicationName</qname>
    	  </supported-publishing-event>
       </portlet>
     
        <portlet>
          <portlet-name>PortletInscription</portlet-name>
     	<portlet-class>fr.natoine.PortletUserAccount.PortletInscription</portlet-class>
          <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>VIEW</portlet-mode>
             <portlet-mode>HELP</portlet-mode>
          </supports>
          <portlet-info>
             <title>Créer un compte</title>
          </portlet-info> 
    	  <supported-processing-event>
    		<qname>newApplicationName</qname>
    	  </supported-processing-event>
       </portlet>
     
        <event-definition>
    		<qname>UserLog</qname>
    		<value-type>fr.natoine.model_user.UserAccount</value-type>
    	</event-definition>
    	 <event-definition>
    		<qname>UserUnLog</qname>
    		<value-type>java.lang.String</value-type>
    	</event-definition>
    	 <event-definition>
    		<qname>newApplicationName</qname>
    		<value-type>java.lang.String</value-type>
    	</event-definition>
    </portlet-app>
    Le descripteur du deuxième portlet :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    <?xml version="1.0" encoding="UTF-8"?>
    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
                 version="2.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
          http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
       <portlet>
          <portlet-name>PortletCreateAnnotation</portlet-name>
     	<portlet-class>fr.natoine.PortletAnnotation.PortletCreateAnnotation</portlet-class>
          <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>VIEW</portlet-mode>
             <portlet-mode>HELP</portlet-mode>
          </supports>
          <portlet-info>
             <title>portlet de création d'annotations</title>
          </portlet-info>
           <supported-processing-event>
    		<qname>selection</qname>
    	  </supported-processing-event> 
    	   <supported-processing-event>
    		<qname>UserLog</qname>
    	  </supported-processing-event>
    	  <supported-processing-event>
    		<qname>UserUnLog</qname>
    	  </supported-processing-event>
    	    <supported-processing-event>
    		<qname>loadedurl</qname>
    	  </supported-processing-event> 
    	  <supported-publishing-event>
    		<qname>highlight</qname>
    	  </supported-publishing-event>
       </portlet>
     
        <event-definition>
    		<qname>UserLog</qname>
    		<value-type>fr.natoine.model_user.UserAccount</value-type>
    	</event-definition>
       <event-definition>
    		<qname>selection</qname>
    		<value-type>fr.natoine.model_htmlDocs.HighlightSelectionHTML</value-type>
    	</event-definition>
    	 <event-definition>
    		<qname>UserUnLog</qname>
    		<value-type>java.lang.String</value-type>
    	</event-definition>
    	<event-definition>
    		<qname>highlight</qname>
    		<value-type>java.util.ArrayList</value-type>
    	</event-definition>
    	<event-definition>
    		<qname>loadedurl</qname>
    		<value-type>java.lang.String</value-type>
    	</event-definition>
    </portlet-app>
    www.natoine.fr
    natoine.developpez.com
    Principalement du Java avec un soupçon de réseaux sociaux.

  2. #2
    Membre averti
    Avatar de natoine
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Décembre 2007
    Messages
    393
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chercheur en informatique

    Informations forums :
    Inscription : Décembre 2007
    Messages : 393
    Points : 343
    Points
    343
    Par défaut
    Arf.
    Alors si ça marche.
    Ca ne marche pas juste dans le cas ou mon objet est persistant JPA...

    Voilà une classe qui marche :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    package fr.natoine.model_htmlDocs;
     
    import java.io.Serializable;
     
    import javax.xml.bind.annotation.XmlRootElement;
     
    @XmlRootElement
    public class HighlightSelectionHTML implements Serializable
    {
    	private SelectionHTML selection ;
    	private String style;
     
    	public SelectionHTML getSelection() {
    		return selection;
    	}
    	public void setSelection(SelectionHTML selection) {
    		this.selection = selection;
    	}
    	public String getStyle() {
    		return style;
    	}
    	public void setStyle(String style) {
    		this.style = style;
    	}
    }
    Et la classe qui ne marche pas :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    package fr.natoine.model_user;
     
    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.Table;
    import javax.persistence.UniqueConstraint;
    import javax.xml.bind.annotation.XmlRootElement;
     
    import fr.natoine.model_resource.Resource;
    import fr.natoine.model_resource.ResourceRepresentable;
     
    @Entity
    @Table(name = "USERACCOUNT" ,
    		uniqueConstraints=@UniqueConstraint(columnNames = {"PSEUDO" , "APPLICATION_ID"}))
    @XmlRootElement
    public class UserAccount extends Agent implements ResourceRepresentable 
    {
    	@Column(name = "PSEUDO" , nullable=false)
    	private String pseudonyme;
     
    	@Column(name = "PASSWORD")
    	private String password;
     
    	@ManyToOne(cascade = CascadeType.ALL, targetEntity = Person.class)
    	@JoinColumn(name = "PERSON_ID")
    	private Person user;
     
    	@ManyToOne(cascade = CascadeType.ALL, targetEntity = Resource.class)
    	@JoinColumn(name = "RESOURCE_ID" , nullable=false)
    	private Resource represents;
     
    	/**
             * Gets the Resource that represents the UserAccount.
             * A UserAccount must be represented by a Resource.
             * The Resource can represent many other things and is not necessary accessible. 
             * @return
             */
    	public Resource getRepresents() {
    		return represents;
    	}
    	/**
             * Sets the Resource that represents the UserAccount.
             * A UserAccount must be represented by a Resource.
             * The Resource can represent many other things and is not necessary accessible. 
             * @param 
             */
    	public void setRepresents(Resource represents) {
    		this.represents = represents;
    	}
    	/**
             * Gets the pseudonyme of the person for this UserAccount
             * @return
             */
    	public String getPseudonyme() {
    		return pseudonyme;
    	}
    	/**
             * Sets the pseudonyme of the person for this UserAccount
             * @param
             */
    	public void setPseudonyme(String pseudonyme) {
    		this.pseudonyme = pseudonyme;
    	}
    	/**
             * Gets the user/person associated to this account.
             * @return a Person
             */
    	public Person getUser() {
    		return user;
    	}
    	/**
             * Sets the user/person associated to this account
             * @param user
             */
    	public void setUser(Person user) {
    		this.user = user;
    	}
    	/**
             * Gets the password of the UserAccount
             * TODO : encrypt this method
             * @return
             */
    	public String getPassword() {
    		return password;
    	}
    	/**
             * Sets the password of the UserAccount
             * TODO : encrypt this method
             * @param password
             */
    	public void setPassword(String password) {
    		this.password = password;
    	}
    }
    www.natoine.fr
    natoine.developpez.com
    Principalement du Java avec un soupçon de réseaux sociaux.

  3. #3
    Membre averti
    Avatar de natoine
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Décembre 2007
    Messages
    393
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chercheur en informatique

    Informations forums :
    Inscription : Décembre 2007
    Messages : 393
    Points : 343
    Points
    343
    Par défaut
    C'est super stupide comme problème et ça risque d'en aider plus d'un.
    En fait, il faut que l'annotation @XmlRootElement soit après les annotations JPA.
    En gros ça donne ça pour ma classe UserAccount :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    @Entity
    @Table(name = "USERACCOUNT" ,
    		uniqueConstraints=@UniqueConstraint(columnNames = {"PSEUDO" , "APPLICATION_ID"}))
    @XmlRootElement
    public class UserAccount extends Agent implements ResourceRepresentable
    {
    www.natoine.fr
    natoine.developpez.com
    Principalement du Java avec un soupçon de réseaux sociaux.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. IPC: communication entre deux exe delphi
    Par ed973 dans le forum API, COM et SDKs
    Réponses: 3
    Dernier message: 10/04/2013, 14h29
  2. Dépendance entre deux WAR
    Par obalais dans le forum Maven
    Réponses: 1
    Dernier message: 24/06/2009, 10h33
  3. Temps de réponse entre deux sites
    Par coup dur dans le forum Décisions SGBD
    Réponses: 6
    Dernier message: 16/10/2003, 15h26
  4. Connexion entre deux ordi [Débutant]
    Par Ryadus dans le forum Développement
    Réponses: 2
    Dernier message: 12/06/2003, 21h47
  5. Réponses: 5
    Dernier message: 25/03/2003, 19h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo