Codota Logo
CastUtils
Code IndexAdd Codota to your IDE (free)

How to use
CastUtils
in
org.apache.cxf.helpers

Best Java code snippets using org.apache.cxf.helpers.CastUtils (Showing top 20 results out of 909)

Refine searchRefine arrow

  • Message
  • Exchange
  • Definition
  • QName
  • Message
  • Binding
  • Endpoint
  • ServiceInfo
  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: org.apache.cxf/cxf-rt-frontend-jaxws

private void initializePorts() {
  try {
    Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
    javax.wsdl.Service serv = def.getService(serviceName);
    if (serv == null) {
      throw new WebServiceException("Could not find service named " + serviceName
    Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
    for (Port port : wsdlports.values()) {
      QName name = new QName(serviceName.getNamespaceURI(), port.getName());
        = CastUtils.cast(port.getBinding().getExtensibilityElements());
      if (!extensions.isEmpty()) {
        ExtensibilityElement e = extensions.get(0);
      extensions = CastUtils.cast(port.getExtensibilityElements());
      if (!extensions.isEmpty()) {
        ExtensibilityElement e = extensions.get(0);
    Service service = sf.create();
    for (ServiceInfo si : service.getServiceInfos()) {
      for (EndpointInfo ei : si.getEndpoints()) {
        String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
        addPort(ei.getName(), bindingID, ei.getAddress());
origin: apache/cxf

private Map<QName, Operation> getOperations(PortType portType) {
  Map<QName, Operation> operations = new HashMap<>();
  Collection<Operation> pops = CastUtils.cast(portType.getOperations());
  for (Operation op : pops) {
    operations.put(new QName(portType.getQName().getNamespaceURI(), op.getName()), op);
  }
  return operations;
}
origin: apache/cxf

private Map<QName, XNode> getBindings(Service service) {
  Map<QName, XNode> bindings = new HashMap<>();
  if (service.getPorts().values().isEmpty()) {
    throw new ToolException("Service " + service.getQName() + " does not contain any usable ports");
  }
  Collection<Port> ports = CastUtils.cast(service.getPorts().values());
  for (Port port : ports) {
    Binding binding = port.getBinding();
    bindings.put(binding.getQName(), getXNode(service, port));
    if (WSDLConstants.NS_WSDL11.equals(binding.getQName().getNamespaceURI())) {
      throw new ToolException("Binding "
                  + binding.getQName().getLocalPart()
                  + " namespace set improperly.");
    }
  }
  return bindings;
}
origin: apache/cxf

private static QName getBindingQNameByID(Definition wsdlDef, String repositoryID,
                     WSDLASTVisitor wsdlVisitor) {
  // We need to find the binding which corresponds with the given repository ID.
  // This is specified in the schema definition for a custom endpoint
  // reference type.
  Collection<Binding> bindings = CastUtils.cast(wsdlDef.getBindings().values());
  if (bindings.isEmpty() && !wsdlVisitor.getModuleToNSMapper().isDefaultMapping()) {
    // If we are not using the default mapping, then the binding definitions are not
    // located in the current Definition object, but nistead in the root Definition
    bindings = CastUtils.cast(wsdlVisitor.getDefinition().getBindings().values());
  }
  for (Binding b : bindings) {
    List<?> extElements = b.getExtensibilityElements();
    for (java.lang.Object element : extElements) {
      if (element instanceof BindingType) {
        BindingType bt = (BindingType)element;
        if (bt.getRepositoryID().equals(repositoryID)) {
          if (wsdlVisitor.getSupportPolymorphicFactories()) {
            return new QName(b.getQName().getNamespaceURI(),
                     "InferFromTypeId",
                     b.getQName().getPrefix());
          }
          return b.getQName();
        }
      }
    }
  }
  return null;
}
origin: apache/cxf

private boolean isServiceExisted() {
  services = CastUtils.cast(wsdlDefinition.getServices());
  if (services == null) {
    return false;
  }
  for (Map.Entry<QName, Service> entry : services.entrySet()) {
    String serviceName = entry.getKey().getLocalPart();
    if (serviceName.equals(env.get(ToolConstants.CFG_SERVICE))) {
      service = entry.getValue();
      break;
    }
  }
  return (service == null) ? false : true;
}
origin: apache/cxf

private boolean isBindingExisted() {
  Map<QName, Binding> bindings = CastUtils.cast(wsdlDefinition.getBindings());
  if (bindings == null) {
    return false;
  }
  for (Entry<QName, Binding> entry : bindings.entrySet()) {
    String existBindingName = entry.getKey().getLocalPart();
    String bindingName = (String)env.get(ToolConstants.CFG_BINDING);
    if (bindingName.equals(existBindingName)) {
      binding = entry.getValue();
    }
  }
  return (binding == null) ? false : true;
}
origin: apache/cxf

protected void buildBindingOperation(Definition def, Binding binding,
                  Collection<BindingOperationInfo> bindingOperationInfos) {
  BindingOperation bindingOperation = null;
  for (BindingOperationInfo bindingOperationInfo : bindingOperationInfos) {
    bindingOperation = def.createBindingOperation();
    addDocumentation(bindingOperation, bindingOperationInfo.getDocumentation());
    bindingOperation.setName(bindingOperationInfo.getName().getLocalPart());
    for (Operation operation
        : CastUtils.cast(binding.getPortType().getOperations(), Operation.class)) {
      if (operation.getName().equals(bindingOperation.getName())) {
        bindingOperation.setOperation(operation);
        break;
      }
    }
    buildBindingInput(def, bindingOperation, bindingOperationInfo.getInput());
    buildBindingOutput(def, bindingOperation, bindingOperationInfo.getOutput());
    buildBindingFault(def, bindingOperation, bindingOperationInfo.getFaults());
    addExtensibilityAttributes(def, bindingOperation, bindingOperationInfo.getExtensionAttributes());
    addExtensibilityElements(def, bindingOperation, getWSDL11Extensors(bindingOperationInfo));
    binding.addBindingOperation(bindingOperation);
  }
}
origin: apache/cxf

private boolean queryBinding(QName bqname) {
  Collection<Binding> bindings = CastUtils.cast(definition.getBindings().values());
  for (Binding binding : bindings) {
    if (binding.getQName().getLocalPart().equals(bqname.getLocalPart())) {
      return true;
    }
  }
  return false;
}
origin: apache/cxf

protected EprMetaData getObjectReferenceBinding(Definition wsdlDef, QName bindingName) {
  EprMetaData info = new EprMetaData();
  Binding wsdlBinding = wsdlDef.getBinding(bindingName);
  // If the binding name does not have a namespace associated with it, then we'll need to
  // get the list of all bindings and compare their local parts against our name.
  if (wsdlBinding == null && bindingName.getNamespaceURI().isEmpty()
    && !bindingName.getLocalPart().isEmpty()) {
    Collection<Binding> bindingsCollection = CastUtils.cast(wsdlDef.getBindings().values());
    for (Binding b : bindingsCollection) {
      if (b.getQName().getLocalPart().equals(bindingName.getLocalPart())) {
        wsdlBinding = b;
        break;
      }
    }
  }
  if (wsdlBinding != null) {
    info.setBinding(wsdlBinding);
    info.setCandidateWsdlDef(wsdlDef);
  }
  return info;
}
origin: apache/cxf

private boolean isPortTypeExisted() {
  portTypes = CastUtils.cast(wsdlDefinition.getPortTypes());
  if (portTypes == null) {
    return false;
  }
  for (Map.Entry<QName, PortType> entry : portTypes.entrySet()) {
    String existPortName = entry.getKey().getLocalPart();
    if (existPortName.equals(env.get(ToolConstants.CFG_PORTTYPE))) {
      portType = entry.getValue();
      break;
    }
  }
  return (portType == null) ? false : true;
}
origin: apache/cxf

private void fixSchema(Schema sc, String pfx) throws ParserConfigurationException {
  Document doc = DOMUtils.getEmptyDocument();
  Element el = doc.createElementNS(sc.getElementType().getNamespaceURI(),
            pfx + ":" + sc.getElementType().getLocalPart());
  sc.setElement(el);
  Map<String, List<String>> mp = CastUtils.cast(sc.getImports());
  for (Map.Entry<String, List<String>> ent : mp.entrySet()) {
    Element imp = doc.createElementNS(sc.getElementType().getNamespaceURI(),
                     pfx + ":import");
    el.appendChild(imp);
    imp.setAttribute("namespace", ent.getKey());
  }
}
origin: apache/cxf

@SuppressWarnings("unchecked")
public QName getServiceQName(Definition def) {
  List<Definition> defs = new ArrayList<>();
  defs.add(def);
  Iterator<?> ite1 = def.getImports().values().iterator();
  while (ite1.hasNext()) {
    List<javax.wsdl.Import> defList = CastUtils.cast((List<?>)ite1.next());
    for (javax.wsdl.Import importDef : defList) {
      defs.add(importDef.getDefinition());
    }
  }
  String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);
  for (Definition definition : defs) {
    if (serviceName != null) {
      for (Iterator<QName> ite = definition.getServices().keySet().iterator(); ite.hasNext();) {
        QName qn = ite.next();
        if (qn.getLocalPart().equalsIgnoreCase(serviceName.toLowerCase())) {
          return qn;
        }
      }
    }
  }
  Message msg = new Message("SERVICE_NOT_FOUND", LOG, new Object[] {serviceName});
  throw new ToolException(msg);
}
origin: org.apache.cxf/cxf-rt-frontend-jaxws

protected void processAttachments(SoapMessage message, SoapBodyInfo sbi) {
  Collection<Attachment> atts = setupAttachmentOutput(message);
  List<Object> outObjects = CastUtils.cast(message.getContent(List.class));
    String partName = mpi.getConcreteName().getLocalPart();
    String ct = (String) mpi.getProperty(Message.CONTENT_TYPE);
      throw new Fault(new org.apache.cxf.common.i18n.Message("ATTACHMENT_NOT_SUPPORTED",
                                  LOG, o.getClass()));
origin: apache/cxf

private List<PortType> getPortTypeList() throws Exception {
  Map<QName, PortType> portTypes = CastUtils.cast(def.getAllPortTypes());
  List<PortType> intfs = null;
  if (portTypes == null) {
    org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(
      "No PortTypes defined in wsdl", LOG);
    throw new Exception(msg.toString());
  }
  PortType portType = null;
  intfs = new ArrayList<>();
  if (portTypes.size() == 1) {
    portType = portTypes.values().iterator().next();
    interfaceNames.add(portType.getQName().getLocalPart());
    intfs.add(portType);
  } else if (portTypes.size() > 1) {
    if (def.getAllBindings().size() > 0) {
      throwMultipleMultipleTypeException(CastUtils.cast(def.getAllBindings().keySet(),
                               QName.class));
    }
    for (PortType port : portTypes.values()) {
      interfaceNames.add(port.getQName().getLocalPart());
      intfs.add(port);
    }
  }
  return intfs;
}
origin: org.apache.cxf/cxf-rt-frontend-jaxws

public Object[] getHeaders(QName name, JAXBContext context, boolean allRoles) {
  SOAPMessage msg = getMessage();
  SOAPHeader header;
  try {
    header = msg.getSOAPPart().getEnvelope().getHeader();
    if (header == null || !header.hasChildNodes()) {
      return new Object[0];
    }
    List<Object> ret = new ArrayList<>();
    Iterator<SOAPHeaderElement> it = CastUtils.cast(header.examineAllHeaderElements());
    while (it.hasNext()) {
      SOAPHeaderElement she = it.next();
      if ((allRoles
        || roles.contains(she.getActor()))
        && name.equals(she.getElementQName())) {
        ret.add(JAXBUtils.unmarshall(context, she));
      }
    }
    return ret.toArray(new Object[0]);
  } catch (SOAPException | JAXBException e) {
    throw new WebServiceException(e);
  }
}
origin: apache/cxf

public Binding[] getCorbaBindings() {
  List<Binding> result = new ArrayList<>();
  Map<QName, Binding> bindings = CastUtils.cast(definition.getBindings());
  for (Binding binding : bindings.values()) {
    List<ExtensibilityElement> extElements
      = CastUtils.cast(binding.getExtensibilityElements());
    for (int i = 0; i < extElements.size(); i++) {
      ExtensibilityElement el = extElements.get(i);
      if (el.getElementType().equals(CorbaConstants.NE_CORBA_BINDING)) {
        result.add(binding);
        break;
      }
    }
  }
  return result.toArray(new Binding[0]);
}
origin: apache/cxf

public void handleMessage(Message message) throws Fault {
  Exchange ex = message.getExchange();
  Set<Endpoint> endpoints = CastUtils.cast((Set<?>)ex.get(MultipleEndpointObserver.ENDPOINTS));
  Endpoint ep = selectEndpoint(message, endpoints);
  if (ep == null) {
    return;
  }
  ex.put(Endpoint.class, ep);
  ex.put(Binding.class, ep.getBinding());
  ex.put(Service.class, ep.getService());
  InterceptorChain chain = message.getInterceptorChain();
  chain.add(ep.getInInterceptors());
  chain.add(ep.getBinding().getInInterceptors());
  chain.add(ep.getService().getInInterceptors());
  chain.setFaultObserver(ep.getOutFaultObserver());
}
origin: apache/cxf

/**
 * {@inheritDoc}
 */
public Object getInstance(Message m) {
  if (singletonInstance != null) {
    return singletonInstance;
  }
  ProviderInfo<?> application = m == null ? null
    : (ProviderInfo<?>)m.getExchange().getEndpoint().get(Application.class.getName());
  Map<Class<?>, Object> mapValues = CastUtils.cast(application == null ? null
    : Collections.singletonMap(Application.class, application.getProvider()));
  Object[] values = ResourceUtils.createConstructorArguments(c, m, !isSingleton(), mapValues);
  Object instance = values.length > 0 ? ac.getBean(beanId, values) : ac.getBean(beanId);
  initInstance(m, instance);
  return instance;
}
origin: org.apache.cxf/cxf-rt-transports-http

/**
 * While extracting the Message.PROTOCOL_HEADERS property from the Message,
 * this call ensures that the Message.PROTOCOL_HEADERS property is
 * set on the Message. If it is not set, an empty map is placed there, and
 * then returned.
 *
 * @param message The outbound message
 * @return The PROTOCOL_HEADERS map
 */
public static Map<String, List<String>> getSetProtocolHeaders(final Message message) {
  Map<String, List<String>> headers =
    CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
  if (null == headers) {
    headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
  } else if (headers instanceof HashMap) {
    Map<String, List<String>> headers2
      = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    headers2.putAll(headers);
    headers = headers2;
  }
  message.put(Message.PROTOCOL_HEADERS, headers);
  return headers;
}
origin: org.apache.cxf/cxf-rt-frontend-jaxws

public void handleMessage(Message message) throws Fault {
  Fault f = (Fault)message.getContent(Exception.class);
  if (f == null) {
    return;
      SoapVersion soapVersion = (SoapVersion)message.get(SoapVersion.class.getName());
      if (soapVersion != null && soapVersion.getVersion() != 1.1) {
        if (f instanceof SoapFault) {
          for (Iterator<QName> it = CastUtils.cast(sf.getFault().getFaultSubcodes()); it.hasNext();) {
            ((SoapFault) f).addSubCode(it.next());
      message.setContent(Exception.class, f);
      throw new Fault(new org.apache.cxf.common.i18n.Message("INVOCATION_TARGET_EXC", BUNDLE), e);
    } catch (IllegalAccessException | IllegalArgumentException e) {
      throw new Fault(new org.apache.cxf.common.i18n.Message("COULD_NOT_INVOKE", BUNDLE), e);
    Service service = message.getExchange().getService();
                                 message.getExchange().getBus());
        writer.setSchema(schema);
      OperationInfo op = message.getExchange().getBindingOperationInfo().getOperationInfo();
      QName faultName = getFaultName(fault, cause.getClass(), op);
      MessagePartInfo part = getFaultMessagePart(faultName, op);
org.apache.cxf.helpersCastUtils

Most used methods

  • cast

Popular in Java

  • Finding current android device location
  • findViewById (Activity)
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
  • BoxLayout (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now