1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.server.core.api.event; 21 22 import org.apache.directory.api.ldap.model.schema.SchemaManager; 23 24 /** 25 * Entry for a {@link DirectoryListener} in the {@link EventService}. 26 * 27 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 28 */ 29 public class RegistrationEntry 30 { 31 /** The associated listener */ 32 private final DirectoryListener listener; 33 34 /** The notification criteria */ 35 private final NotificationCriteria criteria; 36 37 38 /** 39 * Creates a new instance of RegistrationEntry associated with a listener 40 * @param listener The associated listener 41 */ 42 RegistrationEntry( SchemaManager schemaManager, DirectoryListener listener ) 43 { 44 this( listener, new NotificationCriteria( schemaManager ) ); 45 } 46 47 48 /** 49 * Creates a new instance of RegistrationEntry associated with a listener 50 * and a notification criteria 51 * @param listener The associated listener 52 * @param criteria The notification criteria 53 */ 54 public RegistrationEntry( DirectoryListener listener, NotificationCriteria criteria ) 55 { 56 this.listener = listener; 57 this.criteria = criteria; 58 } 59 60 61 /** 62 * @return the criteria 63 */ 64 public NotificationCriteria getCriteria() 65 { 66 return criteria; 67 } 68 69 70 /** 71 * @return the listener 72 */ 73 public DirectoryListener getListener() 74 { 75 return listener; 76 } 77 78 79 /** 80 * {@inheritDoc} 81 */ 82 public String toString() 83 { 84 StringBuilder sb = new StringBuilder(); 85 86 sb.append( listener ).append( '/' ); 87 88 if ( criteria != null ) 89 { 90 sb.append( criteria.toString() ); 91 } 92 93 return sb.toString(); 94 } 95 }