Package org.jboss.resource

Examples of org.jboss.resource.JBossResourceException


    */
   protected Properties getConnectionProperties(Subject subject, ConnectionRequestInfo cri)
      throws ResourceException
   {
      if (cri != null && cri.getClass() != WrappedConnectionRequestInfo.class)
         throw new JBossResourceException("Wrong kind of ConnectionRequestInfo: " + cri.getClass());

      Properties props = new Properties();
      props.putAll(connectionProps);
      if (subject != null)
      {
         if (SubjectActions.addMatchingProperties(subject, props, this) == true)
            return props;
         throw new JBossResourceException("No matching credentials in Subject!");
      }
      WrappedConnectionRequestInfo lcri = (WrappedConnectionRequestInfo)cri;
      if (lcri != null)
      {
         props.setProperty("user", (lcri.getUserName() == null)? "": lcri.getUserName());
View Full Code Here


   }

   public void associateConnection(Object handle) throws ResourceException
   {
      if (!(handle instanceof WrappedConnection))
         throw new JBossResourceException("Wrong kind of connection handle to associate" + handle);
      ((WrappedConnection) handle).setManagedConnection(this);
      synchronized (handles)
      {
         handles.add(handle);
      }
View Full Code Here

   private void checkIdentity(Subject subject, ConnectionRequestInfo cri) throws ResourceException
   {
      Properties newProps = mcf.getConnectionProperties(subject, cri);
      if (!props.equals(newProps))
      {
         throw new JBossResourceException("Wrong credentials passed to getConnection!");
      } // end of if ()
   }
View Full Code Here

   }

   protected void checkException(SQLException e) throws ResourceException
   {
      connectionError(e);
      throw new JBossResourceException("SQLException", e);
   }
View Full Code Here

   private XADataSource createXaDataSource(Properties xaProps)
   throws JBossResourceException
   {
   if(getXADataSourceClass() == null)
   {
      throw new JBossResourceException("No XADataSourceClass supplied!");
   }

   XADataSource xads;
   try
   {
      Class clazz = Thread.currentThread().getContextClassLoader().loadClass(getXADataSourceClass());
      xads = (XADataSource)clazz.newInstance();
      Class[] NOCLASSES = new Class[]{};
      for(Iterator i = xaProps.keySet().iterator(); i.hasNext();)
      {
         String name = (String)i.next();
         String value = xaProps.getProperty(name);
         char firstCharName = Character.toUpperCase(name.charAt(0));
        if (name.length() > 1)
          name = firstCharName+name.substring(1);
        else
           name = ""+firstCharName;                                                                                                           
         //This is a bad solution.  On the other hand the only known example
         // of a setter with no getter is for Oracle with password.
         //Anyway, each xadatasource implementation should get its
         //own subclass of this that explicitly sets the
         //properties individually.
         Class type = null;
         try
         {
            Method getter = clazz.getMethod("get" + name, NOCLASSES);
            type = getter.getReturnType();
         }
         catch(NoSuchMethodException e)
         {
            try
            {
               //HACK for now until we can rethink the XADataSourceProperties variable and pass type information
               Method isMethod = clazz.getMethod("is" + name, NOCLASSES);
               type = isMethod.getReturnType();
            }
            catch(NoSuchMethodException nsme)
            {
               type = String.class;
            }
         } // end of try-catch

         Method setter = clazz.getMethod("set" + name, new Class[]{type});
         PropertyEditor editor = PropertyEditorManager.findEditor(type);
         if(editor == null)
         {
            throw new JBossResourceException("No property editor found for type: " + type);
         } // end of if ()
         editor.setAsText(value);
         setter.invoke(xads, new Object[]{editor.getValue()});

      } // end of for ()
   }
   catch(ClassNotFoundException cnfe)
   {
      throw new JBossResourceException("Class not found for XADataSource " + getXADataSourceClass(), cnfe);
   } // end of try-catch
   catch(InstantiationException ie)
   {
      throw new JBossResourceException("Could not create an XADataSource: ", ie);
   } // end of catch
   catch(IllegalAccessException iae)
   {
      throw new JBossResourceException("Could not set a property: ", iae);
   } // end of catch

   catch(IllegalArgumentException iae)
   {
      throw new JBossResourceException("Could not set a property: ", iae);
   } // end of catch

   catch(InvocationTargetException ite)
   {
      throw new JBossResourceException("Could not invoke setter on XADataSource: ", ite);
   } // end of catch
   catch(NoSuchMethodException nsme)
   {
      throw new JBossResourceException("Could not find accessor on XADataSource: ", nsme);
   } // end of catch

   return xads;
   }
View Full Code Here

         {
            xaProps.load(is);
         }
         catch (IOException ioe)
         {
            throw new JBossResourceException("Could not load connection properties", ioe);
         }
      }
      initSelector();
   }
View Full Code Here

       xadsSelector.failedUrlObject(xaData);
        }
     }
 
     // we have supposedly tried all the urls
     throw new JBossResourceException(
        "Could not create connection using any of the URLs: " + xadsSelector.getAllUrlObjects()
     );    
   }
View Full Code Here

             xaConnection.close();
       }
       catch (Throwable ignored)
       {
       }
       throw new JBossResourceException("Could not create connection", e);
    }
  }
View Full Code Here

       return xada.xads;
    }
      if (xads == null)
      {
         if (xaDataSourceClass == null)
            throw new JBossResourceException("No XADataSourceClass supplied!");
         try
         {
            Class clazz = Thread.currentThread().getContextClassLoader().loadClass(xaDataSourceClass);
            xads = (XADataSource) clazz.newInstance();
            Class[] NOCLASSES = new Class[] {};
            for (Iterator i = xaProps.keySet().iterator(); i.hasNext();)
            {
               String name = (String) i.next();
               String value = xaProps.getProperty(name);     
               char firstCharName = Character.toUpperCase(name.charAt(0));
                if (name.length() > 1)
                     name = firstCharName+name.substring(1);
                else
                   name = ""+firstCharName;                                                                                                  
               //This is a bad solution.  On the other hand the only known example
               // of a setter with no getter is for Oracle with password.
               //Anyway, each xadatasource implementation should get its
               //own subclass of this that explicitly sets the
               //properties individually.
               Class type = null;
               try
               {
                  Method getter = clazz.getMethod("get" + name, NOCLASSES);
                  type = getter.getReturnType();
               }
               catch (NoSuchMethodException e)
               {
                  try
                  {
                     //HACK for now until we can rethink the XADataSourceProperties variable and pass type information
                     Method isMethod = clazz.getMethod("is" + name, NOCLASSES);
                     type = isMethod.getReturnType();
                  }
                  catch(NoSuchMethodException nsme)
                  {
                     type = String.class;
                  }
               }

               Method setter = clazz.getMethod("set" + name, new Class[] { type });
               PropertyEditor editor = PropertyEditorManager.findEditor(type);
               if (editor == null)
                  throw new JBossResourceException("No property editor found for type: " + type);
               editor.setAsText(value);
               setter.invoke(xads, new Object[] { editor.getValue() });
            }
         }
         catch (ClassNotFoundException cnfe)
         {
            throw new JBossResourceException("Class not found for XADataSource " + xaDataSourceClass, cnfe);
         }
         catch (InstantiationException ie)
         {
            throw new JBossResourceException("Could not create an XADataSource: ", ie);
         }
         catch (IllegalAccessException iae)
         {
            throw new JBossResourceException("Could not set a property: ", iae);
         }
         catch (IllegalArgumentException iae)
         {
            throw new JBossResourceException("Could not set a property: ", iae);
         }
         catch (InvocationTargetException ite)
         {
            throw new JBossResourceException("Could not invoke setter on XADataSource: ", ite);
         }
         catch (NoSuchMethodException nsme)
         {
            throw new JBossResourceException("Could not find accessor on XADataSource: ", nsme);
         }
      }
      return xads;
   }
View Full Code Here

    * @return <description>
    * @exception javax.resource.ResourceException <description>
    */
   public Object createConnectionFactory() throws ResourceException
   {
      throw new JBossResourceException("NYI");
      //return createConnectionFactory(new DefaultConnectionManager());
   }
View Full Code Here

TOP

Related Classes of org.jboss.resource.JBossResourceException

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.