r2229 - trunk/topia-persistence/src/main/java/org/nuiton/topia/framework
Author: tchemit Date: 2011-03-17 14:33:29 +0100 (Thu, 17 Mar 2011) New Revision: 2229 Url: http://nuiton.org/repositories/revision/topia/2229 Log: use static import for I18n Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2011-03-17 13:32:57 UTC (rev 2228) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2011-03-17 13:33:29 UTC (rev 2229) @@ -55,7 +55,6 @@ import org.hibernate.event.PreUpdateEventListener; import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaUpdate; -import org.nuiton.i18n.I18n; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; import org.nuiton.topia.TopiaException; @@ -245,15 +244,15 @@ TopiaService service = (TopiaService) newInstance; if (key.equals("topia.service." + service.getServiceName())) { result.put(service.getServiceName(), service); - log.info(I18n._("topia.persistence.service.loaded", + log.info(_("topia.persistence.service.loaded", key, classService)); } else { - log.warn(I18n._("topia.persistence.warn.service.not.loaded", + log.warn(_("topia.persistence.warn.service.not.loaded", key, service.getServiceName())); } } catch (Throwable eee) { String message = - I18n._("topia.persistence.error.service.unknown", + _("topia.persistence.error.service.unknown", key, classService); if (log.isDebugEnabled()) { log.debug(message, eee); @@ -269,7 +268,7 @@ protected void preInitServices(Map<String, TopiaService> services) { for (TopiaService service : services.values()) { if (!service.preInit(this)) { - log.warn(I18n._("topia.persistence.warn.service.not.preInit", + log.warn(_("topia.persistence.warn.service.not.preInit", service.getServiceName())); } } @@ -278,7 +277,7 @@ protected void postInitServices(Map<String, TopiaService> services) { for (TopiaService service : services.values()) { if (!service.postInit(this)) { - log.warn(I18n._("topia.persistence.warn.service.not.postInit", + log.warn(_("topia.persistence.warn.service.not.postInit", service.getServiceName())); } } @@ -343,13 +342,13 @@ result = (E) getService(name); } catch (Exception eee) { throw new TopiaNotFoundException( - I18n._("topia.persistence.error.service.not.retreaved", + _("topia.persistence.error.service.not.retreaved", interfaceService, getProperExceptionMessage(eee)), eee); } if (result == null) { throw new TopiaNotFoundException( - I18n._("topia.persistence.error.service.not.found", + _("topia.persistence.error.service.not.found", interfaceService)); } return result; @@ -363,7 +362,7 @@ String name = getServiceName(interfaceService); result = serviceEnabled(name); } catch (Exception eee) { - String message = I18n._("topia.persistence.warn.service.not.found", + String message = _("topia.persistence.warn.service.not.found", interfaceService, getProperExceptionMessage(eee)); if (log.isDebugEnabled()) { log.debug(message, eee); @@ -464,7 +463,7 @@ getFiresSupport().firePostCreateSchema(this); } catch (HibernateException eee) { throw new TopiaException( - I18n._("topia.persistence.error.create.schema", + _("topia.persistence.error.create.schema", eee.getMessage()), eee); } } @@ -476,7 +475,7 @@ execute(true, false, false, true); } catch (HibernateException eee) { throw new TopiaException( - I18n._("topia.persistence.error.create.schema", + _("topia.persistence.error.create.schema", eee.getMessage()), eee); } } @@ -494,7 +493,7 @@ getFiresSupport().firePostUpdateSchema(this); } catch (HibernateException eee) { throw new TopiaException( - I18n._("topia.persistence.error.update.schema", + _("topia.persistence.error.update.schema", eee.getMessage()), eee); } } @@ -503,7 +502,7 @@ public Session getHibernate() throws TopiaException { if (hibernate == null) { throw new TopiaException( - I18n._("topia.persistence.error.no.hibernate.session")); + _("topia.persistence.error.no.hibernate.session")); } return hibernate; } @@ -683,12 +682,12 @@ throws TopiaException { if (entityClass == null) { throw new IllegalArgumentException( - I18n._("topia.persistence.error.null.param", + _("topia.persistence.error.null.param", "entityClass", "getDAO")); } if (this == getRootContext()) { throw new TopiaException( - I18n._("topia.persistence.error.rootContext.access")); + _("topia.persistence.error.rootContext.access")); } if (getHibernateFactory().getClassMetadata(entityClass) == null && getHibernateFactory().getClassMetadata( @@ -696,10 +695,10 @@ getHibernateFactory().getClassMetadata( entityClass.getName() + "Abstract") == null) { - log.info(I18n._("topia.persistence.supported.classes.for.context", + log.info(_("topia.persistence.supported.classes.for.context", getHibernateFactory().getAllClassMetadata().keySet())); throw new TopiaException( - I18n._("topia.persistence.error.unsupported.class", + _("topia.persistence.error.unsupported.class", entityClass.getName())); } @@ -736,7 +735,7 @@ @Override public TopiaContext beginTransaction() throws TopiaException { - checkClosed(I18n._("topia.persistence.error.context.is.closed")); + checkClosed(_("topia.persistence.error.context.is.closed")); TopiaContextImpl result = new TopiaContextImpl(this); SessionFactory factory = getHibernateFactory(); @@ -770,7 +769,7 @@ } throw new TopiaException( - I18n._("topia.persistence.error.open.transaction.failed", + _("topia.persistence.error.open.transaction.failed", eee.getMessage()), eee); } @@ -786,11 +785,11 @@ @Override public void commitTransaction() throws TopiaException { if (getRootContext() == this) { - throw new TopiaException(I18n._( + throw new TopiaException(_( "topia.persistence.error.unsupported.operation.on.root.context", "commit")); } - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "commit")); @@ -818,7 +817,7 @@ // hibernate = getHibernateFactory().openSession(); // hibernate.setFlushMode(FlushMode.NEVER); } catch (Exception eee) { - throw new TopiaException(I18n._("topia.persistence.error.on.commit", + throw new TopiaException(_("topia.persistence.error.on.commit", eee.getMessage()), eee); } } @@ -826,11 +825,11 @@ @Override public void rollbackTransaction() throws TopiaException { if (equals(getRootContext())) { - throw new TopiaException(I18n._( + throw new TopiaException(_( "topia.persistence.error.unsupported.operation.on.root.context", "rollback")); } - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "rollback")); try { @@ -858,7 +857,7 @@ } catch (HibernateException eee) { throw new TopiaException( - I18n._("topia.persistence.error.on.rollback", + _("topia.persistence.error.on.rollback", eee.getMessage()), eee); } } @@ -866,7 +865,7 @@ @Override public void closeContext() throws TopiaException { // Throw exception if context is already closed - checkClosed(I18n._("topia.persistence.error.context.already.closed")); + checkClosed(_("topia.persistence.error.context.already.closed")); // FD-20100421 : Ano #546 : no need to copy childContext, the // {@link #getChildContext()} provides a thread-safe copy to iterate @@ -928,7 +927,7 @@ @SuppressWarnings({"unchecked"}) @Override public TopiaEntity findByTopiaId(String id) throws TopiaException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "findById")); @@ -951,7 +950,7 @@ @Override public List find(String hql, Object... args) throws TopiaException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "find")); @@ -974,7 +973,7 @@ result = firesSupport.fireEntitiesLoad(this, result); return result; } catch (HibernateException eee) { - throw new TopiaException(I18n._("topia.persistence.error.on.query", + throw new TopiaException(_("topia.persistence.error.on.query", hql, eee.getMessage()), eee); } } @@ -982,7 +981,7 @@ @Override public List<?> find(String hql, int startIndex, int endIndex, Object... args) throws TopiaException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "find")); @@ -1007,7 +1006,7 @@ result = firesSupport.fireEntitiesLoad(this, result); return result; } catch (HibernateException eee) { - throw new TopiaException(I18n._("topia.persistence.error.on.query", + throw new TopiaException(_("topia.persistence.error.on.query", hql, eee.getMessage()), eee); } } @@ -1022,7 +1021,7 @@ */ @Override public int execute(String hql, Object... args) throws TopiaException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "find")); @@ -1034,14 +1033,14 @@ int result = query.executeUpdate(); return result; } catch (HibernateException eee) { - throw new TopiaException(I18n._("topia.persistence.error.on.query", + throw new TopiaException(_("topia.persistence.error.on.query", hql, eee.getMessage()), eee); } } @Override public void add(TopiaEntity e) throws TopiaException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "add")); @@ -1053,7 +1052,7 @@ @Override public void importXML(Reader xml) throws TopiaException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "importXML")); @@ -1067,7 +1066,7 @@ } } catch (DocumentException de) { throw new TopiaException( - I18n._("topia.persistence.error.on.loding.xml.doc", + _("topia.persistence.error.on.loding.xml.doc", de.getMessage()), de); } @@ -1080,7 +1079,7 @@ try { sessionDom4j.replicate(entity, ReplicationMode.EXCEPTION); } catch (HibernateException he) { - log.warn(I18n._("topia.persistence.error.replicate.entity", + log.warn(_("topia.persistence.error.replicate.entity", entity, he.getMessage()), he); } } @@ -1088,14 +1087,14 @@ sessionDom4j.flush(); } else { throw new TopiaException( - I18n._("topia.persistence.error.empty.doc")); + _("topia.persistence.error.empty.doc")); } } @Override public void exportXML(Writer xml, Object... entityAndcondition) throws TopiaException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "exportXML")); @@ -1154,10 +1153,10 @@ result.close(); } catch (HibernateException eee) { - throw new TopiaException(I18n._("topia.persistence.error.on.export", + throw new TopiaException(_("topia.persistence.error.on.export", eee.getMessage()), eee); } catch (IOException eee) { - throw new TopiaException(I18n._("topia.persistence.error.on.export", + throw new TopiaException(_("topia.persistence.error.on.export", eee.getMessage()), eee); } } @@ -1165,18 +1164,18 @@ @Override public void replicate(TopiaContext dstCtxt, Object... entityAndCondition) throws TopiaException, IllegalArgumentException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "replicate")); TopiaContextImpl dstContextImpl = (TopiaContextImpl) dstCtxt; dstContextImpl.checkClosed( - I18n._("topia.persistence.error.unsupported.operation.on.closed.context", + _("topia.persistence.error.unsupported.operation.on.closed.context", "replicate")); if (getRootContext().equals(dstContextImpl.getRootContext())) { throw new IllegalArgumentException( - I18n._("topia.persistence.error.replicate.on.same.context")); + _("topia.persistence.error.replicate.on.same.context")); } String[] queries = buildQueries(entityAndCondition); @@ -1194,7 +1193,7 @@ } } } catch (HibernateException eee) { - throw new TopiaException(I18n._( + throw new TopiaException(_( "topia.persistence.error.on.replicate", eee.getMessage()), eee); } @@ -1204,17 +1203,17 @@ public <T extends TopiaEntity> void replicateEntity(TopiaContext dstCtxt, T entity) throws TopiaException, IllegalArgumentException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "replicateEntity")); TopiaContextImpl dstContextImpl = (TopiaContextImpl) dstCtxt; - dstContextImpl.checkClosed(I18n._( + dstContextImpl.checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "replicateEntity")); if (getRootContext().equals(dstContextImpl.getRootContext())) { - throw new IllegalArgumentException(I18n._( + throw new IllegalArgumentException(_( "topia.persistence.error.replicate.on.same.context")); } replicate0(dstContextImpl, entity); @@ -1224,17 +1223,17 @@ public <T extends TopiaEntity> void replicateEntities(TopiaContext dstCtxt, List<T> entities) throws TopiaException, IllegalArgumentException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "replicateEntities")); TopiaContextImpl dstContextImpl = (TopiaContextImpl) dstCtxt; - dstContextImpl.checkClosed(I18n._( + dstContextImpl.checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "replicateEntities")); if (getRootContext().equals(dstContextImpl.getRootContext())) { - throw new IllegalArgumentException(I18n._( + throw new IllegalArgumentException(_( "topia.persistence.error.replicate.on.same.context")); } replicate0(dstContextImpl, entities.toArray()); @@ -1256,7 +1255,7 @@ */ @Override public void backup(File file, boolean compress) throws TopiaException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "backup")); try { @@ -1270,7 +1269,7 @@ query.list(); } catch (Exception eee) { - throw new TopiaException(I18n._( + throw new TopiaException(_( "topia.persistence.error.on.backup", eee.getMessage()), eee); } @@ -1287,7 +1286,7 @@ public void restore(File file) throws TopiaException { // send event getFiresSupport().firePreRestoreSchema(this); - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "restore")); @@ -1320,7 +1319,7 @@ // send event AFTER restore getFiresSupport().firePostRestoreSchema(this); } catch (Exception eee) { - throw new TopiaException(I18n._( + throw new TopiaException(_( "topia.persistence.error.on.restore", sql, eee.getMessage()), eee); } @@ -1346,7 +1345,7 @@ tx.closeContext(); root.finalize(); } catch (Throwable eee) { - throw new TopiaException(I18n._( + throw new TopiaException(_( "topia.persistence.error.on.clear", eee.getMessage()), eee); } } @@ -1359,7 +1358,7 @@ @Override public boolean isSchemaExist(Class<?> clazz) throws TopiaException { - checkClosed(I18n._( + checkClosed(_( "topia.persistence.error.unsupported.operation.on.closed.context", "replicateEntity")); boolean result = TopiaUtil.isSchemaExist(hibernateConfiguration, @@ -1475,7 +1474,7 @@ /** * Build the list of queries from the given parameter - * <code>entityAndCondition>/code>. + * <code>entityAndCondition</code>. * <p/> * If no parameter is given, then build the queries for all entities is db, * with no condition. @@ -1554,7 +1553,7 @@ } } catch (HibernateException eee) { - throw new TopiaException(I18n._( + throw new TopiaException(_( "topia.persistence.error.on.replicate", eee.getMessage()), eee); }
participants (1)
-
tchemit@users.nuiton.org