users@jersey.java.net

about inject one object

From: tatsuya uesugi <tatsuyazheng_at_gmail.com>
Date: Tue, 16 Jun 2009 22:25:46 +0800

Hi! i have a trouble with inject one object, i want to know how to inject
one object and this object depend on another object which also injected.
maybe you don't understand the problem,i will give the example.
there is one class named ConnectionProvider. that extends the
PerRequestTypeInjectableProvider
public class ConnectionProvider extends
  PerRequestTypeInjectableProvider<Context, Connection> {

 @Context HttpServletRequest httpServletRequest;
 public ConnectionProvider() {
  super(Connection.class);
  }
 @Override
 public Injectable<Connection> getInjectable(ComponentContext cc,
   Context context) {
.....
and there is another class named TransactionProvider which also extends the
PerRequestTypeInjectableProvider class:
@Provider
public class TransactionProvider extends
    PerRequestTypeInjectableProvider<Context, TransactionManager> {
  /** HTTP Servlet Request. */
  @Context
  HttpServletRequest httpServletRequest;
// @Context
// Connection connection;
  /** Count of send event when get transaction failure. */
    private static int gettransactionFailCount = 0;
    /** Count of get session failure. */
    public static boolean firstSendGetSessionFailEvent = true;

    /** Count of send event when get connection failure. */
    private static int getConnFailCount = 0;
    /** Count of get connection pool failure. */
    public static boolean firstSendGetConnPoolFailEvent = true;

  public TransactionProvider() {
    super(TransactionManager.class);
  }
  @Override
  public Injectable<TransactionManager> getInjectable(ComponentContext cc,
Context arg1) {
    return new Injectable<TransactionManager>() {
      public TransactionManager getValue() {
         if(conn == null){
            Debugger.error("[beaf] TransactionProvider.getInjectable() ***
can't get connection.");
            throw new WebApplicationException(500);
          }
.......
this TransactionProvider use the connection which is another provider,and i
can not get the connection by the inject,
i want to know how to get the connection by inject in this
TransactionProvider class.
thank you !!