001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.server.core.api.event; 021 022import org.apache.directory.api.ldap.model.schema.SchemaManager; 023 024/** 025 * Entry for a {@link DirectoryListener} in the {@link EventService}. 026 * 027 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 028 */ 029public class RegistrationEntry 030{ 031 /** The associated listener */ 032 private final DirectoryListener listener; 033 034 /** The notification criteria */ 035 private final NotificationCriteria criteria; 036 037 038 /** 039 * Creates a new instance of RegistrationEntry associated with a listener 040 * @param listener The associated listener 041 */ 042 RegistrationEntry( SchemaManager schemaManager, DirectoryListener listener ) 043 { 044 this( listener, new NotificationCriteria( schemaManager ) ); 045 } 046 047 048 /** 049 * Creates a new instance of RegistrationEntry associated with a listener 050 * and a notification criteria 051 * @param listener The associated listener 052 * @param criteria The notification criteria 053 */ 054 public RegistrationEntry( DirectoryListener listener, NotificationCriteria criteria ) 055 { 056 this.listener = listener; 057 this.criteria = criteria; 058 } 059 060 061 /** 062 * @return the criteria 063 */ 064 public NotificationCriteria getCriteria() 065 { 066 return criteria; 067 } 068 069 070 /** 071 * @return the listener 072 */ 073 public DirectoryListener getListener() 074 { 075 return listener; 076 } 077 078 079 /** 080 * {@inheritDoc} 081 */ 082 public String toString() 083 { 084 StringBuilder sb = new StringBuilder(); 085 086 sb.append( listener ).append( '/' ); 087 088 if ( criteria != null ) 089 { 090 sb.append( criteria.toString() ); 091 } 092 093 return sb.toString(); 094 } 095}