[esb-issues] [JBoss JIRA] Updated: (JBESB-1851) JAXRConnectionFactory should not rely on System properties when creating a Connection

Mark Little (JIRA) jira-events at lists.jboss.org
Fri Feb 13 12:59:44 EST 2009


     [ https://jira.jboss.org/jira/browse/JBESB-1851?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Little updated JBESB-1851:
-------------------------------

    Fix Version/s: 4.6


> JAXRConnectionFactory should not rely on System properties when creating a Connection
> -------------------------------------------------------------------------------------
>
>                 Key: JBESB-1851
>                 URL: https://jira.jboss.org/jira/browse/JBESB-1851
>             Project: JBoss ESB
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Examples, Registry and Repository
>            Reporter: Daniel Bevenius
>             Fix For: 4.6
>
>
> The quickstarts that use the ServiceInvoker all  seem to do this (atleast the ones that I've looked at) :
> System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");
> Now, we have this property in the jbossesb-properties.xml as:
> <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
> This property is read by JAXRConnectionFactory constructor and saved into a Properties object as:
> props.setProperty("javax.xml.registry.factoryClass", Configuration.getRegistryFactoryClass());
> The 'props' are set on the ConnectionFactory object that is created in the getConnection() method:
> protected Connection getConnection()
> {
>         Connection connection = null;
>         try
>         {   // Create the connection, passing it the configuration properties
>             ConnectionFactory factory = ConnectionFactory.newInstance();
>             factory.setProperties(props);
>             connection = factory.createConnection();
>             connection.setCredentials(creds);
>         } catch (JAXRException e) {
>             logger.log(Level.ERROR, "Could not set up a connection to the Registry. " + e.getMessage(), e);
>         }
>         return connection;
> }
> Here we can see that ConnectionFactory.newInstance() method will be called prior to the properties getting set on the factory, which is
> natural. But the problem is that ConnectionFactory.newInstance() method looks like this:
> private static final String SYS_PROP_NAME = "javax.xml.registry.ConnectionFactoryClass";
>    public static ConnectionFactory newInstance() throws JAXRException
>    {
>       String factoryName = null;
>       ConnectionFactory factory = null;
>       try
>       {
>          String defaultName = null;
>          factoryName = System.getProperty(SYS_PROP_NAME, defaultName);
>          ClassLoader loader =Thread.currentThread().getContextClassLoader();
>          Class factoryClass = loader.loadClass(factoryName);
>          factory = (ConnectionFactory) factoryClass.newInstance();
>       }
>       catch(Throwable e)
>       {
>          throw new JAXRException("Failed to create instance of:"+factoryName, e);
>       }
>       return factory;
>    } 
> We should not be relying on the system properties in order to do this.
> Our JAXRConnectionFactory should be creating the factory directly and
> not using ConnectionFactory, this is the real error IMO.  If we do this
> then we will not be affected by anyone else in the AS overriding JAXR.
>         Kev 
> See also this googlegroups thread for more background info: http://groups.google.se/group/jbossesb/browse_frm/thread/3a5ce28b4a0f6bca

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the esb-issues mailing list