Examples of Attributes


Examples of javax.util.jcache.Attributes

     */
    public void resetAttributes(Object name, Attributes attributes) {
        if (!isValid()) {
            return;
        }
        Attributes att = CacheImpl.getCache(true).getRegion(name).getAttributes();
        att.reset();
        att.applyAttributes(attributes);
    }
View Full Code Here

Examples of javax.util.jcache.Attributes

     *         it is not initialized, or it is unavailable.
     */
    public void defineRegion(final String name)
        throws ObjectExistsException, NullObjectNameException,
            CacheNotAvailableException {
        Attributes att = CacheAccessFactory.getInstance().getDefaultAttributes();
        defineRegion(name, att);
    }
View Full Code Here

Examples of javax.util.jcache.Attributes

     */
    public void defineRegion(final String name, final Attributes attributes)
        throws ObjectExistsException, NullObjectNameException,
            CacheNotAvailableException {
    CacheImpl cache = CacheImpl.getCache(true);
    Attributes lAttribs=attributes;
    if(lAttribs==null) lAttribs=CacheAccessFactory.getInstance().getDefaultAttributes();
    cache.addRegion(name, lAttribs);
    }
View Full Code Here

Examples of javax.util.jcache.Attributes

            return true;
        }
        return false;
    }
  private boolean hasExpired(CacheObject obj) throws NullObjectException {
    Attributes attributes = obj.getAttributes();
    if(attributes==null) throw new NullObjectException("A null attributes was detected.");
    /*-1 is the default for attributes, and the default is
     * non invalidation, so if the ttl is -1, the objects remains in the cache.
     */

    if(attributes.getTimeToLive()==-1) {
      return false;
    }
    if(attributes.getLoader()!=null) return false;
    long now = System.currentTimeMillis();
    long timealive = (now - attributes.getCreateTime()) / 1000;

    //only ttl is support for now. the rest of the params can be implemented later.
    if (timealive >= attributes.getTimeToLive()) {
      return true;
    }
    return false;
  }
View Full Code Here

Examples of javax.util.jcache.Attributes

    private CacheObjectInfoImpl impl;
    private static final long TTL = 5;
   
    protected void setUp() throws Exception {
        testObj = new CacheObject("key", "value", new CacheGroup("group"), new CacheRegion("name", new AttributesImpl()), null);
       Attributes att = CacheAccessFactory.getInstance().getDefaultAttributes();
       att.setTimeToLive(TTL);
        testObj.setAttributes(att);
        impl = new CacheObjectInfoImpl(testObj);
       
    }
View Full Code Here

Examples of javax.util.jcache.Attributes

    }

    public final void testGetExpire() throws ParseException {
        SimpleDateFormat form = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
       
        Attributes att = testObj.getAttributes();
        //TTL in seconds
        long ttl = att.getTimeToLive();
        //createtime in millis
        long createTime = att.getCreateTime();
        //expiry is in second precision, lets round ouf our own.
        long expire = form.parse(impl.getExpire()).getTime();
        long expectedExpiry = form.parse(form.format(new Date((ttl*1000)+createTime))).getTime();
        assertEquals(expectedExpiry, expire);
        //check that objects which never expire, never expire....
        CacheObject obj = new CacheObject("key", "value", null, null, null);
        Attributes att1 = CacheAccessFactory.getInstance().getDefaultAttributes();
        obj.setAttributes(att1);
        CacheObjectInfoImpl imp = new CacheObjectInfoImpl(obj);
        assertEquals(CacheObjectInfo.NEVER_EXPIRES, imp.getExpire());
       
    }
View Full Code Here

Examples of javolution.xml.sax.Attributes

        readAttributes( input, obj );
        readElements( input, obj );
    }

    private void readAttributes( final javolution.xml.XMLFormat.InputElement input, final T obj ) throws XMLStreamException {
        final Attributes attributes = input.getAttributes();
        for ( int i = 0; i < attributes.getLength(); i++ ) {
            final CharArray name = attributes.getLocalName( i );
            if ( !name.equals( "class" ) && !name.equals( JavolutionTranscoder.REFERENCE_ATTRIBUTE_ID ) ) {
                final Field field = _attributesMap.get( name.toString() );
                if ( field != null ) {
                    setFieldFromAttribute( obj, field, input );
                } else {
                    LOG.warn( "Did not find field " + name + ", attribute value is " + attributes.getValue( i ) );
                }
            }
        }
    }
View Full Code Here

Examples of marauroa.common.game.Attributes

  /**
   * @throws ParseException
   */
  @Test(expected=ParseException.class)
  public void testParseFail() throws ParseException {
    Attributes attributes = new Attributes(RPClass.getBaseRPObjectDefault());
    AttributesParser parser = new AttributesParser(": [a=b][c=d", attributes);
    parser.parse();
  }
View Full Code Here

Examples of name.abuchen.portfolio.model.Attributes

    }

    @Override
    public Object getValue(Object element) throws Exception
    {
        Attributes attribs = Adaptor.adapt(Attributable.class, element).getAttributes();
        return attribute.getConverter().toString(attribs.get(attribute));
    }
View Full Code Here

Examples of net.htmlparser.jericho.Attributes

        Source source = new Source(previousOut);
        OutputDocument document = new OutputDocument(source);
        StringBuilder sb = new StringBuilder();
        List<StartTag> linkStartTags = source.getAllStartTags(HTMLElementName.LINK);
        for (StartTag linkTag : linkStartTags) {
            Attributes attributes = linkTag.getAttributes();
            String rel = attributes.getValue("rel");
            if (rel == null || !"stylesheet".equalsIgnoreCase(rel)) {
                continue;
            }
            String href = attributes.getValue("href");
            if (href == null) {
                continue;
            }
            String styleSheetContent = null;
            try {
                if (useServletContextResources || request == null || response == null) {
                    if (request != null && StringUtils.startsWith(href, request.getContextPath())) {
                        href = StringUtils.substringAfter(href, request.getContextPath());
                    }                   
                    styleSheetContent = httpClientService.getResourceAsString(href);
                } else {
                    styleSheetContent = httpClientService.getResourceAsString(href, request, response);
                }
            } catch (Exception e) {
                logger.warn("Unable to retrieve resource content for " + href + ".Cause: " + e.getMessage(), e);
            }

            if (StringUtils.isNotEmpty(styleSheetContent)) {
                sb.setLength(0);
                sb.append("<style");
                Attribute typeAttribute = attributes.get("type");
                if (typeAttribute != null) {
                    sb.append(' ').append(typeAttribute);
                }
                if (rewriteUrlsInCss) {
                    String baseUrl = HttpClientService.isAbsoluteUrl(href) ? href : serverUrl + href;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.