Examples of JndiObjectFactoryBean


Examples of org.springframework.jndi.JndiObjectFactoryBean

        as.setId("echo");
        as.setComponent(new EchoComponent());
        as.setService(new QName("echo"));
        jbi.activateComponent(as);
       
        JndiObjectFactoryBean fb = new JndiObjectFactoryBean();
        fb.setJndiName(ClientFactory.DEFAULT_JNDI_NAME);
        fb.afterPropertiesSet();
        ClientFactory cf = (ClientFactory) fb.getObject();
        ServiceMixClient client = cf.createClient();
       
        Destination dest = client.createDestination("service::echo");
        InOut me = dest.createInOutExchange();
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
View Full Code Here

Examples of org.springframework.jndi.JndiObjectFactoryBean

           
            if (dsRefName.equals(RDBMServices.DEFAULT_DATABASE)) {
                // get a DataSource from RDBMServices
                source = RDBMServices.getDataSource(dsRefName);
            } else {
                JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
                factory.setJndiName("jdbc/" + dsRefName);
                factory.setResourceRef(true);
               
                try {
                    factory.afterPropertiesSet();
                    source = (DataSource) factory.getObject();
                } catch (Exception t) {
                    LOG.error("Error looking up datasource [" + dsRefName + "] from JNDI.", t);
                    throw new IllegalArgumentException("Referenced JNDI name [" + dsRefName + "] did not map to a DataSource.");
                }
View Full Code Here

Examples of org.springframework.jndi.JndiObjectFactoryBean

     * @see org.springframework.beans.factory.FactoryBean#getObject()
     */
    public Object getObject() throws Exception {
        if(StringUtils.hasText(dataSourceJndiName)) {
            logger.info("JNDI datasource requested, looking up datasource from JNDI name: '" + dataSourceJndiName + "'");
            JndiObjectFactoryBean factoryBean = new JndiObjectFactoryBean();
            factoryBean.setJndiName(dataSourceJndiName);
           
            // "java:comp/env/" will be prefixed if the JNDI name doesn't already have it
            factoryBean.setResourceRef(true);
           
            // This step actually does the JNDI lookup
            try {
                factoryBean.afterPropertiesSet();
            } catch(Exception e) {
                logger.error("datasource init from JNDI failed : " + e);
                logger.error("aborting application startup");
                throw new RuntimeException(e);
            } // end try..catch
           
            dataSource = (DataSource) factoryBean.getObject();
        } else if(url.startsWith("jdbc:hsqldb:file")) {
            logger.info("embedded HSQLDB mode detected, switching on spring single connection data source");
            SingleConnectionDataSource ds = new SingleConnectionDataSource();
            ds.setUrl(url);
            ds.setDriverClassName(driverClassName);
View Full Code Here

Examples of org.springframework.jndi.JndiObjectFactoryBean

  }

  private void initMailSenderFromJndi(String mailSessionJndiName) {
    logger.info("attempting to initialize mail sender from jndi name = '"
        + mailSessionJndiName + "'");
    JndiObjectFactoryBean factoryBean = new JndiObjectFactoryBean();
    factoryBean.setJndiName(mailSessionJndiName);
    // "java:comp/env/" will be prefixed if the JNDI name doesn't already
    // have it
    factoryBean.setResourceRef(true);
    try {
      // this step actually does the JNDI lookup
      factoryBean.afterPropertiesSet();
    } catch (Exception e) {
      logger.warn("failed to locate mail session : " + e);
      return;
    }
    Session session = (Session) factoryBean.getObject();
    sender = new JavaMailSenderImpl();
    sender.setSession(session);
    logger.info("email sender initialized from jndi name = '"
        + mailSessionJndiName + "'");
  }
View Full Code Here

Examples of org.springframework.jndi.JndiObjectFactoryBean

        as.setId("echo");
        as.setComponent(new EchoComponent());
        as.setService(new QName("echo"));
        jbi.activateComponent(as);
       
        JndiObjectFactoryBean fb = new JndiObjectFactoryBean();
        fb.setJndiName(ClientFactory.DEFAULT_JNDI_NAME);
        fb.afterPropertiesSet();
        ClientFactory cf = (ClientFactory) fb.getObject();
        ServiceMixClient client = cf.createClient();
       
        Destination dest = client.createDestination("service::echo");
        InOut me = dest.createInOutExchange();
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
View Full Code Here

Examples of org.springframework.jndi.JndiObjectFactoryBean

      }
    }

    if ("true".equals(misoProperties.get("miso.statsdb.enabled"))) {
      try {
        JndiObjectFactoryBean jndiBean = new JndiObjectFactoryBean();
        jndiBean.setLookupOnStartup(true);
        jndiBean.setResourceRef(true);
        jndiBean.setJndiName("jdbc/STATSDB");
        jndiBean.setExpectedType(javax.sql.DataSource.class);
        jndiBean.afterPropertiesSet();

        DataSource datasource = (DataSource)jndiBean.getObject();

        JdbcTemplate template = new JdbcTemplate();
        template.setDataSource(datasource);
        template.setNativeJdbcExtractor(new CommonsDbcpNativeJdbcExtractor());
        context.getBeanFactory().registerSingleton("statsInterfaceTemplate", template);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.