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


Java Type类代码示例

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


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

示例1: processPacket

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
public void processPacket(Packet p) {
    if (!(p instanceof IQ)) {
        return;
    }
    final IQ packet = (IQ) p;

    if (packet.getType().equals(IQ.Type.error) || packet.getType().equals(IQ.Type.result)) {
        return;
    }

    // Packet p is an IQ stanza of type GET or SET. Therefor, it _must_ be
    // replied to.
    final IQ replyPacket = handleIQRequest(packet);

    try {
        componentManager.sendPacket(this, replyPacket);
    } catch (ComponentException e) {
        Log.error(e.getMessage(), e);
    }

}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:SearchPlugin.java

示例2: handleDiscoInfo

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * Creates a response specific to the search plugin to Disco#Info requests.
 * 
 * @param iq
 *            The IQ stanza that contains the request.
 * @return An IQ stanza, formulated as an answer to the received request.
 */
private static IQ handleDiscoInfo(IQ iq) {
    if (iq == null) {
        throw new IllegalArgumentException("Argument 'iq' cannot be null.");
    }

    if (!iq.getChildElement().getNamespaceURI().equals(IQDiscoInfoHandler.NAMESPACE_DISCO_INFO) || iq.getType() != Type.get) {
        throw new IllegalArgumentException("This is not a valid disco#info request.");
    }

    final IQ replyPacket = IQ.createResultIQ(iq);

    final Element responseElement = replyPacket.setChildElement("query", IQDiscoInfoHandler.NAMESPACE_DISCO_INFO);
    responseElement.addElement("identity").addAttribute("category", "directory").addAttribute("type", "user")
            .addAttribute("name", "User Search");
    responseElement.addElement("feature").addAttribute("var", NAMESPACE_JABBER_IQ_SEARCH);
    responseElement.addElement("feature").addAttribute("var", IQDiscoInfoHandler.NAMESPACE_DISCO_INFO);
    responseElement.addElement("feature").addAttribute("var", ResultSet.NAMESPACE_RESULT_SET_MANAGEMENT);

    return replyPacket;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:28,代码来源:SearchPlugin.java

示例3: processPacket

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
public void processPacket(Packet p) {
    if (!(p instanceof IQ)) {
        return;
    }
    final IQ packet = (IQ) p;

    if (packet.getType().equals(IQ.Type.error)
            || packet.getType().equals(IQ.Type.result)) {
        return;
    }

    // Packet p is an IQ stanza of type GET or SET. Therefor, it _must_ be
    // replied to.
    final IQ replyPacket = handleIQRequest(packet);

    try {
        componentManager.sendPacket(this, replyPacket);
    } catch (ComponentException e) {
        Log.error(e.getMessage(), e);
    }

}
 
开发者ID:coodeer,项目名称:g3server,代码行数:23,代码来源:SearchPlugin.java

示例4: processPacket

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
public void processPacket(Packet p) {
	if (!(p instanceof IQ)) {
		return;
	}
	final IQ packet = (IQ) p;

	if (packet.getType().equals(IQ.Type.error) || packet.getType().equals(IQ.Type.result)) {
		return;
	}

	// Packet p is an IQ stanza of type GET or SET. Therefor, it _must_ be
	// replied to.
	final IQ replyPacket = handleIQRequest(packet);

	try {
		componentManager.sendPacket(this, replyPacket);
	} catch (ComponentException e) {
		Log.error(e.getMessage(), e);
	}

}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:22,代码来源:SearchPlugin.java

示例5: handleDiscoInfo

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * Creates a response specific to the search plugin to Disco#Info requests.
 * 
 * @param iq
 *            The IQ stanza that contains the request.
 * @return An IQ stanza, formulated as an answer to the received request.
 */
private static IQ handleDiscoInfo(IQ iq) {
	if (iq == null) {
		throw new IllegalArgumentException("Argument 'iq' cannot be null.");
	}

	if (!iq.getChildElement().getNamespaceURI().equals(IQDiscoInfoHandler.NAMESPACE_DISCO_INFO) || iq.getType() != Type.get) {
		throw new IllegalArgumentException("This is not a valid disco#info request.");
	}

	final IQ replyPacket = IQ.createResultIQ(iq);

	final Element responseElement = replyPacket.setChildElement("query", IQDiscoInfoHandler.NAMESPACE_DISCO_INFO);
	responseElement.addElement("identity").addAttribute("category", "directory").addAttribute("type", "user")
			.addAttribute("name", "User Search");
	responseElement.addElement("feature").addAttribute("var", NAMESPACE_JABBER_IQ_SEARCH);
	responseElement.addElement("feature").addAttribute("var", IQDiscoInfoHandler.NAMESPACE_DISCO_INFO);
	responseElement.addElement("feature").addAttribute("var", ResultSet.NAMESPACE_RESULT_SET_MANAGEMENT);

	return replyPacket;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:28,代码来源:SearchPlugin.java

示例6: consumesOnDifferentThreadTest

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * The actual work being done by the component (the consumer) should be done
 * by a different thread than the thread that feeds the input (the
 * producer).
 * 
 * This test uses an AbstractComponent implementation that reports the
 * thread name that was used during processing. This name is compared with
 * the name of the thread that feeds the component the request packet (the
 * producer) to verify that the producer and consumer threads are indeed
 * different.
 */
@Test
public void consumesOnDifferentThreadTest() throws Exception {
	// setup
	final String producerThreadName = Thread.currentThread().getName();
	final IQ request = new IQ(Type.get);
	request.setChildElement(
			SlowRespondingThreadNameComponent.ELEMENTNAME_THREADNAME,
			SlowRespondingThreadNameComponent.DEBUG_NAMESPACE);

	// do magic
	debugComp.processPacket(request);
	final IQ response = (IQ) debugComp.getSentPacket();

	// verify
	final Element elem = response.getChildElement();
	final String consumerThreadName = elem.getText();
	assertFalse(consumerThreadName.equals(producerThreadName));
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:30,代码来源:AbstractComponentIsConsumerTest.java

示例7: consumesAsynchronouslyTest

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * The producer thread should be released as soon as it delivers work to the
 * consumer, regardless of how long the consumer takes to process a packet.
 * 
 * This test uses an AbstractComponent implementation that takes a
 * significant time to process a packet. The test verifies that the producer
 * thread finishes work before the consumer threads finish. This verifies
 * that the workload has been properly offloaded by the producer thread.
 */
@Test
public void consumesAsynchronouslyTest() throws Exception {
	// setup
	final IQ request = new IQ(Type.get);
	request.setChildElement(
			SlowRespondingThreadNameComponent.ELEMENTNAME_SLOWRESPONSE,
			SlowRespondingThreadNameComponent.DEBUG_NAMESPACE);

	// do magic
	final long start = System.currentTimeMillis();
	debugComp.processPacket(request);
	final long end = System.currentTimeMillis();

	// verify
	final long elapsed = end - start;
	assertTrue(elapsed < 4000);
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:27,代码来源:AbstractComponentIsConsumerTest.java

示例8: testXmppPing

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * This test verifies that the abstract component responds to XMPP Ping
 * requests correctly.
 * 
 * @see <a
 *      href="http://www.igniterealtime.org/issues/browse/TINDER-20">Tinder&nbsp;bugtracker:&nbsp;TINDER-20</a>
 */
@Test
public void testXmppPing() throws Exception {
	// setup
	final DummyAbstractComponent component = new DummyAbstractComponent();
	component.initialize(new JID("sub.domain"), null);

	final IQ pingRequest = new IQ(Type.get);
	pingRequest.setChildElement("ping",
			AbstractComponent.NAMESPACE_XMPP_PING);
	pingRequest.setFrom("from.address");
	pingRequest.setTo(component.jid);

	// do magic
	component.start();
	component.processPacket(pingRequest);

	// verify
	final IQ result = (IQ) component.getSentPacket();
	assertNotNull(result);
	assertEquals(Type.result, result.getType());
	assertEquals(pingRequest.getID(), result.getID());
	assertEquals(pingRequest.getFrom(), result.getTo());
	assertEquals(pingRequest.getTo(), result.getFrom());
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:32,代码来源:AbstractComponentTest.java

示例9: testIsRestartable

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * Every component should be functional after it has been shutdown and
 * restarted.
 * 
 * This test creates a component, starts, stops and restarts it, and
 * verifies that it then responds to XMPP Ping requests.
 * 
 * @see <a
 *      href="http://www.igniterealtime.org/issues/browse/TINDER-31">Tinder&nbsp;bugtracker:&nbsp;TINDER-31</a>
 */
@Test
public void testIsRestartable() throws Exception {
	// setup
	final DummyAbstractComponent component = new DummyAbstractComponent();
	component.initialize(new JID("sub.domain"), null);

	final IQ pingRequest = new IQ(Type.get);
	pingRequest.setChildElement("ping",
			AbstractComponent.NAMESPACE_XMPP_PING);
	pingRequest.setFrom("from.address");
	pingRequest.setTo(component.jid);

	// do magic
	component.start();
	component.shutdown();
	component.start();
	component.processPacket(pingRequest);

	// verify
	final IQ result = (IQ) component.getSentPacket();
	assertNotNull(result);
	assertEquals(Type.result, result.getType());
	assertEquals(pingRequest.getID(), result.getID());
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:35,代码来源:AbstractComponentTest.java

示例10: testLastActivity

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * This test verifies that the abstract component responds to XMPP Last Activity
 * requests correctly.
 * 
 * @see <a
 *      href="http://www.igniterealtime.org/issues/browse/TINDER-38">Tinder&nbsp;bugtracker:&nbsp;TINDER-38</a>
 */
@Test
public void testLastActivity() throws Exception {
	// setup
	final DummyAbstractComponent component = new DummyAbstractComponent();
	component.initialize(new JID("sub.domain"), null);

	final IQ request = new IQ(Type.get);
	request.setChildElement("ping",
			AbstractComponent.NAMESPACE_LAST_ACTIVITY);
	request.setFrom("from.address");
	request.setTo(component.jid);
	final int wait = 2;
	
	// do magic
	component.start();
	Thread.sleep(wait*1000);
	component.processPacket(request);

	// verify
	final IQ result = (IQ) component.getSentPacket();
	assertNotNull(result);
	assertEquals(Type.result, result.getType());
	assertEquals(String.valueOf(wait), result.getChildElement().attributeValue("seconds"));
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:32,代码来源:AbstractComponentTest.java

示例11: testEntityTime

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * This test verifies that the abstract component responds to XMPP Entity Time requests.
 */
@Test
public void testEntityTime() throws Exception {
	// setup
	final DummyAbstractComponent component = new DummyAbstractComponent();
	component.initialize(new JID("sub.domain"), null);

	final IQ request = new IQ(Type.get);
	request.setChildElement("ping",
			AbstractComponent.NAMESPACE_ENTITY_TIME);
	request.setFrom("from.address");
	request.setTo(component.jid);

	
	// do magic
	component.start();
	component.processPacket(request);
	
	// verify
	final IQ result = (IQ) component.getSentPacket();
	assertNotNull(result);
	assertEquals(Type.result, result.getType());
	// TODO although this test verifies that a result is produced, it also needs to verify the correctness of the content of the result.
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:27,代码来源:AbstractComponentTest.java

示例12: testSimpleResponse

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * A normal response is expected if an IQ request is sent that is processed
 * by the component.
 */
@Test
public void testSimpleResponse() throws Exception {
	// setup
	final DummyAbstractComponent component = new DummyAbstractComponent();
	final IQ pingRequest = new IQ(Type.get);
	pingRequest.setChildElement("ping",
			AbstractComponent.NAMESPACE_XMPP_PING);
	pingRequest.setFrom("from.address");
	pingRequest.setTo("to.address");

	// do magic
	component.start();
	component.processPacket(pingRequest);

	// verify
	final IQ result = (IQ) component.getSentPacket();
	assertNotNull(result);
	assertTrue(result.isResponse());
	assertEquals(pingRequest.getID(), result.getID());
	assertEquals(pingRequest.getFrom(), result.getTo());
	assertEquals(pingRequest.getTo(), result.getFrom());
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:27,代码来源:AbstractComponentRespondsToIQRequestsTest.java

示例13: testNoImplementation

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * If no implementation is provided for a particular IQ request, a response (an error) should be returned.
 */
@Test
public void testNoImplementation() throws Exception
{
	// setup
	final DummyAbstractComponent component = new DummyAbstractComponent();
	final IQ request = new IQ(Type.set);
	request.setChildElement("junit", "test");
	request.setFrom("from.address");
	request.setTo("to.address");

	// do magic
	component.start();
	component.processPacket(request);

	// verify
	final IQ result = (IQ) component.getSentPacket();
	assertNotNull(result);
	assertTrue(result.isResponse());
	assertEquals(request.getID(), result.getID());
	assertEquals(request.getFrom(), result.getTo());
	assertEquals(request.getTo(), result.getFrom());		
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:26,代码来源:AbstractComponentRespondsToIQRequestsTest.java

示例14: testExceptionResponse

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
/**
 * If an exception is thrown during the processing of an IQ request,
 * AbstractComponent should still return a response to the request.
 * 
 * This test uses a AbstractComponent that throws an exception every time it
 * processes an IQ get request.
 */
@Test
public void testExceptionResponse() throws Exception {
	// setup
	final DummyAbstractComponent component = new ThrowExceptionOnGetComponent();
	final IQ request = new IQ(Type.get);
	request.setChildElement("junit", "test");
	request.setFrom("from.address");
	request.setTo("to.address");

	// do magic
	component.start();
	component.processPacket(request);

	// verify
	final IQ result = (IQ) component.getSentPacket();
	assertNotNull(result);
	assertTrue(result.isResponse());
	assertEquals(request.getID(), result.getID());
	assertEquals(request.getFrom(), result.getTo());
	assertEquals(request.getTo(), result.getFrom());
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:29,代码来源:AbstractComponentRespondsToIQRequestsTest.java

示例15: handleIQ

import org.xmpp.packet.IQ.Type; //导入依赖的package包/类
@Override
public IQ handleIQ(IQ packet) {
    if (Type.get.equals(packet.getType())) {
        return IQ.createResultIQ(packet);
    }
    return null;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:8,代码来源:IQPingHandler.java


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