Using Service Locator in Struts app without ant eejb components

Hi
We are developing a Struts application witjout any EJB components.
But we may go for EJB in future.
Keeping that in mind we want to introduce a service locator between the action class and the business logic. So it may be easier to acomodate in future.
But how do i do that ? Can anyone help me in this?
Since all the Service locator example which i have seen is implemented using ejb
Please do help me in this
Thanks
Ottran

Controller (Action class) gets reference to Business Delegate (BD) and calls a particular business method.
The BD gets reference to Service Locator (from JNDI tree) to access a business service. The business sevice can be implemented using EJB, POJO, Web Service, legacy app, etc.
A UML diagram is available at
http://www.softwareleadership.org/docs/J2EEDesignPatterns.html
Click on Business Delegate to view diagram with Service Locator.

Similar Messages

  • Using service Locator pattern to dynamically access remote EJBs

    Hi All,
    Please help to guide me how I can use a service locator to retrieve a remote object (residing on another application but on same domain) .
    I do not want to use Dependency Injection since I want to dynamically discover them ( there are many implementations of same interface (POJO)). Each EJB implementation implements its own remote/local interface that extends this global POJO interface.
    I have two J2ee-Applications on same domain. J2EE-Application 1 has an EJB module (EJB Module 1) that intends to access an EJB Module (EJB Module 2) in J2EE-Application 2. Following observations:
    1. Dependency Injection fails if (include the EJB Module 2 jar in J2EE-Application 1). Reason App Server complains the EJB has been deployed (Deployment fails)
    2. Dependency Injection works if (exclude the EJB Module 2 jar in J2EE-Application 1) and include the Remote Interface in EJB Module 1(J2EE-Application 1).Positive Observation (Deployment success and DI also success)
    3.Using Service Locator to retrieve the remote object if (exclude the EJB Module 2 jar in J2EE-Application 1) and include the Remote Interface in EJB Module 1(J2EE-Application 1). Negative and Positive Observation.
    Positive Observation: Using dependency injection I can still retrieve the Remote Object
    Another Positive: The Service Locator remote lookup to another Bean in same Application but different EJB Module is successful.
    Negative Observation:
    The Service Locator lookup to this same remote object with Successful Dependency Injection fails (An Ejb in a different application).
    Can't retrieve the Remote Object with Service Locator. Message from Server:.
    NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial.
    Thanks in advance

    "I do not want to use Dependency Injection since I want to dynamically discover them ( there are many implementations of same interface (POJO))"
    If you're calling ejbs from other ejbs or servlets, the same could probably be acomplished by using dependency injection (@EJB) in a number of instance variables typed with different remote/local interfaces or even with different beanName attributes (for when more than one bean implements the same managed interface in the same app - not sure how it works outside the same jee app...) , and dinamically selecting one of them; or encapsulating those injected variables into a stateless ejb as your service locator to make them accessible from POJOs too (which, due to concurrent acess, wouldn't work for statefull ejbs references...).
    Anyway, using the jndi lookup service locator pattern seems ok in this case.
    What doesn't seem ok, given the nature of the error for the negative observation - jndi context initialization - is that
    Another Positive: The Service Locator remote lookup to another Bean in same Application but different EJB Module is successful.
    Can you check your code and reconfirm that you're using the same context initialization code for both the positive and negative observations ?

  • Can Motion be used as a stand-alone app, without FCPX?

    Can "Motion 5" be used as a stand-alone app, without FCPX?

    Yes.
    It's loud.
    70-some decibels of loud, particularly when the fans spool up.
    And you need a big flat spot, or a 19" rack.

  • Is there anyway i can use my ipod to get apps without having to make a itunes, if not my ipod is pointless an mess well take it back, casue i cant put in any cedit card id stuff

    Is there anyway i can use my ipod to get apps without having to make a itunes, if not my ipod is pointless an mess well take it back, casue i cant put in any cedit card id stuff

    Why can you not " put in any cedit card id stuff"?
    You have to have an itunes account to use itunes.
    Perhaps if you explained the issue, someone could help.

  • How Can I Make my iPhone Use Current Location for Facebook App??

    It did ask me "facebook would like to use your current location." But i clicked on "dont allow" button because i did not know what it was for..now I cant use this location section thing where to post for the Facebook since I denied it..how can I enable it for Facebook??

    Go to settings, Location Services, then scroll down to the Facebook icon then click on.

  • How can I use Airplay Mirror of Photos app without slideshow?

    Every time i try to use airplay mirror and go to the photos app it starts the slideshow feature.
    I can't find a way to disable the slide show. I want simply to mirror my photos so I can zoom them and move around.
    Did anyone figure out a way to do that?

    Hi
    To use airplay you need an airplay capable device such as Apple TV and an iPhone that is 4s or higher, mine is only 4 so I can't access airplay. Once both the Apple TV and phone or iPad are connected to the same wireless notwork you will be able to mirror your screens.
    I hope this helps.

  • Can i setup the 'find my phone' app without icloud?

    I'm still using Snow Leopard for work reasons which means no iCloud. Can I use the 'find my phone' app without iCloud? Is there a way? Thanks

    If you had Find My iPhone enabled on your phone, then as well as using the Find My iPhone app on another iOS device, you can also use log into the account on http://icloud.com and try locating the phone via that

  • SERVICE LOCATOR ?? Is it really an interesting Design pattern??

    Hi everybody,
    i've a problem with the J2EE Design Pattern "Services locator" (it's a singleton).
    It is said that by making use of a Service Locator we can :
    - hide to the client the complexities of initial context creation, EJB home object lookup,and EJB objectre-creation.
    - multiple clients can reuse the Service Locator object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.
    But i would like to understand at which side should that service locator object reside??!!??
    If it is at server side then the clients need well an initial context in order to make a lookup on that object.
    Conclusion :
    the service locator doesn't hide the complexities of initial context!!
    Furthermore the client has to perform a look-up on that service locator object!! The only advantage left is caching facility.
    If it is at client side, each client needs his own services locator object
    Conclusion :
    multiple client don't reuse the same service locator. What's the advantage to be a singleton ???
    There is certainly something that i don't understand so help me please!! Thanks.

    Hi Yves,
    But i would like to understand at which side should
    that service locator object reside??!!??
    If it is at client side, each client needs his own
    services locator object
    Conclusion :
    multiple client don't reuse the same service locator.
    What's the advantage to be a singleton ???The service locator resides on the client side and is implemented as
    a singleton. Since it is possible that there could be multiple
    class loaders/JVMs on the client side, and therefore, multiple
    instances of the "singleton" service locator. This is typical
    in a distributed environment (e.g. servlets/JSPs in a web-tier
    cluster using service locator). Thus service locator is not
    a truly "distributed singleton" object. But, the empahsis
    is to design the service locator such that it does not hold
    any state that needs to be replicated across multiple
    instances across different JVMs as mentioned. Thus, there
    is no need for multiple clients to use the "same" service locator,
    but still the benefits of implementing this pattern is realized.
    By making it a singleton, and keeping it from holding state
    that needs to be replicated, we realize the benefits of this pattern.
    You may also want to visit the J2EE Pattern interest list
    and see these relevant discussions :
    Topic: Service Locator and passivation
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=1026
    Topic: Caching EJBHome interfaces
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=9226
    Topic: Using Service Locator for Data Source caching
    http://archives.java.sun.com/cgi-bin/wa?A1=ind0106&L=j2eepatterns-interest#31
    hope this helps,
    thanks,
    -deepak

  • Apple is there a way to locate my ipod without a locator app bc mine got stolen and i want it back so it there a way to use the location services to locate my ipod

    apple is there a way to locate my ipod without a locator app bc mine got stolen and i want it back so it there a way to use the location services to locate my ipod

    No, there is not.
    Sorry.
    BTW, you are not addressing Apple here.  We are ipod users like you.

  • Do I need to leave location services on all the time to use the "Find my iPhone" app?

    Do I need to leave location services on all the time to use the "Find my iPhone" app?

    The Find My IPhone app is used to find OTHER lost devices, it does nothing to make your device "findable".  To make it findable, you must turn on "Find My IPhone" in settings. And than you need location services on.  This however does not guarantee that you'll always find it if lost. A thief can set it to factory settings, even remove the sim card. Then it'll be unfindable.

  • How to create 'service' tier with functionality multiple struts apps

    I am looking for some advice regarding a future project. I have 3 struts webapps (running on Tomcat 4.1.3) each with some overlapping functionality. I would like to create a 'service tier' to accommodate common functionality which can be shared between the 3 struts web apps.
    What framework would best achieve this? Are EJBs the way to go? My struts apps all use DTOs so are not tied to the Action Form object. I have been looking at Spring but am not sure exactly how this will fit? Will tomcat serve my needs or do I need to migrate to something with full J2EE support. I have also considered JBOSS with Seam linking JSF to EJBs. Is this a viable option?
    The service layer can be on the same machine as the struts apps although I would like to have the flexibility to move it to a separate server in the future if necessary.
    I will be happy to provide more details to any who can offer me some guidance.

    Hi Saish,
    Thanks for your help.
    I have considered both options. The main goal is to
    eliminate duplicate code. However the presentation
    tiers of the applications are quite different. I
    will look into Martins book.
    It's outstanding. One of my top five favorite books.
    Would creating a jar file which is included in each
    .war end up becomming a maintenance nightmare?
    Depends on what you mean by ' maintenance'. In terms of onging development with your Java source, in a modern IDE, no. In terms of deployment, it does add a minor bit of complexity. However, if you are using an automated build and deployment tool such as Ant or Maven, the amount of extra work is trivial.
    In your opinion what would be the advantages of
    implementing the common functionality as a seperate
    tier (with SPRING/EJB) vs using a JAR file and
    distributing it with each app?They are not mutually exclusive. If you want to remove duplicate code, then simple refactoring is the start. As part of that refactoring, you may decide enough classes are providing similar functionality (such as transaction management, a coarse-grained public API, etc.) and create a tier. You mentioned in particular a service tier. This is a design and architectural decision. You could still completely refactor common functionality into a better design without the introduction of a new tier.
    Whether to create a tier is, IMO, more art than science. Adding a tier adds complexity. However, the net effect should be to reduce system complexity. It is more 'work' to implement a true persistence tier than to simply code JDBC in model objects (or use Hibernate/JDO objects). However, as overall system complexity grows, the addition of a persistence tier adds many benefits. Business objects concern themselves solely with business logic, where as data acccess objects concern themselves with persistence. You can even have different developers with different skills specialize within a tier.
    So, tiering really is a big topic. Fortunately, there are many architecture templates and design patterns to guide your decisions. "Patterns of Enterprise Architecture" (also by Fowler) compares and contrasts the more common ones. There is lively debate as to the pros and cons of different strategies. In the end, there is no cookie-cutter architecture. You will need (sometimes through the painful process of making a mistake) to see what works best for your actual system.
    Finally, about remoting. Remember the first law of distributed objects, "Don't distribute your objects". There is always a performance penalty compared to an in-JVM local call. Remoting has its uses, but these should be careful architecture-level decisions. (I should concded that even this paragraph is sometimes contentious and debated).
    - Saish

  • I am receiving a new ipad (3 i guess) from my mom who is in the U.S but i am currently in the philippines. I ofcourse, want to have apps,games,movies etc. can i use an itunes giftcard (also from the U.S) to buy my apps without any problems?

    i am receiving a new ipad (3 i guess) from my mom who is in the U.S but i am currently in the philippines. I ofcourse, want to have apps,games,movies etc. on it. can i use an itunes giftcard (also from the U.S) to buy my apps without any problems?

    No.
    iTunes terms of service:
    The iTunes Service is available to you only in the United States, its territories, and possessions. You agree not to use or attempt to use the iTunes Service from outside these locations. Apple may use technologies to verify your compliance.

  • Using iPod location services to find my way round new places

    I  like to use location services with map apps (such as OffMaps and MapsWithMe) to help me find my way around new places.
    I understand that the information  ipod uses for location services,  the positions of various wifi transmitters,  is stored in an Apple database and that the location result is likely to be very approximate.  My problem is that I  cant figure out how and when the relevant data arrives in my ipod.  Typically it seems that when in a new town,  during my first wander round the place, the ipod does not know where it is -  locations will not be shown on these map apps.  On subsequent travels through the town iPod does seem to know where it is and displays its location on the maps quite nicely.  (But by then of course I  too know my way around and so don't need theiPod;s assistance so much to help figure out where I am.) 
    So my questions are
    1) At what point does the ipod get to store the crucial location information?  I'm wondering for instance whether the ipod remembers the SSIDs  as it encounters them, but only learns about their locations when it  is next connected to the  internet?
    2) I'd like to know how much of this information the iPod can remember and for how long is it remembered.  (If I go back to a place visited last year will any of the previously "learnt"  locations be remembered by the iPod. I may well have forgotten my way round the place by then and the iPod's help would be useful)
    3) Is it possible to "teach"  the ipod about  known wifi locations in a particular geographical area before visiting the area.  That would be a tremendous boon to me.

    Good questions. However, I have never seen or heard about any information from Apple about how the iPod (and wifi-only iPad) really determine location.  I am waiting for answers from other users.

  • Location services not working on apps?

    I didn't know where else to put this so I put it here.
    I have an iPod Touch and an iPad and it's not showing my location on either of those.
    It is turned on, so before you say that, yes. I'm not that stupid. It's also not restricted. It can't be a problem with my router because when I use my laptop, it shows the right location.
    Why is it not working on my iPod and iPad? Please help me. It's incredibly frustrating because I use an app that requires location services and I haven't been able to use it because these devices can't find my location.
    Does it have anything to do with a MAC address? I just changed my routers MAC address to "default" a few moments ago thinking that had something to do with it.
    Just please help. It's worked before, but all of a sudden it just stopped.
    Also, when I google "weather" on my iPod/iPad, it tells me where I am, but when I use apps, like Facebook, the popular apps near me, and Whisper, it says it can't find my location.

    For location the iPod uses the location of nearby wifi routers that are in Apple's database. You do not have to be connected to the network/router to use that router's location. It identifies the routers via their MAC address. So changing the MAC address is the cause of your problem
    Apple continuously updated their database based on info they obtain from iPhones. No one has been able to find a way to inform Apple of a router or correct is location.

  • How do you turn on location services for the Photos app?

    I reset my location services and I need to reactivate the location services for those apps I want to use this function.  I have turned on location services for all other apps, including CAMERA, but I cannot figure out how to turn it back on for PHOTOS (Camera Roll).  This option did appear when I did the new iPhone5 setup, but I cannot get it back.  And PHOTOS is not listed in the apps shown under the Location Services setting page.  I set my wife's phone up too and the PHOTOS app is showing on her phones Location Services setting page.  Help please.

    Hi There
    I had the same problem and actually I found out that in Location Services you need to Turn On the option for CAMERA, as there is no photos icon.
    Cheers
    Iva

Maybe you are looking for