com.sun.xml.ws.util.InjectionPlan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webservices-rt Show documentation
Show all versions of webservices-rt Show documentation
This module contains the Metro runtime code.
/*
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package com.sun.xml.ws.util;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import jakarta.annotation.Resource;
import jakarta.xml.ws.WebServiceException;
/**
* Encapsulates which field/method the injection is done, and performs the
* injection.
*/
public abstract class InjectionPlan {
/**
* Perform injection
*
* @param instance
* Instance
* @param resource
* Resource
*/
public abstract void inject(T instance, R resource);
/**
* Perform injection, but resource is only generated if injection is
* necessary.
*
* @param instance
* @param resource
*/
public void inject(T instance, Callable resource) {
try {
inject(instance, resource.call());
} catch(Exception e) {
throw new WebServiceException(e);
}
}
/*
* Injects to a field.
*/
public static class FieldInjectionPlan extends
InjectionPlan {
private final Field field;
public FieldInjectionPlan(Field field) {
this.field = field;
}
public void inject(final T instance, final R resource) {
AccessController.doPrivileged(new PrivilegedAction