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


Java Argument类代码示例

本文整理汇总了Java中org.opennms.core.utils.Argument的典型用法代码示例。如果您正苦于以下问题:Java Argument类的具体用法?Java Argument怎么用?Java Argument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testCreateTicket

import org.opennms.core.utils.Argument; //导入依赖的package包/类
public void testCreateTicket() {
    // Setup the event anticipator
	EventBuilder newSuspectBuilder = new EventBuilder(EventConstants.TROUBLETICKET_CREATE_UEI, m_ticketNotificationStrategy.getName());
    newSuspectBuilder.setParam(EventConstants.PARM_ALARM_ID, "1");
    newSuspectBuilder.setParam(EventConstants.PARM_ALARM_UEI, EventConstants.NODE_DOWN_EVENT_UEI);
    newSuspectBuilder.setParam(EventConstants.PARM_USER, "admin");
    m_anticipator.anticipateEvent(newSuspectBuilder.getEvent());
    
    m_ticketNotificationStrategy.setAlarmState(new TicketNotificationStrategy.AlarmState(1));
    m_ticketNotificationStrategy.setAlarmType(AlarmType.PROBLEM);
    List<Argument> arguments = buildArguments("1", EventConstants.NODE_DOWN_EVENT_UEI);
    
    assertEquals(0, m_ticketNotificationStrategy.send(arguments));
 assertTrue("Expected events not forthcoming", m_anticipator.waitForAnticipated(0).isEmpty());
 assertEquals("Received unexpected events", 0, m_anticipator.unanticipatedEvents().size());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:17,代码来源:TicketNotificationStrategyTest.java

示例2: send

import org.opennms.core.utils.Argument; //导入依赖的package包/类
/** {@inheritDoc} */
public int send(List<Argument> arguments) {
    Twitter svc = buildUblogService(arguments);
    String messageBody = buildMessageBody(arguments);
    Status response;
    
    if (log().isDebugEnabled()) {
        log().debug("Dispatching microblog notification for user '" + svc.getUserId() + "' at base URL '" + svc.getBaseURL() + "' with message '" + messageBody + "'");
    }
    try {
        response = svc.updateStatus(messageBody);
    } catch (TwitterException e) {
        log().error("Microblog notification failed");
        log().info("Failed to update status for user '" + svc.getUserId() + "' at service URL '" + svc.getBaseURL() + "', caught exception: " + e.getMessage());
        return 1;
    }
    
    log().info("Microblog notification succeeded: update posted with ID " + response.getId());
    return 0;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:21,代码来源:MicroblogNotificationStrategy.java

示例3: buildMessageBody

import org.opennms.core.utils.Argument; //导入依赖的package包/类
/**
 * <p>buildMessageBody</p>
 *
 * @param arguments a {@link java.util.List} object.
 * @return a {@link java.lang.String} object.
 */
protected String buildMessageBody(List<Argument> arguments) {
    String messageBody = null;
    
    // Support PARAM_TEXT_MSG and PARAM_NUM_MSG but prefer PARAM_TEXT_MSG
    for (Argument arg : arguments) {
        if (NotificationManager.PARAM_TEXT_MSG.equals(arg.getSwitch())) {
            messageBody = arg.getValue();
        } else if (NotificationManager.PARAM_NUM_MSG.equals(arg.getSwitch())) {
            if (messageBody == null) messageBody = arg.getValue();
        }
    }
    
    if (messageBody == null) {
        // FIXME We should have a better Exception to use here for configuration problems
        throw new IllegalArgumentException("No message specified, but is required");
    }
    
    // Collapse whitespace in final message
    messageBody = messageBody.replaceAll("\\s+", " ");
    if (log().isDebugEnabled()) {
        log().debug("Final message body after collapsing whitespace is: '" + messageBody + "'");
    }

    return messageBody;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:32,代码来源:MicroblogNotificationStrategy.java

示例4: execute

import org.opennms.core.utils.Argument; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * This method calls the send method of the specified class in
 */
public int execute(String className, List<Argument> arguments) {
    log().debug("Going for the class instance: " + className);
    NotificationStrategy ns;
    try {
        ns = (NotificationStrategy) Class.forName(className).newInstance();
        log().debug(className + " class created: " + ns.getClass());
    } catch (Throwable e) {
        log().error("Execption creating notification strategy class: " + className, e);
        return 1;
    }

    try {
        return ns.send(arguments);
    } catch (Throwable t) {
        log().error("Throwable received while sending message: " + t, t);
        return 1;
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:24,代码来源:ClassExecutor.java

示例5: parseArguments

import org.opennms.core.utils.Argument; //导入依赖的package包/类
private void parseArguments(List arguments) {
	// Setup defaults
	recipient = "0000001";
	subject = "OpenNMS Alert";
	message = "No message specified";

	Argument[] argArray = (Argument[]) arguments.toArray(new Argument[0]);
	for (int i = 0; i < argArray.length; i++) {
		System.out.println("Argument["+i+"]="+argArray[i].getSwitch()+":"+argArray[i].getValue());
		String name = argArray[i].getSwitch();
		
		if (name.equals("-tm")) {
			message = argArray[i].getValue();
		} else if (name.equals("eventid")) {
			eventID = argArray[i].getValue();
		} else if (name.equals("-subject")) {
			subject = argArray[i].getValue();
		}
	}
}
 
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:21,代码来源:ReliableResponseNotificationStrategy.java

示例6: testNoticeWithNoAlarmID

import org.opennms.core.utils.Argument; //导入依赖的package包/类
public void testNoticeWithNoAlarmID() {
	m_ticketNotificationStrategy.setAlarmState(new TicketNotificationStrategy.AlarmState(0));
	m_ticketNotificationStrategy.setAlarmType(AlarmType.NOT_AN_ALARM);
	List<Argument> arguments = buildArguments("1", EventConstants.NODE_DOWN_EVENT_UEI);
	assertEquals("Strategy should fail silently if the event has no alarm id.", 0, m_ticketNotificationStrategy.send(arguments));
	assertTrue("Strategy should log a warning if the event has no alarm id.", !MockLogAppender.noWarningsOrHigherLogged());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:8,代码来源:TicketNotificationStrategyTest.java

示例7: buildArguments

import org.opennms.core.utils.Argument; //导入依赖的package包/类
protected List<Argument> buildArguments(String eventID, String eventUEI) 
  {
List<Argument> arguments = new ArrayList<Argument>();
arguments.add(new Argument("eventID", null, eventID, false));
arguments.add(new Argument("eventUEI", null, eventUEI, false));
return arguments;
  }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:8,代码来源:TicketNotificationStrategyTest.java

示例8: send

import org.opennms.core.utils.Argument; //导入依赖的package包/类
/** {@inheritDoc} */
public int send(List<Argument> arguments) {
    if (log().isDebugEnabled()) {
        log().debug("In the " + getClass() + " class");
    }
    
    try {
        AsteriskOriginator originator = buildOriginator(arguments);
        originator.originateCall();
    } catch (AsteriskOriginatorException aoe) {
        log().error("Error originating call for notification.", aoe);
        return 1;
    }
    return 0;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:16,代码来源:AsteriskOriginateNotificationStrategy.java

示例9: send

import org.opennms.core.utils.Argument; //导入依赖的package包/类
public int send(List<Argument> arguments) {
    MockUtil.println("Message sent with arguments:"+arguments);
    
    MockNotification notification = new MockNotification();
    Iterator<Argument> it = arguments.iterator();
    while (it.hasNext()) {
        Argument arg = it.next();
        if (arg.getSwitch().equals(NotificationManager.PARAM_SUBJECT)) {
            notification.setSubject(arg.getValue());
        } else if (arg.getSwitch().equals(NotificationManager.PARAM_EMAIL)) {
            notification.setEmail(arg.getValue());
        } else if (arg.getSwitch().equals(NotificationManager.PARAM_TEXT_MSG)) {
notification.setTextMsg(arg.getValue());
        }
    }
    notification.setExpectedTime(System.currentTimeMillis());

    NotificationAnticipator anticipator = getAnticipator();
    
    if (anticipator != null) {
        anticipator.notificationReceived(notification);
    } else {
        throw new NullPointerException("anticipator is null");
    }

    return 0;
    
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:MockNotificationStrategy.java

示例10: send

import org.opennms.core.utils.Argument; //导入依赖的package包/类
/** {@inheritDoc} */
public int send(List<Argument> arguments) {
    try {
        String message = buildMessage(arguments);
        Socket s = new Socket(getRemoteAddr(), getRemotePort());
        PrintStream stream = new PrintStream(s.getOutputStream());
        stream.println(message);
        stream.close();
    } catch (Throwable e) {
        log().error("send: Error sending IRCcat notification: " + e, e);
        return 1;
    }
    return 0;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:15,代码来源:IrcCatNotificationStrategy.java

示例11: buildMessage

import org.opennms.core.utils.Argument; //导入依赖的package包/类
private String buildMessage(List<Argument> arguments) {
    String recipient = null;
    String message = null;
    
    for (Argument arg : arguments) {
        if (NotificationManager.PARAM_EMAIL.equals(arg.getSwitch())) {
            recipient = arg.getValue();
        } else if (NotificationManager.PARAM_TEXT_MSG.equals(arg.getSwitch())) {
            message = arg.getValue();
        } else if (NotificationManager.PARAM_NUM_MSG.equals(arg.getSwitch())) {
            message = arg.getValue();
        } else {
            throw new IllegalArgumentException("Unsupported notification argument switch '" + arg.getSwitch() + "'");
        }
    }
    
    if (recipient == null) {
        // FIXME We should have a better Exception to use here for configuration problems
        throw new IllegalArgumentException("no recipient specified, but is required");
    }
    if (message == null) {
        // FIXME We should have a better Exception to use here for configuration problems
        throw new IllegalArgumentException("no message specified, but is required");
    }

    return recipient + " " + message;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:28,代码来源:IrcCatNotificationStrategy.java

示例12: getSwitchValue

import org.opennms.core.utils.Argument; //导入依赖的package包/类
@SuppressWarnings("unused")
private String getSwitchValue(String argSwitch) {
    String value = null;
    for (Argument arg : m_arguments) {
        if (arg.getSwitch().equals(argSwitch)) {
            value = arg.getValue();
        }
    }
    if (value != null && value.equals("")) value = null;

    return value;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:13,代码来源:BSFNotificationStrategy.java

示例13: getSwitchSubstitution

import org.opennms.core.utils.Argument; //导入依赖的package包/类
private String getSwitchSubstitution(String argSwitch) {
    String value = null;
    for (Argument arg : m_arguments) {
        if (arg.getSwitch().equals(argSwitch)) {
            value = arg.getSubstitution();
        }
    }
    if (value != null && value.equals("")) value = null;

    return value;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:12,代码来源:BSFNotificationStrategy.java

示例14: buildUblogService

import org.opennms.core.utils.Argument; //导入依赖的package包/类
/**
 * <p>buildUblogService</p>
 *
 * @param arguments a {@link java.util.List} object.
 * @return a {@link twitter4j.Twitter} object.
 */
protected Twitter buildUblogService(List<Argument> arguments) {
    MicroblogProfile profile = null;
    String serviceUrl = "";
    String authenUser = "";
    String authenPass = "";
    
    // First try to get a microblog profile called "notifd", falling back to the default if that fails
    profile = m_microblogConfigurationDao.getProfile("notifd");
    if (profile == null)
        profile = m_microblogConfigurationDao.getDefaultProfile();

    if (profile == null) {
        log().fatal("Unable to find a microblog profile called '" + UBLOG_PROFILE_NAME + "', and default profile does not exist; we cannot send microblog notifications!");
        throw new RuntimeException("Could not find a usable microblog profile.");
    }
    
    log().info("Using microblog profile with name '" + profile.getName() + "'");
    
    serviceUrl = profile.getServiceUrl();
    authenUser = profile.getAuthenUsername();
    authenPass = profile.getAuthenPassword();

    if (authenUser == null || "".equals(authenUser))
        log().warn("Working with a blank username, perhaps you forgot to set this in the microblog configuration?");
    if (authenPass == null || "".equals(authenPass))
        log().warn("Working with a blank password, perhaps you forgot to set this in the microblog configuration?");
    if (serviceUrl == null || "".equals(serviceUrl))
        throw new IllegalArgumentException("Cannot use a blank microblog service URL, perhaps you forgot to set this in the microblog configuration?");
    
    Twitter svc = new Twitter();
    svc.setBaseURL(serviceUrl);
    svc.setSource("OpenNMS");
    svc.setUserId(authenUser);
    svc.setPassword(authenPass);
    return svc;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:43,代码来源:MicroblogNotificationStrategy.java

示例15: findDestName

import org.opennms.core.utils.Argument; //导入依赖的package包/类
/**
 * <p>findDestName</p>
 *
 * @param arguments a {@link java.util.List} object.
 * @return a {@link java.lang.String} object.
 */
protected String findDestName(List<Argument> arguments) {
    for (Argument arg : arguments) {
        if (NotificationManager.PARAM_MICROBLOG_USERNAME.equals(arg.getSwitch())) {
            log().debug("Found destination microblog name: " + arg.getSwitch());
            return arg.getValue();
        }
    }
    log().debug("No destination microblog name found");
    return null;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:17,代码来源:MicroblogNotificationStrategy.java


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