Changeset 1966
- Timestamp:
- 12/12/07 19:44:06 (12 months ago)
- Location:
- trunk/components
- Files:
-
- 7 modified
-
rendering/src/omeis/providers/re/Renderer.java (modified) (5 diffs)
-
server/resources/ome/services/service-ome.api.IThumb.xml (modified) (1 diff)
-
server/src/ome/api/local/LocalQuery.java (modified) (1 diff)
-
server/src/ome/logic/PixelsImpl.java (modified) (1 diff)
-
server/src/ome/logic/QueryImpl.java (modified) (1 diff)
-
server/src/ome/services/RenderingBean.java (modified) (21 diffs)
-
server/src/ome/services/ThumbnailBean.java (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/rendering/src/omeis/providers/re/Renderer.java
r1936 r1966  534 534 RGBBuffer img = renderingStrategy.render(this, pd); 535 535 stats.stop(); 536  log.info(stats.getStats()); 537  // TODO: is this the right place to log??? We want to have as little 538  // impact on performance as possible.  536 // TODO: Commenting this out for now. -- callan  537 //log.info(stats.getStats()); 539 538 return img; 540 539 } … …  569 568 RGBIntBuffer img = renderingStrategy.renderAsPackedInt(this, pd); 570 569 stats.stop(); 571  log.info(stats.getStats()); 572  // TODO: is this the right place to log??? We want to have as little 573  // impact on performance as possible.  570 // TODO: Commenting this out for now. -- callan  571 //log.info(stats.getStats()); 574 572 return img.getDataBuffer(); 575 573 } … …  918 916 "Unable to find default rendering model in enumerated list."); 919 917 } 920  def.setModel(defaultModel); 921    918   919 // Unload the rendering model to avoid transactional headaches  920 RenderingModel unloadedModel = new RenderingModel();  921 unloadedModel.setId(defaultModel.getId());  922 unloadedModel.unload();  923 def.setModel(unloadedModel);  924  922 925 // Quantization settings 923 926 QuantumDef quantumDef = def.getQuantization(); … …  926 929 quantumDef.setBitResolution(QuantumFactory.DEPTH_8BIT); 927 930 def.setQuantization(quantumDef); 928    931  929 932 // Reset the channel bindings 930 933 resetChannelBindings(def, pixels, quantumFactory, buffer); … …  964 967 r.setQuantization(new QuantumDef()); 965 968 r.setWaveRendering(createNewChannelBindings(p)); 966  r.setPixels(p);  969   970 // Unload the pixels object to avoid transactional headaches  971 Pixels unloadedPixels = new Pixels();  972 unloadedPixels.setId(p.getId());  973 unloadedPixels.unload();  974 r.setPixels(unloadedPixels); 967 975 return r; 968 976 } -
trunk/components/server/resources/ome/services/service-ome.api.IThumb.xml
r1748 r1966 Â 25 25 <constructor-arg><value>true</value></constructor-arg>Â 26 26 <property name="ioService" ref="/OMERO/Thumbs"/>Â 27 Â <property name=" renderingEngine"Â28 Â ref="internal:omeis.providers.re.RenderingEngine"/>ÂÂ 27 <property name="IPixels" ref="internal:ome.api.IPixels"/>Â Â 28 <property name="pixelDataService" ref="/OMERO/Pixels"/>Â 29 29 <property name="scaleService" ref="internal:ome.api.IScale"/>Â 30 30 <property name="compressionService" ref="internal:ome.api.ICompress"/>Â -
trunk/components/server/src/ome/api/local/LocalQuery.java
r1167 r1966  73 73 void evict(Object object); 74 74   75 void clear();  76  75 77 /** 76 78 * Uses the Hibernate static method <code>initialize</code> to prepare an -
trunk/components/server/src/ome/logic/PixelsImpl.java
r1949 r1966 Â 121 121 @Transactional(readOnly = false)Â 122 122 public void saveRndSettings(RenderingDef rndSettings) {Â 123 Â iUpdate.save Object(rndSettings);ÂÂ 123 iUpdate.saveAndReturnObject(rndSettings);Â 124 124 }Â 125 125 Â -
trunk/components/server/src/ome/logic/QueryImpl.java
r1949 r1966 Â 99 99 public void evict(Object obj) {Â 100 100 getHibernateTemplate().evict(obj);Â Â 101 }Â Â 102 Â Â 103 @RolesAllowed("user")Â Â 104 @Transactional(readOnly = false)Â Â 105 public void clear() {Â Â 106 getHibernateTemplate().clear();Â 101 107 }Â 102 108 Â -
trunk/components/server/src/ome/services/RenderingBean.java
r1949 r1966  12 12 import java.io.ByteArrayOutputStream; 13 13 import java.io.IOException; 14  import java.io.PrintWriter;Â15 14 import java.io.Serializable; 16  import java.io.StringWriter;Â17  import java.io.Writer;Â18 15 import java.util.ArrayList; 19 16 import java.util.List; … …  39 36 import org.jboss.annotation.ejb.RemoteBinding; 40 37 import org.jboss.annotation.ejb.RemoteBindings; 41  import org.jboss.annotation.ejb.cache.Cache;Â42 38 import org.jboss.annotation.security.SecurityDomain; 43  import org.jboss.ejb3.cache.NoPassivationCache;Â44 39 import org.springframework.transaction.annotation.Transactional; 45 40  … …  47 42 import ome.annotations.RevisionDate; 48 43 import ome.annotations.RevisionNumber; 49  import ome.api.ICompress;Â50 44 import ome.api.IPixels; 51 45 import ome.api.ServiceInterface; … …  58 52 import ome.io.nio.PixelsService; 59 53 import ome.logic.AbstractLevel2Service; 60  import ome.logic.SimpleLifecycle;Â61 54 import ome.model.IObject; 62 55 import ome.model.core.Channel; … …  86 79 * <p> 87 80 * The multi-threaded design of this component is based on dynamic locking and 88  * confinement tech iniques. All access to the component's internal parts happens 81 * confinement techniques. All access to the component's internal parts happens 89 82 * through a <code>RenderingEngineImpl</code> object, which is fully 90 83 * synchronized. Internal parts are either never leaked out or given away only … …  118 111 @LocalBinding(jndiBinding = "omero/local/omeis.providers.re.RenderingEngine") 119 112 @SecurityDomain("OmeroSecurity") 120  @Cache(NoPassivationCache.class)Â121 113 @TransactionManagement(TransactionManagementType.BEAN) 122 114 @Transactional(readOnly = true) … …  152 144  153 145 /** The pixels set to the rendering engine is for. */ 154  private transientPixels pixelsObj; 146 private Pixels pixelsObj; 155 147  156 148 /** The rendering settings associated to the pixels set. */ 157  private transientRenderingDef rendDefObj; 149 private RenderingDef rendDefObj; 158 150  159 151 /** Reference to the service used to retrieve the pixels data. */ … …  171 163 */ 172 164 private transient ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();  165   166 /** Notification that the bean has just returned from passivation. */  167 private transient boolean wasPassivated = false; 173 168  174 169 /** … …  202 197 * Delegates to super class 203 198 */ 204  @PostActivateÂ205 199 @PostConstruct 206 200 public void create() { … …  208 202 } 209 203  210  /** lifecycle method -- {@link PrePassivate}. Disallows all passivation. */  204 /** lifecycle method -- {@link PostPassivate}. */  205 @PostActivate  206 public void postPassivate() {  207 log.info("***** Returning from passivation... ******");  208 create();  209 wasPassivated = true;  210 rwl = new ReentrantReadWriteLock();  211 }  212   213 /** lifecycle method -- {@link PrePassivate}. */ 211 214 @PrePassivate 212 215 public void passivate() { 213  closeRenderer(); 214  getBeanHelper().passivationNotAllowed();  216 log.info("***** Passivating... ******");  217 closeRenderer();  218 renderer = null; 215 219 } 216 220  … …  253 257 */ 254 258 @RolesAllowed("user")  259 @Transactional(readOnly = false) 255 260 public void lookupPixels(long pixelsId) { 256  rwl.writeLock().lock();Â257   258  try {Â259  this.pixelsObj = pixMetaSrv.retrievePixDescription(pixelsId);Â260  closeRenderer();Â261  this.renderer = null;Â262   263  if (pixelsObj == null) {Â264  throw new ValidationException("Pixels object with id "Â265  + pixelsId + " not found.");Â266  }Â267  } finally {Â268  rwl.writeLock().unlock();Â269  }Â270   271  if (log.isDebugEnabled()) {Â272  log.debug("lookupPixels for id " + pixelsId + " succeeded: "Â273  + this.pixelsObj);Â274  } 261 rwl.writeLock().lock();  262   263 try {  264 pixelsObj = pixMetaSrv.retrievePixDescription(pixelsId);  265 closeRenderer();  266 renderer = null;  267   268 if (pixelsObj == null) {  269 throw new ValidationException("Pixels object with id "  270 + pixelsId + " not found.");  271 }  272 } finally {  273 rwl.writeLock().unlock();  274 }  275   276 if (log.isDebugEnabled()) {  277 log.debug("lookupPixels for id " + pixelsId + " succeeded: "  278 + this.pixelsObj);  279 } 275 280 } 276 281  … …  281 286 */ 282 287 @RolesAllowed("user")  288 @Transactional(readOnly = false) 283 289 public boolean lookupRenderingDef(long pixelsId) { 284  rwl.writeLock().lock();Â285   286  try {Â287  rendDefObj = pixMetaSrv.retrieveRndSettings(pixelsId);Â288  closeRenderer();Â289  renderer = null;Â290   291  if (rendDefObj == null) {Â292  // We've been initialized on a pixels set that has no renderingÂ293  // definition for the given user. In order to maintain theÂ294  // proper state and ensure that we avoid transactional problemsÂ295  // we're going to notify the caller instead of performing *any*Â296  // magic that would require a database update.Â297  // *** Ticket #564 -- Chris Allan <callan@blackcat.ca> ***Â298  return false;Â299  }Â300  } finally {Â301  rwl.writeLock().unlock();Â302  }Â303   304  if (log.isDebugEnabled()) {Â305  log.debug("lookupRenderingDef for Pixels=" + pixelsIdÂ306  + " succeeded: " + this.rendDefObj);Â307  }Â308  return true; 290 rwl.writeLock().lock();  291   292 try {  293 rendDefObj = pixMetaSrv.retrieveRndSettings(pixelsId);  294 closeRenderer();  295 renderer = null;  296   297 if (rendDefObj == null) {  298 // We've been initialized on a pixels set that has no rendering  299 // definition for the given user. In order to maintain the  300 // proper state and ensure that we avoid transactional problems  301 // we're going to notify the caller instead of performing *any*  302 // magic that would require a database update.  303 // *** Ticket #564 -- Chris Allan <callan@blackcat.ca> ***  304 return false;  305 }  306 } finally {  307 rwl.writeLock().unlock();  308 }  309   310 if (log.isDebugEnabled()) {  311 log.debug("lookupRenderingDef for Pixels=" + pixelsId  312 + " succeeded: " + this.rendDefObj);  313 }  314 return true; 309 315 } 310 316  … …  318 324 rwl.writeLock().lock(); 319 325   326  320 327 try { 321 328 errorIfNullPixels();  329   330 // Ensure that we do not have "dirty" pixels or rendering settings  331 // left around in the Hibernate session cache.  332 iQuery.clear(); 322 333  323 334 /* … …  401 412 */ 402 413 @RolesAllowed("user") 403  public int[] renderAsPackedInt(PlaneDef pd) throws ResourceError,Â404  ValidationException {Â405  rwl.readLock().lock();Â406   407  try {Â408  errorIfInvalidState();Â409  return renderer.renderAsPackedInt(pd);Â410  } catch (IOException e) {Â411  ResourceError re = new ResourceError("IO error while rendering:\n"Â412  + e.getMessage());Â413  re.initCause(e);Â414  throw re;Â415  } catch (QuantizationException e) {Â416  InternalException ie = new InternalException(Â417  "QuantizationException while rendering:\n" + e.getMessage());Â418  ie.initCause(e);Â419  throw ie;Â420  } finally {Â421  rwl.readLock().unlock();Â422  } 414 public int[] renderAsPackedInt(PlaneDef pd)  415 throws ResourceError, ValidationException {  416 rwl.writeLock().lock();  417   418 try {  419 errorIfInvalidState();  420 return renderer.renderAsPackedInt(pd);  421 } catch (IOException e) {  422 ResourceError re = new ResourceError("IO error while rendering:\n"  423 + e.getMessage());  424 re.initCause(e);  425 throw re;  426 } catch (QuantizationException e) {  427 InternalException ie = new InternalException(  428 "QuantizationException while rendering:\n" + e.getMessage());  429 ie.initCause(e);  430 throw ie;  431 } finally {  432 rwl.writeLock().unlock();  433 } 423 434 } 424 435  … …  481 492 // Ensure that we haven't just been called before  482 493 // lookupRenderingDef(). 483  if (rendDefObj == null 484  && pixMetaSrv.retrieveRndSettings(pixelsId) == null)  494 if (rendDefObj == null) 485 495 {  496 RenderingDef def = pixMetaSrv.retrieveRndSettings(pixelsId);   497 if (def != null)  498 {  499 errorIfInvalidState();  500 } 486 501 List<Family> families = 487 502 pixMetaSrv.getAllEnumerations(Family.class); … …  490 505 QuantumFactory quantumFactory = new QuantumFactory(families); 491 506 PixelBuffer buffer = pixDataSrv.getPixelBuffer(pixelsObj); 492  RenderingDefdef = Renderer.createNewRenderingDef(pixelsObj); 507 def = Renderer.createNewRenderingDef(pixelsObj); 493 508 Renderer.resetDefaults(def, pixelsObj, quantumFactory, 494 509 renderingModels, buffer); … …  515 530 rwl.writeLock().unlock(); 516 531 } 517  iUpdate.flush();Â518 532 } 519 533  … …  573 587 errorIfNullRenderingDef(); 574 588 pixMetaSrv.saveRndSettings(rendDefObj); 575  } finally { 576  rwl.writeLock().unlock(); 577  } 578  iUpdate.flush();  589 rendDefObj = reload(rendDefObj);  590 iQuery.clear();  591 } finally {  592 rwl.writeLock().unlock();  593 } 579 594 } 580 595  … …  1133 1148 // ========================================================================= 1134 1149  1135  protected final static String NULL_RENDERER = "RenderingEngine not ready: renderer is null. " 1150 protected final static String NULL_RENDERER = "RenderingEngine not ready: renderer is null.\n" 1136 1151 + "This method can only be called " 1137 1152 + "after the renderer is properly " 1138  + "initialized (not-null). \n" 1153 + "initialized (not-null).\n" 1139 1154 + "Try lookup and/or use methods."; 1140 1155  … …  1154 1169  1155 1170 protected void errorIfNullRenderingDef() { 1156  if (rendDefObj == null) { 1157  throw new ApiUsageException( 1158  "RenderingEngine not ready: RenderingDef object not set."); 1159  } 1160   1161  } 1162   1163  protected void errorIfNullRenderer() { 1164  if (renderer == null) { 1165  throw new ApiUsageException(NULL_RENDERER); 1166  } 1167    1171 if (rendDefObj == null) {  1172 throw new ApiUsageException(  1173 "RenderingEngine not ready: RenderingDef object not set.");  1174 }  1175 }  1176   1177 protected void errorIfNullRenderer()  1178 {  1179 if (renderer == null && wasPassivated)  1180 {  1181 load();  1182 }  1183 else if (renderer == null)  1184 {  1185 throw new ApiUsageException(NULL_RENDERER);  1186 } 1168 1187 } 1169 1188  … …  1235 1254 } 1236 1255   1256 /**  1257 * Reloads an {@link Pixels} or {@link RenderingDef} object following a  1258 * <pre>clear()</pre> being called on the Hibernate session.  1259 * @param t The object to reload.  1260 * @return A reloaded object of the same type as that passed in.  1261 */  1262 @SuppressWarnings("unchecked")  1263 private <T extends IObject> T reload(T t)  1264 {  1265 if (t != null)  1266 {  1267 if (t instanceof RenderingDef)  1268 {  1269 return (T) pixMetaSrv.retrieveRndSettings(pixelsObj.getId());  1270 }  1271 else if (t instanceof Pixels)  1272 {  1273 return (T) pixMetaSrv.retrievePixDescription(t.getId());  1274 }  1275 else  1276 {  1277 throw new RuntimeException(  1278 "Unknown reload class: " + t.getClass());  1279 }  1280 }  1281 return t;  1282 } 1237 1283 } -
trunk/components/server/src/ome/services/ThumbnailBean.java
r1949 r1966  9 9  10 10 // Java imports 11  import java.awt.Point;Â12 11 import java.awt.image.BufferedImage; 13  import java.awt.image.ColorModel;Â14  import java.awt.image.DataBuffer;Â15  import java.awt.image.DataBufferInt;Â16  import java.awt.image.DirectColorModel;Â17  import java.awt.image.SinglePixelPackedSampleModel;Â18  import java.awt.image.WritableRaster;Â19 12 import java.io.ByteArrayOutputStream; 20 13 import java.io.FileOutputStream; … …  36 29 import javax.interceptor.Interceptors; 37 30  38  import ome.api.I Compress; 31 import ome.api.IPixels; 39 32 import ome.api.IRepositoryInfo; 40 33 import ome.api.IScale; … …  43 36 import ome.api.local.LocalCompress; 44 37 import ome.conditions.ApiUsageException;  38 import ome.conditions.InternalException; 45 39 import ome.conditions.ResourceError;  40 import ome.conditions.ValidationException;  41 import ome.io.nio.PixelBuffer;  42 import ome.io.nio.PixelsService; 46 43 import ome.io.nio.ThumbnailService; 47 44 import ome.logic.AbstractLevel2Service;  45 import ome.model.IObject; 48 46 import ome.model.core.Pixels;  47 import ome.model.display.RenderingDef; 49 48 import ome.model.display.Thumbnail;  49 import ome.model.enums.Family;  50 import ome.model.enums.RenderingModel; 50 51 import ome.parameters.Parameters; 51 52 import ome.services.util.OmeroAroundInvoke; … …  53 54 import ome.system.SimpleEventContext; 54 55 import ome.util.ImageUtil; 55  import omeis.providers.re.Render ingEngine; 56 import omeis.providers.re.Renderer; 56 57 import omeis.providers.re.data.PlaneDef;  58 import omeis.providers.re.quantum.QuantizationException;  59 import omeis.providers.re.quantum.QuantumFactory; 57 60  58 61 import org.apache.commons.logging.Log; … …  61 64 import org.jboss.annotation.ejb.RemoteBinding; 62 65 import org.jboss.annotation.ejb.RemoteBindings;  66 import org.jboss.annotation.ejb.cache.tree.CacheConfig; 63 67 import org.jboss.annotation.security.SecurityDomain; 64 68 import org.springframework.transaction.annotation.Transactional; 65  Â66  import sun.awt.image.IntegerInterleavedRaster;Â67 69  68 70 /** … …  100 102 private transient static Log log = LogFactory.getLog(ThumbnailBean.class); 101 103  102  /** The render ing enginethat this service uses for thumbnail creation. */Â103  private transient Render ingEngine re;Â104   105  /** The scaling service thatwill be used to scale buffered images. */ 104 /** The renderer that this service uses for thumbnail creation. */  105 private transient Renderer renderer;  106   107 /** The scaling service will be used to scale buffered images. */ 106 108 private transient IScale iScale;  109   110 /** The pixels service, will be used to load pixels and settings. */  111 private transient IPixels iPixels;  112   113 /** The service used to retrieve the pixels data. */  114 private transient PixelsService pixelDataService; 107 115  108 116 /** The ROMIO thumbnail service. */ … …  120 128 /** The pixels instance that the service is currently working on. */ 121 129 private Pixels pixels; 122   123  /** The id of the pixels instance. */ 124  private Long pixelsId; 125   126  /** Only set after a passivated bean is activated. */ 127  private transient Long resetPix = null; 128   129  /** Currently unused. */ 130  private transient Long resetRE = null; 131   132  /** The id of the rendering definition instance. */ 133  private Long renderingDefId;  130   131 /** The rendering settings that the service is currently working with. */  132 private RenderingDef settings; 134 133  135 134 /** The default X-width for a thumbnail. */ … …  145 144 public static final String DEFAULT_MIME_TYPE = "image/jpeg"; 146 145   146 /** Notification that the bean has just returned from passivation. */ Â
