use of org.wso2.siddhi.core.query.processor.Processor in project carbon-apimgt by wso2.
the class WSDLProcessFactory method getWSDLProcessor.
/**
* Returns the appropriate WSDL 1.1 or 2.0 processor based on the content {@code wsdlContent}.
*
* @param wsdlContent Content of the WSDL
* @return WSDL 1.1 or 2.0 processor for the provided content
* @throws APIMgtWSDLException If an error occurs while determining the processor
*/
public WSDLProcessor getWSDLProcessor(byte[] wsdlContent) throws APIMgtWSDLException {
for (String clazz : getWSDLProcessorClasses()) {
WSDLProcessor processor;
try {
processor = (WSDLProcessor) Class.forName(clazz).newInstance();
boolean canProcess = processor.init(wsdlContent);
if (canProcess) {
return processor;
}
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new APIMgtWSDLException("Error while instantiating " + clazz, e, ExceptionCodes.INTERNAL_WSDL_EXCEPTION);
}
}
// no processors found if this line reaches
throw new APIMgtWSDLException("No WSDL processor found to process WSDL content", ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT);
}
use of org.wso2.siddhi.core.query.processor.Processor in project carbon-apimgt by wso2.
the class WSDLProcessFactory method getWSDLProcessorForPath.
/**
* Returns the appropriate WSDL 1.1 or 2.0 processor based on the file path {@code wsdlPath}.
*
* @param wsdlPath File path containing WSDL files and dependant files
* @return WSDL 1.1 or 2.0 processor for the provided content
* @throws APIMgtWSDLException If an error occurs while determining the processor
*/
public WSDLProcessor getWSDLProcessorForPath(String wsdlPath) throws APIMgtWSDLException {
for (String clazz : getWSDLProcessorClasses()) {
WSDLProcessor processor;
try {
processor = (WSDLProcessor) Class.forName(clazz).newInstance();
boolean canProcess = processor.initPath(wsdlPath);
if (canProcess) {
return processor;
}
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new APIMgtWSDLException("Error while instantiating " + clazz, e, ExceptionCodes.INTERNAL_WSDL_EXCEPTION);
}
}
// no processors found if this line reaches
throw new APIMgtWSDLException("No WSDL processor found to process WSDL content", ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT);
}
use of org.wso2.siddhi.core.query.processor.Processor in project carbon-apimgt by wso2.
the class WSDLProcessFactoryTestcase method testGetWSDLProcessorForContent.
@Test
public void testGetWSDLProcessorForContent() throws Exception {
byte[] wsdl11Content = SampleTestObjectCreator.createDefaultWSDL11Content();
WSDLProcessor processor = WSDLProcessFactory.getInstance().getWSDLProcessor(wsdl11Content);
Assert.assertTrue(processor instanceof WSDL11ProcessorImpl);
byte[] wsdl20Content = SampleTestObjectCreator.createDefaultWSDL20Content();
processor = WSDLProcessFactory.getInstance().getWSDLProcessor(wsdl20Content);
Assert.assertTrue(processor instanceof WSDL20ProcessorImpl);
}
use of org.wso2.siddhi.core.query.processor.Processor in project carbon-apimgt by wso2.
the class WSDLProcessFactoryTestcase method testGetWSDLProcessorForPath.
@Test
public void testGetWSDLProcessorForPath() throws Exception {
String extractedLocation = SampleTestObjectCreator.createDefaultWSDL11Archive();
WSDLProcessor processor = WSDLProcessFactory.getInstance().getWSDLProcessorForPath(extractedLocation);
Assert.assertTrue(processor instanceof WSDL11ProcessorImpl);
extractedLocation = SampleTestObjectCreator.createDefaultWSDL20Archive();
processor = WSDLProcessFactory.getInstance().getWSDLProcessorForPath(extractedLocation);
Assert.assertTrue(processor instanceof WSDL20ProcessorImpl);
}
use of org.wso2.siddhi.core.query.processor.Processor in project carbon-apimgt by wso2.
the class ThrottleStreamProcessor method process.
@Override
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner, ComplexEventPopulater complexEventPopulater) {
synchronized (this) {
if (expireEventTime == -1) {
long currentTime = siddhiAppContext.getTimestampGenerator().currentTime();
if (startTime != -1) {
expireEventTime = addTimeShift(currentTime);
} else {
expireEventTime = siddhiAppContext.getTimestampGenerator().currentTime() + timeInMilliSeconds;
}
if (scheduler != null) {
scheduler.notifyAt(expireEventTime);
} else {
log.error("scheduler is not initiated");
}
}
long currentTime = siddhiAppContext.getTimestampGenerator().currentTime();
boolean sendEvents;
if (currentTime >= expireEventTime) {
expireEventTime += timeInMilliSeconds;
if (scheduler != null) {
scheduler.notifyAt(expireEventTime);
} else {
log.error("scheduler is not initiated");
}
sendEvents = true;
} else {
sendEvents = false;
}
while (streamEventChunk.hasNext()) {
StreamEvent streamEvent = streamEventChunk.next();
if (streamEvent.getType() != ComplexEvent.Type.CURRENT) {
continue;
}
complexEventPopulater.populateComplexEvent(streamEvent, new Object[] { expireEventTime });
StreamEvent clonedStreamEvent = streamEventCloner.copyStreamEvent(streamEvent);
clonedStreamEvent.setType(StreamEvent.Type.EXPIRED);
clonedStreamEvent.setTimestamp(expireEventTime);
expiredEventChunk.add(clonedStreamEvent);
}
if (sendEvents) {
expiredEventChunk.reset();
if (expiredEventChunk.getFirst() != null) {
streamEventChunk.add(expiredEventChunk.getFirst());
}
expiredEventChunk.clear();
}
}
if (streamEventChunk.getFirst() != null) {
streamEventChunk.setBatch(true);
nextProcessor.process(streamEventChunk);
streamEventChunk.setBatch(false);
}
}
Aggregations