<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pickwiki.org/index.php?action=history&amp;feed=atom&amp;title=FailoverUniSessionFactory</id>
	<title>FailoverUniSessionFactory - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pickwiki.org/index.php?action=history&amp;feed=atom&amp;title=FailoverUniSessionFactory"/>
	<link rel="alternate" type="text/html" href="https://pickwiki.org/index.php?title=FailoverUniSessionFactory&amp;action=history"/>
	<updated>2026-04-28T22:11:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://pickwiki.org/index.php?title=FailoverUniSessionFactory&amp;diff=1783&amp;oldid=prev</id>
		<title>Conversion script: link fix</title>
		<link rel="alternate" type="text/html" href="https://pickwiki.org/index.php?title=FailoverUniSessionFactory&amp;diff=1783&amp;oldid=prev"/>
		<updated>2015-02-26T23:48:54Z</updated>

		<summary type="html">&lt;p&gt;link fix&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Like the original [[UniSessionFactory]], this class provides connected sessions to [[UniData]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package edu.asu.vpia.dao;&lt;br /&gt;
import asjava.uniobjects.[[UniSession]];&lt;br /&gt;
import asjava.uniobjects.[[UniSessionException]];&lt;br /&gt;
&lt;br /&gt;
import java.io.[[InputStream]];&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
&lt;br /&gt;
import org.apache.commons.logging.Log;&lt;br /&gt;
import org.apache.commons.logging.[[LogFactory]];&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *  Factory method to create connected [[UniSession]] objects Uses the provided&lt;br /&gt;
 *  .properties filename, or &amp;#039;unidata.properties&amp;#039; if none is provided. File must&lt;br /&gt;
 *  be on the classpath. The properties file must contain&lt;br /&gt;
 *  [[ACCOUNT_PATH]]=/path/to/data and may contain definitions for [[HOST_NAME]],&lt;br /&gt;
 *  [[HOST_PORT]], [[CONNECTION_STRING]] [[USER_NAME]], PASSWORD and TIMEOUT to override the&lt;br /&gt;
 *  default settings. FAILOVER is optional and&lt;br /&gt;
 *  names the next .properties file to try if we are unable to connect using the&lt;br /&gt;
 *  initial one. &lt;br /&gt;
 *&lt;br /&gt;
 *@author     Wendy Smoak&lt;br /&gt;
 *@created    2003&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class [[UniSessionFactory]]&lt;br /&gt;
{&lt;br /&gt;
   private static Log log = [[LogFactory]].getLog( [[UniSessionFactory]].class );&lt;br /&gt;
&lt;br /&gt;
   /[[/UniData]] defaults:&lt;br /&gt;
   //private static final int [[HOST_PORT]] = 31438;&lt;br /&gt;
   private final static String [[CONNECTION_STRING]] = &amp;quot;udcs&amp;quot;;&lt;br /&gt;
   private final static String [[HOST_NAME]] = &amp;quot;your.host.name&amp;quot;;&lt;br /&gt;
   private final static String [[USER_NAME]] = &amp;quot;user&amp;quot;;&lt;br /&gt;
   private final static String PASSWORD = &amp;quot;pass&amp;quot;;&lt;br /&gt;
   //private static final String [[ACCOUNT_PATH]] = &amp;quot;/path/to/data&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   private final static String [[PROPS_FILENAME]] = &amp;quot;unidata.properties&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   /[[/UniVerse]] defaults:&lt;br /&gt;
   //private static final String [[CONNECTION_STRING]] = &amp;quot;uvcs&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   /**&lt;br /&gt;
    *  Private constructor. This class contains only static methods&lt;br /&gt;
    */&lt;br /&gt;
   private [[UniSessionFactory]]() { }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   /**&lt;br /&gt;
    *  Opens a session using the default .properties filename (unidata.properties)&lt;br /&gt;
    *&lt;br /&gt;
    *@return                          Description of the Return Value&lt;br /&gt;
    *@exception  [[UniSessionException]]  Description of the Exception&lt;br /&gt;
    *@exception  DAOException         Description of the Exception&lt;br /&gt;
    */&lt;br /&gt;
   public static [[UniSession]] openSession() throws [[UniSessionException]], DAOException&lt;br /&gt;
   {&lt;br /&gt;
      log.debug( &amp;quot;openSession: using default unidata.properties filename&amp;quot; );&lt;br /&gt;
      return openSession( [[PROPS_FILENAME]] );&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   /**&lt;br /&gt;
    *  Opens a session using the provided .properties filename&lt;br /&gt;
    *&lt;br /&gt;
    *@param  props[[FileName]]            Description of the Parameter&lt;br /&gt;
    *@return                          Description of the Return Value&lt;br /&gt;
    *@exception  [[UniSessionException]]  Description of the Exception&lt;br /&gt;
    *@exception  DAOException         Description of the Exception&lt;br /&gt;
    */&lt;br /&gt;
   public static [[UniSession]] openSession( String props[[FileName]] )&lt;br /&gt;
       throws [[UniSessionException]], DAOException&lt;br /&gt;
   {&lt;br /&gt;
      [[UniSession]] uSession = new [[UniSession]]();&lt;br /&gt;
      //log.debug( &amp;quot;openSession: uSession=&amp;quot; + uSession );&lt;br /&gt;
&lt;br /&gt;
      //you cannot change the port on [[UniData]], so no need [for me]&lt;br /&gt;
      //to pull this from the .properties file.&lt;br /&gt;
      //uSession.set[[HostPort]]( [[HOST_PORT]] );&lt;br /&gt;
&lt;br /&gt;
      Properties props = new Properties();&lt;br /&gt;
&lt;br /&gt;
      try {&lt;br /&gt;
         [[ClassLoader]] cl = [[UniSessionFactory]].class.get[[ClassLoader]]();&lt;br /&gt;
         [[InputStream]] input = cl.get[[ResourceAsStream]]( props[[FileName]] );&lt;br /&gt;
&lt;br /&gt;
         if ( input == null ) {&lt;br /&gt;
            log.fatal( &amp;quot;openSession: Unable to load &amp;quot; + props[[FileName]] );&lt;br /&gt;
            throw new DAOException( &amp;quot;Properties file &amp;quot; + props[[FileName]] + &amp;quot; missing&amp;quot; );&lt;br /&gt;
         }&lt;br /&gt;
         props.load( input );&lt;br /&gt;
&lt;br /&gt;
         //set the [[UniSession]] properties, using the defaults if the&lt;br /&gt;
         //values are not present in the [[PROPS_FILENAME]] file&lt;br /&gt;
         /[[/ACCOUNT_PATH]] *must* be in the properties file, no default provided&lt;br /&gt;
         //uSession.set[[AccountPath]]( props.getProperty( &amp;quot;[[ACCOUNT_PATH]]&amp;quot;, [[ACCOUNT_PATH]] ) );&lt;br /&gt;
         uSession.set[[AccountPath]]( props.getProperty( &amp;quot;[[ACCOUNT_PATH]]&amp;quot; ) );&lt;br /&gt;
         uSession.set[[HostName]]( props.getProperty( &amp;quot;[[HOST_NAME]]&amp;quot;, [[HOST_NAME]] ) );&lt;br /&gt;
         uSession.set[[UserName]]( props.getProperty( &amp;quot;[[USER_NAME]]&amp;quot;, [[USER_NAME]] ) );&lt;br /&gt;
         uSession.setPassword( props.getProperty( &amp;quot;PASSWORD&amp;quot;, PASSWORD ) );&lt;br /&gt;
         uSession.set[[ConnectionString]]( props.getProperty( &amp;quot;[[CONNECTION_STRING]]&amp;quot;, [[CONNECTION_STRING]] ) );&lt;br /&gt;
&lt;br /&gt;
         int defaultTimeout = uSession.getTimeout();&lt;br /&gt;
         int timeout = Integer.parseInt( props.getProperty( &amp;quot;TIMEOUT&amp;quot;, String.valueOf( defaultTimeout ) ) );&lt;br /&gt;
         uSession.setTimeout( timeout );&lt;br /&gt;
&lt;br /&gt;
         log.debug( &amp;quot;openSession: [[ACCOUNT_PATH]]=&amp;quot; + uSession.get[[AccountPath]]()&lt;br /&gt;
             + &amp;quot; [[HOST_NAME]]=&amp;quot; + uSession.get[[HostName]]()&lt;br /&gt;
             + &amp;quot; [[USER_NAME]]=&amp;quot; + uSession.get[[UserName]]() );&lt;br /&gt;
&lt;br /&gt;
      } catch ( java.io.IOException ex ) {&lt;br /&gt;
         log.error( ex );&lt;br /&gt;
         throw new DAOException( ex );&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      try {&lt;br /&gt;
         uSession.connect();&lt;br /&gt;
      } catch ( [[UniSessionException]] ex ) {&lt;br /&gt;
         String failover = props.getProperty( &amp;quot;FAILOVER&amp;quot; );&lt;br /&gt;
         if ( failover != null &amp;amp;&amp;amp; !failover.equals( &amp;quot;&amp;quot; ) ) {&lt;br /&gt;
            log.debug( &amp;quot;openSession: failing over to &amp;quot; + failover );&lt;br /&gt;
            return [[UniSessionFactory]].openSession( failover );&lt;br /&gt;
         } else {&lt;br /&gt;
            throw new DAOException( ex );&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
      log.debug( &amp;quot;connected to &amp;quot; + uSession.get[[AccountPath]]() );&lt;br /&gt;
&lt;br /&gt;
      return uSession;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Conversion script</name></author>
	</entry>
</feed>