• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MdcInjectionFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: serverStart

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
@Override
protected void serverStart() throws RemotingException {

    acceptor = new NioSocketAcceptor(); //TCP Acceptor

    // acceptor.getFilterChain().addFirst("logging", new MinaLoggingFilter());
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecFactory(getCodec())));
    acceptor.getFilterChain().addLast("mdc", new MdcInjectionFilter());

    acceptor.setHandler(new MinaHandler(this));
    IoSessionConfig cfg = acceptor.getSessionConfig();
    cfg.setReaderIdleTime(remotingServerConfig.getReaderIdleTimeSeconds());
    cfg.setWriterIdleTime(remotingServerConfig.getWriterIdleTimeSeconds());
    cfg.setBothIdleTime(remotingServerConfig.getServerChannelMaxIdleTimeSeconds());

    bindAddress = new InetSocketAddress(remotingServerConfig.getListenPort());
    try {
        acceptor.bind(bindAddress);
    } catch (IOException e) {
        throw new RemotingException("Start Mina server error", e);
    }
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:23,代码来源:MinaRemotingServer.java


示例2: clientStart

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
@Override
protected void clientStart() throws RemotingException {
    try {
        connector = new NioSocketConnector(); //TCP Connector

        // connector.getFilterChain().addFirst("logging", new MinaLoggingFilter());
        connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecFactory(getCodec())));
        connector.getFilterChain().addLast("mdc", new MdcInjectionFilter());

        connector.setHandler(new MinaHandler(this));
        IoSessionConfig cfg = connector.getSessionConfig();
        cfg.setReaderIdleTime(remotingClientConfig.getReaderIdleTimeSeconds());
        cfg.setWriterIdleTime(remotingClientConfig.getWriterIdleTimeSeconds());
        cfg.setBothIdleTime(remotingClientConfig.getClientChannelMaxIdleTimeSeconds());
    } catch (Exception e) {
        throw new RemotingException("Mina Client start error", e);
    }
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:19,代码来源:MinaRemotingClient.java


示例3: messageReceived

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
public void messageReceived(IoSession session, Object message) throws Exception {
	Message msg = (Message)message;
	int command = msg.getCommand();
	String user = msg.getUser();
	switch (command) {
	case Command.QUIT:
		session.write(msg);
		sessionClosed(session);
		break;
	case Command.BROADCAST:
		Date date = new Date();
		broadCast(user + " " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date) +" "+msg.getMsgContent());//发送广播
		break;
	case Command.LOGIN:
		//保存当前会话
		sessions.add(session);
		session.setAttribute("user", user);
        MdcInjectionFilter.setProperty(session, "user", user);
        users.add(user);
        broadCast("用户:"+user+"加入了会话!");//发送广播
		break;
	default:
		broadCast("阁下莫非来自外太空?地球很危险,快回火星去吧!");//发送广播
		break;
	}
}
 
开发者ID:ameizi,项目名称:mina-examples,代码行数:27,代码来源:HelloServerHandler.java


示例4: main

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
public static void main(String[] args) {
	NioSocketConnector connector = new NioSocketConnector(); //TCP Connector
	connector.getFilterChain().addLast("logging", new LoggingFilter());
	connector.getFilterChain().addLast("codec",new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
    connector.getFilterChain().addLast("mdc", new MdcInjectionFilter());
	connector.setHandler(new HelloClientHandler());
    IoSession session;

    for (;;) {
        try {
            ConnectFuture future = connector.connect(new InetSocketAddress(HOSTNAME, PORT));
            future.awaitUninterruptibly();
            session = future.getSession();
            break;
        } catch (RuntimeIoException e) {
            System.err.println("Failed to connect.");
            e.printStackTrace();
        }
    }
    session.getCloseFuture().awaitUninterruptibly();
    connector.dispose();
}
 
开发者ID:ameizi,项目名称:mina-examples,代码行数:23,代码来源:HelloTcpClient.java


示例5: addVehicle

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
@WebMethod
public String addVehicle(String name, String vin, String type)
throws PluginWebServicesException {

String q1 = "insert into Vehicle (vin,name,vehicleConfig_id) select '" + vin + "','" + name + "',c.id from VehicleConfig c where c.name = '" + type + "'";
int rows = mysql.update(q1);
if (rows != 0) {
    IoSession session = ServerHandler.getSession(vin);
    if (session != null) {
	String is_sim = MdcInjectionFilter.getProperty(session, "is_sim");
	System.out.println("vehicle " + vin + " simulator: " + is_sim);
	    String q2 = "update Vehicle set simulator=" + is_sim +
		" where vin='" + vin + "'";
	int rows2 = mysql.update(q2);
    }

    return jsonOK();
} else {
    // distinguish between causes.
    return jsonError("addVehicle failed");
}
   }
 
开发者ID:sics-sse,项目名称:moped,代码行数:23,代码来源:PluginWebServicesImpl.java


示例6: main

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	NioDatagramAcceptor acceptor = new NioDatagramAcceptor();//UDP Acceptor
	acceptor.getFilterChain().addLast("logging", new LoggingFilter());
	acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
	acceptor.getFilterChain().addLast("mdc", new MdcInjectionFilter());
	acceptor.setHandler(new HelloServerHandler());
	acceptor.getSessionConfig().setReadBufferSize(2048);
	acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10);
	DatagramSessionConfig dcfg = acceptor.getSessionConfig();
	dcfg.setReuseAddress(true);
	acceptor.bind(new InetSocketAddress(PORT));
}
 
开发者ID:ameizi,项目名称:mina-examples,代码行数:13,代码来源:HelloUdpServer.java


示例7: main

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	IoAcceptor acceptor = new NioSocketAcceptor(); //TCP Acceptor
	acceptor.getFilterChain().addLast("logging", new LoggingFilter());
	acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
	acceptor.getFilterChain().addLast("mdc", new MdcInjectionFilter());
	acceptor.setHandler(new HelloServerHandler());
	acceptor.getSessionConfig().setReadBufferSize(2048);
	acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10);
	acceptor.bind(new InetSocketAddress(PORT));
}
 
开发者ID:ameizi,项目名称:mina-examples,代码行数:11,代码来源:HelloTcpServer.java


示例8: connectAndSend

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
/**
    * Default constructor.
    */
   public void connectAndSend() {
   	
   	LOGGER.debug(ipAddress +":"+ portNo);
   	SocketAddress address = parseSocketAddress(ipAddress +":"+ portNo);
  	

       LOGGER.debug("UDPClient::UDPClient");
       LOGGER.debug("Created a datagram connector");
       connector = new NioDatagramConnector();

       LOGGER.debug("Setting the handler");
       connector.setHandler(this);


       IoFilter LOGGING_FILTER = new LoggingFilter();
       IoFilter CODEC_FILTER = new ProtocolCodecFilter(
               new TextLineCodecFactory());                
       connector.getFilterChain().addLast("mdc", new MdcInjectionFilter());
       connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
       connector.getFilterChain().addLast("logger", LOGGING_FILTER);
       
       
       LOGGER.debug("About to connect to the server...");
       ConnectFuture future1 = connector.connect(address);
       future1.awaitUninterruptibly();
       if (!future1.isConnected()) {
           return;
       }
       session = future1.getSession();
//       try {
		//sendData(fileSignature);
       /*
		UdpMessage m = new UdpMessage();
        m.setSequence(0);
        m.setFileSignature(fileSignature);
           session.write(m);*/
       
	RequestSignatureMessage signatureMessage = new RequestSignatureMessage();
	FileSignature fileSignature;
	try {
		fileSignature = new FileSignature(query);
		signatureMessage.setSequence(0);
		signatureMessage.setFileSignature(fileSignature);
		signatureMessage.setMatches(matches);
		System.out.println("Sending the query: " + query);
		System.out.println("[PeerlessSendUdpMessageSupport] file signature" + fileSignature);
        session.write(signatureMessage);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}		
	//fileSignature.setFileSignature(query);
	

	
	
   }
 
开发者ID:knowpd,项目名称:p2p-file-sharing-system,代码行数:61,代码来源:PeerlessSendUdpMessageSupport.java


示例9: connect

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
public boolean connect(NioSocketConnector connector, SocketAddress address,
        boolean useSsl) {
    if (session != null && session.isConnected()) {
        throw new IllegalStateException(
                "Already connected. Disconnect first.");
    }

    try {
        IoFilter LOGGING_FILTER = new LoggingFilter();

        IoFilter CODEC_FILTER = new ProtocolCodecFilter(
                new TextLineCodecFactory());
        
        connector.getFilterChain().addLast("mdc", new MdcInjectionFilter());
        //connector.getFilterChain().addLast("codec", CODEC_FILTER);
        connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
        connector.getFilterChain().addLast("logger", LOGGING_FILTER);
        

        if (useSsl) {
            SSLContext sslContext = BogusSslContextFactory
                    .getInstance(false);
            SslFilter sslFilter = new SslFilter(sslContext);
            sslFilter.setUseClientMode(true);
            connector.getFilterChain().addFirst("sslFilter", sslFilter);
        }

        connector.setHandler(handler);
        ConnectFuture future1 = connector.connect(address);
        future1.awaitUninterruptibly();
        if (!future1.isConnected()) {
            return false;
        }
        session = future1.getSession();
        login();

        return true;
    } catch (Exception e) {
        return false;
    }
}
 
开发者ID:knowpd,项目名称:p2p-file-sharing-system,代码行数:42,代码来源:PeerlessClientSupport.java


示例10: register

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
public boolean register(NioSocketConnector connector, SocketAddress address,
		String name, String id, String password, String question,
		String passwordReminder, boolean useSsl) {
	System.out.println("This is address: " + address);
       if (session != null && session.isConnected()) {
           throw new IllegalStateException(
                   "Already connected. Disconnect first.");
         
       }

       try {
           IoFilter LOGGING_FILTER = new LoggingFilter();

           IoFilter CODEC_FILTER = new ProtocolCodecFilter(
                   new TextLineCodecFactory());
           
           connector.getFilterChain().addLast("mdc", new MdcInjectionFilter());
           //connector.getFilterChain().addLast("codec", CODEC_FILTER);

           connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
           connector.getFilterChain().addLast("logger", LOGGING_FILTER);

           if (useSsl) {
               SSLContext sslContext = BogusSslContextFactory
                       .getInstance(false);
               SslFilter sslFilter = new SslFilter(sslContext);
               sslFilter.setUseClientMode(true);
               connector.getFilterChain().addFirst("sslFilter", sslFilter);
           }

           connector.setHandler(handler);
           ConnectFuture future1 = connector.connect(address);
           future1.awaitUninterruptibly();
		if (!future1.isConnected()) {
			return false;
		}
		session = future1.getSession();
		register m = new register();
        m.setSequence(0);
        m.setCommand("REGISTER");
        m.setUserId(id);
        m.setpassword(password);
        m.setQuestion(question);
        m.setpasswordReminder(passwordReminder);
        session.write(m);
		/*session.write("REGISTER " + id + CommonConfig.delimeter + name
				+ CommonConfig.delimeter + password
				+ CommonConfig.delimeter + question
				+ CommonConfig.delimeter + passwordReminder);*/
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:knowpd,项目名称:p2p-file-sharing-system,代码行数:56,代码来源:PeerlessClientSupport.java


示例11: main

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	NioSocketAcceptor acceptor = new NioSocketAcceptor();
	DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();

	MdcInjectionFilter mdcInjectionFilter = new MdcInjectionFilter();
	chain.addLast("mdc", mdcInjectionFilter);

	SigHashTable sht = new SigHashTable();

	/*
	 * FileSignature d0=new FileSignature("test data");
	 * SigManager.printByteArray(d0);
	 * 
	 * FileSignature d1=new FileSignature(new File("ftphome//test.txt"));
	 * SigManager.printByteArray(d1);
	 * 
	 * FileSignature d2=newFileSignature(
	 * "Design and Implementation of Virtualized Network Simulator");
	 * SigManager.printByteArray(d2);
	 * 
	 * sht.addSignature(d0); sht.addSignature(d1); sht.addSignature(d2);
	 */

	PeerlessDbSupport peerlessDbSupport = new PeerlessDbSupport(ServerConfig.ServerDb);
	peerlessDbSupport.connect();
	peerlessDbSupport.createSchema();

	SuperPeerManager superPeerManager = new SuperPeerManager();
	
	// Add SSL filter if SSL is enabled.
	if (USE_SSL) {
		addSSLSupport(chain);
	}

	// chain.addLast("codec", new ProtocolCodecFilter(new
	// TextLineCodecFactory()));
	chain.addLast("codec", new ProtocolCodecFilter(
			new ObjectSerializationCodecFactory()));

	addLogger(chain);

	// Bind
	acceptor.setHandler(new PeerlessProtocolHandler(sht, peerlessDbSupport, superPeerManager));
	acceptor.bind(new InetSocketAddress(ServerConfig.PORT));

	System.out.println("Listening on port " + ServerConfig.PORT);
	
	try {
		new PeerlessUdpServer(peerlessDbSupport, sht);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}


}
 
开发者ID:knowpd,项目名称:p2p-file-sharing-system,代码行数:57,代码来源:PeerlessServerMain.java


示例12: sessionCreated

import org.apache.mina.filter.logging.MdcInjectionFilter; //导入依赖的package包/类
public void sessionCreated(IoSession session) throws Exception {
    FtpIoSession ftpSession = new FtpIoSession(session, context);
    MdcInjectionFilter.setProperty(session, "session", ftpSession.getSessionId().toString());

    ftpHandler.sessionCreated(ftpSession);
    
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:8,代码来源:FtpHandlerAdapter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ByteArrayEntity类代码示例发布时间:2022-05-22
下一篇:
Java Requests类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap