- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {StringBuilder s =
new StringBuilder()
new StringBuilder(32)
String str;new StringBuilder(str)
- Smart code suggestions by Codota
}
/** * 删除链接 * * @throws SoaException */ @Override public synchronized void removeConnection() throws SoaException { InvocationContext context = InvocationContext.Factory.getCurrentInstance(); if (context.getCalleeIp() == null || context.getCalleePort() <= 0) return; String connectKey = context.getCalleeIp() + ":" + String.valueOf(context.getCalleePort()); if (connectionMap.containsKey(connectKey)) connectionMap.remove(connectKey); if (scalaConnectionMap.containsKey(connectKey)) scalaConnectionMap.remove(connectKey); }
@Override public synchronized SoaConnection getConnection() throws SoaException { InvocationContext context = InvocationContext.Factory.getCurrentInstance(); if (context.getCalleeIp() == null || context.getCalleePort() <= 0) throw new SoaException(SoaBaseCode.NotFoundServer); String connectKey = context.getCalleeIp() + ":" + String.valueOf(context.getCalleePort()); if (connectionMap.containsKey(connectKey)) { return connectionMap.get(connectKey); } SoaConnectionImpl soaConnection = new SoaConnectionImpl(context.getCalleeIp(), context.getCalleePort()); connectionMap.put(connectKey, soaConnection); return soaConnection; }
@Override public SoaCommonConnection getCommonConnection() throws SoaException { InvocationContext context = InvocationContext.Factory.getCurrentInstance(); if (context.getCalleeIp() == null || context.getCalleePort() <= 0) throw new SoaException(SoaBaseCode.NotFoundServer); String connectKey = context.getCalleeIp() + ":" + String.valueOf(context.getCalleePort()); if (scalaConnectionMap.containsKey(connectKey)) { return scalaConnectionMap.get(connectKey); } SoaCommonConnectionImpl soaConnection = new SoaCommonConnectionImpl(context.getCalleeIp(), context.getCalleePort()); scalaConnectionMap.put(connectKey, soaConnection); return soaConnection; }
@Override public void doFilter(FilterChain chain) throws TException { final SoaHeader soaHeader = (SoaHeader) chain.getAttribute(StubFilterChain.ATTR_KEY_HEADER); final Object request = chain.getAttribute(StubFilterChain.ATTR_KEY_REQUEST); final long startTime = System.currentTimeMillis(); final InvocationContext context = (InvocationContext) chain.getAttribute(StubFilterChain.ATTR_KEY_CONTEXT); LOGGER.info("{} {} {} request", soaHeader.getServiceName(), soaHeader.getVersionName(), soaHeader.getMethodName()); try { chain.doFilter(); } finally { // Object response = chain.getAttribute(StubFilterChain.ATTR_KEY_RESPONSE); final long endTime = System.currentTimeMillis(); LOGGER.info("{} {} {} callee: {}:{} response respCode:{} time:{}ms", soaHeader.getServiceName(), soaHeader.getVersionName(), soaHeader.getMethodName(), context.getCalleeIp(), context.getCalleePort(), soaHeader.getRespCode(), endTime-startTime); } }
Socket socket = new Socket(context.getCalleeIp(), context.getCalleePort()); BufferedOutputStream output = new BufferedOutputStream(socket.getOutputStream()); BufferedInputStream input = new BufferedInputStream(socket.getInputStream());