All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.legstar.host.invoke.AbstractServiceAdapter Maven / Gradle / Ivy

There is a newer version: 1.5.3
Show newest version
/*******************************************************************************
 * Copyright (c) 2010 LegSem.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     LegSem - initial API and implementation
 ******************************************************************************/
package com.legstar.host.invoke;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 * A super class for service adapters.
 * 

* Adapters provide one or more methods which map to host programs. * This class offers a simple JNDI based setting for the host invokers. * */ public abstract class AbstractServiceAdapter { /** An identifier for this service adapter.*/ private String mServiceAdapterName; /** The JNDI locator for the invoker configuration file name.*/ private static final String JNDI_CONFIG_FILE = "java:comp/env/legstar/configFileName"; /** The default configuration file name if not recovered from JNDI. */ private static final String DEFAULT_CONFIG_FILE = "legstar-invoker-config.xml"; /** The host invoker configuration file name.*/ private String mConfigFileName; /** * This constructor attempts to locate a configuration file name from * JNDI. If it fails, it falls back to a default configuration file name. * @param serviceAdapterName the service adapter identifier */ public AbstractServiceAdapter(final String serviceAdapterName) { mServiceAdapterName = serviceAdapterName; try { Context initCtx = new InitialContext(); mConfigFileName = (String) initCtx.lookup(JNDI_CONFIG_FILE); } catch (NamingException e) { mConfigFileName = DEFAULT_CONFIG_FILE; } } /** * This constructor gets configuration file name from implementing class. * @param serviceAdapterName the service adapter identifier * @param configFileName host invoker configuration file name */ public AbstractServiceAdapter( final String serviceAdapterName, final String configFileName) { mServiceAdapterName = serviceAdapterName; mConfigFileName = configFileName; } /** * @return a friendly name identifying this service adapter */ public String getServiceAdapterName() { return mServiceAdapterName; } /** * @return the host invoker configuration file name */ public String getConfigFileName() { return mConfigFileName; } /** * @param configFileName the host invoker configuration file name to set */ public void setConfigFileName(final String configFileName) { mConfigFileName = configFileName; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy