List of usage examples for org.apache.mina.filter.logging LoggingFilter LoggingFilter
public LoggingFilter()
From source file:com.ambimmort.minatutorial.part1.filter.firewall.blacklist.MinaClient.java
public static void main(String[] args) { IoConnector connector = new NioSocketConnector(); connector.getFilterChain().addLast("log", new LoggingFilter()); connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("utf-8")))); connector.setHandler(new MinaClientHandler()); ConnectFuture f = connector.connect(new InetSocketAddress("localhost", 8888)); boolean b = f.awaitUninterruptibly(3, TimeUnit.SECONDS); if (b && !f.isConnected()) { System.out.println("try connected but can not connect."); }/*from ww w . j ava2 s. c o m*/ }
From source file:com.ambimmort.minatutorial.part1.filter.firewall.blacklist.MinaServer.java
public static void main(String[] args) { IoAcceptor acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("log", new LoggingFilter()); //tag1:/*from w ww.jav a2s.c o m*/ BlacklistFilter filter = new BlacklistFilter(); try { Subnet subnet = new Subnet(InetAddress.getByName("127.0.0.0"), 24); filter.block(subnet); } catch (UnknownHostException ex) { Logger.getLogger(MinaServer.class.getName()).log(Level.SEVERE, null, ex); } acceptor.getFilterChain().addLast("blacklist", filter); //tag1:finished acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("utf-8")))); acceptor.setHandler(new MinaServerHandler()); try { acceptor.bind(new InetSocketAddress(8888)); } catch (IOException ex) { ex.printStackTrace(); System.exit(0); } }
From source file:com.ambimmort.minatutorial.part1.filter.firewall.throttle.enhancement.MinaClient.java
public static void main(String[] args) { IoConnector connector = new NioSocketConnector(); connector.getFilterChain().addLast("log", new LoggingFilter()); connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("utf-8")))); connector.setHandler(new MinaClientHandler()); ConnectFuture f = connector.connect(new InetSocketAddress("localhost", 8888)); boolean b = f.awaitUninterruptibly(3, TimeUnit.SECONDS); if (b && !f.isConnected()) { System.out.println("try connected but can not connect."); }/*from ww w.j av a2 s.c o m*/ }
From source file:com.ambimmort.minatutorial.part1.filter.firewall.throttle.enhancement.MinaServer.java
public static void main(String[] args) { IoAcceptor acceptor = new NioSocketAcceptor(); ////from w w w . java 2 s . c om EnhancedConnectionThrottleFilter throttle = new EnhancedConnectionThrottleFilter(1000, 100); acceptor.getFilterChain().addLast("log", new LoggingFilter()); acceptor.getFilterChain().addLast("throttle", throttle); acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("utf-8")))); acceptor.setHandler(new MinaServerHandler()); try { acceptor.bind(new InetSocketAddress(8888)); } catch (IOException ex) { ex.printStackTrace(); System.exit(0); } }
From source file:com.ambimmort.minatutorial.part1.filter.firewall.throttle.MinaServer.java
public static void main(String[] args) { IoAcceptor acceptor = new NioSocketAcceptor(); ///*from w w w . j a v a 2s . c o m*/ ConnectionThrottleFilter throttle = new ConnectionThrottleFilter(1000); acceptor.getFilterChain().addLast("log", new LoggingFilter()); acceptor.getFilterChain().addLast("throttle", throttle); acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("utf-8")))); acceptor.setHandler(new MinaServerHandler()); try { acceptor.bind(new InetSocketAddress(8888)); } catch (IOException ex) { ex.printStackTrace(); System.exit(0); } }
From source file:com.ambimmort.minatutorial.part1.filter.firewall.whitelist.MinaServer.java
public static void main(String[] args) { IoAcceptor acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("log", new LoggingFilter()); //tag1://from w w w. ja v a 2s. com WhitelistFilter filter = new WhitelistFilter(); try { Subnet subnet = new Subnet(InetAddress.getByName("127.0.0.0"), 24); filter.allow(subnet); } catch (UnknownHostException ex) { Logger.getLogger(MinaServer.class.getName()).log(Level.SEVERE, null, ex); } acceptor.getFilterChain().addLast("whitelist", filter); //tag1:finished acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("utf-8")))); acceptor.setHandler(new MinaServerHandler()); try { acceptor.bind(new InetSocketAddress(8888)); } catch (IOException ex) { ex.printStackTrace(); System.exit(0); } }
From source file:com.ambimmort.minatutorial.part1.filter.log.MinaServer.java
public static void main(String[] args) { IoAcceptor acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("log", new LoggingFilter()); acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("utf-8")))); acceptor.setHandler(new MinaServerHandler()); try {//from w w w . j a v a2 s . co m acceptor.bind(new InetSocketAddress(8888)); } catch (IOException ex) { ex.printStackTrace(); System.exit(0); } }
From source file:com.ambimmort.uc.zfserver.component.zfserver.ZFServerComponent.java
private ZFServerComponent() { acceptor = new NioSocketAcceptor(); connectionThrottleFilter = new ConnectionThrottleFilter(); try {// w ww . jav a 2s . co m connectionThrottleFilter.setAllowedInterval( Integer.parseInt(ZFPropertyBeanDao.getInstance().getProperty("zfserver.throttle"))); } catch (SQLException ex) { Logger.getLogger(ZFServerComponent.class.getName()).log(Level.SEVERE, null, ex); } acceptor.getFilterChain().addLast("logger", new LoggingFilter()); acceptor.getFilterChain().addLast("whiteList", whiteListFilter); // acceptor.getFilterChain().addLast("ConnectionThrottleFilter", connectionThrottleFilter); acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new UcProtocolCodecFactory())); acceptor.setHandler(new ServerChannelHandler()); }
From source file:com.buzzdavidson.spork.geroa.MinaLocalhostPopServer.java
@Override public void start() { IoBuffer.setUseDirectBuffer(false);/* ww w . ja v a 2s . co m*/ IoBuffer.setAllocator(new SimpleBufferAllocator()); acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("logger", new LoggingFilter()); acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("US-ASCII")))); acceptor.getFilterChain().addLast("stream", new StreamWriteFilter()); acceptor.setHandler(new PopIOHandlerAdapter(this)); try { acceptor.bind(new InetSocketAddress("127.0.0.1", getPopPort())); } catch (IOException ex) { throw new RuntimeException("Couldnt bind to port: " + getPopPort(), ex); } }
From source file:com.chantake.MituyaProject.Api.ConnectionManager.java
License:Open Source License
public void init() { try {/*from w w w .ja v a2 s.co m*/ this.plugin.Log("MituyaApi??" + Parameter328.api_port + ""); IoAcceptor acceptor = new NioSocketAcceptor(); LoggingFilter loggingFilter = new LoggingFilter(); ProtocolCodecFilter protocolCodecFilter = new ProtocolCodecFilter( new TextLineCodecFactory(Charset.forName("UTF-8"))); acceptor.getFilterChain().addLast("logger", loggingFilter); acceptor.getFilterChain().addLast("codec", protocolCodecFilter); acceptor.setHandler(new ServerHandler(plugin, this)); acceptor.getSessionConfig().setReadBufferSize(2048); acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10); acceptor.bind(new InetSocketAddress(Parameter328.api_port)); this.plugin.Log("MituyaApi?"); } catch (IOException ex) { this.plugin.ErrLog("Api????? " + ex); } }