Changeset 5517
- Timestamp:
- Mar 31, 2020, 4:20:48 AM (5 years ago)
- Location:
- jomc-modlet/branches/jomc-modlet-1.x
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
jomc-modlet/branches/jomc-modlet-1.x ¶
- Property svn:mergeinfo changed
/jomc-modlet/trunk merged: 5506,5516
- Property svn:mergeinfo changed
-
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/java/org/jomc/modlet/DefaultModletValidator.java ¶
r5269 r5517 253 253 @Override 254 254 public ModelValidationReport validateModlets( final ModelContext context, final Modlets modlets ) 255 throws NullPointerException,ModelException255 throws ModelException 256 256 { 257 257 if ( context == null ) -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/java/org/jomc/modlet/DefaultServiceFactory.java ¶
r5485 r5517 57 57 58 58 /** 59 * Constant for the name of the system property controlling property {@code defaultEnabled}. 60 * 61 * @see #isDefaultEnabled() 62 * @since 1.11.0 63 */ 64 private static final String DEFAULT_ENABLED_PROPERTY_NAME = 65 "org.jomc.modlet.DefaultServiceFactory.defaultEnabled"; 66 67 /** 68 * Default value of the flag indicating the factory is enabled by default. 69 * 70 * @see #isDefaultEnabled() 71 * @since 1.11.0 72 */ 73 private static final Boolean DEFAULT_ENABLED = Boolean.TRUE; 74 75 /** 76 * Flag indicating the factory is enabled by default. 77 * @since 1.11.0 78 */ 79 private static volatile Boolean defaultEnabled; 80 81 /** 82 * Flag indicating the factory is enabled. 83 * @since 1.11.0 84 */ 85 private volatile Boolean enabled; 86 87 /** 59 88 * Constant for the name of the system property controlling property {@code defaultOrdinal}. 60 89 * … … 87 116 { 88 117 super(); 118 } 119 120 /** 121 * Gets a flag indicating the factory is enabled by default. 122 * <p> 123 * The default enabled flag is controlled by system property 124 * {@code org.jomc.modlet.DefaultServiceFactory.defaultEnabled} holding a value indicating the factory is 125 * enabled by default. If that property is not set, the {@code true} default is returned. 126 * </p> 127 * 128 * @return {@code true}, if the factory is enabled by default; {@code false}, if the factory is disabled by 129 * default. 130 * 131 * @see #isEnabled() 132 * @see #setDefaultEnabled(java.lang.Boolean) 133 * @since 1.11.0 134 */ 135 public static boolean isDefaultEnabled() 136 { 137 if ( defaultEnabled == null ) 138 { 139 defaultEnabled = Boolean.valueOf( System.getProperty( 140 DEFAULT_ENABLED_PROPERTY_NAME, Boolean.toString( DEFAULT_ENABLED ) ) ); 141 142 } 143 144 return defaultEnabled; 145 } 146 147 /** 148 * Sets the flag indicating the factory is enabled by default. 149 * 150 * @param value The new value of the flag indicating the factory is enabled by default or {@code null}. 151 * 152 * @see #isDefaultEnabled() 153 * @since 1.11.0 154 */ 155 public static void setDefaultEnabled( final Boolean value ) 156 { 157 defaultEnabled = value; 158 } 159 160 /** 161 * Gets a flag indicating the factory is enabled. 162 * 163 * @return {@code true}, if the factory is enabled; {@code false}, if the factory is disabled. 164 * 165 * @see #isDefaultEnabled() 166 * @see #setEnabled(java.lang.Boolean) 167 * @since 1.11.0 168 */ 169 public final boolean isEnabled() 170 { 171 if ( this.enabled == null ) 172 { 173 this.enabled = isDefaultEnabled(); 174 } 175 176 return this.enabled; 177 } 178 179 /** 180 * Sets the flag indicating the factory is enabled. 181 * 182 * @param value The new value of the flag indicating the factory is enabled or {@code null}. 183 * 184 * @see #isEnabled() 185 * @since 1.11.0 186 */ 187 public final void setEnabled( final Boolean value ) 188 { 189 this.enabled = value; 89 190 } 90 191 … … 171 272 try 172 273 { 173 final Class<?> clazz = context.findClass( service.getClazz() ); 174 175 if ( clazz == null ) 176 { 177 throw new ModelException( getMessage( "serviceNotFound", service.getOrdinal(), service. 178 getIdentifier(), 179 service.getClazz() ) ); 180 181 } 182 183 if ( !type.isAssignableFrom( clazz ) ) 184 { 185 throw new ModelException( getMessage( "illegalService", service.getOrdinal(), service. 186 getIdentifier(), 187 service.getClazz(), type.getName() ) ); 188 189 } 190 191 final T serviceObject = clazz.asSubclass( type ).newInstance(); 192 193 if ( !service.getProperty().isEmpty() ) 194 { 195 if ( context.getExecutorService() != null && service.getProperty().size() > 1 ) 196 { 197 final List<Callable<Void>> tasks = 198 new ArrayList<Callable<Void>>( service.getProperty().size() ); 199 200 for ( int i = 0, s0 = service.getProperty().size(); i < s0; i++ ) 201 { 202 final Property p = service.getProperty().get( i ); 203 204 tasks.add( new Callable<Void>() 274 final T serviceObject; 275 if ( this.isEnabled() ) 276 { 277 final Class<?> clazz = context.findClass( service.getClazz() ); 278 279 if ( clazz == null ) 280 { 281 throw new ModelException( getMessage( "serviceNotFound", service.getOrdinal(), 282 service.getIdentifier(), service.getClazz() ) ); 283 284 } 285 286 if ( !type.isAssignableFrom( clazz ) ) 287 { 288 throw new ModelException( getMessage( "illegalService", service.getOrdinal(), 289 service.getIdentifier(), service.getClazz(), 290 type.getName() ) ); 291 292 } 293 294 serviceObject = clazz.asSubclass( type ).newInstance(); 295 296 if ( !service.getProperty().isEmpty() ) 297 { 298 if ( context.getExecutorService() != null && service.getProperty().size() > 1 ) 299 { 300 final List<Callable<Void>> tasks = 301 new ArrayList<Callable<Void>>( service.getProperty().size() ); 302 303 for ( int i = 0, s0 = service.getProperty().size(); i < s0; i++ ) 205 304 { 206 207 public Void call() throws ModelException 305 final Property p = service.getProperty().get( i ); 306 307 tasks.add( new Callable<Void>() 208 308 { 209 initProperty( context, serviceObject, p.getName(), p.getValue() ); 210 return null; 211 } 212 213 } ); 214 } 215 216 for ( final Future<Void> task : context.getExecutorService().invokeAll( tasks ) ) 217 { 218 task.get(); 219 } 220 } 221 else 222 { 223 for ( int i = 0, s0 = service.getProperty().size(); i < s0; i++ ) 224 { 225 final Property p = service.getProperty().get( i ); 226 this.initProperty( context, serviceObject, p.getName(), p.getValue() ); 227 } 309 310 public Void call() throws ModelException 311 { 312 initProperty( context, serviceObject, p.getName(), p.getValue() ); 313 return null; 314 } 315 316 } ); 317 } 318 319 for ( final Future<Void> task : context.getExecutorService().invokeAll( tasks ) ) 320 { 321 task.get(); 322 } 323 } 324 else 325 { 326 for ( int i = 0, s0 = service.getProperty().size(); i < s0; i++ ) 327 { 328 final Property p = service.getProperty().get( i ); 329 this.initProperty( context, serviceObject, p.getName(), p.getValue() ); 330 } 331 } 332 } 333 } 334 else 335 { 336 serviceObject = null; 337 338 if ( context.isLoggable( Level.FINER ) ) 339 { 340 context.log( Level.FINER, getMessage( "disabled", this.getClass().getSimpleName() ), null ); 228 341 } 229 342 } -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/java/org/jomc/modlet/ModelProcessor.java ¶
r5101 r5517 52 52 * @throws ModelException if processing fails. 53 53 */ 54 Model processModel( ModelContext context, Model model ) throws NullPointerException,ModelException;54 Model processModel( ModelContext context, Model model ) throws ModelException; 55 55 56 56 } -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/java/org/jomc/modlet/ModelProvider.java ¶
r5101 r5517 52 52 * @throws ModelException if searching the context fails. 53 53 */ 54 Model findModel( ModelContext context, Model model ) throws NullPointerException,ModelException;54 Model findModel( ModelContext context, Model model ) throws ModelException; 55 55 56 56 } -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/java/org/jomc/modlet/ModelValidationReport.java ¶
r5269 r5517 152 152 return new StringBuilder( 200 ).append( '{' ). 153 153 append( "identifier=" ).append( this.getIdentifier() ). 154 append( ", level=" ).append( this.getLevel() .getLocalizedName()).154 append( ", level=" ).append( this.getLevel() ). 155 155 append( ", message=" ).append( this.getMessage() ). 156 156 append( ", element=" ).append( this.getElement() ).append( '}' ).toString(); -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/java/org/jomc/modlet/ModelValidator.java ¶
r5101 r5517 55 55 */ 56 56 ModelValidationReport validateModel( ModelContext context, Model model ) 57 throws NullPointerException,ModelException;57 throws ModelException; 58 58 59 59 } -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/java/org/jomc/modlet/ModletProcessor.java ¶
r5101 r5517 60 60 * @throws ModelException if processing {@code Modlets} fails. 61 61 */ 62 Modlets processModlets( ModelContext context, Modlets modlets ) throws NullPointerException,ModelException;62 Modlets processModlets( ModelContext context, Modlets modlets ) throws ModelException; 63 63 64 64 } -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/java/org/jomc/modlet/ModletProvider.java ¶
r5488 r5517 77 77 * @since 1.6 78 78 */ 79 Modlets findModlets( ModelContext context, Modlets modlets ) throws NullPointerException,ModelException;79 Modlets findModlets( ModelContext context, Modlets modlets ) throws ModelException; 80 80 81 81 } -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/java/org/jomc/modlet/ModletValidator.java ¶
r5101 r5517 63 63 */ 64 64 ModelValidationReport validateModlets( ModelContext context, Modlets modlets ) 65 throws NullPointerException,ModelException;65 throws ModelException; 66 66 67 67 } -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/java/org/jomc/modlet/ServiceFactory.java ¶
r5101 r5517 64 64 */ 65 65 <T> T createServiceObject( ModelContext context, Service service, Class<T> type ) 66 throws NullPointerException,ModelException;66 throws ModelException; 67 67 68 68 } -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/resources/org/jomc/modlet/DefaultServiceFactory.properties ¶
r5028 r5517 8 8 unsupportedCharacterValue=Unsupported character value for property ''{1}'' of class ''{0}''. 9 9 unsupportedPropertyType=Unsupported property type ''{2}'' setting property ''{1}'' of class ''{0}''. 10 disabled={0} - Not producing service objects. Disabled. -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/resources/org/jomc/modlet/DefaultServiceFactory_de.properties ¶
r5028 r5517 8 8 unsupportedCharacterValue=Nicht unterst\u00fctztes Zeichen f\u00fcr Eigenschaft ''{1}'' der Klasse ''{0}''. 9 9 unsupportedPropertyType=Unsupported property type ''{2}'' setting property ''{1}'' of class ''{0}''. 10 disabled={0} - Keine Erstellung von Serviceobjekten. Deaktiviert. -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/main/resources/org/jomc/modlet/DefaultServiceFactory_en.properties ¶
r5028 r5517 8 8 unsupportedCharacterValue=Unsupported character value for property ''{1}'' of class ''{0}''. 9 9 unsupportedPropertyType=Unsupported property type ''{2}'' setting property ''{1}'' of class ''{0}''. 10 disabled={0} - Not producing service objects. Disabled. -
TabularUnified jomc-modlet/branches/jomc-modlet-1.x/src/site/apt/system-properties.apt ¶
r5101 r5517 70 70 | <<<org.jomc.modlet.ModelContextFactory>>> | <<<java.lang.String>>> | <<<org.jomc.modlet.DefaultModelContextFactory>>> | 71 71 *---------------------------------------------*-------------------------------*----------------------------------------* 72 | <<<org.jomc.modlet.DefaultServiceFactory.defaultEnabled>>> | <<<java.lang.Boolean>>> | <<<true>>> | 73 *---------------------------------------------*-------------------------------*----------------------------------------*
Note:
See TracChangeset
for help on using the changeset viewer.