[GeoNetwork-devel] Spring beans in Geonetwork

Hi

With the changes for Spring JPA, DataManager, SettingManager, etc. are managed as Spring beans, but the way to obtain them is not clear to me:

For example, for DataManager I see code like:

GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dm = gc.getBean(DataManager.class);

But for SettingManager:

SettingManager sm = context.getBean(SettingManager.class);

What is the rule to use ServiceContext of GeonetContext to get the beans?

Regards,
Jose García


GeoCat Bridge for ArcGIS allows instant publishing of data and metadata on GeoServer and GeoNetwork. Visit http://geocat.net for details.


Jose García
GeoCat bv
Veenderweg 13
6721 WD Bennekom
The Netherlands
http://GeoCat.net

Hi Jose,

All the methods just delegate to ApplicationContext.getBean(). They are therefore short for: gc.getApplicationContext().getBean(). or context.getApplicationContext.getBean().

The reason both have them is a historical issue. When first ApplicationContext was added it was only added to GeonetContext. Later (in a later version) it was added to ServiceContext. In the long run it should be removed from GeonetContext and only be in ServiceContext. It could be argued as well that even ServiceContext should not have it and the dependencies should be Autowired everywhere.

Jesse

···

On Wed, Nov 13, 2013 at 2:14 PM, Jose Garcia <jose.garcia@anonymised.com> wrote:

Hi

With the changes for Spring JPA, DataManager, SettingManager, etc. are managed as Spring beans, but the way to obtain them is not clear to me:

For example, for DataManager I see code like:

GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dm = gc.getBean(DataManager.class);

But for SettingManager:

SettingManager sm = context.getBean(SettingManager.class);

What is the rule to use ServiceContext of GeonetContext to get the beans?

Regards,
Jose García


GeoCat Bridge for ArcGIS allows instant publishing of data and metadata on GeoServer and GeoNetwork. Visit http://geocat.net for details.


Jose García
GeoCat bv
Veenderweg 13
6721 WD Bennekom
The Netherlands
http://GeoCat.net


DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk


GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

Hi Jesse

Thanks for the explanation, for now will get directly from the ServiceContext then.

Another question related to the entities, in Spring JPA there’s a class AbstractPersistable that provides the entities Id and equals and hashCode methods.

Do you think that should be fine that GeonetEntity extends this class and remove the id, equals and hashCode from actual entities or can be problematic?

Regards,
Jose García

···

On Wed, Nov 13, 2013 at 2:18 PM, Jesse Eichar <jesse.eichar@anonymised.com> wrote:

Hi Jose,

All the methods just delegate to ApplicationContext.getBean(). They are therefore short for: gc.getApplicationContext().getBean(). or context.getApplicationContext.getBean().

The reason both have them is a historical issue. When first ApplicationContext was added it was only added to GeonetContext. Later (in a later version) it was added to ServiceContext. In the long run it should be removed from GeonetContext and only be in ServiceContext. It could be argued as well that even ServiceContext should not have it and the dependencies should be Autowired everywhere.

Jesse


GeoCat Bridge for ArcGIS allows instant publishing of data and metadata on GeoServer and GeoNetwork. Visit http://geocat.net for details.


Jose García
GeoCat bv
Veenderweg 13
6721 WD Bennekom
The Netherlands
http://GeoCat.net

On Wed, Nov 13, 2013 at 2:14 PM, Jose Garcia <jose.garcia@anonymised.com> wrote:

Hi

With the changes for Spring JPA, DataManager, SettingManager, etc. are managed as Spring beans, but the way to obtain them is not clear to me:

For example, for DataManager I see code like:

GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dm = gc.getBean(DataManager.class);

But for SettingManager:

SettingManager sm = context.getBean(SettingManager.class);

What is the rule to use ServiceContext of GeonetContext to get the beans?

Regards,
Jose García


GeoCat Bridge for ArcGIS allows instant publishing of data and metadata on GeoServer and GeoNetwork. Visit http://geocat.net for details.


Jose García
GeoCat bv
Veenderweg 13
6721 WD Bennekom
The Netherlands
http://GeoCat.net


DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk


GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

I have not looked at AbstractPersistable. It could be that we can use it. We have to be a bit careful since we need to carefully map our id and sometimes we need out own hashCode and equals… That said I think we should be able to override them in most cases when we need to.

Jesse

···

On Wed, Nov 13, 2013 at 2:24 PM, Jose Garcia <jose.garcia@anonymised.com> wrote:

Hi Jesse

Thanks for the explanation, for now will get directly from the ServiceContext then.

Another question related to the entities, in Spring JPA there’s a class AbstractPersistable that provides the entities Id and equals and hashCode methods.

Do you think that should be fine that GeonetEntity extends this class and remove the id, equals and hashCode from actual entities or can be problematic?

Regards,
Jose García

On Wed, Nov 13, 2013 at 2:18 PM, Jesse Eichar <jesse.eichar@anonymised.com…189…> wrote:

Hi Jose,

All the methods just delegate to ApplicationContext.getBean(). They are therefore short for: gc.getApplicationContext().getBean(). or context.getApplicationContext.getBean().

The reason both have them is a historical issue. When first ApplicationContext was added it was only added to GeonetContext. Later (in a later version) it was added to ServiceContext. In the long run it should be removed from GeonetContext and only be in ServiceContext. It could be argued as well that even ServiceContext should not have it and the dependencies should be Autowired everywhere.

Jesse


GeoCat Bridge for ArcGIS allows instant publishing of data and metadata on GeoServer and GeoNetwork. Visit http://geocat.net for details.


Jose García
GeoCat bv
Veenderweg 13
6721 WD Bennekom
The Netherlands
http://GeoCat.net

On Wed, Nov 13, 2013 at 2:14 PM, Jose Garcia <jose.garcia@anonymised.com> wrote:

Hi

With the changes for Spring JPA, DataManager, SettingManager, etc. are managed as Spring beans, but the way to obtain them is not clear to me:

For example, for DataManager I see code like:

GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dm = gc.getBean(DataManager.class);

But for SettingManager:

SettingManager sm = context.getBean(SettingManager.class);

What is the rule to use ServiceContext of GeonetContext to get the beans?

Regards,
Jose García


GeoCat Bridge for ArcGIS allows instant publishing of data and metadata on GeoServer and GeoNetwork. Visit http://geocat.net for details.


Jose García
GeoCat bv
Veenderweg 13
6721 WD Bennekom
The Netherlands
http://GeoCat.net


DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk


GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork