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:org.homeautomation.doormanager.plugin.impl.util.DoorManagerUtils.java

public static void setupDeviceManagementSchema() throws DoorManagerDeviceMgtPluginException {
    DeviceManagementConfiguration deviceManagementConfiguration = DoorManagerManagementDataHolder.getInstance()
            .getDeviceTypeConfigService().getConfiguration(DoorManagerConstants.DEVICE_TYPE,
                    DoorManagerConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
    String datasource = deviceManagementConfiguration.getDeviceManagementConfigRepository()
            .getDataSourceConfig().getJndiLookupDefinition().getJndiName();
    try {//from w w w  .jav  a2 s. c o  m
        Context ctx = new InitialContext();
        DataSource dataSource = (DataSource) ctx.lookup(datasource);
        DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
        log.info("Initializing device management repository database schema");
        initializer.createRegistryDatabase();
    } catch (NamingException e) {
        log.error("Error while looking up the data source: " + datasource, e);
    } catch (Exception e) {
        throw new DoorManagerDeviceMgtPluginException(
                "Error occurred while initializing Iot Device " + "Management database schema", e);
    }
}

From source file:org.homeautomation.digitaldisplay.plugin.impl.dao.DigitalDisplayDAO.java

public static void initDigitalDisplayDAO() {
    try {//  w w w.j  a  v  a  2  s .c om
        Context ctx = new InitialContext();
        dataSource = (DataSource) ctx.lookup(DigitalDisplayConstants.DATA_SOURCE_NAME);
    } catch (NamingException e) {
        log.error("Error while looking up the data source: " + DigitalDisplayConstants.DATA_SOURCE_NAME);
    }
}

From source file:com.tdclighthouse.prototype.utils.EmailUtils.java

public static Session getMailSession(final String sessionName) {
    Session result = null;/* w  w  w  .ja v  a 2  s .  c  om*/
    InitialContext initialContext = null;
    try {
        initialContext = new InitialContext();
        Context context = (Context) initialContext.lookup("java:comp/env");
        result = (Session) context.lookup(sessionName);
    } catch (NamingException e) {
        throw new HstComponentException(e);
    } finally {
        try {
            if (initialContext != null) {
                initialContext.close();
            }
        } catch (NamingException e) {
            LOG.error(e.getMessage(), e);
        }
    }

    return result;
}

From source file:org.deviceautomation.geolocationTracker.plugin.impl.util.GeoLocationTrackerUtils.java

public static void setupDeviceManagementSchema() throws DeviceMgtPluginException {
    DeviceManagementConfiguration deviceManagementConfiguration = GeoLocationTrackerManagementDataHolder
            .getInstance().getDeviceTypeConfigService()
            .getConfiguration(GeoLocationTrackerConstants.DEVICE_TYPE,
                    GeoLocationTrackerConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
    String datasource = deviceManagementConfiguration.getDeviceManagementConfigRepository()
            .getDataSourceConfig().getJndiLookupDefinition().getJndiName();
    try {/* ww  w  . j av a 2 s.c  o m*/
        Context ctx = new InitialContext();
        DataSource dataSource = (DataSource) ctx.lookup(datasource);
        DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
        log.info("Initializing device management repository database schema");
        initializer.createRegistryDatabase();
    } catch (NamingException e) {
        log.error("Error while looking up the data source: " + datasource, e);
    } catch (Exception e) {
        throw new DeviceMgtPluginException(
                "Error occurred while initializing Iot Device " + "Management database schema", e);
    }
}

From source file:org.homeautomation.digitaldisplay.plugin.impl.util.DigitalDisplayUtils.java

/**
 * Creates the device management schema.
 *//*  w  w w  .ja v  a  2s  . c  om*/
public static void setupDeviceManagementSchema() throws DigitalDisplayDeviceMgtPluginException {
    try {
        Context ctx = new InitialContext();
        DataSource dataSource = (DataSource) ctx.lookup(DigitalDisplayConstants.DATA_SOURCE_NAME);
        DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
        log.info("Initializing device management repository database schema");
        initializer.createRegistryDatabase();

    } catch (NamingException e) {
        log.error("Error while looking up the data source: " + DigitalDisplayConstants.DATA_SOURCE_NAME);
    } catch (Exception e) {
        throw new DigitalDisplayDeviceMgtPluginException(
                "Error occurred while initializing Iot Device " + "Management database schema", e);
    }
}

From source file:org.coffeeking.connectedcup.plugin.impl.dao.ConnectedCupDAOUtil.java

public static void initConnectedCupDAO() {
    try {// w  w w . j  a va  2  s  .  c  om
        Context ctx = new InitialContext();
        dataSource = (DataSource) ctx.lookup(ConnectedCupConstants.DATA_SOURCE_NAME);
    } catch (NamingException e) {
        log.error("Error while looking up the data source: " + ConnectedCupConstants.DATA_SOURCE_NAME);
    }

}

From source file:org.homeautomation.currentsensor.plugin.impl.dao.CurrentSensorDAOUtil.java

public static void initCurrentSensorDAO() {
    try {//from   www.j  ava 2s  . c o m
        Context ctx = new InitialContext();
        dataSource = (DataSource) ctx.lookup(CurrentSensorConstants.DATA_SOURCE_NAME);
    } catch (NamingException e) {
        log.error("Error while looking up the data source: " + CurrentSensorConstants.DATA_SOURCE_NAME);
    }

}

From source file:org.homeautomation.droneanalyzer.plugin.impl.dao.DroneAnalyzerDAO.java

public static void initDroneAnalyzerDAO() {
    try {/*from  w  w  w . j  a  v  a 2  s  .co  m*/
        Context ctx = new InitialContext();
        dataSource = (DataSource) ctx.lookup(DroneAnalyzerConstants.DATA_SOURCE_NAME);
    } catch (NamingException e) {
        log.error("Error while looking up the data source: " + DroneAnalyzerConstants.DATA_SOURCE_NAME);
    }
}

From source file:org.google.pen.plugin.impl.dao.DeviceTypeDAO.java

public static void initDeviceTypeDAO() {
    try {/*from w  ww  . ja v a  2  s .c om*/
        Context ctx = new InitialContext();
        dataSource = (DataSource) ctx.lookup(DeviceTypeConstants.DATA_SOURCE_NAME);
    } catch (NamingException e) {
        log.error("Error while looking up the data source: " + DeviceTypeConstants.DATA_SOURCE_NAME);
    }
}

From source file:org.homeautomation.doormanager.plugin.impl.dao.DoorManagerDAOUtil.java

public static void initAutomaticDoorLOckerDAO() {
    try {/*  ww  w . j a v a2s  . co  m*/
        Context ctx = new InitialContext();
        dataSource = (DataSource) ctx.lookup(DoorManagerConstants.DATA_SOURCE_NAME);
    } catch (NamingException e) {
        log.error("Error while looking up the data source: " + DoorManagerConstants.DATA_SOURCE_NAME);
    }

}