public void write(HTTPBinding httpBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { // writer.writeStartElement(Constants.SCA10_NS, BINDING_HTTP); writeStart(writer, HTTPBinding.TYPE.getNamespaceURI(), HTTPBinding.TYPE.getLocalPart()); // Write binding name if (httpBinding.getName() != null) { writer.writeAttribute(NAME, httpBinding.getName()); } // Write binding URI if (httpBinding.getURI() != null) { writer.writeAttribute(URI, httpBinding.getURI()); } // Write operation selectors if (httpBinding.getOperationSelector() != null) { extensionProcessor.write(httpBinding.getOperationSelector(), writer, context); } // Write wire formats if (httpBinding.getRequestWireFormat() != null) { extensionProcessor.write(httpBinding.getRequestWireFormat(), writer, context); } if (httpBinding.getResponseWireFormat() != null && httpBinding.getRequestWireFormat() != httpBinding .getResponseWireFormat()) { writeStart(writer, RESPONSE_QNAME.getNamespaceURI(), RESPONSE_QNAME.getLocalPart()); extensionProcessor.write(httpBinding.getResponseWireFormat(), writer, context); writeEnd(writer); } writeEnd(writer); // writer.writeEndElement(); }
public HTTPBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException,XMLStreamException { HTTPBinding httpBinding = httpBindingFactory.createHTTPBinding(); String name = getString(reader, NAME); if (name != null) { httpBinding.setName(name); String uri = getURIString(reader, URI); if (uri != null) { httpBinding.setURI(uri); if (extension != null) { if (extension instanceof WireFormat) { httpBinding.setResponseWireFormat((WireFormat)extension); if (extension != null) { if (extension instanceof WireFormat) { httpBinding.setRequestWireFormat((WireFormat)extension); } else if (extension instanceof OperationSelector) { httpBinding.setOperationSelector((OperationSelector)extension);
public void start() { /** * Consider three scenarios here : * - Default servlet using service level operation * - Default servlet using GET, PUT, POST, DELETE operations mapped to interface names with same name * - RPC over HTTP like : http://localhost:8080/HelloworldComponent/Helloworld/sayHello?name=Petra */ if (binding.getOperationSelector() == null || binding.getRequestWireFormat() == null || binding.getResponseWireFormat() == null) { throw new IllegalStateException("Binding operation selector and/or wire formats not properly setup."); } Servlet servlet = new HTTPBindingServiceServlet(endpoint, messageFactory); // Create our HTTP service listener Servlet and register it with the // Servlet host servletMapping = binding.getURI(); if (!servletMapping.endsWith("/")) { servletMapping += "/"; } if (!servletMapping.endsWith("*")) { servletMapping += "*"; } String deployedURI = servletHost.addServletMapping(servletMapping, servlet); endpoint.setDeployedURI(deployedURI); }
this.servletHost = servletHost; if (binding.getOperationSelector() == null) { binding.setOperationSelector(new HTTPDefaultOperationSelector()); if (binding.getRequestWireFormat() == null) { binding.setRequestWireFormat(new HTTPDefaultWireFormat()); if (binding.getResponseWireFormat() == null) { binding.setResponseWireFormat(new HTTPDefaultWireFormat()); if (binding.getOperationSelector() != null) { OperationSelectorProviderFactory osProviderFactory = (OperationSelectorProviderFactory) providerFactories.getProviderFactory(binding.getOperationSelector().getClass()); if (osProviderFactory != null) { this.osProvider = osProviderFactory.createServiceOperationSelectorProvider(endpoint); if (binding.getRequestWireFormat() != null && binding.getResponseWireFormat() != null) { WireFormatProviderFactory wfProviderFactory = (WireFormatProviderFactory) providerFactories.getProviderFactory(binding.getRequestWireFormat().getClass()); if (wfProviderFactory != null) { this.wfProvider = wfProviderFactory.createServiceWireFormatProvider(endpoint); servletMapping = binding.getURI(); if (!servletMapping.endsWith("/")) { servletMapping += "/";
/** * Utility methods */ private void addService(WidgetImplementation implementation) { Service widgetService = null; // Resource implementation always provide a single service exposing // the Resource interface, and have no references and properties widgetService = assemblyFactory.createService(); widgetService.setName("Widget"); // Create the Java interface contract for the Resource service JavaInterface javaInterface; try { javaInterface = javaInterfaceFactory.createJavaInterface(Widget.class); } catch (InvalidInterfaceException e) { throw new IllegalArgumentException(e); } JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); interfaceContract.setInterface(javaInterface); widgetService.setInterfaceContract(interfaceContract); HTTPBinding binding = httpBindingFactory.createHTTPBinding(); binding.setURI(implementation.getWidgetUri()); widgetService.getBindings().add(binding); implementation.getServices().add(widgetService); }
/** * Utility methods */ private void addService(WidgetImplementation implementation) { Service widgetService = null; // Resource implementation always provide a single service exposing // the Resource interface, and have no references and properties widgetService = assemblyFactory.createService(); widgetService.setName("Widget"); // Create the Java interface contract for the Resource service JavaInterface javaInterface; try { javaInterface = javaInterfaceFactory.createJavaInterface(Widget.class); } catch (InvalidInterfaceException e) { throw new IllegalArgumentException(e); } JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); interfaceContract.setInterface(javaInterface); widgetService.setInterfaceContract(interfaceContract); HTTPBinding binding = httpBindingFactory.createHTTPBinding(); binding.setURI(implementation.getWidgetUri()); widgetService.getBindings().add(binding); implementation.getServices().add(widgetService); }