• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Question about accessing /restriction on public objects

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 4 differnt java applications

Client ----- Engine ------ Java Classes ------ Server

In "Java classes" module I have the two public classess public class A and public class B

my client can access class A throuhg engine but at the same time I dont want to give the access of public clas B to the client. in this case I could think making class B as private/protected but I can not do this because In my server module I need object of Class B thats the root cause of making these classes public

I am thinkning about the following solutions
1. add the key in these clasess and give the access to these classes depending upon the key thay client is passing - but it requried lots of code changes

is there any best solution for this problem



Thanks,
Santosh ( )
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of exposing the complete Object B to the client, who don't you create an interface which encapsulates just those methods the client should see?
 
Santosh Maskar
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
Instead of exposing the complete Object B to the client, who don't you create an interface which encapsulates just those methods the client should see?



Because I need the same object in my Server module.

I found one solution for this problme but I am not happy with this


Customize scoping with object keys
[ December 22, 2005: Message edited by: Santosh Maskar ]
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you give the necessary visibility by adjusting packages and classpath setting?
 
Santosh Maskar
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My question is like I already explained.

How can I restric the access of public class for one application and at the same time I need these public classes in my other application.
 
Ulf Dittmer
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Because I need the same object in my Server module.


Yes, you would use the object in the Server app, but you would define the client API so that it only deals in terms of the interface (which the object implements), not in terms of the object itself.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can introduce a layer of public objects that hides a layer of private objects.

This doesn't prevent a Client coder from using the ServerAPI unless you can somehow avoid distributing the ServerAPI class to the client team.

It's a little odd to have both client and server depending on JavaClasses. It might be a global framework, a case of really cool Dependency Inversion or a case of circular dependencies. Why does that happen?
[ December 22, 2005: Message edited by: Stan James ]
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic