List of usage examples for java.lang Long longValue
@HotSpotIntrinsicCandidate public long longValue()
From source file:org.apache.niolex.config.service.impl.GroupServiceImpl.java
/** * Override super method/*from w ww .j a v a 2 s.c o m*/ * @see org.apache.niolex.config.service.GroupService#cliSyncGroup(org.apache.niolex.config.bean.SyncBean, org.apache.niolex.network.IPacketWriter) */ @Override public void cliSyncGroup(SyncBean bean, IPacketWriter wt) { String groupName = bean.getGroupName(); ConfigGroup group = storage.get(groupName); if (group != null) { // Authenticate Group Read. if (service.hasReadAuth(group, wt)) { Map<String, Long> groupData = bean.getGroupData(); for (ConfigItem item : group.getGroupData().values()) { Long time = groupData.get(item.getKey()); if (time == null || time.longValue() < item.getUpdateTime()) { // This item is new at server side, so dispatch it. wt.handleWrite(PacketTranslater.translate(item)); } } } else { // Has no right to read this group. wt.handleWrite(new PacketData(CodeMap.GROUP_NOA, groupName)); } } else { // Group not found. wt.handleWrite(new PacketData(CodeMap.GROUP_NOF, groupName)); } }
From source file:org.matsim.analysis.IterationStopWatch.java
/** * Formats the time given in milliseconds (e.g. returned by {@link java.lang.System#currentTimeMillis()} * nicely for output./*from w ww . j av a2 s . c om*/ * * @param millis A time value in milliseconds * @return A String containing the formatted time, or an empty String if <code>millis</code> is null */ private String formatMilliTime(final Long millis) { if (millis == null) { return ""; } return this.formatter.format(new Date(millis.longValue())); }
From source file:com.netpace.aims.controller.application.WapApplicationHelper.java
public static boolean checkDeleteAccess(String currUserType, Long aimsLifecyclePhaseId) { if (currUserType.equals(AimsConstants.ALLIANCE_USERTYPE)) { if ((aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_INITIAL_APPROVAL_ID.longValue()) || (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_INITIAL_DENIED_ID.longValue()) || (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_BUSINESS_APPROVAL_GRANTED_ID .longValue())//from ww w . j av a 2 s .c om || (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_BUSINESS_APPROVAL_DENIED_ID .longValue()) || (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_PENDING_DCR_ID.longValue()) || (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_PENDING_ARM_ID.longValue()) || (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_SUBMITTED_DCR_ID.longValue()) || (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_TESTING_PASSED_ID.longValue()) || (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_TESTING_FAILED_ID.longValue()) || (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_PUBLICATION_READY_ID.longValue()) || (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_COMPLETED_IN_PRODUCTION_ID .longValue()) || (aimsLifecyclePhaseId.longValue() == AimsConstants.SUNSET_ID.longValue())) return false; else return true; } else return true; }
From source file:com.springsource.hq.plugin.tcserver.plugin.TomcatMeasurementPlugin.java
private long getTotalGarbageCollectionTime(MBeanServerConnection connection) throws MetricUnreachableException, MetricNotFoundException, PluginException { long totalGcTimeMillis = 0; try {/*from w w w. j a va 2s . c o m*/ // Use of the MXBean replaced by plain old JMX query for TCS-71 // // Set<ObjectName> garbageCollectors = connection.queryNames( // new ObjectName("java.lang:type=GarbageCollector,*"), null); // for (ObjectName garbageCollectorName : garbageCollectors) { // GarbageCollectorMXBean garbageCollector = getGarbageCollectorMXBean( // connection, garbageCollectorName); // long collectionTime = garbageCollector.getCollectionTime(); ObjectName gcObjName = new ObjectName("java.lang:type=GarbageCollector,*"); Set<ObjectInstance> garbageCollectors = connection.queryMBeans(gcObjName, null); for (ObjectInstance instance : garbageCollectors) { ObjectName instanceName = instance.getObjectName(); Long l = (Long) connection.getAttribute(instance.getObjectName(), "CollectionTime"); long collectionTime = l.longValue(); LOGGER.debug(instanceName + "::CollectionTime=" + collectionTime); if (collectionTime > -1) { totalGcTimeMillis += collectionTime; } } } catch (MalformedObjectNameException e) { throw new MetricInvalidException("Error querying for GarbageCollector MBeans: " + e.getMessage(), e); } catch (IOException e) { throw new MetricUnreachableException("Error querying for GarbageCollector MBeans:" + e.getMessage(), e); } catch (AttributeNotFoundException e) { throw new MetricNotFoundException("Error querying for GarbageCollector MBeans:" + e.getMessage(), e); } catch (InstanceNotFoundException e) { throw new MetricNotFoundException("Error querying for GarbageCollector MBeans:" + e.getMessage(), e); } catch (MBeanException e) { throw new PluginException("Error querying for GarbageCollector MBeans:" + e.getMessage(), e); } catch (ReflectionException e) { throw new PluginException("Error querying for GarbageCollector MBeans:" + e.getMessage(), e); } catch (NullPointerException e) { throw new PluginException("Error querying for GarbageCollector MBeans:" + e.getMessage(), e); } return totalGcTimeMillis; }
From source file:com.android.vending.licensing.i.java
private void a(String paramString) { try {//from w w w.ja v a2 s .co m Long localLong2 = Long.valueOf(Long.parseLong(paramString)); localLong1 = localLong2; this.m = localLong1.longValue(); this.s.a("validityTimestamp", paramString); return; } catch (NumberFormatException localNumberFormatException) { while (true) { Log.w("ServerManagedPolicy", "License validity timestamp (VT) missing, caching for a minute"); Long localLong1 = Long.valueOf(60000L + System.currentTimeMillis()); paramString = Long.toString(localLong1.longValue()); } } }
From source file:com.redhat.rhn.domain.errata.ErrataFactory.java
/** * Lookup ErrataFiles by errata and file type * @param errataId errata id//from w w w.ja v a 2s. co m * @param fileType file type label * @return list of ErrataFile instances */ public static List lookupErrataFilesByErrataAndFileType(Long errataId, String fileType) { Session session = null; List retval = null; try { session = HibernateFactory.getSession(); Query q = session.getNamedQuery("PublishedErrataFile.listByErrataAndFileType"); q.setLong("errata_id", errataId.longValue()); q.setString("file_type", fileType.toUpperCase()); retval = q.list(); if (retval == null) { q = session.getNamedQuery("UnpublishedErrataFile.listByErrataAndFileType"); q.setLong("errata_id", errataId.longValue()); q.setString("file_type", fileType.toUpperCase()); retval = q.list(); } } catch (HibernateException e) { throw new HibernateRuntimeException(e.getMessage(), e); } return retval; }
From source file:com.vportal.portal.servlet.PortalSessionListener.java
public void sessionDestroyed(HttpSessionEvent event) { /*if (PropsValues.SESSION_DISABLED) { return;//from w ww .j av a2s.c o m }*/ //hoan if (GetterUtil.getBoolean(PropsUtil.get("SESSION_DISABLED"))) { return; } //hoan HttpSession ses = event.getSession(); MethodKey method = new MethodKey("com.liferay.portal.kernel.util.Validator.PortalSessionContext", "remove", String.class); Object[] args = new Object[] { ses.getId() }; try { PortalClassInvoker.invoke(false, method, args); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //PortalSessionContext.remove(ses.getId()); try { Long userIdObj = (Long) ses.getAttribute(WebKeys.USER_ID); if (userIdObj == null) { _log.warn("User id is not in the session"); } else { long userId = userIdObj.longValue(); if (CompanyThreadLocal.getCompanyId() == 0) { setCompanyId(userId); } //MailSessionLock.cleanUp(ses); MethodKey methodSignOut = new MethodKey("com.liferay.portal.liveusers.LiveUsers", "signOut", long.class, String.class, String.class); Object[] argsSignOut = new Object[] { CompanyThreadLocal.getCompanyId(), userId, ses.getId() }; PortalClassInvoker.invoke(false, methodSignOut, argsSignOut); //LiveUsers.signOut(CompanyThreadLocal.getCompanyId(), userId, ses.getId()); } } catch (IllegalStateException ise) { _log.warn("Please upgrade to a servlet 2.4 compliant container"); } catch (Exception e) { _log.error(e, e); } //ses.removeAttribute(WebKeys.PORTLET_SESSION_TRACKER); //ses.removeAttribute(WebKeys.REVERSE_AJAX); //MessagingUtil.closeXMPPConnection(ses); // Process session destroyed events try { /*EventsProcessor.process( PropsKeys.SERVLET_SESSION_DESTROY_EVENTS, PropsValues.SERVLET_SESSION_DESTROY_EVENTS, ses);*/ //hoan MethodKey methodProcess = new MethodKey("com.liferay.portal.events.EventsProcessorUtil", "process", String.class, String.class, HttpSession.class); Object[] argsProcess = new Object[] { PropsKeys.SERVLET_SESSION_DESTROY_EVENTS, PropsUtil.getArray(PropsKeys.SERVLET_SESSION_DESTROY_EVENTS), ses }; PortalClassInvoker.invoke(false, methodProcess, argsProcess); /*EventsProcessorUtil.process( PropsKeys.SERVLET_SESSION_DESTROY_EVENTS, PropsValues.SERVLET_SESSION_DESTROY_EVENTS, ses);*/ //hoan } catch (ActionException ae) { _log.error(ae, ae); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.redhat.rhn.frontend.action.systems.monitoring.ProbeGraphAction.java
/** {@inheritDoc} */ public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest req, HttpServletResponse resp) throws Exception { RequestContext rctx = new RequestContext(req); Probe probe = rctx.lookupProbe();/*from ww w. j a va2 s . c om*/ String[] metrics = req.getParameterValues(METRICS); Long start = rctx.getParamAsLong(STARTTS); Long end = rctx.getParamAsLong(ENDTS); if (start == null || end == null) { log.debug("No start or end date passed into execute()"); return null; } Timestamp startts = new Timestamp(start.longValue()); Timestamp endts = new Timestamp(end.longValue()); List tsdList = MonitoringManager.getInstance().getProbeDataList(probe, metrics, startts, endts); if (rctx.isRequestedExport()) { writeExport(tsdList, resp, metrics, rctx.getCurrentUser().getCsvSeparator()); } else { writeGraph(tsdList, resp, req, metrics, startts, endts); } return null; }
From source file:grails.plugin.cache.redis.GrailsRedisCache.java
/** * Constructor.//from ww w . j a v a2s . c o m * * @param name cache name * @param prefix * @param cachePrefix */ public GrailsRedisCache(String name, byte[] prefix, RedisTemplate<? extends Object, ? extends Object> template, Long ttl) { Assert.hasText(name, "non-empty cache name is required"); this.name = name; this.template = template; this.prefix = prefix; this.ttl = ttl == null ? NEVER_EXPIRE : ttl.longValue(); StringRedisSerializer stringSerializer = new StringRedisSerializer(); // name of the set holding the keys setName = stringSerializer.serialize(name + "~keys"); cacheLockName = stringSerializer.serialize(name + "~lock"); }
From source file:org.focusns.web.console.cms.ArticleConsoleWidget.java
@RequestMapping("/article-list") public String doList(@RequestParam(required = false) Long categoryId, Model model) { ////from w ww .j a va2s. co m List<BlogCategory> articleCategories = blogCategoryService.getBlogCategories(); if (!articleCategories.isEmpty()) { BlogCategory articleCategory = articleCategories.get(0); if (categoryId != null) { for (BlogCategory tmp : articleCategories) { if (categoryId.longValue() == tmp.getId()) { articleCategory = tmp; } } } // Page<BlogPost> page = new Page<BlogPost>(10); page = blogPostService.fetchPageByCategoryId(page, 0, articleCategory.getId()); // model.addAttribute("articleCategories", articleCategories); model.addAttribute("articleCategory", articleCategory); model.addAttribute("page", page); } // return "console/cms/article-list"; }