Index: src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManager.java =================================================================== --- src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManager.java (revision 5534) +++ src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManager.java (working copy) @@ -115,6 +115,8 @@ private List notificationFailures = new ArrayList(); // The host that the dispatcher is bound to private String bindAddress; + // Manager's address + private String managerAddress; private static EventingBuilder builder = EventingBuilder.createEventingBuilder(); @@ -225,20 +227,15 @@ if (eventSourceMapping.containsKey(eventSource.getNameSpace()) == false) { eventSourceMapping.put(eventSource.getNameSpace(), eventSource); - updateManagerAddress(deploymentInfo, eventSource); - + subscriptionMapping.put(eventSource.getNameSpace(), new CopyOnWriteArrayList()); eventSource.setState(EventSource.State.CREATED); log.debug("Created: " + eventSource); } else { eventSource = eventSourceMapping.get(eventSource.getNameSpace()); - updateManagerAddress(deploymentInfo, eventSource); - subscriptionMapping.put(eventSource.getNameSpace(), new CopyOnWriteArrayList()); - - eventSource.setState(EventSource.State.STARTED); - log.debug("Started: " + eventSource); } + updateManagerAddress(deploymentInfo, eventSource); } private void lazyBindEventDispatcher() @@ -265,14 +262,26 @@ * @param deploymentInfo * @param eventSource */ - private static void updateManagerAddress(EventingEndpointDeployment deploymentInfo, EventSource eventSource) + private void updateManagerAddress(EventingEndpointDeployment deploymentInfo, EventSource source) { - String addr = null; + // start all sources (including source which is already in eventSourceMapping) if (deploymentInfo.getPortName().getLocalPart().equals("SubscriptionManagerPort")) - addr = deploymentInfo.getEndpointAddress(); - - if (addr != null) - eventSource.setManagerAddress(addr); + { + managerAddress = deploymentInfo.getEndpointAddress(); + for (EventSource createdSource : eventSourceMapping.values()) + { + createdSource.setManagerAddress(deploymentInfo.getEndpointAddress()); + createdSource.setState(EventSource.State.STARTED); + log.debug("Started: " + createdSource); + } + } + // start this source if managerAddress is known + else if(managerAddress != null) + { + source.setManagerAddress(managerAddress); + source.setState(EventSource.State.STARTED); + log.debug("Started: " + source); + } } public void removeEventSource(URI eventSourceNS) Index: src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java =================================================================== --- src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java (revision 5534) +++ src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java (working copy) @@ -426,39 +426,63 @@ protected void processEndpointMetaDataExtensions(EndpointMetaData epMetaData, WSDLDefinitions wsdlDefinitions) { - for (WSDLInterface wsdlInterface : wsdlDefinitions.getInterfaces()) + // SubscriptionManagers need all sources + if (epMetaData.getPortName().getLocalPart().equals("SubscriptionManagerPort")) { - WSDLProperty eventSourceProp = wsdlInterface.getProperty(Constants.WSDL_PROPERTY_EVENTSOURCE); - if (eventSourceProp != null && epMetaData instanceof ServerEndpointMetaData) - { - ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData; - String eventSourceNS = wsdlInterface.getName().getNamespaceURI() + "/" + wsdlInterface.getName().getLocalPart(); + for (WSDLInterface wsdlInterface : wsdlDefinitions.getInterfaces()) + { + processEndpointMetaDataExtensions(epMetaData, wsdlInterface); + } + } + else + { + for (WSDLService service : wsdlDefinitions.getServices()) + { + for (WSDLEndpoint endpoint : service.getEndpoints()) + { + if (endpoint.getAddress() == epMetaData.getEndpointAddress()) + { + WSDLBinding binding = wsdlDefinitions.getBinding(endpoint.getBinding()); + WSDLInterface wsdlInterface = wsdlDefinitions.getInterface(binding.getInterfaceName()); + processEndpointMetaDataExtensions(epMetaData, wsdlInterface); + } + } + } + } + } - // extract the schema model - JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes()); - String[] notificationSchema = EventingUtils.extractNotificationSchema(schemaModel); + protected void processEndpointMetaDataExtensions(EndpointMetaData epMetaData, WSDLInterface wsdlInterface) + { + WSDLProperty eventSourceProp = wsdlInterface.getProperty(Constants.WSDL_PROPERTY_EVENTSOURCE); + if (eventSourceProp != null && epMetaData instanceof ServerEndpointMetaData) + { + ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData; + String eventSourceNS = wsdlInterface.getName().getNamespaceURI() + "/" + wsdlInterface.getName().getLocalPart(); - // extract the root element NS - String notificationRootElementNS = null; - WSDLInterfaceOperation wsdlInterfaceOperation = wsdlInterface.getOperations()[0]; - if (wsdlInterfaceOperation.getOutputs().length > 0) - { - WSDLInterfaceOperationOutput wsdlInterfaceOperationOutput = wsdlInterfaceOperation.getOutputs()[0]; - notificationRootElementNS = wsdlInterfaceOperationOutput.getElement().getNamespaceURI(); - } - else - { - // WSDL operation of an WSDL interface that is marked as an event source - // requires to carry an output message. - throw new WSException("Unable to resolve eventing root element NS. No operation output found at " + wsdlInterfaceOperation.getName()); - } + // extract the schema model + JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlInterface.getWsdlDefinitions().getWsdlTypes()); + String[] notificationSchema = EventingUtils.extractNotificationSchema(schemaModel); - EventingEpMetaExt ext = new EventingEpMetaExt(EventingConstants.NS_EVENTING); - ext.setEventSourceNS(eventSourceNS); - ext.setNotificationSchema(notificationSchema); - ext.setNotificationRootElementNS(notificationRootElementNS); - sepMetaData.addExtension(ext); + // extract the root element NS + String notificationRootElementNS = null; + WSDLInterfaceOperation wsdlInterfaceOperation = wsdlInterface.getOperations()[0]; + if (wsdlInterfaceOperation.getOutputs().length > 0) + { + WSDLInterfaceOperationOutput wsdlInterfaceOperationOutput = wsdlInterfaceOperation.getOutputs()[0]; + notificationRootElementNS = wsdlInterfaceOperationOutput.getElement().getNamespaceURI(); } + else + { + // WSDL operation of an WSDL interface that is marked as an event source + // requires to carry an output message. + throw new WSException("Unable to resolve eventing root element NS. No operation output found at " + wsdlInterfaceOperation.getName()); + } + + EventingEpMetaExt ext = new EventingEpMetaExt(EventingConstants.NS_EVENTING); + ext.setEventSourceNS(eventSourceNS); + ext.setNotificationSchema(notificationSchema); + ext.setNotificationRootElementNS(notificationRootElementNS); + sepMetaData.addExtension(ext); } }