• 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

Spring + MVC pattern in non-web application

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

I am new to Spring MVC (few experience with basic Spring IoC only).
I need to create java standalone application using Spring framework. The design will be using MVC pattern. Actually the VIEW part will be very simple ( can be ignored, no Swing no GUI).
The design will start from a custom Dispatcher to dispatch request to specific Controller, etc.
Some other design features are persistence, transaction management, security, AOP interceptor for logging and validation.

My questions:
1. Is there any way so that I could reuse Spring MVC?
So, far I read, MVC is meant for web application. Can I make (modify) the spring MVC application to be non-web application (normal java).
2. Is there any suggestion how to design and what features of spring can be used?
3. Will other modules of Spring works on the non-web application? such as Spring security, AOP, etc.

Thanks. Looking forward any helpful idea from you guys.

arief
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the client? What transport is needed. Without a GUI, things like Spring Remoting, Spring Web Services, Spring JMS and Spring Integration come to mind as solutions. Spring MVC is for Web development, and I wouldn't want to use it in some other capacity. Spring has all the other options covered with different projects, so we can help steer you in the right direction with more information.

Mark
 
arief hidayat
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Spritzler wrote:What is the client? What transport is needed. Without a GUI, things like Spring Remoting, Spring Web Services, Spring JMS and Spring Integration come to mind as solutions. Spring MVC is for Web development, and I wouldn't want to use it in some other capacity. Spring has all the other options covered with different projects, so we can help steer you in the right direction with more information.

Mark



Hi Mark,
The output of this application is jar file. So, this will be a standalone (non-web application), using MVC pattern + Spring framework.
To be more specific. The client is Oracle BPM. And this jar file will be added as one of its jar dependencies and be called from BPM process activities.
(well, I found the requirement quite strange because usually when talking about Spring, we most likely developing web apps or enterprise apps).
So, the BPM process activity will call the custom Dispatcher. It's normal java call.
Not a remote one. So, not Spring remoting, not Spring WS, not JMS. I am not sure about spring integration (never read about it).

Hope my explanation is clear.
Thanks Marks. Hope you can help


arief
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the funny thing is that Oracle uses BPEL as their web services language. So the question again, is what exactly is Oracle going to call. So you have a jar file, and it loads the classes in the jar file, and calls Java code. The real question is what is that Java Code, and can it pass Java objects, or is it passing in XML. To me it still sounds like something in JBoss Remoting, but still within maybe the same JVM. Something like Burlap or Hessian might work.

We still need more information. But definitely Spring MVC is not your solution.

Mark
 
arief hidayat
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Spritzler wrote:Well the funny thing is that Oracle uses BPEL as their web services language. So the question again, is what exactly is Oracle going to call. So you have a jar file, and it loads the classes in the jar file, and calls Java code. The real question is what is that Java Code, and can it pass Java objects, or is it passing in XML. To me it still sounds like something in JBoss Remoting, but still within maybe the same JVM. Something like Burlap or Hessian might work.

We still need more information. But definitely Spring MVC is not your solution.

Mark



I am sorry my explanation is not so clear.

let me give analogue..
It's the same like when you create a java application with logging features you need to add log4j.jar. In this analogue the java application is the BPM, and the log4j.jar is the application that I need to create.
Umm.. perhaps I should use term 'java library' instead of 'java application'.

Oracle BPM and this java library will share same set of data objects.

The process might be like this:
1. Oracle BPM will call custom dispatcher of this java library by passing some of those shared data objects. (Spring AOP interceptor will be applied for logging etc)
2. custom dispatcher will dispatch the request to one of controller (this step defined in spring configuration).
3. the controller will do business logic (do remote EJB call to other components), then it delegate to DAO level to persist the result into local DB (might use ORM like Hibernate).


there will be no XML here. Its normal method call. BPM passes object as input parameter and the java library will return java object (if any).
There will be no remoting. All in the same JVM.

It's like developing sets of J2SE API with using the power of Spring Framework (for IoC, AOP, security, etc).. and the design pattern applied would be MVC ( or any other design pattern to encapsulate business logic).

Hope I don't make you even more confuse. I am not good at explaining things , sorry

arief



 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope that is perfect.

So it is a plain simple Java call to a POJO. So the simplest solution is create a singleton that creates the instance of the ApplicationContext, then the "dispatcher" just takes in a string. It would be best if the information passed in, "String" was the name of the bean. Then you can just take that String value and call getBean(String) and you have the Spring configured bean.

No need for some over complex logic to determine things like which controller to call. It won't be a controller, and it wouldn't be a dispatcher servlet.

Mark
 
arief hidayat
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Spritzler wrote:Nope that is perfect.

So it is a plain simple Java call to a POJO. So the simplest solution is create a singleton that creates the instance of the ApplicationContext, then the "dispatcher" just takes in a string. It would be best if the information passed in, "String" was the name of the bean. Then you can just take that String value and call getBean(String) and you have the Spring configured bean.

No need for some over complex logic to determine things like which controller to call. It won't be a controller, and it wouldn't be a dispatcher servlet.

Mark




Thanks mark.

Other questions.
1. which one is better: create instance of ApplicationContext, each time a request (in this case it will be BPM) comes. Or we only create one instance of ApplicationContext in the beginning and then reuse?
2. I am planning to use object pooling for some of the bean. But I don't have much knowledge on object pooling. perhaps you tell in which situation this object pooling is good to be implemented.

arief
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Definitely only create one instance. ApplicationContext objects are heavyweight, and could take a bit of time to create, so creating it up front is the best way.

2) Your service layer objects and DAO layer objects should never hold any state, and therefore, having the default Singleton scope should be plenty fine. Where, if you have performance issues, it becomes adding more hardware to a cluster/farm, rather than changing how code works. In my opinion.
But if you want a new instance of your objects, then changing the scope to "prototype".

Mark
 
arief hidayat
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Spritzler wrote:1) Definitely only create one instance. ApplicationContext objects are heavyweight, and could take a bit of time to create, so creating it up front is the best way.

2) Your service layer objects and DAO layer objects should never hold any state, and therefore, having the default Singleton scope should be plenty fine. Where, if you have performance issues, it becomes adding more hardware to a cluster/farm, rather than changing how code works. In my opinion.
But if you want a new instance of your objects, then changing the scope to "prototype".

Mark



Thanks mark for the advise.
 
"How many licks ..." - I think all of this dog's research starts with these words. Tasty tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic