Lin Ren
2018-03-22 13:25:25 UTC
Hi Team,
Â
Iâm not sure if Iâm mailing the correct alias but Iâve a question about Jetty usage.
Â
Iâm currently trying to build up applications based on standalone Jetty and have a requirement that, some of the server services need be started before the war applications are deployed and started to provide general services for the deployed applications.
Â
I tried to create a class which inherits âorg.eclipse.jetty.util.component.AbstractLifeCycleâ with annotation â@ManagedObjectâ, and also, it is injected by adding definitions into jetty.xml like below:
Â
   <Call name="addManaged">
     <Arg>
       <New class="oraclel.ocsg.jetty.trial.MyAbstractLifeCycle"/>
     </Arg>
   </Call>
Â
And, within the class, I need get access to the JDBC connection data source. I checked the document and found that, for applications, it is required to add the jdbc resource reference into the web.xml. While for my case, I donât know how to get the data source. I tried to lookup JNDI in the MyAbstractLifeCycle class I created, but it failed.
Â
Below is my JDBC connection pool definition in the jetty.xml:
Â
   <New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg></Arg>
    <Arg>jdbc/DSTest</Arg>
    <Arg>
       <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
          <Set name="Url">jdbc:mysql://10.182.12.146:3306/linren</Set>
          <Set name="User">ocsgtest</Set>
          <Set name="Password">123456</Set>
       </New>
    </Arg>
   </New>
Â
Can anyone tell me how to get the JDBC connection from the inherited class MyAbstractLifeCycle?
Â
Thanks!
Â
Lin
Â
Â
Iâm not sure if Iâm mailing the correct alias but Iâve a question about Jetty usage.
Â
Iâm currently trying to build up applications based on standalone Jetty and have a requirement that, some of the server services need be started before the war applications are deployed and started to provide general services for the deployed applications.
Â
I tried to create a class which inherits âorg.eclipse.jetty.util.component.AbstractLifeCycleâ with annotation â@ManagedObjectâ, and also, it is injected by adding definitions into jetty.xml like below:
Â
   <Call name="addManaged">
     <Arg>
       <New class="oraclel.ocsg.jetty.trial.MyAbstractLifeCycle"/>
     </Arg>
   </Call>
Â
And, within the class, I need get access to the JDBC connection data source. I checked the document and found that, for applications, it is required to add the jdbc resource reference into the web.xml. While for my case, I donât know how to get the data source. I tried to lookup JNDI in the MyAbstractLifeCycle class I created, but it failed.
Â
Below is my JDBC connection pool definition in the jetty.xml:
Â
   <New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg></Arg>
    <Arg>jdbc/DSTest</Arg>
    <Arg>
       <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
          <Set name="Url">jdbc:mysql://10.182.12.146:3306/linren</Set>
          <Set name="User">ocsgtest</Set>
          <Set name="Password">123456</Set>
       </New>
    </Arg>
   </New>
Â
Can anyone tell me how to get the JDBC connection from the inherited class MyAbstractLifeCycle?
Â
Thanks!
Â
Lin
Â