I am still trying to get a handle on how to use components. Using components with other components seems pretty straightforward. What I am still having some trouble with is mixing components with non-component classes. In particular, how to properly propegate resources to classes that require them like DataSources.
For example, I have a hypothetical class that does some kind of database operation but is not a component. Call it "MyQuery". Is the best way to use a DataSource without breaking IOC by implementing a setDataSource() method in MyQuery? So.. MyQuery mq = new MyQuery(); JdbcDataSource datasource = null; try { datasource = container.lookup(JdbcDataSource.ROLE); mq.setDataSource(datasource); catch (ComponentException e) { ... } finally { if (datasource != null) container.release(datasource); } Is there anything wrong with passing a Component object ot a Non-Component object? Then what about an object where it's scope isn't localized because the object is passed to another object or a context like in Velocity. The only thing I can think of is to implement implement a setConnection() method instead of a setDataSource to quickly release dependancy on the component. MyQuery mq = new MyQuery(); JdbcDataSource datasource = null; try { datasource = container.lookup(JdbcDataSource.ROLE); mq.setConnection(datasource.getConnection()); velocitycontext.put("myqueryobject",mq); catch (ComponentException e) { ... } finally { if (datasource != null) container.release(datasource); } Now, there is a possiblity that a user of MyQuery may forget to set the Connection or DataSource so this becomes a source of errors if incorrectly applied and I have to throw runtime exceptions. I was also wondering if it might be possible to make the setting of required resources like datasources more transparent. One thought I had might be to use a factory that is a component to create non-component classes and set its required resources like datasources. Does that make sence or am I on the wrong track here? I would really appreciate some suggestions. The fundamentals of avalon are pretty easy to grasp and the benefits to my code were clear right away. It is just some of these implementation details that are a bit tricky. Thanks in advance. Kerry Todyruik -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>