@Override public void doBeforeRender(HstRequest request, HstResponse response) { // TODO Auto-generated method stub if (log.isInfoEnabled()) { log.info("This is Other Income page"); } super.doBeforeRender(request, response); String whichITRForm = request.getRequestContext().getResolvedSiteMapItem().getParameter("whichITRForm"); if (whichITRForm != null) { request.setAttribute("ITR2", whichITRForm); } if (log.isInfoEnabled()) { log.info(whichITRForm + " do before render whichITRForm"); } request.setAttribute("Max_allowed_ITR1", eRROR_MAX_ALLOWED); // the following line of code is needed to add a field if the package is ITR3 or ITR4 MemberPersonalInformation objMemberPersonalInformation = (MemberPersonalInformation) request.getAttribute(MemberPersonalInformation.class.getSimpleName().toLowerCase()); if (objMemberPersonalInformation != null) { String packageName = objMemberPersonalInformation.getFlexField("flex_string_ITRForm", ""); if ((!packageName.isEmpty()) && (packageName.equals("ITR3")) || (packageName.equals("ITR4"))) { request.setAttribute("ITR3_4", packageName); } } }
private boolean checkForConvergence() { if (maxNumberOfIterations == currentIteration) { if (log.isInfoEnabled()) { log.info( formatLogString( "maximum number of iterations [" + currentIteration + "] reached, terminating...")); } return true; } if (convergenceAggregatorName != null) { @SuppressWarnings("unchecked") Aggregator<Value> aggregator = (Aggregator<Value>) aggregators.get(convergenceAggregatorName); if (aggregator == null) { throw new RuntimeException("Error: Aggregator for convergence criterion was null."); } Value aggregate = aggregator.getAggregate(); if (convergenceCriterion.isConverged(currentIteration, aggregate)) { if (log.isInfoEnabled()) { log.info( formatLogString( "convergence reached after [" + currentIteration + "] iterations, terminating...")); } return true; } } return false; }
@Override public WSDocument extendSignature( final WSDocument signedDocument, final WSParameters wsParameters) throws DSSException { String exceptionMessage; try { if (LOG.isInfoEnabled()) { LOG.info("WsExtendSignature: begin"); } final SignatureParameters params = createParameters(wsParameters); final DocumentSignatureService service = getServiceForSignatureLevel(params.getSignatureLevel()); final DSSDocument dssDocument = service.extendDocument(signedDocument, params); final WSDocument wsDocument = new WSDocument(dssDocument); if (LOG.isInfoEnabled()) { LOG.info("WsExtendSignature: end"); } return wsDocument; } catch (Throwable e) { e.printStackTrace(); exceptionMessage = e.getMessage(); } LOG.info("WsExtendSignature: end with exception"); throw new DSSException(exceptionMessage); }
@Override public void run() { if (logger.isInfoEnabled()) logger.info("FxRate simulator starting continuous publishing..."); while (this.isRunning) { if (!this.isSuspended) { for (Map.Entry<String, FxRateGenerator> item : this.FxRateMap.entrySet()) { FxRateGenerator currency = item.getValue(); if (currency.isAwake() && currency.hasChanged()) { double FxRate = currency.getLatestFxRate(); if (logger.isDebugEnabled()) logger.debug("Publishing FxRate: " + FxRate + " for currency: " + item.getKey()); // TODO // this.applicationEventPublisher.publishEvent(); } } } try { sleep(this.getNextSleepDuration()); } catch (InterruptedException ie) { if (logger.isInfoEnabled()) logger.info("Interruption exception raised. Terminating FxRate simulator..."); this.isRunning = false; } } if (logger.isInfoEnabled()) logger.info("FxRate simulator activity terminated!"); }
private void scrubCells( TransactionManager txManager, Multimap<String, Cell> tableNameToCells, long scrubTimestamp, Transaction.TransactionType transactionType) { for (Entry<String, Collection<Cell>> entry : tableNameToCells.asMap().entrySet()) { String tableName = entry.getKey(); if (log.isInfoEnabled()) { log.info( "Attempting to immediately scrub " + entry.getValue().size() + " cells from table " + tableName); } for (List<Cell> cells : Iterables.partition(entry.getValue(), batchSizeSupplier.get())) { Multimap<Cell, Long> timestampsToDelete = HashMultimap.create( keyValueService.getAllTimestamps( tableName, ImmutableSet.copyOf(cells), scrubTimestamp)); for (Cell cell : ImmutableList.copyOf(timestampsToDelete.keySet())) { // Don't scrub garbage collection sentinels timestampsToDelete.remove(cell, Value.INVALID_VALUE_TIMESTAMP); } // If transactionType == TransactionType.AGGRESSIVE_HARD_DELETE this might // force other transactions to abort or retry deleteCellsAtTimestamps(txManager, tableName, timestampsToDelete, transactionType); } if (log.isInfoEnabled()) { log.info( "Immediately scrubbed " + entry.getValue().size() + " cells from table " + tableName); } } }
@Override public byte[] getDataToSign(final WSDocument document, final WSParameters wsParameters) throws DSSException { String exceptionMessage; try { if (LOG.isInfoEnabled()) { LOG.info("WsGetDataToSign: begin"); } final SignatureParameters params = createParameters(wsParameters); final DocumentSignatureService service = getServiceForSignatureLevel(params.getSignatureLevel()); final byte[] dataToSign = service.getDataToSign(document, params); if (LOG.isInfoEnabled()) { LOG.info("WsGetDataToSign: end"); } return dataToSign; } catch (Throwable e) { e.printStackTrace(); exceptionMessage = e.getMessage(); } LOG.info("WsGetDataToSign: end with exception"); throw new DSSException(exceptionMessage); }
private static DhcpV4Message handleMessage1(InetAddress localAddress, DhcpV4Message dhcpMessage) { InetAddress linkAddress; if (dhcpMessage.getGiAddr().equals(DhcpConstants.ZEROADDR_V4)) { linkAddress = localAddress; if (log.isInfoEnabled()) { log.info( "Handling client request on local client link address: {}", linkAddress.getHostAddress()); } } else { linkAddress = dhcpMessage.getGiAddr(); if (log.isInfoEnabled()) { log.info( "Handling client request on remote client link address: {}", linkAddress.getHostAddress()); } } DhcpV4MsgTypeOption msgTypeOption = (DhcpV4MsgTypeOption) dhcpMessage.getDhcpOption(DhcpConstants.V4OPTION_MESSAGE_TYPE); DhcpV4Message result; if (msgTypeOption != null) { result = handleMessage2(dhcpMessage, linkAddress, msgTypeOption); } else { log.error("No message type option found in request."); result = null; } return result; }
public BufferedImage createGraphImage( long nowInSeconds, SourceIdentifier sourceIdentifier, BufferedImage result, boolean showMax) { RrdGraphDef graphDef = getGraphDef(nowInSeconds, sourceIdentifier, showMax); //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (graphDef) { RrdGraph graph; try { graph = new RrdGraph(graphDef); RrdGraphInfo graphInfo = graph.getRrdGraphInfo(); int width = graphInfo.getWidth(); int height = graphInfo.getHeight(); if (result != null && (result.getWidth() != width || result.getHeight() != height)) { if (logger.isInfoEnabled()) logger.info("Flushing previous image because of wrong size."); result.flush(); result = null; } if (result == null) { result = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); if (logger.isInfoEnabled()) logger.info("Created new image."); } graph.render(result.getGraphics()); } catch (IOException ex) { if (logger.isWarnEnabled()) logger.warn("Exception while creating graph!", ex); if (result != null) { result.flush(); result = null; } } } return result; }
/** * Loads an existing EhCache from the cache manager, or starts a new cache if one is not found. * * @param name the name of the cache to load/create. */ public final <K, V> Cache<K, V> getCache(String name) throws CacheException { if (log.isTraceEnabled()) { log.trace("Acquiring EhCache instance named [" + name + "]"); } try { net.sf.ehcache.Ehcache cache = ensureCacheManager().getEhcache(name); if (cache == null) { if (log.isInfoEnabled()) { log.info("Cache with name '{}' does not yet exist. Creating now.", name); } this.manager.addCache(name); cache = manager.getCache(name); if (log.isInfoEnabled()) { log.info("Added EhCache named [" + name + "]"); } } else { if (log.isInfoEnabled()) { log.info("Using existing EHCache named [" + cache.getName() + "]"); } } return new EhCache<K, V>(cache); } catch (net.sf.ehcache.CacheException e) { throw new CacheException(e); } }
private void runDataCheck(String mode, TableMonitor tableMon, DateTime now, long time) { int periodInMinutes = (int) tableMon.getUpdatePeriod(); // find begin period and add 30 seconds as well in case last data point // was a little early. DateTime beginPeriod = now.minusMinutes(periodInMinutes).minusSeconds(30); DateTime lastDataPoint = new DateTime(time); String msg = "lastpoint=(" + time + ")" + lastDataPoint + " beginPeriod=" + beginPeriod + " now=" + now + " m=" + tableMon.getId(); if (lastDataPoint.isAfter(beginPeriod)) { if (log.isInfoEnabled()) log.info("Stream is good. " + msg); return; // nothing to do } if (log.isInfoEnabled()) log.info("Stream is down. " + msg); fireEmailStreamIsDown(mode, lastDataPoint, now, tableMon); }
private List<ServerNode> doNodesDiscovery() throws Exception { if (logger_ != null) { if (logger_.isInfoEnabled()) logger_.info("nodes discovery start..."); } List<String> serverNodes = registerPathNodeDataChangeWatcher(zkNodePath_); if (serverNodes == null) serverNodes = new ArrayList<>(); List<ServerNode> newestServerNodes = new ArrayList<>(); for (final String nodeKey : serverNodes) { final byte[] nodeValueBytes = zkClient_.getData().forPath(String.format("%s/%s", zkNodePath_, nodeKey)); if (nodeValueBytes == null || nodeValueBytes.length <= 0) continue; final String nodeValueInfo = new String(nodeValueBytes, ZK_CHAR_SET); final ServerNodeInfo serverNode = JSONObject.parseObject(nodeValueInfo, ServerNodeInfo.class); newestServerNodes.add(serverNode); } if (serverNodes != null) serverNodes.clear(); synchronized (this.serverNodes_) { this.serverNodes_.clear(); this.serverNodes_.addAll(newestServerNodes); if (logger_ != null) { if (logger_.isInfoEnabled()) logger_.info( String.format( "current discovery's server nodes count (%d)", this.serverNodes_.size())); } } if (logger_ != null) { if (logger_.isInfoEnabled()) logger_.info("nodes discovery end..."); } return this.nodes(); }
public void inject(Path crawlDb, Path urlDir) throws IOException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); long start = System.currentTimeMillis(); if (LOG.isInfoEnabled()) { LOG.info("Injector: starting at " + sdf.format(start)); LOG.info("Injector: crawlDb: " + crawlDb); LOG.info("Injector: urlDir: " + urlDir); } Path tempDir = new Path( getConf().get("mapred.temp.dir", ".") + "/inject-temp-" + Integer.toString(new Random().nextInt(Integer.MAX_VALUE))); // map text input file to a <url,CrawlDatum> file if (LOG.isInfoEnabled()) { LOG.info("Injector: Converting injected urls to crawl db entries."); } JobConf sortJob = new NutchJob(getConf()); sortJob.setJobName("inject " + urlDir); FileInputFormat.addInputPath(sortJob, urlDir); sortJob.setMapperClass(InjectMapper.class); FileOutputFormat.setOutputPath(sortJob, tempDir); sortJob.setOutputFormat(SequenceFileOutputFormat.class); sortJob.setOutputKeyClass(Text.class); sortJob.setOutputValueClass(CrawlDatum.class); sortJob.setLong("injector.current.time", System.currentTimeMillis()); RunningJob mapJob = JobClient.runJob(sortJob); long urlsInjected = mapJob.getCounters().findCounter("injector", "urls_injected").getValue(); long urlsFiltered = mapJob.getCounters().findCounter("injector", "urls_filtered").getValue(); LOG.info("Injector: total number of urls rejected by filters: " + urlsFiltered); LOG.info( "Injector: total number of urls injected after normalization and filtering: " + urlsInjected); // merge with existing crawl db if (LOG.isInfoEnabled()) { LOG.info("Injector: Merging injected urls into crawl db."); } JobConf mergeJob = CrawlDb.createJob(getConf(), crawlDb); FileInputFormat.addInputPath(mergeJob, tempDir); mergeJob.setReducerClass(InjectReducer.class); JobClient.runJob(mergeJob); CrawlDb.install(mergeJob, crawlDb); // clean up FileSystem fs = FileSystem.get(getConf()); fs.delete(tempDir, true); long end = System.currentTimeMillis(); LOG.info( "Injector: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end)); }
@Override public void reset() { if (LOGGER.isInfoEnabled()) LOGGER.info("Resetting store."); runQueryUntilResultIsZero( "MATCH (n)-[r]-() WITH n, collect(r) as rels LIMIT 10000 FOREACH (r in rels | DELETE r) DELETE n RETURN COUNT(*) as deleted"); runQueryUntilResultIsZero("MATCH (n) WITH n LIMIT 50000 DELETE n RETURN COUNT(*) as deleted"); if (LOGGER.isInfoEnabled()) LOGGER.info("Reset finished."); }
public void afterPropertiesSet() throws Exception { // 实例化一个AnnotationServletServiceRouter serviceRouter = new AnnotationServletServiceRouter(); // 设置国际化错误资源 if (extErrorBasename != null) { serviceRouter.setExtErrorBasename(extErrorBasename); } if (extErrorBasenames != null) { serviceRouter.setExtErrorBasenames(extErrorBasenames); } DefaultSecurityManager securityManager = BeanUtils.instantiate(DefaultSecurityManager.class); securityManager.setSessionManager(sessionManager); securityManager.setAppSecretManager(appSecretManager); securityManager.setServiceAccessController(serviceAccessController); securityManager.setInvokeTimesController(invokeTimesController); securityManager.setFileUploadController(buildFileUploadController()); serviceRouter.setSecurityManager(securityManager); serviceRouter.setThreadPoolExecutor(threadPoolExecutor); serviceRouter.setSignEnable(signEnable); serviceRouter.setServiceTimeoutSeconds(serviceTimeoutSeconds); serviceRouter.setFormattingConversionService(formattingConversionService); serviceRouter.setSessionManager(sessionManager); serviceRouter.setThreadFerryClass(threadFerryClass); serviceRouter.setInvokeTimesController(invokeTimesController); // 注册拦截器 ArrayList<Interceptor> interceptors = getInterceptors(); if (interceptors != null) { for (Interceptor interceptor : interceptors) { serviceRouter.addInterceptor(interceptor); } if (logger.isInfoEnabled()) { logger.info("register total {} interceptors", interceptors.size()); } } // 注册监听器 ArrayList<RopEventListener> listeners = getListeners(); if (listeners != null) { for (RopEventListener listener : listeners) { serviceRouter.addListener(listener); } if (logger.isInfoEnabled()) { logger.info("register total {} listeners", listeners.size()); } } // 设置Spring上下文信息 serviceRouter.setApplicationContext(this.applicationContext); // 启动之 serviceRouter.startup(); }
/** {@inheritDoc} */ @Override @MethodLog public synchronized long registerPlatformIdent( List<String> definedIPs, String agentName, String version) throws BusinessException { if (log.isInfoEnabled()) { log.info("Trying to register Agent '" + agentName + "'"); } // find existing registered List<PlatformIdent> platformIdentResults; if (ipBasedAgentRegistration) { platformIdentResults = platformIdentDao.findByNameAndIps(agentName, definedIPs); } else { platformIdentResults = platformIdentDao.findByName(agentName); } PlatformIdent platformIdent = new PlatformIdent(); platformIdent.setAgentName(agentName); if (1 == platformIdentResults.size()) { platformIdent = platformIdentResults.get(0); } else if (platformIdentResults.size() > 1) { // this cannot occur anymore, if it occurs, then there is something totally wrong! log.error( "More than one platform ident has been retrieved! Please send your Database to the NovaTec inspectIT support!"); throw new BusinessException( "Register the agent with name " + agentName + " and following network interfaces " + definedIPs + ".", AgentManagementErrorCodeEnum.MORE_THAN_ONE_AGENT_REGISTERED); } // always update the time stamp and ips, no matter if this is an old or new record. platformIdent.setTimeStamp(new Timestamp(GregorianCalendar.getInstance().getTimeInMillis())); platformIdent.setDefinedIPs(definedIPs); // also always update the version information of the agent platformIdent.setVersion(version); platformIdentDao.saveOrUpdate(platformIdent); agentStatusDataProvider.registerConnected(platformIdent.getId()); if (log.isInfoEnabled()) { log.info( "Successfully registered the Agent '" + agentName + "' with id " + platformIdent.getId() + ", version " + version + " and following network interfaces:"); printOutDefinedIPs(definedIPs); } return platformIdent.getId(); }
@SuppressWarnings({"unchecked", "rawtypes"}) private void addEntity0(Object diagram, EntityType entity, Class<?> cacheId, boolean reload) { ICache<String, EntityType> cache; if (appName != null) { // add the customized entity. if (!appEntityCache.containsKey(cacheId)) { appEntityCache.put( cacheId, CacheManager.getInstance() .getCache(appName + "_" + cacheId.getName(), String.class, entity.getClass())); } cache = (ICache<String, EntityType>) appEntityCache.get(cacheId); } else { if (!sysEntityCache.containsKey(cacheId)) { throw new IllegalArgumentException( "Please register " + cacheId + " cache id before using it."); } cache = sysEntityCache.get(cacheId); } EntityType oldEntity = cache.putIfAbsent(entity.getEntityName(), entity); if (oldEntity != null) { if (reload) { if (logger.isInfoEnabled()) { logger.info("Reload this entity: " + entity.getEntityName()); } cache.put(entity.getEntityName(), entity); } else { logger.warn("Entity already existed: " + entity.getEntityName()); } for (IEntityEventListener<? extends EntityType, ?> listener : listeners) { if (listener.getEventType().isAssignableFrom(entity.getClass())) { EntityUpdatedEvent event = new EntityUpdatedEvent(diagram, oldEntity, entity); try { listener.notify(event); } catch (Throwable e) { logger.warn(e.getMessage(), e); } } } } else { if (logger.isInfoEnabled()) { logger.info("Added entity: " + entity.getEntityName()); } for (IEntityEventListener<? extends EntityType, ?> listener : listeners) { if (listener.getEventType().isAssignableFrom(entity.getClass())) { try { listener.notify(new EntityAddedEvent(diagram, entity)); } catch (Throwable e) { logger.warn(e.getMessage(), e); } } } } }
public void connect(String host, int port) throws Exception { // if (!this.connected.compareAndSet(false, true)) { return; } // if (isVerbose() && LOGGER.isInfoEnabled()) { LOGGER.info("connecting to host: {}, port: {}", host, port); } // this.socket = this.socketFactory.create(host, port); this.os = new TransportOutputStreamImpl(this.socket.getOutputStream()); if (this.level2BufferSize <= 0) { this.is = new TransportInputStreamImpl(this.socket.getInputStream(), this.level1BufferSize); } else { this.is = new TransportInputStreamImpl( new ActiveBufferedInputStream(this.socket.getInputStream(), this.level2BufferSize), this.level1BufferSize); } // final Packet packet = this.is.readPacket(); if (packet.getPacketBody()[0] == ErrorPacket.PACKET_MARKER) { final ErrorPacket error = ErrorPacket.valueOf(packet); LOGGER.info( "failed to connect to host: {}, port: {}, error", new Object[] {host, port, error}); throw new TransportException(error); } else { // final GreetingPacket greeting = GreetingPacket.valueOf(packet); this.context.setServerHost(host); this.context.setServerPort(port); this.context.setServerStatus(greeting.getServerStatus()); this.context.setServerVersion(greeting.getServerVersion().toString()); this.context.setServerCollation(greeting.getServerCollation()); this.context.setServerCapabilities(greeting.getServerCapabilities()); this.context.setThreadId(greeting.getThreadId()); this.context.setProtocolVersion(greeting.getProtocolVersion()); this.context.setScramble( greeting.getScramble1().toString() + greeting.getScramble2().toString()); // if (isVerbose() && LOGGER.isInfoEnabled()) { LOGGER.info( "connected to host: {}, port: {}, context: {}", new Object[] {host, port, this.context}); } } // this.authenticator.login(this); }
/** * @throws Exception * @see com.peigen.common.lang.ip.IPRepository#refreshData() */ public void refreshData() throws Exception { ipMap.clear(); starts.clear(); if (logger.isInfoEnabled()) { logger.info("手动更新IP库开始...."); } afterPropertiesSet(); if (logger.isInfoEnabled()) { logger.info("手动更新IP库完成"); } }
// must call this method once for destroying public void destroy() { if (log.isInfoEnabled()) { log.info("start to destroy " + this.getClass().getSimpleName()); } this.exec.shutdown(); if (log.isInfoEnabled()) { log.info("success to destroy " + this.getClass().getSimpleName()); } }
@Override public void stop() { if (logger.isInfoEnabled()) logger.info("Server stopping ..."); if (applicationContext != null) { try { applicationContext.destroy(); applicationContext = null; } catch (RuntimeException ex) { logger.error("Server stop failed", ex); throw ex; } } if (logger.isInfoEnabled()) logger.info("Server stopped"); }
/** * Send a packet to the multicast group. Messages have the form (name): msg * * @param message message */ public void sendToGroup(final String message) { try { if (LOG.isInfoEnabled()) { LOG.info(BUNDLE_MARKER, "Sending packet to group: " + message); } final DatagramPacket sendPacket = toDatagramPacket(message, groupAddress, GROUP_PORT); groupSocket.send(sendPacket); if (LOG.isInfoEnabled()) { LOG.info(BUNDLE_MARKER, "Packet sent to group: " + message); } } catch (IOException ioe) { LOG.error(BUNDLE_MARKER, "Failed to send packet: " + ioe.toString(), ioe); } }
public String dropKeyspace(final String keyspace) throws Exception { if (logger.isInfoEnabled()) logger.info("Dropping keyspace '{}'", keyspace); IManagerOperation<String> operation = new IManagerOperation<String>() { @Override public String execute(Client conn) throws Exception { return conn.system_drop_keyspace(keyspace); } }; String schemaVersion = tryOperation(operation); if (logger.isInfoEnabled()) logger.info("Dropped keyspace '{}', schema version is now '{}'", keyspace, schemaVersion); return schemaVersion; }
private void processIQ(IQ iq) { long start = System.currentTimeMillis(); Element childElement = iq.getChildElement(); String namespace = childElement.getNamespaceURI(); // 构造返回dom IQ reply = IQ.createResultIQ(iq); Element childElementCopy = childElement.createCopy(); reply.setChildElement(childElementCopy); if (XConstants.PROTOCOL_DISCO_INFO.equals(namespace)) { generateDisco(childElementCopy); // 构造disco反馈信息 if (LOG.isInfoEnabled()) { LOG.info( "[spend time:{}ms],reqId: {},IRComponent服务发现,response:{}", System.currentTimeMillis() - start, iq.getID(), reply.toXML()); } } try { ComponentManagerFactory.getComponentManager().sendPacket(this, reply); } catch (Throwable t) { LOG.error( "[spend time:{}ms],reqId: {},IRComponent IQ处理异常! iq:{},replay:{}", System.currentTimeMillis() - start, iq.getID(), reply.toXML(), t); } }
/** * 店铺一览 * * @param shop */ @OperationLog("根据条件查询店铺") @RequestMapping("/shop/list") @ResponseBody public JsonResult listShop(Shop shop, HttpServletRequest request) throws IOException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { if (log.isInfoEnabled()) { log.info("店铺:查询店铺一览," + shop); } Page page = PageFactory.getPage(request); // 查询店铺一览 shopService.findShop(page, shop); Shop dbShop = null; ShopVo shopVo = null; List<ShopVo> shopVoList = new ArrayList<ShopVo>(); for (Object object : page.getResult()) { dbShop = (Shop) object; shopVo = convertShopAndAuth2ShopVo(dbShop); if (shopVo != null) { shopVoList.add(shopVo); } } page.setResult(shopVoList); return new JsonResult(true).addObject(page); }
/** * 使用DataSource初始化SqlSessionFactory * * @param ds */ public static void initialize(DataSource ds) { TransactionFactory transactionFactory = new MybatisTransactionFactory(); Environment environment = new Environment("snaker", transactionFactory, ds); Configuration configuration = new Configuration(environment); configuration.getTypeAliasRegistry().registerAliases(SCAN_PACKAGE, Object.class); if (log.isInfoEnabled()) { Map<String, Class<?>> typeAliases = configuration.getTypeAliasRegistry().getTypeAliases(); for (Entry<String, Class<?>> entry : typeAliases.entrySet()) { log.info( "Scanned class:[name=" + entry.getKey() + ",class=" + entry.getValue().getName() + "]"); } } try { for (String resource : resources) { InputStream in = Resources.getResourceAsStream(resource); XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(in, configuration, resource, configuration.getSqlFragments()); xmlMapperBuilder.parse(); } } catch (Exception e) { e.printStackTrace(); } finally { ErrorContext.instance().reset(); } sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration); }
@Override @Deprecated public void info(String message, Throwable throwable) { if (logger.isInfoEnabled()) { logger.warn(message, throwable); } }
@Override public Qrcode httpQrcode(ReqTicket reqTicket, String scene) { Serializable sceneValue = reqTicket.generateScene(); String actionName = reqTicket.getActionName().toString(); Ticket ticket = weixinProxy.httpTicket(reqTicket); // 通过参数获取ticket String qrcodeUrl = String.format(QRCODE_URL, ticket.getTicket()); byte[] results = HttpClientUtil.httpGet(qrcodeUrl); Qrcode qrcode = new Qrcode(); qrcode.setTicketId(ticket.getId()); qrcode.setActionName(actionName); qrcode.setSceneValue(sceneValue.toString()); qrcode.setSceneType(sceneValue.getClass().getName()); qrcode.setName(weixinConfig.getName()); qrcode.setSuffix(weixinConfig.getSuffix()); qrcode.setBytes(results); qrcode.setSceneName(scene); if (log.isInfoEnabled()) { log.info( "返回二维码信息:{}", JSON.toJSONString( qrcode, SerializerFeature.PrettyFormat, SerializerFeature.WriteClassName)); } return qrcode; }
@Override public <T> List<T> lookupAll(Class<T> clazz) throws LookupFailedException { ServiceTemplate template = new ServiceTemplate(null, new Class[] {clazz}, null); List<T> list = new ArrayList<T>(); for (ServiceRegistrar serviceRegistrar : discovery.getRegistrars()) { try { T t = (T) serviceRegistrar.lookup(template); if (t != null) { list.add(t); } } catch (RemoteException e) { if (LOG.isErrorEnabled()) { LOG.error( String.format("Exception occured while looking up service of class [%s].", clazz), e); } } } if (list.isEmpty()) { if (LOG.isInfoEnabled()) { LOG.info(String.format("Lookup found no services of class [%s].", clazz)); } throw new LookupFailedException("No such services found!"); } return list; }
/** * 删除方法 * * @param id */ @Transactional public void deleteOriginalOrder(Integer id) { if (logger.isInfoEnabled()) { logger.info("deleteOriginalOrder方法参数为id[{}]", id); } generalDAO.removeById(OriginalOrder.class, id); }
/** * Fetches data from Steam Web API using the specified interface, method and version. Additional * parameters are supplied via HTTP GET. Data is returned as a String in the given format. * * @param apiInterface The Web API interface to call, e.g. <code>ISteamUser</code> * @param format The format to load from the API ("json", "vdf", or "xml") * @param method The Web API method to call, e.g. <code>GetPlayerSummaries</code> * @param params Additional parameters to supply via HTTP GET * @param version The API method version to use * @return Data is returned as a String in the given format (which may be "json", "vdf", or * "xml"). * @throws WebApiException In case of any request failure */ public static String load( String format, String apiInterface, String method, int version, Map<String, Object> params) throws WebApiException { String protocol = secure ? "https" : "http"; String url = String.format( "%s://api.steampowered.com/%s/%s/v%04d/?", protocol, apiInterface, method, version); if (params == null) { params = new HashMap<String, Object>(); } params.put("format", format); if (apiKey != null) { params.put("key", apiKey); } boolean first = true; for (Map.Entry<String, Object> param : params.entrySet()) { if (first) { first = false; } else { url += '&'; } url += String.format("%s=%s", param.getKey(), param.getValue()); } if (LOG.isInfoEnabled()) { String debugUrl = (apiKey == null) ? url : url.replace(apiKey, "SECRET"); LOG.info("Querying Steam Web API: " + debugUrl); } String data; try { DefaultHttpClient httpClient = new DefaultHttpClient(); httpClient.getParams().setBooleanParameter(ClientPNames.HANDLE_AUTHENTICATION, false); HttpGet request = new HttpGet(url); HttpResponse response = httpClient.execute(request); Integer statusCode = response.getStatusLine().getStatusCode(); if (!statusCode.toString().startsWith("20")) { if (statusCode == 401) { throw new WebApiException(WebApiException.Cause.UNAUTHORIZED); } throw new WebApiException( WebApiException.Cause.HTTP_ERROR, statusCode, response.getStatusLine().getReasonPhrase()); } data = EntityUtils.toString(response.getEntity()); } catch (WebApiException e) { throw e; } catch (Exception e) { throw new WebApiException("Could not communicate with the Web API.", e); } return data; }