public boolean isCommitEnabled() { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); return mgr.isCommitValveEnabled(); }
protected void logError(Exception e) { if (getManager() != null) { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); mgr.getLogger().error(e); } }
private void checkBackingCacheAvailable() { if (!((SessionManager) getManager()).isBackingCacheAvailable()) { throw new IllegalStateException("No backing cache server is available."); } }
protected byte[] serialize(Object obj) { byte[] serializedValue = null; try { serializedValue = BlobHelper.serializeToBlob(obj); } catch (IOException e) { StringBuilder builder = new StringBuilder(); builder.append(this).append(": Object ").append(obj) .append(" cannot be serialized due to the following exception"); ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e); } return serializedValue; }
@Override public void setPrincipal(Principal principal) { super.setPrincipal(principal); // Put the session into the region to serialize the principal if (getManager() != null) { // TODO convert this to a delta getManager().add(this); DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Cached principal: " + principal); // mgr.logCurrentStack(); } } }
@Override public void invalidate() { super.invalidate(); // getOperatingRegion().destroy(this.id, true); // already done in super (remove) ((DeltaSessionManager) getManager()).getStatistics().incSessionsInvalidated(); }
@Override public Object getAttribute(String name) { checkBackingCacheAvailable(); Object value = super.getAttribute(name); // If the attribute is a byte[] (meaning it came from the server), // deserialize it and add it to attributes map before returning it. if (value instanceof byte[]) { try { value = BlobHelper.deserializeBlob((byte[]) value); } catch (Exception e) { StringBuilder builder = new StringBuilder(); builder.append(this).append(": Attribute named ").append(name).append( " contains a byte[] that cannot be deserialized due to the following exception"); ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e); } if (this.preferDeserializedForm) { localUpdateAttribute(name, value); } } // Touch the session region if necessary. This is an asynchronous operation // that prevents the session region from prematurely expiring a session that // is only getting attributes. ((DeltaSessionManager) getManager()).addSessionToTouch(getId()); return value; }
@Override public Principal getPrincipal() { if (this.principal == null && this.serializedPrincipal != null) { SerializablePrincipal sp = null; try { sp = (SerializablePrincipal) BlobHelper.deserializeBlob(this.serializedPrincipal); } catch (Exception e) { StringBuilder builder = new StringBuilder(); builder.append(this).append( ": Serialized principal contains a byte[] that cannot be deserialized due to the following exception"); ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e); return null; } this.principal = sp.getPrincipal(((DeltaSessionManager) this.manager).getTheContext().getRealm()); if (getManager() != null) { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Deserialized principal: " + this.principal); // mgr.logCurrentStack(); } } } return this.principal; }
@Override public void processExpired() { DeltaSessionManager manager = (DeltaSessionManager) getManager(); if (manager != null && manager.getLogger() != null && manager.getLogger().isDebugEnabled()) { ((DeltaSessionManager) getManager()).getLogger().debug(this + ": Expired"); } // Set expired (so region.destroy is not called again) setExpired(true); // Do expire processing super.expire(true); // Update statistics if (manager != null) { manager.getStatistics().incSessionsExpired(); } }
private byte[] getSerializedPrincipal() { if (this.serializedPrincipal == null) { if (this.principal != null && this.principal instanceof GenericPrincipal) { GenericPrincipal gp = (GenericPrincipal) this.principal; SerializablePrincipal sp = SerializablePrincipal.createPrincipal(gp); this.serializedPrincipal = serialize(sp); if (manager != null) { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Serialized principal: " + sp); // mgr.logCurrentStack(); } } } } return this.serializedPrincipal; }
private void checkBackingCacheAvailable() { if (!((SessionManager) getManager()).isBackingCacheAvailable()) { throw new IllegalStateException("No backing cache server is available."); } }
public boolean isCommitEnabled() { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); return mgr.isCommitValveEnabled(); }
protected byte[] serialize(Object obj) { byte[] serializedValue = null; try { serializedValue = BlobHelper.serializeToBlob(obj); } catch (IOException e) { StringBuilder builder = new StringBuilder(); builder.append(this).append(": Object ").append(obj) .append(" cannot be serialized due to the following exception"); ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e); } return serializedValue; }
public void setPrincipal(Principal principal) { super.setPrincipal(principal); // Put the session into the region to serialize the principal if (getManager() != null) { // TODO convert this to a delta getManager().add(this); DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Cached principal: " + principal); // mgr.logCurrentStack(); } } }
public void invalidate() { super.invalidate(); // getOperatingRegion().destroy(this.id, true); // already done in super (remove) ((DeltaSessionManager) getManager()).getStatistics().incSessionsInvalidated(); }
public Object getAttribute(String name) { checkBackingCacheAvailable(); Object value = super.getAttribute(name); // If the attribute is a byte[] (meaning it came from the server), // deserialize it and add it to attributes map before returning it. if (value instanceof byte[]) { try { value = BlobHelper.deserializeBlob((byte[]) value); } catch (Exception e) { StringBuilder builder = new StringBuilder(); builder.append(this).append(": Attribute named ").append(name).append( " contains a byte[] that cannot be deserialized due to the following exception"); ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e); } if (this.preferDeserializedForm) { localUpdateAttribute(name, value); } } // Touch the session region if necessary. This is an asynchronous operation // that prevents the session region from prematurely expiring a session that // is only getting attributes. ((DeltaSessionManager) getManager()).addSessionToTouch(getId()); return value; }
public Principal getPrincipal() { if (this.principal == null && this.serializedPrincipal != null) { SerializablePrincipal sp = null; try { sp = (SerializablePrincipal) BlobHelper.deserializeBlob(this.serializedPrincipal); } catch (Exception e) { StringBuilder builder = new StringBuilder(); builder.append(this).append( ": Serialized principal contains a byte[] that cannot be deserialized due to the following exception"); ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e); return null; } this.principal = sp.getPrincipal(((DeltaSessionManager) this.manager).getTheContext().getRealm()); if (getManager() != null) { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Deserialized principal: " + this.principal); // mgr.logCurrentStack(); } } } return this.principal; }
public void processExpired() { DeltaSessionManager manager = (DeltaSessionManager) getManager(); if (manager != null && manager.getLogger() != null && manager.getLogger().isDebugEnabled()) { ((DeltaSessionManager) getManager()).getLogger().debug(this + ": Expired"); } // Set expired (so region.destroy is not called again) setExpired(true); // Do expire processing super.expire(true); // Update statistics if (manager != null) { manager.getStatistics().incSessionsExpired(); } }
private byte[] getSerializedPrincipal() { if (this.serializedPrincipal == null) { if (this.principal != null && this.principal instanceof GenericPrincipal) { GenericPrincipal gp = (GenericPrincipal) this.principal; SerializablePrincipal sp = SerializablePrincipal.createPrincipal(gp); this.serializedPrincipal = serialize(sp); if (manager != null) { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Serialized principal: " + sp); // mgr.logCurrentStack(); } } } } return this.serializedPrincipal; }