protected void setUp() throws Exception { source = new SynapseEventSource("foo"); subMan = new DefaultInMemorySubscriptionManager(); source.setSubscriptionManager(subMan); }
public boolean mediate(MessageContext synCtx) { if (log.isDebugEnabled()) { log.debug("Mediation for Event Publisher started"); } SynapseEventSource eventSource = synCtx.getConfiguration().getEventSource(eventSourceName); eventSource.dispatchEvents(synCtx); return true; }
artifactConfig, properties); if (es != null) { es.setFileName((new File(fileName)).getName()); if (log.isDebugEnabled()) { log.debug("EventSource named '" + es.getName() + "' has been built from the file " + fileName); es.buildService(getSynapseConfiguration().getAxisConfiguration()); if (log.isDebugEnabled()) { log.debug("Initialized the EventSource : " + es.getName()); getSynapseConfiguration().addEventSource(es.getName(), es); if (log.isDebugEnabled()) { log.debug("EventSource Deployment from file : " + fileName + " : Completed"); log.info("EventSource named '" + es.getName() + "' has been deployed from file : " + fileName); return es.getName(); } else { handleSynapseArtifactDeploymentError("EventSource Deployment Failed. The " +
public OMElement serializeEventSource(SynapseEventSource source, SynapseConfiguration synapseConfig, OMElement parent) throws Exception { File eventsDir = createDirectory(currentDirectory, MultiXMLConfigurationBuilder.EVENTS_DIR); OMElement eventSrcElem = EventSourceSerializer.serializeEventSource(null, source); String fileName = source.getFileName(); if (fileName != null) { if (currentDirectory == rootDirectory) { handleDeployment(eventsDir, fileName, source.getName(), synapseConfig.getArtifactDeploymentStore()); } File eventSrcFile = new File(eventsDir, source.getFileName()); writeToFile(eventSrcElem, eventSrcFile); } else if (parent != null) { parent.addChild(eventSrcElem); } return eventSrcElem; }
handleException("The 'name' attribute is required for a event source de"); } else { eventSource = new SynapseEventSource(name.getAttributeValue()); String key = eventSource.getName() + "." + propName; eventSource.putConfigurationProperty(propName, propValue); propValue = passwordManager.resolve(propValue); eventSource.setSubscriptionManager(manager); eventSource.getSubscriptionManager()
if (EventingConstants.WSE_SUBSCRIBE.equals(mc.getWSAAction())) { processSubscriptionRequest(mc, messageBuilder); } else if (EventingConstants.WSE_UNSUBSCRIBE.equals(mc.getWSAAction())) { processUnSubscribeRequest(mc, messageBuilder); } else if (EventingConstants.WSE_GET_STATUS.equals(mc.getWSAAction())) { processGetStatusRequest(mc, messageBuilder); } else if (EventingConstants.WSE_RENEW.equals(mc.getWSAAction())) { processReNewRequest(mc, messageBuilder); } else { log.debug("Event received"); dispatchEvents(smc); handleException("Subscription manager processing error", e);
if (eventSource.getName() != null) { evenSourceElem .addAttribute(fac.createOMAttribute("name", nullNS, eventSource.getName())); if (eventSource.getSubscriptionManager() != null) { OMElement subManagerElem = fac.createOMElement("subscriptionManager", XMLConfigConstants.SYNAPSE_OMNAMESPACE); subManagerElem.addAttribute(fac.createOMAttribute("class", nullNS, eventSource.getSubscriptionManager().getClass().getName())); Collection<String> names = (Collection<String>) eventSource.getSubscriptionManager().getPropertyNames(); for (String name : names) { String value; if (eventSource.isContainsConfigurationProperty(name)) { value = eventSource.getConfigurationProperty(name); } else { value = eventSource.getSubscriptionManager().getPropertyValue(name); eventSource.getSubscriptionManager().getStaticSubscriptions(); for (Iterator<Subscription> iterator = staticSubscriptionList.iterator(); iterator.hasNext();) {
public void eventSourceAdded(SynapseEventSource eventSource) { log.info("Event source : " + eventSource.getName() + " was added " + "to the Synapse configuration successfully"); }
assertItemRemoved(startup.getName(), STARTUP); SynapseEventSource eventSrc = new SynapseEventSource("eventSrc1"); synapseConfig.addEventSource(eventSrc.getName(), eventSrc); assertItemAdded(eventSrc.getName(), EVENT_SRC); synapseConfig.removeEventSource(eventSrc.getName()); assertItemRemoved(eventSrc.getName(), EVENT_SRC);
private static void createEventSources(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) { File eventsDir = new File(rootDirPath, EVENTS_DIR); if (eventsDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading event sources from : " + eventsDir.getPath()); } Iterator events = FileUtils.iterateFiles(eventsDir, extensions, false); while (events.hasNext()) { File file = (File) events.next(); OMElement document = null; try { document = getOMElement(file); } catch (Exception e) { String msg = "Error while building Event Source configuration from file : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_EVENT_SOURCE, msg, e); } if (document != null) { SynapseEventSource eventSource = SynapseXMLConfigurationFactory. defineEventSource(synapseConfig, document, properties); if (eventSource != null) { eventSource.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact( file.getAbsolutePath(), eventSource.getName()); } } } } }
dispatchResponse(soapEnvelope, EventingConstants.WSE_UNSUBSCRIBE_RESPONSE, mc, false); } else { EventingConstants.WSE_FAULT_CODE_RECEIVER, "EventSourceUnableToProcess", "Unable to Unsubscribe", ""); dispatchResponse(soapEnvelope, EventingConstants.WSA_FAULT, mc, true);
/** * Test serializeEventSource and assert OMElement returned is not null. * * @throws XMLStreamException - XMLStreamException */ @Test public void testSerializeEvent2() throws XMLStreamException { SynapseEventSource synapseEventSource = new SynapseEventSource("Test"); OMElement omElement = EventSourceSerializer.serializeEventSource(null, synapseEventSource); Assert.assertNotNull("OMElement cannot be null.", omElement); }
@Override public void restoreSynapseArtifact(String artifactName) { if (log.isDebugEnabled()) { log.debug("Restoring the EventSource with name : " + artifactName + " : Started"); } try { SynapseEventSource es = getSynapseConfiguration().getEventSource(artifactName); OMElement esElem = EventSourceSerializer.serializeEventSource(null, es); if (es.getFileName() != null) { String fileName = getServerConfigurationInformation().getSynapseXMLLocation() + File.separator + MultiXMLConfigurationBuilder.EVENTS_DIR + File.separator + es.getFileName(); writeToFile(esElem, fileName); if (log.isDebugEnabled()) { log.debug("Restoring the EventSource with name : " + artifactName + " : Completed"); } log.info("EventSource named '" + artifactName + "' has been restored"); } else { handleSynapseArtifactDeploymentError("Couldn't restore the EventSource named '" + artifactName + "', filename cannot be found"); } } catch (Exception e) { handleSynapseArtifactDeploymentError( "Restoring of the EventSource named '" + artifactName + "' has failed", e); } } }
public void buildService(AxisConfiguration axisCfg) throws AxisFault { AxisService eventSourceService = new AxisService(); eventSourceService.setName(this.name); // Add wse operations addOperations(eventSourceService); axisCfg.addService(eventSourceService); //Set the service parameters eventSourceService .addParameter(EventingConstants.SUBSCRIPTION_MANAGER, subscriptionManager); eventSourceService.addParameter(SynapseEventingConstants.SERVICE_TYPE, SynapseEventingConstants.EVENTING_ST); }
/** * Deploys all event sources. * * @throws AxisFault if an error occurs deploying the event sources. */ private void deployEventSources() throws AxisFault { log.info("Deploying EventSources..."); for (SynapseEventSource eventSource : synapseConfiguration.getEventSources()) { eventSource.buildService(configurationContext.getAxisConfiguration()); } }
synapseEventSource.getSubscriptionManager().subscribe(synapseSubscription);
handleException("The 'name' attribute is required for a event source de"); } else { eventSource = new SynapseEventSource(name.getAttributeValue()); String key = eventSource.getName() + "." + propName; eventSource.putConfigurationProperty(propName, propValue); propValue = passwordManager.resolve(propValue); eventSource.setSubscriptionManager(manager); eventSource.getSubscriptionManager()
if (EventingConstants.WSE_SUBSCRIBE.equals(mc.getWSAAction())) { processSubscriptionRequest(mc, messageBuilder); } else if (EventingConstants.WSE_UNSUBSCRIBE.equals(mc.getWSAAction())) { processUnSubscribeRequest(mc, messageBuilder); } else if (EventingConstants.WSE_GET_STATUS.equals(mc.getWSAAction())) { processGetStatusRequest(mc, messageBuilder); } else if (EventingConstants.WSE_RENEW.equals(mc.getWSAAction())) { processReNewRequest(mc, messageBuilder); } else { log.debug("Event received"); dispatchEvents(smc); handleException("Subscription manager processing error", e);
if (eventSource.getName() != null) { evenSourceElem .addAttribute(fac.createOMAttribute("name", nullNS, eventSource.getName())); if (eventSource.getSubscriptionManager() != null) { OMElement subManagerElem = fac.createOMElement("subscriptionManager", XMLConfigConstants.SYNAPSE_OMNAMESPACE); subManagerElem.addAttribute(fac.createOMAttribute("class", nullNS, eventSource.getSubscriptionManager().getClass().getName())); Collection<String> names = (Collection<String>) eventSource.getSubscriptionManager().getPropertyNames(); for (String name : names) { String value; if (eventSource.isContainsConfigurationProperty(name)) { value = eventSource.getConfigurationProperty(name); } else { value = eventSource.getSubscriptionManager().getPropertyValue(name); eventSource.getSubscriptionManager().getStaticSubscriptions(); for (Iterator<Subscription> iterator = staticSubscriptionList.iterator(); iterator.hasNext();) {
public void eventSourceRemoved(SynapseEventSource eventSource) { log.info("Event source : " + eventSource.getName() + " was removed " + "from the Synapse configuration successfully"); }