Example usage for javax.naming Context lookup

List of usage examples for javax.naming Context lookup

Introduction

In this page you can find the example usage for javax.naming Context lookup.

Prototype

public Object lookup(String name) throws NamingException;

Source Link

Document

Retrieves the named object.

Usage

From source file:gov.nih.nci.ess.safetyreporting.ruleseval.service.globus.resource.SafetyReportRulesEvaluationResourceBase.java

public SafetyReportRulesEvaluationResourceConfiguration getConfiguration() {
    if (this.configuration != null) {
        return this.configuration;
    }//from www . j a va  2 s  . c  om
    MessageContext ctx = MessageContext.getCurrentContext();

    String servicePath = ctx.getTargetService();
    servicePath = servicePath.substring(0, servicePath.lastIndexOf("/"));
    servicePath += "/SafetyReportRulesEvaluation";

    String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration";
    logger.debug("Will read configuration from jndi name: " + jndiName);
    try {
        Context initialContext = new InitialContext();
        this.configuration = (SafetyReportRulesEvaluationResourceConfiguration) initialContext.lookup(jndiName);
    } catch (Exception e) {
        logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e);
    }

    return this.configuration;
}

From source file:gov.nih.nci.ess.safetyreporting.service.globus.resource.SafetyReportingEnterpriseServiceResourceBase.java

public SafetyReportingEnterpriseServiceResourceConfiguration getConfiguration() {
    if (this.configuration != null) {
        return this.configuration;
    }/*from   ww w. j  a  va 2  s.c  o m*/
    MessageContext ctx = MessageContext.getCurrentContext();

    String servicePath = ctx.getTargetService();
    servicePath = servicePath.substring(0, servicePath.lastIndexOf("/"));
    servicePath += "/SafetyReportingEnterpriseService";

    String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration";
    logger.debug("Will read configuration from jndi name: " + jndiName);
    try {
        Context initialContext = new InitialContext();
        this.configuration = (SafetyReportingEnterpriseServiceResourceConfiguration) initialContext
                .lookup(jndiName);
    } catch (Exception e) {
        logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e);
    }

    return this.configuration;
}

From source file:com.xwiki.authentication.puma.PUMAAuthServiceImpl.java

protected PumaHome getPumaHome(XWikiContext context) throws XWikiException {
    try {//from www. j a v a 2 s.  c om
        PortletServiceHome portletServiceHome;

        javax.naming.Context ctx;
        ctx = new javax.naming.InitialContext();
        portletServiceHome = (PortletServiceHome) ctx
                .lookup("portletservice/com.ibm.portal.um.portletservice.PumaHome");

        if (portletServiceHome == null) {
            throw new XWikiException(XWikiException.MODULE_XWIKI_USER, XWikiException.ERROR_XWIKI_USER_INIT,
                    "Can't access PUMA service.");
        }

        return (PumaHome) portletServiceHome.getPortletService(PumaHome.class);
    } catch (NamingException e) {
        throw new XWikiException(XWikiException.MODULE_XWIKI_USER, XWikiException.ERROR_XWIKI_USER_INIT,
                "Can't access PUMA service.", e);
    } catch (PortletServiceUnavailableException e) {
        throw new XWikiException(XWikiException.MODULE_XWIKI_USER, XWikiException.ERROR_XWIKI_USER_INIT,
                "Can't access PUMA service.", e);
    }
}

From source file:gov.nih.nci.ess.safetyreporting.rdm.service.globus.resource.SafetyReportDefinitionManagementResourceBase.java

public SafetyReportDefinitionManagementResourceConfiguration getConfiguration() {
    if (this.configuration != null) {
        return this.configuration;
    }/*from  w w  w  .j  a v a  2  s  . c om*/
    MessageContext ctx = MessageContext.getCurrentContext();

    String servicePath = ctx.getTargetService();
    servicePath = servicePath.substring(0, servicePath.lastIndexOf("/"));
    servicePath += "/SafetyReportDefinitionManagement";

    String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration";
    logger.debug("Will read configuration from jndi name: " + jndiName);
    try {
        Context initialContext = new InitialContext();
        this.configuration = (SafetyReportDefinitionManagementResourceConfiguration) initialContext
                .lookup(jndiName);
    } catch (Exception e) {
        logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e);
    }

    return this.configuration;
}

From source file:org.apache.openaz.xacml.std.pip.engines.jdbc.JDBCEngine.java

protected Connection getJNDIConnection() throws PIPException {
    try {/*from   w  w w. j av  a  2  s. c  o m*/
        Context initialContext = new InitialContext();
        DataSource datasource = (DataSource) initialContext.lookup(this.jndiDataSource);
        if (datasource == null) {
            throw new PIPException("");
        }
        return datasource.getConnection();
    } catch (NamingException | SQLException e) {
        this.logger.error("JNDIException creating Connection", e);
        throw new PIPException("JNDIException creating Connection", e);
    }
}

From source file:gov.nih.nci.cagrid.cabio.service.globus.resource.CaBIO42GridSvcResourceBase.java

public CaBIO42GridSvcResourceConfiguration getConfiguration() {
    if (this.configuration != null) {
        return this.configuration;
    }//from  w  w w .j  a  v  a 2s.c o  m
    MessageContext ctx = MessageContext.getCurrentContext();

    String servicePath = ctx.getTargetService();
    servicePath = servicePath.substring(0, servicePath.lastIndexOf("/"));
    servicePath += "/CaBIO42GridSvc";

    String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration";
    logger.debug("Will read configuration from jndi name: " + jndiName);
    try {
        Context initialContext = new InitialContext();
        this.configuration = (CaBIO42GridSvcResourceConfiguration) initialContext.lookup(jndiName);
    } catch (Exception e) {
        logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e);
    }

    return this.configuration;
}

From source file:de.zib.gndms.GORFX.context.service.globus.resource.TaskResourceBase.java

public TaskResourceConfiguration getConfiguration() {
    if (this.configuration != null) {
        return this.configuration;
    }/* w  w  w  . j ava2  s.  c o  m*/
    MessageContext ctx = MessageContext.getCurrentContext();

    String servicePath = ctx.getTargetService();
    servicePath = servicePath.substring(0, servicePath.lastIndexOf("/"));
    servicePath += "/Task";

    String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration";
    logger.debug("Will read configuration from jndi name: " + jndiName);
    try {
        Context initialContext = new InitialContext();
        this.configuration = (TaskResourceConfiguration) initialContext.lookup(jndiName);
    } catch (Exception e) {
        logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e);
    }

    return this.configuration;
}

From source file:org.cagrid.CBM.service.globus.resource.CBMResourceBase.java

public CBMResourceConfiguration getConfiguration() {
    if (this.configuration != null) {
        return this.configuration;
    }/*from   w  w  w  .  j  a  v  a 2s . com*/
    MessageContext ctx = MessageContext.getCurrentContext();

    String servicePath = ctx.getTargetService();
    servicePath = servicePath.substring(0, servicePath.lastIndexOf("/"));
    servicePath += "/CBM";

    String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration";
    logger.debug("Will read configuration from jndi name: " + jndiName);
    try {
        Context initialContext = new InitialContext();
        this.configuration = (CBMResourceConfiguration) initialContext.lookup(jndiName);
    } catch (Exception e) {
        logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e);
    }

    return this.configuration;
}

From source file:gov.nih.nci.cagrid.cananolab.service.globus.resource.CaNanoLabServiceResourceBase.java

public CaNanoLabServiceResourceConfiguration getConfiguration() {
    if (this.configuration != null) {
        return this.configuration;
    }//from w w  w  .  j  a v  a2 s . c  om
    MessageContext ctx = MessageContext.getCurrentContext();

    String servicePath = ctx.getTargetService();
    servicePath = servicePath.substring(0, servicePath.lastIndexOf("/"));
    servicePath += "/CaNanoLabService";

    String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration";
    logger.debug("Will read configuration from jndi name: " + jndiName);
    try {
        Context initialContext = new InitialContext();
        this.configuration = (CaNanoLabServiceResourceConfiguration) initialContext.lookup(jndiName);
    } catch (Exception e) {
        logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e);
    }

    return this.configuration;
}

From source file:org.cvit.cabig.dmr.service.globus.resource.DmrResourceBase.java

public DmrResourceConfiguration getConfiguration() {
    if (this.configuration != null) {
        return this.configuration;
    }/*www .j  a  v a 2 s  . c  o m*/
    MessageContext ctx = MessageContext.getCurrentContext();

    String servicePath = ctx.getTargetService();
    servicePath = servicePath.substring(0, servicePath.lastIndexOf("/"));
    servicePath += "/Dmr";

    String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration";
    logger.debug("Will read configuration from jndi name: " + jndiName);
    try {
        Context initialContext = new InitialContext();
        this.configuration = (DmrResourceConfiguration) initialContext.lookup(jndiName);
    } catch (Exception e) {
        logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e);
    }

    return this.configuration;
}