Creates a <code>ServiceInfo</code> from a SrvReg message.

@param srvReg the SrvReg message to convert into a ServiceInfo
@return a new ServiceInfo from the given message
359686
public static ServiceInfo from(SrvReg srvReg)
    {
        return new ServiceInfo(srvReg.getServiceType(), srvReg.getURLEntry().toServiceURL(), srvReg.getLanguage(), srvReg.getScopes(), srvReg.getAttributes());
    }
385170
public MessageRecordDesc createNewMessage(BaseMessage message, String strKey)
    {
        MessageRecordDesc messageData = null;
        String strClassName = this.getField(MessageInfo.MESSAGE_CLASS).toString();
        messageData = (MessageRecordDesc)ClassServiceUtility.getClassService().makeObjectFromClassName(strClassName);
        if (messageData != null)
               messageData.init(message, strKey);
        return messageData;
    }
1313852
private Service getServiceInstance(TransientWebServiceRefInfo tInfo, WebServiceRefInfo wsrInfo) throws Exception {
        Class<?> svcSubClass = null;
        Service instance = null;
        if (tInfo.getServiceRefTypeClass() != null && Service.class.getName().equals(tInfo.getServiceRefTypeClassName())) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating service instance using generic Service.create(QName)");
            }
            return Service.create(tInfo.getServiceQName());
        }

        if (tInfo.getServiceRefTypeClass() != null && Service.class.isAssignableFrom(tInfo.getServiceRefTypeClass())) {
            svcSubClass = tInfo.getServiceRefTypeClass();
        } else {
            svcSubClass = tInfo.getServiceInterfaceClass();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Attempting to create instance of service sub-class: " + svcSubClass.getName());
        }
        final Class<?> finalSvcSubClass = svcSubClass;
        Constructor<?> constructor = null;

        // first we get the constructor for the service subclass, we will always use
        // the URL, QName constructor because this constructor allow for null arguments
        try {
            final Constructor<?> finalConstructor = (Constructor<?>) AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                @Override
                public Object run() throws NoSuchMethodException {
                    return finalSvcSubClass.getDeclaredConstructor(new Class[] { URL.class, QName.class });
                }
            });
            constructor = finalConstructor;
        } catch (PrivilegedActionException e) {
            if (e.getException() != null) {
                throw e.getException();
            } else {
                throw e;
            }
        }

        // now we will create the service instance with the constructor that was
        // previously created, it's okay if the URL we try to obtain turns out
        // to be null, a service instance will be created without the use of
        // the WSDL document we supplied
        final URL url = tInfo.getWsdlURL();

        //jsr-109:
//        For co-located clients (where the client and the server are in the same Java EE application unit) with
//        generated Service class, the location of the final WSDL document is resolved by comparing the Service name
//        on the @WebServiceClient annotation on the the generated Service to the Service names of all the deployed
//        port components in the Java EE application unit

        // Future plan need to consider:
//        if it is a co-located clients, need to verify the defined wsdlLocation and make it use the dynamic one
//        if there is no wsdlLocation defined, need to use the dynamic one
//        need to consider in the ear level
//        need to consider virtual host

        if (url == null)
        {
            JaxWsModuleMetaData jaxwsModuleMetaData = tInfo.getClientMetaData().getModuleMetaData();
            String applicationName = jaxwsModuleMetaData.getJ2EEName().getApplication();
            String contextRoot = jaxwsModuleMetaData.getContextRoot();
            Map<String, String> appNameURLMap = jaxwsModuleMetaData.getAppNameURLMap();
            Container moduleContainer = jaxwsModuleMetaData.getModuleContainer();
            NonPersistentCache overlayCache;
            try {
                overlayCache = moduleContainer.adapt(NonPersistentCache.class);
                JaxWsModuleInfo jaxWsModuleInfo = (JaxWsModuleInfo) overlayCache.getFromCache(JaxWsModuleInfo.class);
                if (jaxWsModuleInfo != null) {
                    for (EndpointInfo endpointInfo : jaxWsModuleInfo.getEndpointInfos()) {
                        String address = endpointInfo.getAddress(0).substring(1);
                        String serviceName = wsrInfo.getServiceQName().getLocalPart();
                        if (serviceName.equals(address))
                        {
                            String wsdlLocation = null;
                            if ((appNameURLMap != null) && (!appNameURLMap.isEmpty())) {
                                String applicationURL = appNameURLMap.get(applicationName);
                                wsdlLocation = applicationURL + "/" + address + "?wsdl";
                            } else {
                                wsdlLocation = getWsdlUrl() + contextRoot + "/" + address + "?wsdl";
                            }

                            final URL newURl = new URL(wsdlLocation);
                            wsrInfo.setWsdlLocation(wsdlLocation);

                            try {
                                final Constructor<?> finalConstructor = constructor;
                                final QName serviceQName = tInfo.getServiceQName();
                                instance = (Service) AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                                    @Override
                                    public Object run() throws InstantiationException, IllegalAccessException, InvocationTargetException {
                                        finalConstructor.setAccessible(true);
                                        return finalConstructor.newInstance(new Object[] { newURl, serviceQName });
                                    }
                                });
                            } catch (PrivilegedActionException e) {
                                if (e.getException() != null) {
                                    throw e.getException();
                                } else {
                                    throw e;
                                }
                            }
                            break;

                        }

                    }
                }
            } catch (UnableToAdaptException e) {

            }
        }
        if (instance != null)
        {
            return instance;
        }

        if (url != null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating Service with WSDL URL: " + url + " and QName: " + tInfo.getServiceQName() + " for class: " + svcSubClass.getName());
            }
        }
        try {
            final Constructor<?> finalConstructor = constructor;
            final QName serviceQName = tInfo.getServiceQName();
            instance = (Service) AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                @Override
                public Object run() throws InstantiationException, IllegalAccessException, InvocationTargetException {
                    finalConstructor.setAccessible(true);
                    return finalConstructor.newInstance(new Object[] { url, serviceQName });
                }
            });
        } catch (PrivilegedActionException e) {
            if (e.getException() != null) {
                throw e.getException();
            } else {
                throw e;
            }
        }

        return instance;
    }
862207
@SuppressWarnings("unchecked")
  private static <T> T newInstance(Class<?> type) {
    try {
      return (T) type.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
      throw new ServiceException("Cannot instantiate service class " + type, e);
    }
  }
188172
public static UniversalIdIntQueueMessage newInstance(Map<String, Object> data) {
        UniversalIdIntQueueMessage msg = newInstance();
        return msg.fromMap(data);
    }
508751
public static ServiceAgentInfo from(SAAdvert saAdvert)
    {
        IdentifierExtension identifierExtension = IdentifierExtension.findFirst(saAdvert.getExtensions());
        String identifier = identifierExtension == null ? null : identifierExtension.getIdentifier();
        return new ServiceAgentInfo(identifier, saAdvert.getURL(), saAdvert.getScopes(), saAdvert.getAttributes(), saAdvert.getLanguage());
    }
933947
public final ControlReject createNewControlReject() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewControlReject");
    ControlReject msg = null;
    try {
      msg = new ControlRejectImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewControlReject");
    return msg;
  }
473278
function createService (app, Service, Model, options) {
  Model = options.Model || Model;
  if (typeof Model === 'function') {
    assert(options.ModelName, 'createService but options.ModelName not provided');
    options.Model = Model(app, options.ModelName);
  } else {
    options.Model = Model;
  }
  const service = new Service(options);
  return service;
}
895519
public CorsService build(Service<HttpRequest, HttpResponse> delegate) {
        if (delegate.as(CorsService.class).isPresent()) {
            throw new IllegalArgumentException(
                    "decorated with a " + CorsService.class.getSimpleName() + " already: " +
                    delegate);
        }

        return new CorsService(delegate, new CorsConfig(this));
    }
1130539
public BindingInfo createBindingInfo(Service service, String namespace,
                                         Object obj) {

        ServiceInfo si = new ServiceInfo();
        si.setTargetNamespace(ProtobufBindingFactory.PROTOBUF_BINDING_ID);

        BindingInfo info = new BindingInfo(si,
                ProtobufBindingFactory.PROTOBUF_BINDING_ID);

        return info;
    }
723009
public Message getOrCreateMessage(TextChannel channel, JsonNode data) {
        long id = Long.parseLong(data.get("id").asText());
        synchronized (messages) {
            return getCachedMessageById(id).orElseGet(() -> new MessageImpl(this, channel, data));
        }
    }
1161415
public BaseMessageReceiver createMessageReceiver()
    {
        RemoteTask server = (RemoteTask)((Application)this.getMessageManager().getApplication()).getRemoteTask(null);
        try   {
            return new DualMessageReceiver(server, this);
        } catch (RemoteException ex)    {
            ex.printStackTrace();
        }
        return null;
    }
782646
public ServiceInstance<T> build()
    {
        return new ServiceInstance<T>(name, id, address, port, sslPort, payload, registrationTimeUTC, serviceType, uriSpec, enabled);
    }
973099
public final ControlBrowseStatus createNewControlBrowseStatus() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewControlBrowseStatus");
    ControlBrowseStatus msg = null;
    try {
      msg = new ControlBrowseStatusImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewControlBrowseStatus");
    return msg;
  }
457992
@Override
    public ServiceDelegate createServiceDelegate(URL url, QName qname,
                                                 @SuppressWarnings("rawtypes") Class cls) {
        Bus bus = null;
        JaxWsClientMetaData clientMetaData = JaxWsMetaDataManager.getJaxWsClientMetaData();
        if (clientMetaData != null) {
            bus = clientMetaData.getClientBus();
        }
        if (bus == null) {
            bus = BusFactory.getThreadDefaultBus();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "No client  bus is found, the thread context default bus " + bus.getId() + " is used");
            }
        }

        WebServiceRefInfo wsrInfo = wsRefInfo.get();

        List<WebServiceFeature> serviceFeatures = wsFeatures.get();
        final List<WebServiceFeature> fServiceFeatures = serviceFeatures;

        AtomicServiceReference<JaxWsSecurityConfigurationService> secConfigSR = securityConfigSR.get();
        JaxWsSecurityConfigurationService securityConfigService = secConfigSR == null ? null : secConfigSR.getService();

        // @TJJ create final vars in order to call a doPriv when creating the LibertyServiceImpl as required by java 2 security
        final JaxWsSecurityConfigurationService scs = securityConfigService;
        final WebServiceRefInfo wi = wsrInfo;
        final Bus b = bus;
        final URL u = url;
        final QName qn = qname;
        final Class c = cls;
        final List<WebServiceFeature> sf = serviceFeatures;

        if (serviceFeatures != null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Thread context features are configured with " + serviceFeatures);
            }
            LibertyServiceImpl lsl = AccessController.doPrivileged(new PrivilegedAction<LibertyServiceImpl>() {
                @Override
                public LibertyServiceImpl run() {
                    return new LibertyServiceImpl(scs, wi, b, u, qn, c, sf.toArray(new WebServiceFeature[sf.size()]));
                }
            });
            return lsl;

        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Thread context features are not set");
            }

            LibertyServiceImpl lsl = AccessController.doPrivileged(new PrivilegedAction<LibertyServiceImpl>() {
                @Override
                public LibertyServiceImpl run() {
                    return new LibertyServiceImpl(scs, wi, b, u, qn, c);
                }
            });
            return lsl;

        }
    }
791466
public static ServiceDependencyBuilder copyOf(final ServiceDependency prototype) {
        return new ServiceDependencyBuilder()
                .withName(prototype.getName())
                .withDescription(prototype.getDescription())
                .withUrl(prototype.getUrl())
                .withType(prototype.getType())
                .withSubtype(prototype.getSubtype())
                .withMethods(prototype.getMethods())
                .withMediaTypes(prototype.getMediaTypes())
                .withAuthentication(prototype.getAuthentication())
                .withCriticality(prototype.getCriticality())
                .withExpectations(prototype.getExpectations());
    }
901269
private Service getServiceInstance(TransientWebServiceRefInfo tInfo, WebServiceRefInfo wsrInfo) throws Exception {
        Class<?> svcSubClass = null;
        Service instance = null;
        if (tInfo.getServiceRefTypeClass() != null && Service.class.getName().equals(tInfo.getServiceRefTypeClassName())) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating service instance using generic Service.create(QName)");
            }
            return Service.create(tInfo.getServiceQName());
        }

        if (tInfo.getServiceRefTypeClass() != null && Service.class.isAssignableFrom(tInfo.getServiceRefTypeClass())) {
            svcSubClass = tInfo.getServiceRefTypeClass();
        } else {
            svcSubClass = tInfo.getServiceInterfaceClass();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Attempting to create instance of service sub-class: " + svcSubClass.getName());
        }
        final Class<?> finalSvcSubClass = svcSubClass;
        Constructor<?> constructor = null;

        // first we get the constructor for the service subclass, we will always use
        // the URL, QName constructor because this constructor allow for null arguments
        try {
            final Constructor<?> finalConstructor = (Constructor<?>) AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                @Override
                public Object run() throws NoSuchMethodException {
                    return finalSvcSubClass.getDeclaredConstructor(new Class[] { URL.class, QName.class });
                }
            });
            constructor = finalConstructor;
        } catch (PrivilegedActionException e) {
            if (e.getException() != null) {
                throw e.getException();
            } else {
                throw e;
            }
        }

        // now we will create the service instance with the constructor that was
        // previously created, it's okay if the URL we try to obtain turns out
        // to be null, a service instance will be created without the use of
        // the WSDL document we supplied
        final URL url = tInfo.getWsdlURL();
        if (url != null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating Service with WSDL URL: " + url + " and QName: " + tInfo.getServiceQName() + " for class: " + svcSubClass.getName());
            }
        }
        ClassLoader currentThreadClassLoader = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(tInfo.classLoader);
            final Constructor<?> finalConstructor = constructor;
            final QName serviceQName = tInfo.getServiceQName();
            instance = (Service) AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                @Override
                public Object run() throws InstantiationException, IllegalAccessException, InvocationTargetException {
                    finalConstructor.setAccessible(true);
                    return finalConstructor.newInstance(new Object[] { url, serviceQName });
                }
            });
        } catch (PrivilegedActionException e) {
            if (e.getException() != null) {
                throw e.getException();
            } else {
                throw e;
            }
        } finally {
            Thread.currentThread().setContextClassLoader(currentThreadClassLoader);
        }

        return instance;
    }