ServiceLocator.java

// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by ServiceLocator.vsl in andromda-ejb3-cartridge on 08/08/2014 12:21:05.
//
package org.andromda.demo.ejb3;

import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.andromda.demo.ejb3.account.AccountManagerRemote;
import org.andromda.demo.ejb3.animal.AnimalServiceRemote;
import org.andromda.demo.ejb3.athlete.AthleteManagerRemote;
import org.andromda.demo.ejb3.bicycle.BicycleServiceRemote;
import org.andromda.demo.ejb3.bio.BioServiceRemote;
import org.andromda.demo.ejb3.book.BookManagerLocal;
import org.andromda.demo.ejb3.book.BookManagerRemote;
import org.andromda.demo.ejb3.book.BookServiceLocal;
import org.andromda.demo.ejb3.book.BookServiceRemote;
import org.andromda.demo.ejb3.camera.CameraManagerRemote;
import org.andromda.demo.ejb3.customer.CustomerServiceRemote;
import org.andromda.demo.ejb3.email.EmailSenderServiceRemote;
import org.andromda.demo.ejb3.employee.EmployeeServiceRemote;
import org.andromda.demo.ejb3.mobile.MobileServiceRemote;
import org.andromda.demo.ejb3.order.OrderManagerRemote;
import org.andromda.demo.ejb3.rental.PaymentServiceRemote;
import org.andromda.demo.ejb3.rental.RentalServiceRemote;
import org.andromda.demo.ejb3.rider.RiderServiceRemote;
import org.andromda.demo.ejb3.ticket.TicketManagerRemote;
import org.andromda.demo.ejb3.user.UserManagerRemote;
import org.andromda.demo.ejb3.vehicle.VehicleManagerRemote;

/**
 * Locates and provides all available application services.
 */
public class ServiceLocator
{
    /**
     * The shared instance of this ServiceLocator.
     */
    private static ServiceLocator instance;

    /**
     * The Context to lookup the service beans.
     */
    protected InitialContext context = null;

    /**
     * Cannot be instantiated constructor
     */
    private ServiceLocator()
    {
        // shouldn't be instantiated
    }

    /**
     * Gets the instance of this Class.
     * Create it if doesn't already exist, otherwise return the current instance.
     *
     * @return the shared service locator instance.
     */
    public static final ServiceLocator getInstance()
    {
        if (instance == null)
        {
            instance = new ServiceLocator();
        }
        return instance;
    }

    /**
     * Gets the InitialContext.
     *
     * @param env the Context environment properties.
     * @return the InitialContext.
     * @throws NamingException failure to create InitialContext
     */
    protected synchronized InitialContext getContext(Properties env)
        throws NamingException
    {
        if (this.context == null)
        {
            this.context = new InitialContext(env);
        }
        return this.context;
    }

    /**
     * Instantiate a new InitialContext using the properties table.
     *
     * @param env passed to the InitialContext constructor.
     * @return the InitialContext.
     * @throws NamingException failure to create InitialContext
     */
    protected synchronized InitialContext newContext(Properties env)
        throws NamingException
    {
        this.context = new InitialContext(env);
        return this.context;
    }

    /**
     * Shuts down the ServiceLocator and releases any used resources.
     */
    public synchronized void shutdown()
    {
        if (this.context != null)
        {
            try
            {
                this.context.close();
            }
            catch (NamingException ne)
            {
                // ignore
            }
            finally
            {
                this.context = null;
            }
        }
    }

    /**
     * Gets the remote interface {@link AccountManagerRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return AccountManagerRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final AccountManagerRemote get_org_andromda_demo_ejb3_account_AccountManagerBean_Remote(Properties env)
        throws NamingException
    {
        return (AccountManagerRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/AccountManagerBean/remote");
    }


    /**
     * Gets the remote interface {@link UserManagerRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return UserManagerRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final UserManagerRemote get_org_andromda_demo_ejb3_user_UserManagerBean_Remote(Properties env)
        throws NamingException
    {
        return (UserManagerRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/UserManagerBean/remote");
    }


    /**
     * Gets the remote interface {@link VehicleManagerRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return VehicleManagerRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final VehicleManagerRemote get_org_andromda_demo_ejb3_vehicle_VehicleManagerBean_Remote(Properties env)
        throws NamingException
    {
        return (VehicleManagerRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/VehicleManagerBean/remote");
    }


    /**
     * Gets the remote interface {@link TicketManagerRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return TicketManagerRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final TicketManagerRemote get_org_andromda_demo_ejb3_ticket_TicketManagerBean_Remote(Properties env)
        throws NamingException
    {
        return (TicketManagerRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/TicketManagerBean/remote");
    }


    /**
     * Gets the remote interface {@link EmailSenderServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return EmailSenderServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final EmailSenderServiceRemote get_org_andromda_demo_ejb3_email_EmailSenderServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (EmailSenderServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/EmailSenderServiceBean/remote");
    }


    /**
     * Gets the remote interface {@link MobileServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return MobileServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final MobileServiceRemote get_org_andromda_demo_ejb3_mobile_MobileServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (MobileServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/MobileServiceBean/remote");
    }


    /**
     * Gets the remote interface {@link CameraManagerRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return CameraManagerRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final CameraManagerRemote get_org_andromda_demo_ejb3_camera_CameraManagerBean_Remote(Properties env)
        throws NamingException
    {
        return (CameraManagerRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/CameraManagerBean/remote");
    }


    /**
     * Gets the remote interface {@link EmployeeServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return EmployeeServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final EmployeeServiceRemote get_org_andromda_demo_ejb3_employee_EmployeeServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (EmployeeServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/EmployeeServiceBean/remote");
    }


    /**
     * Gets the remote interface {@link OrderManagerRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return OrderManagerRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final OrderManagerRemote get_org_andromda_demo_ejb3_order_OrderManagerBean_Remote(Properties env)
        throws NamingException
    {
        return (OrderManagerRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/OrderManagerBean/remote");
    }


    /**
     * Gets the remote interface {@link BicycleServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return BicycleServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final BicycleServiceRemote get_org_andromda_demo_ejb3_bicycle_BicycleServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (BicycleServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/BicycleServiceBean/remote");
    }


    /**
     * Gets the remote interface {@link RentalServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return RentalServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final RentalServiceRemote get_org_andromda_demo_ejb3_rental_RentalServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (RentalServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/RentalServiceBean/remote");
    }


    /**
     * Gets the remote interface {@link PaymentServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return PaymentServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final PaymentServiceRemote get_org_andromda_demo_ejb3_rental_PaymentServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (PaymentServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/PaymentServiceBean/remote");
    }


    /**
     * Gets the remote interface {@link AnimalServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return AnimalServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final AnimalServiceRemote get_org_andromda_demo_ejb3_animal_AnimalServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (AnimalServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/AnimalServiceBean/remote");
    }


    /**
     * Gets the remote interface {@link RiderServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return RiderServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final RiderServiceRemote get_org_andromda_demo_ejb3_rider_RiderServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (RiderServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/RiderServiceBean/remote");
    }


    /**
     * Gets the remote interface {@link BioServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return BioServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final BioServiceRemote get_org_andromda_demo_ejb3_bio_BioServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (BioServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/BioServiceBean/remote");
    }


    /**
     * Gets the remote interface {@link BookServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return BookServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final BookServiceRemote get_org_andromda_demo_ejb3_book_BookServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (BookServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/BookServiceBean/remote");
    }

    /**
     * Gets the local interface {@link BookServiceLocal}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return BookServiceRemote
     * @throws NamingException failure to lookup local service interface.
     */
    public final BookServiceLocal get_org_andromda_demo_ejb3_book_BookServiceBean_Local(Properties env)
        throws NamingException
    {
        return (BookServiceLocal)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/BookServiceBean/local");
    }


    /**
     * Gets the remote interface {@link BookManagerRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return BookManagerRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final BookManagerRemote get_org_andromda_demo_ejb3_book_BookManagerBean_Remote(Properties env)
        throws NamingException
    {
        return (BookManagerRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/BookManagerBean/remote");
    }

    /**
     * Gets the local interface {@link BookManagerLocal}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return BookManagerRemote
     * @throws NamingException failure to lookup local service interface.
     */
    public final BookManagerLocal get_org_andromda_demo_ejb3_book_BookManagerBean_Local(Properties env)
        throws NamingException
    {
        return (BookManagerLocal)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/BookManagerBean/local");
    }


    /**
     * Gets the remote interface {@link CustomerServiceRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return CustomerServiceRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final CustomerServiceRemote get_org_andromda_demo_ejb3_customer_CustomerServiceBean_Remote(Properties env)
        throws NamingException
    {
        return (CustomerServiceRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/CustomerServiceBean/remote");
    }


    /**
     * Gets the remote interface {@link AthleteManagerRemote}.
     *
     * @param env the Context environment properties.  Null represents no properties.
     * @return AthleteManagerRemote
     * @throws NamingException failure to lookup remote service interface.
     */
    public final AthleteManagerRemote get_org_andromda_demo_ejb3_athlete_AthleteManagerBean_Remote(Properties env)
        throws NamingException
    {
        return (AthleteManagerRemote)
            getContext(env).lookup("demo-ejb3-3.5-SNAPSHOT/AthleteManagerBean/remote");
    }


    /**
     * Gets an instance of the given service.
     *
     * @param serviceName lookup this service from the context.
     * @return Object getService(serviceName, null)
     * @throws NamingException failure to lookup remote service interface.
     */
    public final Object getService(String serviceName)
        throws NamingException
    {
        return getService(serviceName, null);
    }

    /**
     * Gets an instance of the given service.
     *
     * @param serviceName lookup this service from the context.
     * @param env the Context environment properties.  Null represents no properties.
     * @return Object getContext(env).lookup(serviceName)
     * @throws NamingException failure to lookup remote service interface.
     */
    public final Object getService(String serviceName, Properties env)
        throws NamingException
    {
        return getContext(env).lookup(serviceName);
    }
}