001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bstefanescu 018 */ 019package org.nuxeo.ecm.core.event.impl; 020 021import org.nuxeo.ecm.core.api.CoreSession; 022import org.nuxeo.ecm.core.api.NuxeoPrincipal; 023 024/** 025 * Default implementation 026 * 027 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 028 */ 029public class EventContextImpl extends AbstractEventContext { 030 031 private static final long serialVersionUID = 1L; 032 033 protected transient CoreSession session; 034 035 protected NuxeoPrincipal principal; 036 037 /** 038 * Constructor to be used by derived classes 039 */ 040 protected EventContextImpl() { 041 } 042 043 public EventContextImpl(Object... args) { 044 this(null, null, args); 045 } 046 047 public EventContextImpl(CoreSession session, NuxeoPrincipal principal, Object... args) { 048 super(args); 049 this.session = session; 050 this.principal = principal; 051 updateRepositoryName(); 052 } 053 054 public EventContextImpl(CoreSession session, NuxeoPrincipal principal) { 055 this.session = session; 056 this.principal = principal; 057 args = EMPTY; 058 updateRepositoryName(); 059 } 060 061 public void setArgs(Object[] args) { 062 this.args = args; 063 } 064 065 @Override 066 public CoreSession getCoreSession() { 067 return session; 068 } 069 070 @Override 071 public NuxeoPrincipal getPrincipal() { 072 return principal; 073 } 074 075 @Override 076 public void setCoreSession(CoreSession session) { 077 this.session = session; 078 updateRepositoryName(); 079 } 080 081 protected void updateRepositoryName() { 082 if (session != null) { 083 repositoryName = session.getRepositoryName(); 084 } 085 } 086 087 @Override 088 public void setPrincipal(NuxeoPrincipal principal) { 089 this.principal = principal; 090 } 091 092}