Java Code Examples for com.oracle.svm.core.annotate.Substitute

The following examples show how to use com.oracle.svm.core.annotate.Substitute. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: camel-quarkus   Source File: WebClientSubstitution.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 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;
}
 
Example 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();
}
 
Example 4
Source Project: camel-quarkus   Source File: BasicAuthCacheAlias.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source Project: camel-quarkus   Source File: SpringJMSSubstitutions.java    License: Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 6
Source Project: camel-quarkus   Source File: DozerOSGiSubstitutions.java    License: Apache License 2.0 5 votes vote down vote up
@Substitute
private DozerClassLoader getClassLoader() {
    // Substituted method impl without unwanted references to OSGiClassLoader
    if (fluentDefinedClassLoader == null) {
        return new DefaultClassLoader(DozerBeanMapperBuilder.class.getClassLoader());
    } else {
        return fluentDefinedClassLoader;
    }
}
 
Example 7
Source Project: camel-quarkus   Source File: SubstituteMetrics.java    License: Apache License 2.0 5 votes vote down vote up
@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.");
}
 
Example 8
Source Project: camel-quarkus   Source File: PlatformSubstitution.java    License: Apache License 2.0 5 votes vote down vote up
@Substitute
List<Object> defaultCallAdapterFactories(Executor callbackExecutor) {
    return Arrays.asList(
            CompletableFutureCallAdapterFactorySubstitution.INSTANCE,
            callbackExecutor != null
                    ? new ExecutorCallAdapterFactorySubstitution(callbackExecutor)
                    : DefaultCallAdapterFactorySubstitution.INSTANCE);
}
 
Example 9
Source Project: camel-quarkus   Source File: SubstituteBeansWeakCache.java    License: Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 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);
}
 
Example 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();
}
 
Example 12
Source Project: camel-quarkus   Source File: SubstituteHostUtils.java    License: Apache License 2.0 4 votes vote down vote up
@Substitute
private static InetAddress chooseAddress() throws UnknownHostException {
    return InetAddress.getByName("0.0.0.0");
}
 
Example 13
@Substitute
private static void convertAndSetItemsEnum(ExtensibleNode items, List<String> allowableValues, Class<?> type) {
    throw new UnsupportedOperationException("RestOpenApiReader::convertAndSetItemsEnum should not be invoked");
}
 
Example 14
Source Project: camel-quarkus   Source File: BasicAuthCacheAlias.java    License: Apache License 2.0 4 votes vote down vote up
@Substitute
@Override
public AuthScheme get(final HttpHost host) {
    Args.notNull(host, "HTTP host");
    return this.map.get(getKey(host));
}
 
Example 15
Source Project: camel-quarkus   Source File: DeepCopySubstitution.java    License: Apache License 2.0 4 votes vote down vote up
@Substitute
public static Object simpleDeepCopy(Object toCopy) {
    return JsonUtils.cloneJson(toCopy);
}
 
Example 16
Source Project: camel-quarkus   Source File: SubstituteConfigJMXManager.java    License: Apache License 2.0 4 votes vote down vote up
@Substitute
public static ConfigMBean registerConfigMbean(AbstractConfiguration config) {
    return null;
}
 
Example 17
Source Project: micronaut-sql   Source File: HibernateSubstitutions.java    License: Apache License 2.0 4 votes vote down vote up
@Substitute
public NoopXmlMappingBinderAccess(ServiceRegistry serviceRegistry) {
}
 
Example 18
@Substitute
public static boolean isUnsafeAvailable() {
    return false;
}
 
Example 19
Source Project: camel-quarkus   Source File: FhirContextSubstitution.java    License: Apache License 2.0 4 votes vote down vote up
@Substitute
public IParser newRDFParser() {
    throw new UnsupportedOperationException();
}
 
Example 20
@Substitute
public URL determineDefaultPersistenceUnitRootUrl() {
	return null;
}
 
Example 21
@Substitute
protected boolean isOsgiContext() {
    return false;
}
 
Example 22
Source Project: camel-quarkus   Source File: ODataImplSubstitutions.java    License: Apache License 2.0 4 votes vote down vote up
@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");
}
 
Example 23
Source Project: camel-quarkus   Source File: SubstituteBase64.java    License: Apache License 2.0 4 votes vote down vote up
@Substitute
public static String encode(String s) {
    return Base64.getEncoder().encodeToString(s.getBytes(StandardCharsets.UTF_8));
}
 
Example 24
Source Project: camel-quarkus   Source File: SubstituteBase64.java    License: Apache License 2.0 4 votes vote down vote up
@Substitute
public static String encodeBytes(byte[] b) {
    return Base64.getEncoder().encodeToString(b);
}
 
Example 25
@Substitute
public SubstituteDefaultCacheManager() {
    throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
 
Example 26
@Substitute
public SubstituteDefaultCacheManager(boolean start) {
    throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
 
Example 27
@Substitute
public SubstituteDefaultCacheManager(Configuration defaultConfiguration) {
    throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
 
Example 28
@Substitute
public SubstituteDefaultCacheManager(Configuration defaultConfiguration, boolean start) {
    throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
 
Example 29
@Substitute
public SubstituteDefaultCacheManager(GlobalConfiguration globalConfiguration) {
    throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
 
Example 30
Source Project: micronaut-sql   Source File: HibernateSubstitutions.java    License: Apache License 2.0 4 votes vote down vote up
@Substitute
public Binding bind(InputStreamAccess xmlInputStreamAccess) {
    return null;
}