RuntimeContextTLS can init the EJB or CDI provider

@param <T>

@param <T>

@param resource
@param message
178612
public static <T> void initSingletonEJBCDIProvider(AbstractResourceInfo resource, Message message, T resourceObject) {

        /*
         * Only @Provider will use logic here.
         * As EJB can only be default constructor, CDI can be default constructor or 1 param with @Inject constructor
         * And a provider must have 1 public constructor(default constructor or @Context params constructor)
         * then the intersection is only default constructor.
         * so if ConstructorProxies!=null means there are some other invalid constructors to EJB or CDI container
         */
        if ((!(resource instanceof ProviderInfo)) || (resource instanceof ApplicationInfo) || resource.getConstructorProxies() != null) {
            return;
        }

        ProviderInfo<T> pi = (ProviderInfo<T>) resource;

        /**
         * if this provider is inited which means it may be replaced by EJB or CDI bean or it may be invoked with @PostConstrcut
         */
        if (pi.isInit()) {
            return;
        }

        synchronized(pi) {
            if (pi.isInit()) {
                return;
            }
            Class clz = pi.getProvider().getClass();
            Bus bus = resource.getBus();

            if (bus != null) { // if bus is null, then we don't need to do injection on this provider
                List<JaxRsFactoryBeanCustomizer> beanCustomizers = (List<JaxRsFactoryBeanCustomizer>) bus.getProperty(JaxRsConstants.ENDPOINT_LIST_BEANCUSTOMIZER);
                Map<String, Object> beanCustomizerContexts = (Map<String, Object>) bus.getProperty(JaxRsConstants.ENDPOINT_BEANCUSTOMIZER_CONTEXTOBJ);

                if (beanCustomizers != null && !beanCustomizers.isEmpty() && beanCustomizerContexts != null) {

                    Object newProviderInstance = null;
                    for (JaxRsFactoryBeanCustomizer beanCustomizer : beanCustomizers) {
                        if (beanCustomizer.isCustomizableBean(clz, beanCustomizerContexts.get(Integer.toString(beanCustomizer.hashCode())))) {

                            newProviderInstance = beanCustomizer.onSingletonProviderInit(pi.getProvider(), beanCustomizerContexts.get(Integer.toString(beanCustomizer.hashCode())), message);

                            /**
                             * if newProviderInstance!= the original object, which means it is replaced to EJB or CDI, so just return
                             * no need call @PostConstruct
                             */
                            if (newProviderInstance != null) {
                                //call setProvider to set isInit==true
                                pi.setProvider(newProviderInstance);
                                pi.setIsInit(true);
                                return;
                            }
                        }
                    }
                }
                //No replacement happens which means this is a POJO, call @PostConstruct
                pi.setIsInit(true);
                Method postConstructMethod = ResourceUtils.findPostConstructMethod(clz);
                InjectionUtils.invokeLifeCycleMethod(pi.getProvider(), postConstructMethod);
            }
        }
    }
1220304
@Override
	public void setInitializationData(IConfigurationElement configElem, String propertyName,
			Object data) throws CoreException {

		final String sourceMethod = "setInitializationData"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(sourceClass, sourceMethod, new Object[]{configElem, propertyName, data});
		}
		contributingBundle = Platform.getBundle(configElem.getNamespaceIdentifier());
		if (contributingBundle.getState() != Bundle.ACTIVE) {
			try {
				contributingBundle.start();
			} catch (BundleException e) {
				throw new CoreException(
						new Status(Status.ERROR, configElem.getNamespaceIdentifier(),
								e.getMessage(), e)
						);
			}
		}


		Map<String, String> configMap = new HashMap<String, String>();
		configMap = getConfigMap(configElem);
		initParams = getConfigInitParams(configElem);
		singletonExtensions = new HashMap<String, Object>();

		try {
			BundleContext bundleContext = Activator.getBundleContext();
			platformServices = new PlatformServicesImpl(contributingBundle);
			name = getAggregatorName(configMap);

			// Make sure there isn't already an instance of the aggregator registered for the current name
			if (getPlatformServices().getServiceReferences(
					IAggregator.class.getName(),
					"(name=" + getName() + ")") != null) { //$NON-NLS-1$ //$NON-NLS-2$
				throw new IllegalStateException("Name already registered - " + name); //$NON-NLS-1$
			}
			registerLayerListener();
			executorsServiceTracker = getExecutorsServiceTracker(bundleContext);
			variableResolverServiceTracker = getVariableResolverServiceTracker(bundleContext);
			initExtensions(configElem);
			initOptions(initParams);
			IConfig config = newConfig();
			initWorkingDirectory(configMap, config); // this must be after initOptions
			primeCache(config);
			super.initialize(config);

		} catch (Exception e) {
			throw new CoreException(
					new Status(Status.ERROR, configElem.getNamespaceIdentifier(),
							e.getMessage(), e)
					);
		}

		if (isTraceLogging) {
			log.exiting(sourceClass, sourceMethod);
		}
	}
381006
public void setResourceAdaptorContext(ResourceAdaptorContext arg0) {
        resourceAdaptorContext = arg0;
        tracer = resourceAdaptorContext.getTracer(HttpClientResourceAdaptor.class.getSimpleName());
        try {
            fireableEventType = resourceAdaptorContext.getEventLookupFacility().getFireableEventType(
                    new EventTypeID("net.java.client.slee.resource.http.event.ResponseEvent", "net.java.client.slee",
                            "4.0"));
        } catch (Throwable e) {
            throw new RuntimeException(e.getMessage(), e);
        }
        sbbInterface = new HttpClientResourceAdaptorSbbInterfaceImpl(this);
    }
229269
public void eInit(XtendTypeDeclaration container, String name, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlBehaviorUnit == null) {
			this.container = container;
			this.sarlBehaviorUnit = SarlFactory.eINSTANCE.createSarlBehaviorUnit();
			this.sarlBehaviorUnit.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember());
			this.sarlBehaviorUnit.setName(newTypeRef(container, name));
			container.getMembers().add(this.sarlBehaviorUnit);
		}
	}
1193215
public void init(BaseMessage message, Object objRawMessage)
    {
        m_message = message;
        if (message != null)
            message.setExternalMessage(this);
        if (objRawMessage != null)
            this.setRawData(objRawMessage);
    }
1173920
@Override
    public void initialize(BeanContext context) {
        Resource resource = ConsoleUtil.getConsoleResource(context);
        initialize(context, ResourceHandle.use(resource));
    }
67396
public void init(ClientContext clientContext) {
        this.clientContext = clientContext;
        this.clientConnectionStrategyConfig = clientContext.getClientConfig().getConnectionStrategyConfig();
        this.logger = clientContext.getLoggingService().getLogger(ClientConnectionStrategy.class);
    }
1008368
@SuppressWarnings("unchecked")
    @Override
    public <T> T onSingletonProviderInit(T provider, Object context, Message m) {
        if (context == null) {
            return null;
        }
        Map<Class<?>, ManagedObject<?>> newContext = (Map<Class<?>, ManagedObject<?>>) (context);
        if (newContext.isEmpty()) {
            return null;
        }
        ManagedObject<?> managedObject = newContext.get(provider.getClass());
        Object newProviderObject = null;
        if (managedObject == null) {
            newProviderObject = getInstanceFromManagedObject(provider, context);
        } else {
            newProviderObject = managedObject.getObject();
        }

        return (T) newProviderObject;
    }
525919
private static Endpoint initServiceEndpoint(EndpointRegistry epRegistry, String contextPath, String servletName)
   {
      if (contextPath.startsWith("/"))
         contextPath = contextPath.substring(1);

      final ObjectName oname = ObjectNameFactory.create(Endpoint.SEPID_DOMAIN + ":" + Endpoint.SEPID_PROPERTY_CONTEXT
            + "=" + contextPath + "," + Endpoint.SEPID_PROPERTY_ENDPOINT + "=" + servletName);
      Endpoint endpoint = epRegistry.getEndpoint(oname);
      if (endpoint == null)
      {
         throw Messages.MESSAGES.cannotObtainEndpoint(oname);
      }

      //Inject the EJB and JNDI resources if possible
      injectServiceAndHandlerResources(endpoint);

      return endpoint;
   }
960137
@Override
    public SseEventSink createContext(Message message) {
        MessageBodyWriter<OutboundSseEvent> writer = new OutboundSseEventBodyWriter(ServerProviderFactory.getInstance(message), message.getExchange());
        LibertySseEventSinkImpl impl = new LibertySseEventSinkImpl(writer, message);
        message.put(SseEventSink.class.getName(), impl);
        
        // treat SSE methods like async methods
        AsyncResponseImpl ar = new AsyncResponseImpl(message);
        message.put(AsyncResponseImpl.class.getName(), ar);
        
        return impl;
    }
1043283
public void eInit(XtendTypeDeclaration container, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlConstructor == null) {
			this.container = container;
			this.sarlConstructor = SarlFactory.eINSTANCE.createSarlConstructor();
			this.sarlConstructor.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember());
			container.getMembers().add(this.sarlConstructor);
		}
	}
1319095
public void init(HttpInboundServiceContext context) {
        this.isc = context;
        this.message = context.getResponse();
        this.body = null;
    }
1087063
public void contextInitialized(ServletContextEvent sce) {
    	LogLog.debug("Start to initialize log4j");

    	LogLog.debug("Confige CXF to use log4j!");

    	ServletContext sc = sce.getServletContext();
        if (Log4jWebUtils.isWatchDisabled(sc)) {
            Log4jWebUtils.reload(sc);
        } else {
            Log4jWebUtils.reloadAndWatch(sc, Log4jWebUtils.getWatchDelay(sc));
        }
        logger.info("Log4j initialized...");
    }
227492
@Override
    void addMessagingEngine(JsMessagingEngine messagingEngine) throws ResourceException
    {
        final String methodName = "addMessagingEngine";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.entry(this, TRACE, methodName, messagingEngine);
        }
        if ((_destinationStrategy.isNonDurablePubSub()) && (_connections.size() > 0))
        {
            // Ignore for non durable pub sub
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
            {
                SibTr.exit(this, TRACE, methodName);
            }
            return;
        }
        else
        {
            clearTimer();
            checkMEs(new JsMessagingEngine[] { messagingEngine });
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.exit(this, TRACE, methodName);
        }
    }
86626
public void initialize(ContextRefreshedEvent event) {
    ApplicationContext ctx = event.getApplicationContext();
    Stream<String> languageCodes = LanguageService.getLanguageCodes();

    EntityTypeMetadata entityTypeMeta = ctx.getBean(EntityTypeMetadata.class);
    AttributeMetadata attrMetaMeta = ctx.getBean(AttributeMetadata.class);
    L10nStringMetadata l10nStringMeta = ctx.getBean(L10nStringMetadata.class);

    languageCodes.forEach(
        languageCode -> {
          entityTypeMeta
              .addAttribute(getI18nAttributeName(EntityTypeMetadata.LABEL, languageCode))
              .setNillable(true)
              .setLabel("Label (" + languageCode + ')');
          entityTypeMeta
              .addAttribute(getI18nAttributeName(EntityTypeMetadata.DESCRIPTION, languageCode))
              .setNillable(true)
              .setLabel("Description (" + languageCode + ')')
              .setDataType(TEXT);
          attrMetaMeta
              .addAttribute(getI18nAttributeName(AttributeMetadata.LABEL, languageCode))
              .setNillable(true)
              .setLabel("Label (" + languageCode + ')');
          attrMetaMeta
              .addAttribute(getI18nAttributeName(AttributeMetadata.DESCRIPTION, languageCode))
              .setNillable(true)
              .setLabel("Description (" + languageCode + ')')
              .setDataType(TEXT);
          l10nStringMeta.addAttribute(languageCode).setNillable(true).setDataType(TEXT);
        });
  }
1040901
public ResponseBuilder initialize(final Resource resource) {

        if (MISSING_RESOURCE.equals(resource)) {
            throw new NotFoundException();
        } else if (DELETED_RESOURCE.equals(resource)) {
            throw new ClientErrorException(GONE);
        }

        setResource(resource);
        return status(NO_CONTENT);
    }
1000652
protected void handleInboundMessageProperties(final MessageContext messageContext,
                                                  final SoapMessage message) {
        if (messageContext == null) { return; }
        
        final String[] propertyNames = messageContext.getPropertyNames();
        if (propertyNames != null) {
            for (final String propertyName : propertyNames) {
                message.setHeader(propertyName, messageContext.getProperty(propertyName));
            }
        }
    }