Package org.exolab.castor.jdo.conf

Examples of org.exolab.castor.jdo.conf.Param


        Properties properties = new Properties();
         
        Enumeration parameters = transactionManager.enumerateParam();
        while (parameters.hasMoreElements()) {
          Param param = (Param) parameters.nextElement();
          properties.put(param.getName(), param.getValue());
        }
     
        factory.setParams(properties);
       
      }
View Full Code Here


      throws MappingException
  {

        DataSource dataSource;
    Param[] parameters;
    Param param;
   
    String className = database.getDatabaseChoice().getDataSource().getClassName();
    if (classLoader == null) {
      classLoader = Thread.currentThread().getContextClassLoader();
    }
   
    try {
      dataSource = (DataSource) Class.forName (className, true, classLoader).newInstance();
    }
    catch (Exception e) {
      throw new MappingException(Messages.format ("jdo.engine.classNotInstantiable",
                     className), e);
    }

    parameters = database.getDatabaseChoice().getDataSource().getParam();
   
    Unmarshaller unmarshaller = new Unmarshaller(dataSource);
    UnmarshalHandler handler = unmarshaller.createHandler();
   
    try {
      handler.startDocument();
      handler.startElement("data-source", null);

      for (int i = 0; i < parameters.length; i++) {
         param = (Param) parameters[i];
         handler.startElement(param.getName(), null);
         handler.characters(param.getValue().toCharArray(), 0, param.getValue().length());
         handler.endElement(param.getName());
      }

      handler.endElement("data-source");
      handler.endDocument();
    } catch (SAXException e) {
View Full Code Here

    throws MappingException, SQLException
  {
    DatabaseRegistry dbs;
    Properties  props;
    Enumeration params;
    Param       param;

        String driverName = database.getDatabaseChoice().getDriver().getClassName();
    if (driverName != null ) {
        try {
            Class.forName (database.getDatabaseChoice().getDriver().getClassName()).newInstance();
        }
      catch (InstantiationException e) {
        _log.error (Messages.format ("jdo.engine.classNotInstantiable", driverName), e);
            throw new MappingException(Messages.format ("jdo.engine.classNotInstantiable", driverName), e);
      }
      catch (IllegalAccessException e) {
        _log.error (Messages.format ("jdo.engine.classNotAccessable", driverName, "constructor"), e);
            throw new MappingException(Messages.format ("jdo.engine.classNotAccessable", driverName, "constructor"), e);
      }
      catch (ClassNotFoundException e) {
        _log.error ("Can not load class " + driverName, e);
            throw new MappingException("Can not load class " + driverName, e);
      }
    }

    if (DriverManager.getDriver (database.getDatabaseChoice().getDriver().getUrl()) == null)
        throw new MappingException( "jdo.missingDriver", database.getDatabaseChoice().getDriver().getUrl());

    props = new Properties();
    params = database.getDatabaseChoice().getDriver().enumerateParam();
    while (params.hasMoreElements()) {
        param = (Param) params.nextElement();
        props.put (param.getName(), param.getValue());
    }

    dbs = new DatabaseRegistry (database.getName(),
                  mapping.getResolver(Mapping.JDO, factory),
                  factory,
View Full Code Here

   * @param value parameter value
   * @return Param object
   */
  public static Param createJdoConfParam(String name, String value)
  {
    Param param = new Param();

    param.setName(name);
    param.setValue(value);

    return param;
  }
View Full Code Here

            if ( database.getDriver() != null ) {
                // JDO configuration file specifies a driver, use the driver
                // properties to create a new registry object.
                Properties  props;
                Enumeration params;
                Param       param;

                if ( database.getDriver().getClassName() != null ) {
                    try {
                        Class.forName( database.getDriver().getClassName() ).newInstance();
                    } catch ( Exception except ) {
                        throw new MappingException( except );
                    }
                }
                if ( DriverManager.getDriver( database.getDriver().getUrl() ) == null )
                    throw new MappingException( "jdo.missingDriver", database.getDriver().getUrl() );

                props = new Properties();
                params = database.getDriver().enumerateParam();
                while ( params.hasMoreElements() ) {
                    param = (Param) params.nextElement();
                    props.put( param.getName(), param.getValue() );
                }
                dbs = new DatabaseRegistry( database.getName(), mapping.getResolver( Mapping.JDO, factory ), factory,
                                            database.getDriver().getUrl(), props, logInterceptor );
            } else if ( database.getDataSource() != null ) {
                // JDO configuration file specifies a DataSource object, use the
View Full Code Here

TOP

Related Classes of org.exolab.castor.jdo.conf.Param

Copyright © 2018 www.massapicom. 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.