1 15 package org.apache.hivemind.impl; 16 17 import org.apache.commons.logging.Log; 18 import org.apache.commons.logging.LogFactory; 19 import org.apache.hivemind.ErrorLog; 20 import org.apache.hivemind.Location; 21 import org.apache.hivemind.definition.ExtensionPointDefinition; 22 import org.apache.hivemind.definition.Visibility; 23 import org.apache.hivemind.internal.ExtensionPoint; 24 import org.apache.hivemind.internal.Module; 25 import org.apache.hivemind.util.ToStringBuilder; 26 27 32 35 public abstract class AbstractExtensionPoint extends BaseLocatable implements ExtensionPoint 36 { 37 private ExtensionPointDefinition _definition; 38 39 private Module _module; 40 41 42 43 private ErrorLog _errorLog; 44 45 48 public AbstractExtensionPoint(Module module, ExtensionPointDefinition definition) 49 { 50 _module = module; 51 _definition = definition; 52 } 53 54 public synchronized String toString() 55 { 56 ToStringBuilder builder = new ToStringBuilder(this); 57 builder.append("extensionPointId", getExtensionPointId()); 58 builder.append("visibility", getVisibility()); 59 60 extendDescription(builder); 61 62 return builder.toString(); 63 } 64 65 68 protected abstract void extendDescription(ToStringBuilder builder); 69 70 public Visibility getVisibility() 71 { 72 return _definition.getVisibility(); 73 } 74 75 public Location getLocation() 76 { 77 return _definition.getLocation(); 78 } 79 80 public String getExtensionPointId() 81 { 82 return _module.getModuleId() + "." + _definition.getId(); 83 } 84 85 public Module getModule() 86 { 87 return _module; 88 } 89 90 99 public boolean visibleToModule(Module module) 100 { 101 if (getVisibility() == Visibility.PUBLIC) 102 return true; 103 104 return _module.equals(module); 105 } 106 107 108 public Log getLog() 109 { 110 return LogFactory.getLog(getExtensionPointId()); 111 } 112 113 114 public synchronized ErrorLog getErrorLog() 115 { 116 if (_errorLog == null) 117 _errorLog = new ErrorLogImpl(_module.getErrorHandler(), getLog()); 118 119 return _errorLog; 120 } 121 122 protected ExtensionPointDefinition getDefinition() 123 { 124 return _definition; 125 } 126 127 128 } | Popular Tags |