Creates an instance of {@link RepositoryBrowser} from a form submission.

@deprecated since 2008-06-19.
Use {@link #createInstance(Class, StaplerRequest, JSONObject, String)}.
198664
@Deprecated
    public static <T extends RepositoryBrowser>
    T createInstance(Class<T> type, StaplerRequest req, String fieldName) throws FormException {
        List<Descriptor<RepositoryBrowser<?>>> list = filter(type);
        String value = req.getParameter(fieldName);
        if(value==null || value.equals("auto"))
            return null;

        // TODO: There was a TODO in the original code, which presumes passing something meaningful to the newInstance() JSON param
        // Now we just pass empty JSON in order to make the code compliant with the defined interface
        final JSONObject emptyJSON = new JSONObject();
        return type.cast(list.get(Integer.parseInt(value)).newInstance(req, emptyJSON));
    }
492998
public JSONObject instantiateJsonObject(InputStream in) throws IOException,
                                                                JSONException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    StringBuffer contents = new StringBuffer();
    String text = null;
    while ((text = reader.readLine()) != null) {
      contents.append(text).append(System.getProperty("line.separator"));
    }
    in.close();
    JSONObject json = new JSONObject(contents.toString());
    return json;
  }
1129263
@Override
    public <T> PagedResult<T> deserializeDataWrapper(Class<T> objectClass, java.io.InputStream inputStream) throws JSONSerializerException{
        Util.throwIfNull(objectClass, inputStream);

        PagedResult<T> rw = null;

        try {
            // Read the json input stream into a List.
            rw = OBJECT_MAPPER.readValue(inputStream,
                    OBJECT_MAPPER.getTypeFactory().constructParametrizedType(PagedResult.class, PagedResult.class, objectClass));
        } catch (JsonParseException e) {
            throw new JSONSerializerException(e);
        } catch (JsonMappingException e) {
            throw new JSONSerializerException(e);
        } catch (IOException e) {
            throw new JSONSerializerException(e);
        }

        return rw;
    }
698296
private Object getDefaultJavaCompObjectInstance(NamingConstants.JavaColonNamespace namespace,
                                                    String bindingName,
                                                    ResourceInfo resourceRefInfo) throws Exception {
        String name = namespace.unprefix(bindingName);
        // Use a filter that ignores an extra service for the supertype that config processing code creates
        // with the properties of the subtype (currently the extra service is required to support ibm:extends)
        StringBuilder filter = new StringBuilder("(&")
                        .append(FilterUtils.createPropertyFilter(com.ibm.ws.resource.ResourceFactory.JAVA_COMP_DEFAULT_NAME, name))
                        .append("(!(ibm.extends.source.factoryPid=*))")
                        .append(')');
        return createResourceWithFilter(filter.toString(), resourceRefInfo);
    }
723727
@Override
    public InjectionBinding<WebServiceRef> createInjectionBinding(WebServiceRef webServiceRef, Class<?> instanceClass, Member member, String jndiName) throws InjectionException {
        InjectionBinding<WebServiceRef> binding;

        WebServiceRefInfo wsrInfo = WebServiceRefInfoBuilder.buildWebServiceRefInfo(webServiceRef, instanceClass.getClassLoader());
        wsrInfo.setClientMetaData(JaxWsMetaDataManager.getJaxWsClientMetaData(ivNameSpaceConfig.getModuleMetaData()));
        if (member == null) { //Annotated on class
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating new injection binding for @WebServiceRef annotation found on the " + instanceClass.getName() + " class.");
            }

            this.validateAndSetClassLevelWebServiceRef(webServiceRef, instanceClass, wsrInfo);

            // Now add the @HandlerChain instance
            javax.jws.HandlerChain hcAnnot = instanceClass.getAnnotation(javax.jws.HandlerChain.class);
            if (hcAnnot != null) {
                wsrInfo.setHandlerChainAnnotation(hcAnnot);
                wsrInfo.setHandlerChainDeclaringClassName(instanceClass.getName());
            }

            binding = new WebServiceRefBinding(wsrInfo, ivNameSpaceConfig);

        } else if (member instanceof Method) { //Annotated on method
            Method method = (Method) member;
            wsrInfo.setJndiName(jndiName);

            // Send the wsrInfo to this call so that both the 'type' and 'value' properties can be set correctly
            this.validateAndSetMemberLevelWebServiceRef(webServiceRef, method, wsrInfo);

            // Now add the @HandlerChain instance
            javax.jws.HandlerChain hcAnnot = method.getAnnotation(javax.jws.HandlerChain.class);
            if (hcAnnot != null) {
                wsrInfo.setHandlerChainAnnotation(hcAnnot);
                wsrInfo.setHandlerChainDeclaringClassName(instanceClass.getName());
            }

            //MTOM, RespectBinding, Addressing  
            //Merge any features that might be set on the field (@MTOM, @RespectBinding, @Addressing)
            //Note that we only support features for port-component-ref type injections.
            //For a port-component-ref type injection, the "Service SEI class" will be set on
            //'wsrMetadata'.
            if (wsrInfo.getServiceRefTypeClassName() != null) {
                handleMTOM(webServiceRef, wsrInfo, method.getAnnotation(MTOM.class));
                handleRespectBinding(webServiceRef, wsrInfo, method.getAnnotation(RespectBinding.class));
                handleAddressing(webServiceRef, wsrInfo, method.getAnnotation(Addressing.class));
            }

            // Create binding for @WebServiceRef annotation
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating new injection binding for the @WebServiceRef annotation on the " + method.getName() + " method in the "
                             + method.getDeclaringClass().getName() + " class.");
            }
            binding = new WebServiceRefBinding(wsrInfo, ivNameSpaceConfig);
            addInjectionBinding(binding);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Successfully created an injection binding for the @WebServiceRef annotation on the " + method.getName() + " method in the "
                             + method.getDeclaringClass().getName() + " class.");
            }

        } else { //Annotated on field
            Field field = (Field) member;
            wsrInfo.setJndiName(jndiName);

            // Send the wsrInfo to this call so that both the 'type' and 'value' properties can be set correctly
            this.validateAndSetMemberLevelWebServiceRef(webServiceRef, field, wsrInfo);

            // Now add the @HandlerChain instance
            javax.jws.HandlerChain hcAnnot = field.getAnnotation(javax.jws.HandlerChain.class);
            if (hcAnnot != null) {
                wsrInfo.setHandlerChainAnnotation(hcAnnot);
                wsrInfo.setHandlerChainDeclaringClassName(instanceClass.getName());
            }

            //MTOM, RespectBinding, Addressing  
            // Merge any features that might be set on the field (@MTOM, @RespectBinding, @Addressing)
            // Note that we only support features for port-component-ref type injections.
            // For a port-component-ref type injection, the "Service SEI class" will be set on
            // 'wsrMetadata'.
            if (wsrInfo.getServiceRefTypeClassName() != null) {
                handleMTOM(webServiceRef, wsrInfo, field.getAnnotation(MTOM.class));
                handleRespectBinding(webServiceRef, wsrInfo, field.getAnnotation(RespectBinding.class));
                handleAddressing(webServiceRef, wsrInfo, field.getAnnotation(Addressing.class));
            }

            // Create binding for @WebServiceRef annotation
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating new injection binding for the @WebServiceRef annotation on the " + field.getName() + " field in the "
                             + field.getDeclaringClass().getName() + " class.");
            }
            binding = new WebServiceRefBinding(wsrInfo, ivNameSpaceConfig);
            addInjectionBinding(binding);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Successfully created an injection binding for the @WebServiceRef annotation on the " + field.getName() + " field in the "
                             + field.getDeclaringClass().getName() + " class. HashCode=" + Integer.toHexString(System.identityHashCode(this)));
            }
        }

        return binding;
    }
634981
public Object loadObject(String breadcrumb, Object defaultObject) {
    String json = getSerializedPreferencesValue(breadcrumb, gson.toJson(defaultObject));
    return gson.fromJson(json, Object.class);
  }
831914
private static Converter<List<String>, Object> createStringConstructorConverter(Class<?> resultClass) {
    try {
      final Constructor<?> constructor = resultClass.getConstructor(String.class);
      return new BasicConverter(defaultValue(resultClass)) {
        @Override
        protected Object convert(String value) throws Exception {
          return constructor.newInstance(value);
        }
      };
    } catch (Exception e) {
      return null;
    }
  }
1060595
@Override
    public WebDriverBrowser<?> create(Object obj) {
        try {
            WebDriverProperties webDriverProperties;
            if (obj instanceof Scriptable && "String".equals(((Scriptable) obj).getClassName())) {
                obj = obj.toString();
            }

            if (obj instanceof String) {
                webDriverProperties = new WebDriverProperties();
                webDriverProperties.getDesiredCapabilities().put("browserName", obj);
            } else if (obj instanceof Scriptable) {
                final Scriptable scriptable = (Scriptable) obj;
                String json = engine.runWithContext(engine.new RhinoCallable<String, RuntimeException>() {
                    @Override
                    protected String doCall(Context cx, Scriptable scope) throws RuntimeException {
                        return (String) cx.evaluateString(scriptable, "JSON.stringify(this)", "<expression>", 1, null);
                    }
                });
                webDriverProperties = mapper.readValue(json, WebDriverProperties.class);
            } else {
                throw new IllegalArgumentException("Only strings or maps are accepted");
            }
            WebDriver wd = webDriverFactory.create(webDriverProperties);
            WebModule webModule = combine(defaultModule(wd), WebModules.debugModule(), RhinoWebModules.rhinoModule());
            return new WebDriverBrowser<DefaultWebElements>(wd, DefaultWebElements.class, webModule);
        } catch (IOException e) {
            throw Throwables.propagate(e);
        }
    }
112905
public CreateClusterResponse createCluster(CreateClusterRequest request) {
        checkNotNull(request, "request should not be null.");
        checkStringNotEmpty(request.getImageType(), "The imageType should not be null or empty string.");
        checkStringNotEmpty(request.getImageVersion(), "The imageVersion should not be null or empty string.");
        checkNotNull(request.getInstanceGroups(), "The instanceGroups should not be null.");

        StringWriter writer = new StringWriter();
        try {
            JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer);
            jsonGenerator.writeStartObject();
            jsonGenerator.writeStringField("imageType", request.getImageType());
            jsonGenerator.writeStringField("imageVersion", request.getImageVersion());
            jsonGenerator.writeArrayFieldStart("instanceGroups");
            for (InstanceGroupConfig instanceGroup : request.getInstanceGroups()) {
                jsonGenerator.writeStartObject();
                if (instanceGroup.getName() != null) {
                    jsonGenerator.writeStringField("name", instanceGroup.getName());
                }
                jsonGenerator.writeStringField("type", instanceGroup.getType());
                jsonGenerator.writeStringField("instanceType", instanceGroup.getInstanceType());
                jsonGenerator.writeNumberField("instanceCount", instanceGroup.getInstanceCount());
                jsonGenerator.writeEndObject();
            }
            jsonGenerator.writeEndArray();
            if (request.getName() != null) {
                jsonGenerator.writeStringField("name", request.getName());
            }
            if (request.getLogUri() != null) {
                jsonGenerator.writeStringField("logUri", request.getLogUri());
            }
            jsonGenerator.writeBooleanField("autoTerminate", request.getAutoTerminate());

            if (request.getApplications() != null) {
                jsonGenerator.writeArrayFieldStart("applications");
                for (ApplicationConfig application : request.getApplications()) {
                    jsonGenerator.writeStartObject();
                    jsonGenerator.writeStringField("name", application.getName());
                    jsonGenerator.writeStringField("version", application.getVersion());
                    if (application.getProperties() != null) {
                        jsonGenerator.writeObjectFieldStart("properties");
                        for (Map.Entry<String, Object> entry : application.getProperties().entrySet()) {
                            jsonGenerator.writeObjectField(entry.getKey(), entry.getValue());
                        }
                        jsonGenerator.writeEndObject();
                    }
                    jsonGenerator.writeEndObject();
                }
                jsonGenerator.writeEndArray();
            }

            if (request.getSteps() != null) {
                jsonGenerator.writeArrayFieldStart("steps");
                for (StepConfig step : request.getSteps()) {
                    jsonGenerator.writeStartObject();
                    if (step.getName() != null) {
                        jsonGenerator.writeStringField("name", step.getName());
                    }
                    jsonGenerator.writeStringField("type", step.getType());
                    jsonGenerator.writeStringField("actionOnFailure", step.getActionOnFailure());
                    jsonGenerator.writeObjectFieldStart("properties");
                    for (Map.Entry<String, String> entry : step.getProperties().entrySet()) {
                        jsonGenerator.writeStringField(entry.getKey(), entry.getValue());
                    }
                    jsonGenerator.writeEndObject();
                    jsonGenerator.writeEndObject();
                }
                jsonGenerator.writeEndArray();
            }

            jsonGenerator.writeEndObject();
            jsonGenerator.close();
        } catch (IOException e) {
            throw new BceClientException("Fail to generate json", e);
        }

        byte[] json = null;
        try {
            json = writer.toString().getBytes(DEFAULT_ENCODING);
        } catch (UnsupportedEncodingException e) {
            throw new BceClientException("Fail to get UTF-8 bytes", e);
        }

        InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CLUSTER);
        internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length));
        internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json");
        internalRequest.setContent(RestartableInputStream.wrap(json));

        if (request.getClientToken() != null) {
            internalRequest.addParameter("clientToken", request.getClientToken());
        }

        return this.invokeHttpClient(internalRequest, CreateClusterResponse.class);
    }
218386
public static <T extends JsonBuilder> T create(Class<T> clz, IsProperties obj) {
    T ret = create(clz);
    ret.load(obj.getDataImpl());
    return ret;
  }
301454
public static DocumentBuilderFactory newInstance(String factoryClassName,
            ClassLoader classLoader) {
        if (factoryClassName == null) {
            throw new FactoryConfigurationError("factoryClassName == null");
        }
        if (classLoader == null) {
            classLoader = Thread.currentThread().getContextClassLoader();
        }
        try {
            Class<?> type = classLoader != null
                    ? classLoader.loadClass(factoryClassName)
                    : Class.forName(factoryClassName);
            return (DocumentBuilderFactory) type.newInstance();
        } catch (ClassNotFoundException e) {
            throw new FactoryConfigurationError(e);
        } catch (InstantiationException e) {
            throw new FactoryConfigurationError(e);
        } catch (IllegalAccessException e) {
            throw new FactoryConfigurationError(e);
        }
    }
791578
@SuppressWarnings("all")
	protected Object newInstance(String className) {
		log.debug("Loading class: {}", className);
		Object instance = null;
		Class<?> clazz = null;
		if ("".equals(className) || className == null)
			return instance;
		try {
			// check for special DS class aliases
			if (className.length() == 3) {
				className = classAliases.get(className);
			}
			if (className.startsWith("flex.")) {
				// Use Red5 compatibility class instead
				className = "org.red5.compatibility." + className;
				log.debug("Modified classname: {}", className);
			}
			if (!classAllowed(className)) {
				log.error("Class creation is not allowed {}", className);
			} else {
				clazz = Thread.currentThread().getContextClassLoader()
						.loadClass(className);
				instance = clazz.newInstance();
			}
		} catch (InstantiationException iex) {
			try {
				// check for default ctor
				clazz.getConstructor(null);
				log.error("Error loading class: {}", className);
			} catch (NoSuchMethodException nse) {
				log.error(
						"Error loading class: {}; this can be resolved by adding a default constructor to your class",
						className);
			}
			log.debug("Exception was: {}", iex);
		} catch (Exception ex) {
			log.error("Error loading class: {}", className);
			log.debug("Exception was: {}", ex);
		}
		return instance;
	}
366069
private Enumeration instantiateBrowser() throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "instantiateBrowser");
        EnumImpl vEnum = null;

        try {
            DestinationType dt = DestinationType.QUEUE;
            String discrim = null;
            String mediation = null;
            boolean gather = false;

            // Establish the correct gatherMessages setting.
            String gatherStr = ((JmsQueue) theDestination).getGatherMessages();
            if (ApiJmsConstants.GATHER_MESSAGES_ON.equals(gatherStr))
                gather = true;

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, " destName: " + jsDestName + ", destType: " + dt + ", discrim: " + discrim + ", mediation: " + mediation + ", gather: " + gather);

            // Need to create a selection criteria object for create browser call.
            SelectionCriteria selectionCriteria = null;
            try {
                selectionCriteria = selectionCriteriaFactory.createSelectionCriteria(discrim, // discriminator (topic)
                                                                                     theSelector, // selector string
                                                                                     SelectorDomain.JMS // selector domain
                );
            } catch (SIErrorException sice) {
                // No FFDC code needed
                // d238447 FFDC review. FFDC here is good.
                throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                                "EXCEPTION_RECEIVED_CWSIA0144",
                                                                new Object[] { sice, "JmsQueueBrowserImpl.instantiateBrowser" },
                                                                sice,
                                                                "JmsQueueBrowserImpl.instantiateBrowser#1",
                                                                this,
                                                                tc
                                );
            }

            // Core API call to create the browser.
            BrowserSession bs = coreConnection.createBrowserSession(theDestination.getConsumerSIDestinationAddress(),
                                                                    dt,
                                                                    selectionCriteria,
                                                                    null, // alternateUserID
                                                                    gather // gatherMessages
            );

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, "core BrowserSession created: " + bs);
            if (bs != null) {
                // Create an enumeration object to drive the bs.
                vEnum = new EnumImpl(bs);
                // Add the enum to the internal list.
                enums.add(vEnum);
            }
            else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(this, tc, "createBrowserSession returned null - internal error for coreAPI");
                // d238447 FFDC review. This was using the wrong version of newThrowable, presumably with
                // the intent of generating an FFDC, but the caughtThrowable param has to be non-null.
                // Changed to use the correct newThrowable method.
                throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                                "FAILED_TO_CREATE_BSESSION_CWSIA0143",
                                                                null,
                                                                tc
                                );
            }

        } catch (SISelectorSyntaxException e) {
            // No FFDC code needed
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, "An invalid selector was supplied to createBrowser", e);
            // d238447 modify to not throw FFDC
            throw (InvalidSelectorException) JmsErrorUtils.newThrowable(InvalidSelectorException.class,
                                                                        "INVALID_SELECTOR_CWSIA0147",
                                                                        null,
                                                                        e,
                                                                        null, // null probeId = no ffdc
                                                                        this,
                                                                        tc
                            );
        } catch (SINotAuthorizedException sinae) {
            // No FFDC code needed
            // d238447: app or config error, no ffdc required.
            throw (JMSSecurityException) JmsErrorUtils.newThrowable(JMSSecurityException.class,
                                                                    "BROWSER_AUTH_ERROR_CWSIA0149",
                                                                    null,
                                                                    sinae,
                                                                    null, // null probeId = no ffdc
                                                                    this,
                                                                    tc
                            );
        } catch (SINotPossibleInCurrentConfigurationException dwte) {
            // No FFDC code needed
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, "failed to create browserSession", dwte);
            // We asked to connect to a queue and got a topic
            // d238447: app or config error, no ffdc required.
            throw (InvalidDestinationException) JmsErrorUtils.newThrowable(InvalidDestinationException.class,
                                                                           "BROWSE_FAILED_CWSIA0145",
                                                                           new Object[] { jsDestName },
                                                                           dwte,
                                                                           null, // null probeId = no ffdc
                                                                           this,
                                                                           tc
                            );
        } catch (SITemporaryDestinationNotFoundException tdnf) {
            // No FFDC code needed
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, "failed to create browserSession", tdnf);
            // We asked to connect to a queue and got a topic
            // d238447: app or config error, no ffdc required.
            throw (InvalidDestinationException) JmsErrorUtils.newThrowable(InvalidDestinationException.class,
                                                                           "BROWSE_FAILED_CWSIA0145",
                                                                           new Object[] { jsDestName },
                                                                           tdnf,
                                                                           null, // no ffdc required
                                                                           this,
                                                                           tc
                            );
        } catch (SIException e) {
            // No FFDC code needed
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, "Exception creating browser session", e);
            // d222942 review - default message ok for 'everything else' use
            // d238447 FFDC review - generate FFDC for this case
            throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                            "EXCEPTION_RECEIVED_CWSIA0144",
                                                            new Object[] { e, "createBrowserSession" },
                                                            e,
                                                            "JmsQueueBrowserImpl.instantiateBrowser#7",
                                                            this,
                                                            tc
                            );
        } catch (Exception e) {
            // No FFDC code needed
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, "Exception creating browser session", e);
            // d222942 review - default message ok for 'everything else' use
            // d238447 FFDC review - generate FFDC for this case
            throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                            "EXCEPTION_RECEIVED_CWSIA0144",
                                                            new Object[] { e, "createBrowserSession" },
                                                            e,
                                                            "JmsQueueBrowserImpl.instantiateBrowser#8",
                                                            this,
                                                            tc
                            );
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "instantiateBrowser", vEnum);
        return vEnum;
    }
554552
@Override
    public QueueBrowser createBrowser(Queue queue) throws JMSRuntimeException, InvalidDestinationRuntimeException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createBrowser", queue);

        QueueBrowser queueBrowser = null;
        try {
            queueBrowser = jmsSession.createBrowser(queue);
        } catch (InvalidDestinationException ide) {
            throw (InvalidDestinationRuntimeException) JmsErrorUtils.getJMS2Exception(ide, InvalidDestinationRuntimeException.class);
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createBrowser");
        }

        return queueBrowser;
    }
320665
protected Object createInstance(String classname) {

        // get the classloader to use
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader == null) {
            classLoader = this.getClass().getClassLoader();
        }

        // create an instance of the class using the default constructor
        try {

            return classLoader.loadClass(classname).newInstance();

        } catch (InstantiationException e) {
            throw new IllegalStateException(e);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException(e);
        }

    }
297920
@Override
    public InjectionBinding<WebServiceRef> createOverrideInjectionBinding(Class<?> instanceClass, Member member,
                                                                          Resource resource, String jndiName) throws InjectionException {

        Class<?> typeClass = resource.type();

        if (member != null) {
            Class<?> inferredType = InjectionHelper.getTypeFromMember(member);
            if (typeClass.getName().equals(Object.class.getName())) { //default
                typeClass = inferredType;
            } else {
                if (!inferredType.isAssignableFrom(typeClass)) {
                    Tr.error(tc, "error.service.ref.member.level.annotation.type.not.compatible",
                             member.getName(), member.getDeclaringClass().getName(), typeClass.getName(), inferredType.getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.type.not.compatible",
                                                                  member.getName(), member.getDeclaringClass().getName(), typeClass.getName(), inferredType.getName()));
                }
            }
        }

        InjectionBinding<WebServiceRef> binding;

        //only service type injections are possible with the @Resource annotation
        if (Service.class.isAssignableFrom(typeClass)) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "The @Resource annotation found has type=" + typeClass.getName() + " and is refers to a JAX-WS service reference");
            }
            binding = WebServiceRefBindingBuilder.createWebServiceRefBindingFromResource(resource, ivNameSpaceConfig, typeClass, jndiName);
        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "The @Resource annotation found did not refer to a web service reference type.");
            }
            binding = null;
        }

        return binding;
    }
539021
@NonNull
    @Override
    public From from(@NonNull DataSource dataSource) {
        if (dataSource == null) {
            throw new IllegalArgumentException("dataSource cannot be null.");
        }
        return new From(this, dataSource);
    }