• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Package Design

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys, Here Jerry again.

I have one more question.
Listen, I'm done my Data class which implements DBAccess.

And I want to make a business class to wrap the Data class.
so that I try to use it both standalone and network.

I made a interface which included booking, search method.
and I would implement LocalBusiness and RemoteBusiness.
LocalBusiness directly use Data class.
RemoteBusiness is just adaptor for LocalBusiness.
when the client is executed in standalone mode then I just use LocalService.
when the client is executed in network mode then I use RemoteService.

Please note to me If there is something that I missed. ^__^

Thanks for regards.

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jerry,

The code you have submitted will not compile because method signatures in your Service interface reference RemoteException and this exception is checked exception, thus methods in your LocalService class have to reference that RemoteException as well, which is wrong. I believe you need to think how to resolve that problem
 
Jerry Ju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roman.

Thanks for replay.

It doesn't occure any compile error.
And compile error is not important in that code, most important thing is architecture.

please focus on that one. ^__^
 
Ranch Hand
Posts: 123
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And compile error is not important in that code, most important thing is architecture.
In my opinion making use of the decorate design pattern to encapsulate your LocalServiceImpl object in your RemoteServiceImpl is a great idea. More so I have designed a similar service/business layer.

More so I think a major advantage is the all your business logic only exists in one place (LocalServiceImpl) which is neat and clean design and further promotes ease of maintainability.

I think you're on the right track!
 
Roman Yankin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, yes, you are right there are no compile time errors... so, from the architectural point I don't think it is a good idea to implement both LocalService and RemoteService from the java.rmi.Remote interface, thus you say "LocalService is a Remote" class. This is just my opinion, but I think the decoupling has to be made on interface level not on class level.
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Justin, I think it's a good idea! I have implemented the same architecture a couple of days back.
 
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I rather did something like that:



The local Service make no use of "Remote", but rather a higher level IOException. I consider extending "Remote" from your local interface to be wrong. You'll find many threads on this if you search on the forum about throwing IOException from your Services class.

Regards,
Alex
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My suggestion is:
* Create similar interface as provided by Sun, but with all methods throwing RemoteException in addition.
* Make your implementation of Sun interface to implement this new interface as well.
* Make your remote interface to extend this new interface (then it will be empty)
* As to remote implementation class - initialize Sun's interface with local implementation class.
 
reply
    Bookmark Topic Watch Topic
  • New Topic