当前位置: 首页>>代码示例>>Java>>正文


Java EPStatementObjectModel.getAnnotations方法代码示例

本文整理汇总了Java中com.espertech.esper.client.soda.EPStatementObjectModel.getAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java EPStatementObjectModel.getAnnotations方法的具体用法?Java EPStatementObjectModel.getAnnotations怎么用?Java EPStatementObjectModel.getAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.espertech.esper.client.soda.EPStatementObjectModel的用法示例。


在下文中一共展示了EPStatementObjectModel.getAnnotations方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compile

import com.espertech.esper.client.soda.EPStatementObjectModel; //导入方法依赖的package包/类
void  compile(boolean checkSink) throws EPException{
	
	m_esperService = EPServiceProviderManager.getProvider(m_strName, getConfiguration().getEsperConfiguration());
	
	m_epAdmin = m_esperService.getEPAdministrator(); // 6908 fix - getAdmin caused recursion here
	
	for(Map.Entry<String, AnnotationConfiguration> annotConfig : getConfiguration().getAnnotationConfigMap().entrySet()){
		m_epAdmin.getConfiguration().addImport(annotConfig.getValue().getClassName());
	}
	m_epAdmin.getConfiguration().addImport(com.ebay.jetstream.epl.EPLUtilities.class);
	m_epAdmin.getConfiguration().addImport(com.ebay.jetstream.epl.EPLUtils.class);
	m_epAdmin.getConfiguration().addPlugInSingleRowFunction("toJson", "com.ebay.jetstream.epl.EPLUtils", "toJsonString");
	m_epAdmin.getConfiguration().addPlugInSingleRowFunction("fromJson", "com.ebay.jetstream.epl.EPLUtils", "fromJsonString");
	m_epAdmin.getConfiguration().addPlugInSingleRowFunction("generateEventId", "com.ebay.jetstream.epl.EPLUtils", "generateEventId");
	m_epAdmin.getConfiguration().addEventType("EsperStartup", Object.class);
	m_epAdmin.getConfiguration().addEventType("EsperEndEvent", Object.class);
	m_epAdmin.getConfiguration().addPlugInAggregationFunctionFactory("histogram", "com.ebay.jetstream.epl.HistogramAggregatorFactory");
	m_epAdmin.getConfiguration().addPlugInAggregationFunctionFactory("distinctcount", "com.ebay.jetstream.event.processor.esper.aggregates.CardinalityAggregatorFactory");
	m_epAdmin.getConfiguration().addPlugInAggregationFunctionFactory("percentile", "com.ebay.jetstream.event.processor.esper.aggregates.QuantileAggregatorFactory");
	m_epAdmin.getConfiguration().addPlugInAggregationFunctionFactory("topN", "com.ebay.jetstream.event.processor.esper.aggregates.TopKAggregatorFactory");
	
	
	m_suppliedEpl = m_suppliedEpl == null ? getEpl() : m_suppliedEpl;  
	
	for(String statement : m_suppliedEpl.getStatements()) {

		EPStatementObjectModel model = m_epAdmin.compileEPL(statement);
		
		List<AnnotationPart> annots = model.getAnnotations();
		if (getConfiguration().getAnnotationProcesssor() != null) {
			Map<String, List<AnnotationPart>> annotationPartsMapList = new HashMap<String, List<AnnotationPart>>();
			List<AnnotationPart> parts = null;
			for (AnnotationPart part : annots) {
				parts = annotationPartsMapList.get(part.getName());

				if (parts == null) {
					parts = new LinkedList<AnnotationPart>();
					annotationPartsMapList.put(part.getName(),
							parts);
				}
				parts.add(part);
			}
			EPStatement epStmt = null;
			if (annotationPartsMapList.size() == 0) {
				epStmt = m_epAdmin.create(model, null,
						new StatementAnnotationInfo());
			} else {
				StatementAnnotationInfo annotationInfo;
				try {
					annotationInfo = getConfiguration()
							.getAnnotationProcesssor()
							.getStatementAnnotationInfo(
									annots,
									statement,
									model,
									annotationPartsMapList,
									((EventSinkList) getEventSinks())
											.getSinks());
				} catch (Exception e) {
					throw new EPException("Exception from Annotation processing.." , e);
				}
				epStmt = m_epAdmin
						.create(model, null, annotationInfo);
				if(m_esperEventListener != null)
					epStmt.addListener(m_esperEventListener);
			}

		}
		
	}
	
}
 
开发者ID:pulsarIO,项目名称:jetstream-esper,代码行数:73,代码来源:EsperProcessor.java

示例2: EsperController

import com.espertech.esper.client.soda.EPStatementObjectModel; //导入方法依赖的package包/类
public EsperController(EPL eplStatements, EsperDeclaredEvents eventDefinition, String baseName,
        List<String> imports, EsperSessionizerCounter esperCounter, Set<String> sessionizerNames) {
    EPL epl = eplStatements;
    LOGGER.info("EPL Event definition {}", eventDefinition);

    Configuration config = createConfig(eventDefinition);
    config.getEngineDefaults().getExceptionHandling().addClass(SessionizerEsperExceptionHandlerFactory.class);
    String name = EsperController.class.getName() + "-" + baseName + "-" + Thread.currentThread().getId();
    esperService = EPServiceProviderManager.getProvider(name, config);
    if (imports != null) {
        for (String importName : imports) {
            esperService.getEPAdministrator().getConfiguration().addImport(importName);
        }
    }

    esperService.getEPAdministrator().getConfiguration().addImport(DebugSession.class);
    esperService.getEPAdministrator().getConfiguration().addImport(DecorateEvent.class);
    esperService.getEPAdministrator().getConfiguration()
    .addImport(com.ebay.pulsar.sessionizer.esper.annotation.Session.class);

    esperService.getEPAdministrator().getConfiguration().addImport(com.ebay.jetstream.epl.EPLUtilities.class);
    esperService.getEPAdministrator().getConfiguration().addImport(com.ebay.jetstream.epl.EPLUtils.class);
    esperService.getEPAdministrator().getConfiguration()
    .addPlugInSingleRowFunction("toJson", "com.ebay.jetstream.epl.EPLUtils", "toJsonString");
    esperService.getEPAdministrator().getConfiguration()
    .addPlugInSingleRowFunction("fromJson", "com.ebay.jetstream.epl.EPLUtils", "fromJsonString");

    eventListener = new DecorateEventListener();

    for (String s : epl.getStatements()) {
        EPStatement statement = esperService.getEPAdministrator().createEPL(s);
        EPStatementObjectModel model = esperService.getEPAdministrator().compileEPL(s);
        List<AnnotationPart> annots = model.getAnnotations();
        for (AnnotationPart part : annots) {
            if (DebugSession.class.getSimpleName().equals(part.getName())) {
                String prefix = (String) getAnnotationValue(part, "counter");
                String field = (String) getAnnotationValue(part, "colname");
                Boolean auditValue = (Boolean) getAnnotationValue(part, "audit");
                if (auditValue == null) {
                    auditValue = Boolean.FALSE;
                }
                statement.addListener(new SessionizerCounterListener(prefix, field, auditValue, esperCounter));
            }
            if (DecorateEvent.class.getSimpleName().equals(part.getName())) {
                statement.addListener(eventListener);
            }
            if (com.ebay.pulsar.sessionizer.esper.annotation.Session.class.getSimpleName().equals(part.getName())) {
                String sessionizerName = (String) part.getAttributes().get(0).getValue();
                if (!sessionizerNames.contains(sessionizerName)) {
                    throw new IllegalArgumentException("The sessionizer referenced by EPL " + sessionizerName
                            + " not configured.");
                }
                statement.addListener(new SessionizerListener(sessionizerName, sessionizationMap));
            }
        }
    }

}
 
开发者ID:pulsarIO,项目名称:realtime-analytics,代码行数:59,代码来源:EsperController.java

示例3: processAnnotations

import com.espertech.esper.client.soda.EPStatementObjectModel; //导入方法依赖的package包/类
private void processAnnotations(EsperSessionizerCounter esperCounter, boolean isMainSessionizer,
        Set<String> subSessionNames, List<SessionizerExtension> extensions, EPL epl) {
    for (String s : epl.getStatements()) {
        EPStatement statement = esperService.getEPAdministrator().createEPL(s);
        EPStatementObjectModel model = esperService.getEPAdministrator().compileEPL(s);
        List<AnnotationPart> annots = model.getAnnotations();
        for (AnnotationPart part : annots) {
            if (isMainSessionizer && com.ebay.pulsar.sessionizer.esper.annotation.SubSession.class.getSimpleName().equals(part.getName())) {
                String sessionizerName = (String) part.getAttributes().get(0).getValue();
                if (!subSessionNames.contains(sessionizerName)) {
                    throw new IllegalArgumentException("The sub sessionizer referenced by EPL " + sessionizerName + " not configured.");
                }
                statement.addListener(new SubSessionizerListener(sessionizerName, context));
            }
            if (isMainSessionizer && UpdateDuration.class.getSimpleName().equals(part.getName())) {
                statement.addListener(new UpdateTTLListener(context, maxTTL));
            }
            if (DecorateEvent.class.getSimpleName().equals(part.getName())) {
                statement.addListener(new DecorateEventListener(context));
            }
            if (AppendState.class.getSimpleName().equals(part.getName())) {
                statement.addListener(new AppendStateListener(context, (String) getAnnotationValue(part, "name", null),
                        (String) getAnnotationValue(part, "colname", null),
                        (Boolean) getAnnotationValue(part, "unique", true),
                        (Integer) getAnnotationValue(part, "maxlength", 0)));
            }
            if (UpdateState.class.getSimpleName().equals(part.getName())) {
                statement.addListener(new SessionStateListener(context));
            }
            if (UpdateMetadata.class.getSimpleName().equals(part.getName())) {
                statement.addListener(new SessionMetadataListener(context));
            }
            if (UpdateCounter.class.getSimpleName().equals(part.getName())) {
                statement.addListener(new SessionCounterListener((String) part.getAttributes().get(0).getValue(), context));
            }
            if (DebugSession.class.getSimpleName().equals(part.getName())) {
                String prefix = (String) getAnnotationValue(part, "counter", null);
                String field = (String) getAnnotationValue(part, "colname", null);
                Boolean auditValue = (Boolean) getAnnotationValue(part, "audit", false);
                statement.addListener(new SessionizerCounterListener(prefix, field, auditValue, esperCounter));
            }
            if (extensions != null) {
                for (SessionizerExtension ext : extensions) {
                    if (ext.getAnnotation().getSimpleName().equals(part.getName())) {
                        statement.addListener(ext.createUpdateListener(context, part, model));
                    }
                }
            }
        }
    }
}
 
开发者ID:pulsarIO,项目名称:realtime-analytics,代码行数:52,代码来源:EsperSessionizer.java

示例4: handleDeployRule

import com.espertech.esper.client.soda.EPStatementObjectModel; //导入方法依赖的package包/类
protected void handleDeployRule(String strategyName, String moduleName, String ruleName, Integer targetId) throws Exception {

		EPAdministrator administrator = getServiceProvider(strategyName).getEPAdministrator();

		// do nothing if the statement already exists
		EPStatement oldStatement = administrator.getStatement(ruleName);
		if (oldStatement != null && oldStatement.isStarted()) {
			return;
		}

		// read the statement from the module
		EPDeploymentAdmin deployAdmin = administrator.getDeploymentAdmin();
		Module module = deployAdmin.read("module-" + moduleName + ".epl");
		List<ModuleItem> items = module.getItems();

		// go through all statements in the module
		EPStatement newStatement = null;
		items: for (ModuleItem item : items) {
			String exp = item.getExpression();

			// get the ObjectModel for the statement
			EPStatementObjectModel model;
			EPPreparedStatementImpl prepared = null;
			if (exp.contains("?")) {
				prepared = (EPPreparedStatementImpl) administrator.prepareEPL(exp);
				model = prepared.getModel();
			} else {
				model = administrator.compileEPL(exp);
			}

			// go through all annotations and check if the statement has the 'name' 'ruleName'
			List<AnnotationPart> annotationParts = model.getAnnotations();
			for (AnnotationPart annotationPart : annotationParts) {
				if (annotationPart.getName().equals("Name")) {
					for (AnnotationAttribute attribute : annotationPart.getAttributes()) {
						if (attribute.getValue().equals(ruleName)) {

							// create the statement
							newStatement = administrator.createEPL(model.toEPL());

							// check if the statement is elgible, other destory it righ away
							processAnnotations(strategyName, newStatement);

							// break iterating over the statements
							break items;
						}
					}
				}
			}
		}

		if (newStatement == null) {
			logger.warn("statement " + ruleName + " was not found");
		} else {
			logger.debug("deployed rule " + newStatement.getName() + " on service provider: " + strategyName);
		}
	}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:58,代码来源:RuleServiceImpl.java


注:本文中的com.espertech.esper.client.soda.EPStatementObjectModel.getAnnotations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。