You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Eugene Prokopiev <pr...@stc.donpac.ru> on 2006/07/12 11:23:12 UTC

XBeans -> Spring configuration translation

Hi,

I have this XBeans:

<persistenceAdapter>
	<journaledJDBC journalLogFiles="5" dataDirectory="activemq-data" 
dataSource="#postgres-ds"/>
</persistenceAdapter>

I need to use it in my Spring config. How can I implement it in raw 
Spring beans? What it the general way to do it?

--
Thanks,
Eugene Prokopiev


Re: XBeans -> Spring configuration translation

Posted by James Strachan <ja...@gmail.com>.
Try switch to   <property name="persistenceAdapter"
ref="myPersistenceAdapter"/> and move the nested bean out to the top level
(so a peer of 'broker')? This is a pure Spring discussion now so you could
always try the Spring forums if you have questions on spring or the spring
IDE

On 7/12/06, Eugene Prokopiev <pr...@stc.donpac.ru> wrote:
>
> > <bean class="org.apache.activemq.store.PersistenceAdapterFactoryBean">
> > <property name="journalLogFiles" value="...."/>
> > <property> name="dataSource" ref="postgres-ds"/>
> > ....
> >
> > etc
> >
> > If you use the Spring IDE plugin it will pop up all the available
> > properties for you to save you hunting around the code to find what
> > properties are available on what POJOs.
>
> It's very interesting. I have this spring configuration:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> "http://www.springframework.org/dtd/spring-beans.dtd">
>
> <beans>
>         <bean id="broker" class="org.apache.activemq.broker.BrokerService"
> init-method="start" destroy-method="stop">
>                 <property name="persistent" value="true"/>
>                 <property name="transportConnectorURIs">
>                         <list>
>                                 <value>tcp://localhost:61234</value>
>                         </list>
>                 </property>
>                 <property name="persistenceAdapter">
>                         <bean id="myPersistenceAdapter"
> class="org.apache.activemq.store.PersistenceAdapterFactoryBean">
>                                 <property name="journalLogFiles"
> value="5"/>
>                                 <property name="dataDirectory"
> value="amq-data"/>
>                                 <property name="dataSource">
>                                         <bean class="
> org.postgresql.ds.PGSimpleDataSource">
>                                                 <property
> name="serverName" value="ats-manager"/>
>                                                 <property
> name="databaseName" value="activemq"/>
>                                                 <property name="user"
> value="activemq"/>
>                                         </bean>
>                                 </property>
>                         </bean>
>                 </property>
>         </bean>
> </beans>
>
> I attached Spring Beans View in Eclipse. So I can't see
> myPersistenceAdapter bean and I can't view all available properties even
> for broker bean. In context menu I see only Open config file, Open bean
> class, Show graph and Properties for broker bean and see Open config and
> Properties for persistenceAdapter property :(
>
> What's wrong?
>
> --
> Thanks,
> Eugene Prokopiev
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: XBeans -> Spring configuration translation

Posted by Eugene Prokopiev <pr...@stc.donpac.ru>.
> <bean class="org.apache.activemq.store.PersistenceAdapterFactoryBean">
> <property name="journalLogFiles" value="...."/>
> <property> name="dataSource" ref="postgres-ds"/>
> ....
> 
> etc
> 
> If you use the Spring IDE plugin it will pop up all the available
> properties for you to save you hunting around the code to find what
> properties are available on what POJOs.

It's very interesting. I have this spring configuration:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
"http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
	<bean id="broker" class="org.apache.activemq.broker.BrokerService" 
init-method="start" destroy-method="stop">
		<property name="persistent" value="true"/>
		<property name="transportConnectorURIs">
			<list>
				<value>tcp://localhost:61234</value>
			</list>
		</property>
		<property name="persistenceAdapter">
			<bean id="myPersistenceAdapter" 
class="org.apache.activemq.store.PersistenceAdapterFactoryBean">
				<property name="journalLogFiles" value="5"/>
				<property name="dataDirectory" value="amq-data"/>
				<property name="dataSource">
					<bean class="org.postgresql.ds.PGSimpleDataSource">
						<property name="serverName" value="ats-manager"/>
						<property name="databaseName" value="activemq"/>
						<property name="user" value="activemq"/>
					</bean>
				</property>
			</bean>
		</property>
	</bean>	
</beans>

I attached Spring Beans View in Eclipse. So I can't see 
myPersistenceAdapter bean and I can't view all available properties even 
for broker bean. In context menu I see only Open config file, Open bean 
class, Show graph and Properties for broker bean and see Open config and 
Properties for persistenceAdapter property :(

What's wrong?

-- 
Thanks,
Eugene Prokopiev

Re: XBeans -> Spring configuration translation

Posted by James Strachan <ja...@gmail.com>.
so something like

<bean class="org.apache.activemq.store.PersistenceAdapterFactoryBean">
<property name="journalLogFiles" value="...."/>
<property> name="dataSource" ref="postgres-ds"/>
...

etc

If you use the Spring IDE plugin it will pop up all the available
properties for you to save you hunting around the code to find what
properties are available on what POJOs.


On 7/12/06, Eugene Prokopiev <pr...@stc.donpac.ru> wrote:
> > If you grep the code for the element names you should see the POJOs
> > which map to <journaledJDBC> etc. Then just use the Java code to
> > configure in Spring.
>
> $ grep -r journaledJDBC . | grep java
> ./activemq-core/src/main/java/org/apache/activemq/store/PersistenceAdapterFactoryBean.java:
> * @org.apache.xbean.XBean element="journaledJDBC"
>
> $ cat
> ./activemq-core/src/main/java/org/apache/activemq/store/PersistenceAdapterFactoryBean.java
>
> ...
> package org.apache.activemq.store;
>
> import org.springframework.beans.factory.FactoryBean;
>
> /**
>   * Creates a default persistence model using the Journal and JDBC
>   *
>   * @org.apache.xbean.XBean element="journaledJDBC"
>   *
>   * @version $Revision: 1.1 $
>   */
> public class PersistenceAdapterFactoryBean extends
> DefaultPersistenceAdapterFactory implements FactoryBean {
>
>      private PersistenceAdapter persistenceAdaptor;
>
>      public Object getObject() throws Exception {
>          if (persistenceAdaptor == null) {
>              persistenceAdaptor = createPersistenceAdapter();
>          }
>          return persistenceAdaptor;
>      }
>
>      public Class getObjectType() {
>          return PersistenceAdapter.class;
>      }
>
>      public boolean isSingleton() {
>          return false;
>      }
>
> }
>
> So, it's not visible how can I define journalLogFiles, dataDirectory and
> dataSource elements :(
>
> > The dataSource="#postgres-ds" maps to a bean <property
> > name="dataSource" ref="postgres-ds"/>
>
> This is more simple than first case ...
>
> --
> Thanks,
> Eugene Prokopiev
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: XBeans -> Spring configuration translation

Posted by Eugene Prokopiev <pr...@stc.donpac.ru>.
> If you grep the code for the element names you should see the POJOs
> which map to <journaledJDBC> etc. Then just use the Java code to
> configure in Spring.

$ grep -r journaledJDBC . | grep java
./activemq-core/src/main/java/org/apache/activemq/store/PersistenceAdapterFactoryBean.java: 
* @org.apache.xbean.XBean element="journaledJDBC"

$ cat 
./activemq-core/src/main/java/org/apache/activemq/store/PersistenceAdapterFactoryBean.java 

...
package org.apache.activemq.store;

import org.springframework.beans.factory.FactoryBean;

/**
  * Creates a default persistence model using the Journal and JDBC
  *
  * @org.apache.xbean.XBean element="journaledJDBC"
  *
  * @version $Revision: 1.1 $
  */
public class PersistenceAdapterFactoryBean extends 
DefaultPersistenceAdapterFactory implements FactoryBean {

     private PersistenceAdapter persistenceAdaptor;

     public Object getObject() throws Exception {
         if (persistenceAdaptor == null) {
             persistenceAdaptor = createPersistenceAdapter();
         }
         return persistenceAdaptor;
     }

     public Class getObjectType() {
         return PersistenceAdapter.class;
     }

     public boolean isSingleton() {
         return false;
     }

}

So, it's not visible how can I define journalLogFiles, dataDirectory and 
dataSource elements :(

> The dataSource="#postgres-ds" maps to a bean <property
> name="dataSource" ref="postgres-ds"/>

This is more simple than first case ...

-- 
Thanks,
Eugene Prokopiev


Re: XBeans -> Spring configuration translation

Posted by James Strachan <ja...@gmail.com>.
On 7/12/06, Eugene Prokopiev <pr...@stc.donpac.ru> wrote:
> Hi,
>
> I have this XBeans:
>
> <persistenceAdapter>
>         <journaledJDBC journalLogFiles="5" dataDirectory="activemq-data"
> dataSource="#postgres-ds"/>
> </persistenceAdapter>
>
> I need to use it in my Spring config. How can I implement it in raw
> Spring beans? What it the general way to do it?

If you grep the code for the element names you should see the POJOs
which map to <journaledJDBC> etc. Then just use the Java code to
configure in Spring.

The dataSource="#postgres-ds" maps to a bean <property
name="dataSource" ref="postgres-ds"/>

-- 

James
-------
http://radio.weblogs.com/0112098/