Access to private parts of a package in classes shared in Eclipse projects

I have a model class ( MVC pattern ) that I use in two Eclipse projects.

One project, calling it Producer, captures data from the stream and stores it in the database. The model class ObjectModelunder consideration, for example , is used to deserialize a stream for manipulations before serialization and storage in db.

Another project, calling him Consumer, pulls out the data stored in the database, and visualizes them on the screen. It uses the same model class to deserialize stored data for use in a visualization application.

I planned to put ObjectModelin an Eclipse project to share my source in projects Producerand Consumer. However, each application has classes located in the same package that use the private access modifier to get and set fields in ObjectModel.

Is there any way to share the source in several Eclipse projects and still maintain private sharing with the public?

UPDATE . I'm having trouble getting code for shared Eclipse projects, so I didn’t just try this before posting. Finally, this piece worked and wrote it as another answer here .

+5
source share
2 answers

Producer Consumer , ObjectModel, .

(getters seters) ObjectModel.

+1

@GreyBeardedGeek :

Producer Consumer , ObjectModel, .

++ Java. , . , " " Java . , ... , , , Heper. :

public class SomeClass {
 void foo(){...
 }
}

public class SomeClassHelper {
 private SomeClass someClass;
 public SomeClassHelper(SomeClass someClass){
  //you can do it better this with some DI Framework,
  //for illustration purpose
  this.someClass=someClass;
 }

 public SomeClassHelper(){
  //for illustration purpose only
  this.someClass=new SomeClass();
 }

 **public** void foo(){
    //this is punch line
    someClass.foo();
  }

}

SomeClassHelper , SomeClass, SomeClassHelper .

+1

All Articles