📄 axisconnector.java
字号:
throws MuleException { // If this is the first receiver we need to create the Axis service // component this will be registered with Mule when the Connector starts // See if the axis descriptor has already been added. This allows // developers to override the default configuration, say to increase // the threadpool if (axisComponent == null) { axisComponent = getOrCreateAxisComponent(); } else { // Lets unregister the 'template' instance, configure it and // then register again later muleContext.getRegistry().unregisterService(AXIS_SERVICE_PROPERTY + getName()); } String serviceName = ((AxisMessageReceiver) receiver).getSoapService().getName(); // No determine if the endpointUri requires a new connector to be // registed in the case of http we only need to register the new endpointUri // if the port is different If we're using VM or Jms we just use the resource // info directly without appending a service name String endpoint; String scheme = ep.getScheme().toLowerCase(); if (scheme.equals("jms") || scheme.equals("vm")) { endpoint = ep.toString(); } else { endpoint = receiver.getEndpointURI().getAddress() + "/" + serviceName; } if (logger.isDebugEnabled()) { logger.debug("Modified endpoint with " + scheme + " scheme to " + endpoint); } boolean sync = receiver.getEndpoint().isSynchronous(); EndpointBuilder serviceEndpointbuilder = new EndpointURIEndpointBuilder(endpoint, muleContext); serviceEndpointbuilder.setSynchronous(sync); serviceEndpointbuilder.setName(ep.getScheme() + ":" + serviceName); // Set the transformers on the endpoint too serviceEndpointbuilder.setTransformers(receiver.getEndpoint().getTransformers().isEmpty() ? null : receiver.getEndpoint().getTransformers()); serviceEndpointbuilder.setResponseTransformers(receiver.getEndpoint().getResponseTransformers().isEmpty() ? null : receiver.getEndpoint().getResponseTransformers()); // set the filter on the axis endpoint on the real receiver endpoint serviceEndpointbuilder.setFilter(receiver.getEndpoint().getFilter()); // set the Security filter on the axis endpoint on the real receiver // endpoint serviceEndpointbuilder.setSecurityFilter(receiver.getEndpoint().getSecurityFilter()); // TODO Do we really need to modify the existing receiver endpoint? What happens if we don't security, // filters and transformers will get invoked twice? EndpointBuilder receiverEndpointBuilder = new EndpointURIEndpointBuilder(receiver.getEndpoint(), muleContext); // Remove the Axis filter now receiverEndpointBuilder.setFilter(null); // Remove the Axis Receiver Security filter now receiverEndpointBuilder.setSecurityFilter(null); InboundEndpoint serviceEndpoint = muleContext.getRegistry() .lookupEndpointFactory() .getInboundEndpoint(serviceEndpointbuilder); InboundEndpoint receiverEndpoint = muleContext.getRegistry() .lookupEndpointFactory() .getInboundEndpoint(receiverEndpointBuilder); receiver.setEndpoint(receiverEndpoint); axisComponent.getInboundRouter().addEndpoint(serviceEndpoint); } private String getCounterEndpointKey(EndpointURI endpointURI) { StringBuffer endpointKey = new StringBuffer(64); endpointKey.append(endpointURI.getScheme()); endpointKey.append("://"); endpointKey.append(endpointURI.getHost()); if (endpointURI.getPort() > -1) { endpointKey.append(":"); endpointKey.append(endpointURI.getPort()); } return endpointKey.toString(); } // This initialization could be performed in the initialize() method. Putting it here essentially makes // it a lazy-create/lazy-init // Another option would be to put it in the default-axis-config.xml (MULE-2102) with lazy-init="true" // but that makes us depend on Spring. // Another consideration is how/when this implicit component gets disposed. protected Service getOrCreateAxisComponent() throws MuleException { Service c = muleContext.getRegistry().lookupService(AXIS_SERVICE_PROPERTY + getName()); if (c == null) { // TODO MULE-2228 Simplify this API c = new SedaService(); c.setName(AXIS_SERVICE_PROPERTY + getName()); c.setModel(muleContext.getRegistry().lookupSystemModel()); Map props = new HashMap(); props.put(AXIS, axis); SingletonObjectFactory of = new SingletonObjectFactory(AxisServiceComponent.class, props); of.initialise(); c.setComponent(new DefaultJavaComponent(of)); } return c; } /** * Template method to perform any work when starting the connectoe * * @throws org.mule.api.MuleException if the method fails */ protected void doStart() throws MuleException { axis.start(); } /** * Template method to perform any work when stopping the connectoe * * @throws org.mule.api.MuleException if the method fails */ protected void doStop() throws MuleException { axis.stop(); // Model model = muleContext.getRegistry().lookupModel(); // model.unregisterComponent(model.getDescriptor(AXIS_SERVICE_COMPONENT_NAME)); } protected void doConnect() throws Exception { // template method } protected void doDisconnect() throws Exception { // template method } protected void doDispose() { // template method } public String getServerConfig() { return serverConfig; } public void setServerConfig(String serverConfig) { this.serverConfig = serverConfig; } public List getBeanTypes() { return beanTypes; } public void setBeanTypes(List beanTypes) { this.beanTypes = beanTypes; } public String getClientConfig() { return clientConfig; } public void setClientConfig(String clientConfig) { this.clientConfig = clientConfig; } public AxisServer getAxis() { return axis; } public void setAxis(AxisServer axisServer) { this.axis = axisServer; } public SimpleProvider getServerProvider() { return serverProvider; } public void setServerProvider(SimpleProvider serverProvider) { this.serverProvider = serverProvider; } public SimpleProvider getClientProvider() { return clientProvider; } public void setClientProvider(SimpleProvider clientProvider) { this.clientProvider = clientProvider; } public Map getAxisTransportProtocols() { return axisTransportProtocols; } public void setAxisTransportProtocols(Map axisTransportProtocols) { this.axisTransportProtocols.putAll(axisTransportProtocols); } void addServletService(SOAPService service) { servletServices.add(service); } public List getSupportedSchemes() { return supportedSchemes; } public void setSupportedSchemes(List supportedSchemes) { this.supportedSchemes = supportedSchemes; } public boolean isDoAutoTypes() { return doAutoTypes; } public void setDoAutoTypes(boolean doAutoTypes) { this.doAutoTypes = doAutoTypes; } void registerTypes(TypeMappingRegistryImpl registry, List types) throws ClassNotFoundException { if (types != null) { Class clazz; for (Iterator iterator = types.iterator(); iterator.hasNext();) { clazz = ClassUtils.loadClass(iterator.next().toString(), getClass()); String localName = Types.getLocalNameFromFullName(clazz.getName()); QName xmlType = new QName(Namespaces.makeNamespace(clazz.getName()), localName); registry.getDefaultTypeMapping().register(clazz, xmlType, new BeanSerializerFactory(clazz, xmlType), new BeanDeserializerFactory(clazz, xmlType)); } } } public boolean isTreatMapAsNamedParams() { return treatMapAsNamedParams; } public void setTreatMapAsNamedParams(boolean treatMapAsNamedParams) { this.treatMapAsNamedParams = treatMapAsNamedParams; } public void onNotification(ServerNotification notification) { if (notification.getAction() == MuleContextNotification.CONTEXT_STARTED) { // We need to register the Axis service component once the muleContext // starts because when the model starts listeners on components are started, thus // all listener need to be registered for this connector before the Axis service // component is registered. // The implication of this is that to add a new service and a // different http port the model needs to be restarted before the listener is available if (muleContext.getRegistry().lookupService(AXIS_SERVICE_PROPERTY + getName()) == null) { try { // Descriptor might be null if no inbound endpoints have been // register for the Axis connector if (axisComponent == null) { axisComponent = getOrCreateAxisComponent(); } muleContext.getRegistry().registerService(axisComponent); // We have to perform a small hack here to rewrite servlet:// // endpoints with the // real http:// address for (Iterator iterator = servletServices.iterator(); iterator.hasNext();) { SOAPService service = (SOAPService) iterator.next(); ServletConnector servletConnector = (ServletConnector) TransportFactory.getConnectorByProtocol("servlet"); String url = servletConnector.getServletUrl(); if (url != null) { service.getServiceDescription().setEndpointURL(url + "/" + service.getName()); } else { logger.error("The servletUrl property on the ServletConntector has not been set this means that wsdl generation for service '" + service.getName() + "' may be incorrect"); } } servletServices.clear(); } catch (MuleException e) { handleException(e); } } } } public boolean isSyncEnabled(String protocol) { protocol = protocol.toLowerCase(); if (protocol.equals("http") || protocol.equals("https") || protocol.equals("ssl") || protocol.equals("tcp") || protocol.equals("servlet")) { return true; } else { return super.isSyncEnabled(protocol); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -