001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Nuxeo - initial API and implementation 011 * 012 * $Id$ 013 */ 014 015package org.nuxeo.ecm.core.event.impl; 016 017import java.io.Serializable; 018import java.security.Principal; 019import java.util.Map; 020 021import org.nuxeo.ecm.core.api.CoreSession; 022import org.nuxeo.ecm.core.event.Event; 023 024/** 025 * Minimal eventContext implementation that can be used for events that are not bound to a CoreSession. 026 * 027 * @author Thierry Delprat 028 */ 029public class InlineEventContext extends EventContextImpl { 030 031 private static final long serialVersionUID = 1L; 032 033 protected boolean boundToCoreSession = false; 034 035 public InlineEventContext(Principal principal, Map<String, Serializable> properties) { 036 this(null, principal, properties); 037 } 038 039 public InlineEventContext(CoreSession session, Principal principal, Map<String, Serializable> properties) { 040 super(session, principal); 041 setProperties(properties); 042 boundToCoreSession = session != null; 043 } 044 045 @Override 046 public Event newEvent(String name) { 047 int flags = boundToCoreSession ? Event.FLAG_NONE : Event.FLAG_INLINE; 048 return newEvent(name, flags); 049 } 050 051}