1 Reply Latest reply on Mar 24, 2003 9:24 AM by Sanne de

    Remote CMR with certain QWAN?

    Sanne de Novice

      Hi,

      It's my understanding that cmr in ejb 2.0 only worls on local interfaces.

      So if I have a remote client creating a person:

      Person p = PersonHome.create("Walter");
      Address a = AddressHome.create("Amsterdam","1045zx","25");

      I can't just stick it in:

      p.setAddress(a);

      Due to the fact that Address is a remote interface.

      Possible soltutions involving Facades and Value objects are possible, but which solution would have a Certain QWAN and not result in setAddressByVO(AddressVO) calling setAddress() with a local refernce?

      I would be obliged!

      Sanne

        • 1. Re: Remote CMR with certain QWAN?
          Sanne de Novice

          O.k. FYI.

          I think I'll revert to the session facades and make it work that way, now I've got:


          public Address getRemoteAddress() {return localToRemote(getAddressLocal());}
          /**
          * @ejb.interface-method view-type="remote"
          */
          public void setRemoteAddress(Address address) {setAddressLocal(remoteToLocal(address));}

          public AddressLocal remoteToLocal(Address remoteAddress){
          if(remoteAddress == null) {return null;}
          try
          {
          AddressLocalHome addressLocalHome = AddressUtil.getLocalHome();
          return addressLocalHome.findByPrimaryKey((String)remoteAddress.getPrimaryKey());

          } catch (NamingException e)
          {
          throw new EJBException("Error converting remote into local Unit", e);
          }
          catch (RemoteException e)
          {
          throw new EJBException("Error converting remote into local Unit", e);

          } catch (FinderException e)
          {
          throw new EJBException("Error converting remote into local Unit", e);
          }
          }
          public Address localToRemote(AddressLocal localAddress){
          if(localAddress == null) {return null;}
          try
          {
          AddressHome addressHome = AddressUtil.getHome();
          return addressHome.findByPrimaryKey((String)localAddress.getPrimaryKey());

          } catch (NamingException e)
          {
          throw new EJBException("Error converting remote into local Unit", e);
          } catch (FinderException e)
          {
          throw new EJBException("Error converting remote into local Unit", e);
          } catch (RemoteException e)
          {
          throw new EJBException("Error converting remote into local Unit", e);
          }
          }