/** * Gets the service object. It can be a proxy, a client or whatever object depending on the service type. Unlike * {@link #get()} this method let you configure the type of object you want to retrieve. This parameter must match * the expected service type, and must pass the "polyglot" version of the class. * * @param x the * @return the object to access the service */ @Override public <X> X getAs(Class<X> x) { Object svc = get(); if (x == null || x.isInstance(svc)) { return (X) svc; } else { return ClassLoaderUtils.createWithDelegate(x, svc); } }
/** * Gets the service object. It can be a proxy, a client or whatever object depending on the service type. Unlike * {@link #get()} this method let you configure the type of object you want to retrieve. This parameter must match * the expected service type, and must pass the "polyglot" version of the class. * * @param x the * @return the object to access the service */ @Override public <X> X getAs(Class<X> x) { Object svc = get(); if (x == null || x.isInstance(svc)) { return (X) svc; } else { return ClassLoaderUtils.createWithDelegate(x, svc); } }