• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Design Question: Passing objects without direct use

 
Ranch Hand
Posts: 120
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question in regards to passing objects into methods that don't directly use the object, but pass them to other methods. This object requires a spring bean. Is this a bad idea and a sign of a design problem? In the code below ExpeditionEntitiesService is the object which requires the spring bean (BcidService). Do you have any suggestions on how I can make this code better?

Here is a REST service which uploads a file:

The next class is used to convert the file to triples to be stored in Apache fuseki TBD:


The next class is used by the Triplifier to generate the mapping file used to create the triples:



The next class is used to get the unique persistent identifier for the triples. Here is where I need the spring bean (BcidService):



 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a lot of code

Can you show us only the code where you have the problem, I can't figure out which Spring bean you are passing to another method. Just remove the irrelevant code (like file creation code, methods which don't have anything to do with the design problem etc).

I never had to pass a Spring bean to another method because my Spring beans interact with other Spring beans. So if the other Spring bean which I'm calling also depends on another bean it can get it injected. So in your case when you are passing a Spring bean to another object, can you make that object a Spring bean? If you are creating new object because you need a new object with each request or user, then you can declare your spring bean with different scopes like Request or Session or Prototype...
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic