Java源码示例:com.oracle.svm.core.annotate.Substitute
示例1
@Substitute
static JAXRSClientFactoryBean getBean(String baseAddress, String configLocation) {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
// configLocation is always null and no need to create SpringBusFactory.
CXFBusFactory bf = new CXFBusFactory();
// It can not load the extensions from the bus-extensions.txt dynamically.
// So have to set all of necessary ones here.
List<Extension> extensions = new ArrayList<>();
Extension http = new Extension();
http.setClassname(HTTPTransportFactory.class.getName());
http.setDeferred(true);
extensions.add(http);
ExtensionRegistry.addExtensions(extensions);
Bus bus = bf.createBus();
bus.setExtension(new PhaseManagerImpl(), PhaseManager.class);
bus.setExtension(new ClientLifeCycleManagerImpl(), ClientLifeCycleManager.class);
bus.setExtension(new ConduitInitiatorManagerImpl(bus), ConduitInitiatorManager.class);
bean.setBus(bus);
bean.setAddress(baseAddress);
return bean;
}
示例2
@SuppressWarnings("unchecked")
@Substitute
private <T> Collection<T> getSpringFactoriesInstances(Class<T> type, Class<?>[] parameterTypes, Object... args) {
List<T> instances;
if (type.equals(SpringApplicationRunListener.class)) {
instances = (List<T>) Arrays.asList(new EventPublishingRunListener((SpringApplication)(Object)this, new String[0])); // TODO convert args
// Error when using it, and we probably should do that at build time
//AnnotationAwareOrderComparator.sort(instances);
}
else if (type.equals(SpringBootExceptionReporter.class)) {
instances = (List<T>) Arrays.asList(DiagnosticsProvider.getFailureAnalyzers((ConfigurableApplicationContext) args[0])); // Package private
// Error when using it, and we probably should do that at build time
//AnnotationAwareOrderComparator.sort(instances);
}
else {
instances = SpringFactoriesLoader.loadFactories(type, null);
}
return instances;
}
示例3
@Substitute
protected Target_AbstractMappingContext() {
this.persistentPropertyPathFactory = new PersistentPropertyPathFactory<E, P>((AbstractMappingContext)(Object)this);
EntityInstantiators instantiators = new EntityInstantiators();
Target_BeanWrapperPropertyAccessorFactory accessorFactory = Target_BeanWrapperPropertyAccessorFactory.INSTANCE;
this.persistentPropertyAccessorFactory = new InstantiationAwarePropertyAccessorFactory(accessorFactory,
instantiators);
NONE = Optional.empty();
persistentEntities = new HashMap<>();
evaluationContextProvider = EvaluationContextProvider.DEFAULT;
initialEntitySet = new HashSet<>();
strict = false;
simpleTypeHolder = SimpleTypeHolder.DEFAULT;
lock = new ReentrantReadWriteLock();
read = lock.readLock();
write = lock.writeLock();
}
示例4
@Substitute
@Override
public void put(final HttpHost host, final AuthScheme authScheme) {
Args.notNull(host, "HTTP host");
if (authScheme == null) {
return;
}
this.map.put(getKey(host), authScheme);
}
示例5
@Substitute
protected MessageConsumer createConsumer(Session session, Destination destination) throws JMSException {
// Removes references to JMS 2.0 shared subscriptions
if (pubSubDomain && destination instanceof Topic) {
if (subscriptionDurable) {
return session.createDurableSubscriber(
(Topic) destination, subscriptionName, messageSelector, pubSubNoLocal);
} else {
return session.createConsumer(destination, messageSelector, pubSubNoLocal);
}
} else {
return session.createConsumer(destination, messageSelector);
}
}
示例6
@Substitute
private DozerClassLoader getClassLoader() {
// Substituted method impl without unwanted references to OSGiClassLoader
if (fluentDefinedClassLoader == null) {
return new DefaultClassLoader(DozerBeanMapperBuilder.class.getClassLoader());
} else {
return fluentDefinedClassLoader;
}
}
示例7
@Substitute
public synchronized void register(Logger logger) {
//JMX is not supported in the native mode
//because there is no API for avoiding MBean registration, substitution is used to skip registration
// enhancement in debezium:https://issues.redhat.com/browse/DBZ-2089
logger.warn("Metrics are not registered in native mode.");
}
示例8
@Substitute
List<Object> defaultCallAdapterFactories(Executor callbackExecutor) {
return Arrays.asList(
CompletableFutureCallAdapterFactorySubstitution.INSTANCE,
callbackExecutor != null
? new ExecutorCallAdapterFactorySubstitution(callbackExecutor)
: DefaultCallAdapterFactorySubstitution.INSTANCE);
}
示例9
@Substitute
public V get(K key) {
Reference<V> reference = this.map.get(key);
if (reference == null) {
return null;
}
V value = reference.get();
if (value == null) {
this.map.remove(key);
}
return value;
}
示例10
@Substitute
public Object invoke(MethodInvocation invocation) throws Throwable {
Method method = invocation.getMethod();
Object[] arguments = invocation.getArguments();
Object proxy = ((ProxyMethodInvocation)invocation).getProxy();
return method.invoke(proxy,arguments);
}
示例11
@Substitute
public static JsonParser getJsonParser() {
if (ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", null)) {
return new JacksonJsonParser();
}
if (ClassUtils.isPresent("com.google.gson.Gson", null)) {
return new GsonJsonParser();
}
return new BasicJsonParser();
}
示例12
@Substitute
private static InetAddress chooseAddress() throws UnknownHostException {
return InetAddress.getByName("0.0.0.0");
}
示例13
@Substitute
private static void convertAndSetItemsEnum(ExtensibleNode items, List<String> allowableValues, Class<?> type) {
throw new UnsupportedOperationException("RestOpenApiReader::convertAndSetItemsEnum should not be invoked");
}
示例14
@Substitute
@Override
public AuthScheme get(final HttpHost host) {
Args.notNull(host, "HTTP host");
return this.map.get(getKey(host));
}
示例15
@Substitute
public static Object simpleDeepCopy(Object toCopy) {
return JsonUtils.cloneJson(toCopy);
}
示例16
@Substitute
public static ConfigMBean registerConfigMbean(AbstractConfiguration config) {
return null;
}
示例17
@Substitute
public NoopXmlMappingBinderAccess(ServiceRegistry serviceRegistry) {
}
示例18
@Substitute
public static boolean isUnsafeAvailable() {
return false;
}
示例19
@Substitute
public IParser newRDFParser() {
throw new UnsupportedOperationException();
}
示例20
@Substitute
public URL determineDefaultPersistenceUnitRootUrl() {
return null;
}
示例21
@Substitute
protected boolean isOsgiContext() {
return false;
}
示例22
@Substitute
public ODataHttpHandler createHandler(final ServiceMetadata serviceMetadata) {
// Avoid the optional and redundant servlet-api dependency
throw new UnsupportedOperationException("OData HTTP handlers are not supported in native mode");
}
示例23
@Substitute
public static String encode(String s) {
return Base64.getEncoder().encodeToString(s.getBytes(StandardCharsets.UTF_8));
}
示例24
@Substitute
public static String encodeBytes(byte[] b) {
return Base64.getEncoder().encodeToString(b);
}
示例25
@Substitute
public SubstituteDefaultCacheManager() {
throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
示例26
@Substitute
public SubstituteDefaultCacheManager(boolean start) {
throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
示例27
@Substitute
public SubstituteDefaultCacheManager(Configuration defaultConfiguration) {
throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
示例28
@Substitute
public SubstituteDefaultCacheManager(Configuration defaultConfiguration, boolean start) {
throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
示例29
@Substitute
public SubstituteDefaultCacheManager(GlobalConfiguration globalConfiguration) {
throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
示例30
@Substitute
public Binding bind(InputStreamAccess xmlInputStreamAccess) {
return null;
}