BookManagerDelegate.java

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

import java.util.Collection;
import java.util.Properties;
import javax.naming.NamingException;
import org.andromda.demo.ejb3.ServiceDelegateBase;
import org.andromda.demo.ejb3.ServiceLocator;

/**
 * Web service delegator for {@link org.andromda.demo.ejb3.book.BookManagerBean}.
 *
 * @see org.andromda.demo.ejb3.book.BookManagerBean
 */
public class BookManagerDelegate
    extends ServiceDelegateBase
{
    /**
     * Default constructor
     */
    public BookManagerDelegate()
    {
        super();
    }

    /**
     * Constructor setting the environment properties.
     *
     * @param properties
     */
    public BookManagerDelegate(Properties properties)
    {
        super(properties);
    }

    /**
     * Gets an instance of {@link BookManagerRemote}
     */
    private BookManagerRemote getBookManagerRemote()
        throws NamingException
    {
        return ServiceLocator.getInstance().get_org_andromda_demo_ejb3_book_BookManagerBean_Remote(getProperties());
    }

    /**
     * Gets an instance of {@link BookManagerLocal}
     */
    private BookManagerLocal getBookManagerLocal()
        throws NamingException
    {
        return ServiceLocator.getInstance().get_org_andromda_demo_ejb3_book_BookManagerBean_Local(getProperties());
    }

    /**
     * Call the session bean operation using appropriate view type
     * @see org.andromda.demo.ejb3.book.BookManagerBean#getAllBooks()
     *
     * @return Collection
     * @throws BookException
     */
    public Collection getAllBooks()
        throws BookException
    {
        try
        {
            switch (getViewType())
            {
                case LOCAL_VIEW_TYPE:
                    return getBookManagerLocal().getAllBooks();
                    
                case REMOTE_VIEW_TYPE:
                default:
                    return getBookManagerRemote().getAllBooks();
                                }
        }
        catch (BookException ex)
        {
            throw ex;
        }
        catch (NamingException ex)
        {
            throw new BookManagerException(
                "Error performing 'org.andromda.demo.ejb3.book.BookManager.getAllBooks()' --> " + ex, ex);
        }
    }

}