Announcement Announcement Module
Collapse
No announcement yet.
Eclipse roo shell command parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Eclipse roo shell command parameters

    It appears that you can't set any options when starting the roo shell from within eclipse.

    I'd like to be able to send a parameter, or anything, so that when roo reads pom.xml, a 'roo' profile in pom.xml can pick it up.
    Or so that I can use Spring expression language to make a choice between two different actions.

    For example when roo does database reverse engineering it obviously can't use a jndi ref from Tomcat.
    So I want to tell the pom to read from database.properties, and in other circumstances to use the jndi ref.

    But I can't work out for the life of me who to tell the pom that this is roo calling.

    Anybody got any ideas? Thanks.

  • #2
    Hope nobody minds if I bump this. Anybody got any ideas?

    Comment


    • #3
      Ok, finally worked it out.

      You use spring profiles in applicationContext.xml (available since 3.1).

      I have a 'roo' profile which uses a BasicDataSource to call the database without a container
      and a 'tomcat' profile which uses JNDI within the Tomcat Container.

      The tomcat profile is made active in web.xml with a context-param: <context-param>
      <param-name>spring.profiles.active</param-name>
      <param-value>tomcat</param-value>
      </context-param>

      and the roo profile is made active in ROO_HOME/conf/config.properties thus:

      #The profile we need to configure the datasource
      -Dspring.profiles.active=roo
      ----------------

      Here is the stuff from applicationContext.xml, unfortunately you have to repeat the EntityManagerFactory bean in both profiles otherwise Tomcat says that it can't find it <!-- active profile is set in ROO_HOME/conf/config.properties -->
      <beans profile="roo">
      <bean class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean" id="entityManagerFactory">
      <property name="persistenceUnitName" value="persistenceUnit"/>
      <property name="dataSource" ref="dataSource"/>
      <!-- added for jpa -->
      <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
      <property name="showSql" value="false" />
      <property name="generateDdl" value="true" />
      <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
      </bean>
      </property>
      </bean>

      <bean class="org.springframework.orm.jpa.JpaTransactionM anager" id="transactionManager">
      <property name="entityManagerFactory" ref="entityManagerFactory"/>
      <property name="jpaDialect">
      <bean class="org.springframework.orm.jpa.vendor.Hibernat eJpaDialect" />
      </property>
      </bean>

      <bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
      <property name="driverClassName" value="${database.driverClassName}"/>
      <property name="url" value="${database.url}"/>
      <property name="username" value="${database.username}"/>
      <property name="password" value="${database.password}"/>
      <property name="testOnBorrow" value="true"/>
      <property name="testOnReturn" value="true"/>
      <property name="testWhileIdle" value="true"/>
      <property name="timeBetweenEvictionRunsMillis" value="1800000"/>
      <property name="numTestsPerEvictionRun" value="3"/>
      <property name="minEvictableIdleTimeMillis" value="1800000"/>
      <property name="validationQuery" value="SELECT 1"/>
      </bean>
      </beans>

      <!-- profile is set in web.xml in a context-param -->
      <beans profile="tomcat">
      <bean class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean" id="entityManagerFactory">
      <property name="persistenceUnitName" value="persistenceUnit"/>
      <property name="dataSource" ref="dataSource"/>
      <!-- added for jpa -->
      <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
      <property name="showSql" value="false" />
      <property name="generateDdl" value="true" />
      <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
      </bean>
      </property>
      </bean>

      <bean class="org.springframework.orm.jpa.JpaTransactionM anager" id="transactionManager">
      <property name="entityManagerFactory" ref="entityManagerFactory"/>
      <property name="jpaDialect">
      <bean class="org.springframework.orm.jpa.vendor.Hibernat eJpaDialect" />
      </property>
      </bean>

      <jee:jndi-lookup id="dataSource" jndi-name="jdbc/mySql"/>
      </beans>

      Comment

      Working...
      X