Hmm, good point. Thx
On 18 February 2015 at 08:54, Martin Grigorov <[email protected]> wrote: > On Wed, Feb 18, 2015 at 10:24 AM, <[email protected]> wrote: > > > Repository: isis > > Updated Branches: > > refs/heads/ISIS-903 980586f51 -> 1b9f7e8df > > > > > > ISIS-903: renaming UrlResolver to TranslationsResolver > > > > > > Project: http://git-wip-us.apache.org/repos/asf/isis/repo > > Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/1b9f7e8d > > Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/1b9f7e8d > > Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/1b9f7e8d > > > > Branch: refs/heads/ISIS-903 > > Commit: 1b9f7e8dfeb5b3e87ea2288eec8708c3fd013859 > > Parents: 980586f > > Author: Dan Haywood <[email protected]> > > Authored: Wed Feb 18 08:23:59 2015 +0000 > > Committer: Dan Haywood <[email protected]> > > Committed: Wed Feb 18 08:23:59 2015 +0000 > > > > ---------------------------------------------------------------------- > > .../services/TranslationsResolverWicket.java | 68 > ++++++++++++++++++++ > > .../viewer/services/UrlResolverWicket.java | 68 > -------------------- > > .../services/i18n/TranslationsResolver.java | 29 +++++++++ > > .../isis/applib/services/i18n/UrlResolver.java | 29 --------- > > .../metamodel/services/i18n/po/PoReader.java | 10 +-- > > .../services/i18n/po/TranslationServicePo.java | 20 +++--- > > 6 files changed, 113 insertions(+), 111 deletions(-) > > ---------------------------------------------------------------------- > > > > > > > > > http://git-wip-us.apache.org/repos/asf/isis/blob/1b9f7e8d/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/services/TranslationsResolverWicket.java > > ---------------------------------------------------------------------- > > diff --git > > > a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/services/TranslationsResolverWicket.java > > > b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/services/TranslationsResolverWicket.java > > new file mode 100644 > > index 0000000..0a104b8 > > --- /dev/null > > +++ > > > b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/services/TranslationsResolverWicket.java > > @@ -0,0 +1,68 @@ > > +/* > > + * Licensed to the Apache Software Foundation (ASF) under one > > + * or more contributor license agreements. See the NOTICE file > > + * distributed with this work for additional information > > + * regarding copyright ownership. The ASF licenses this file > > + * to you under the Apache License, Version 2.0 (the > > + * "License"); you may not use this file except in compliance > > + * with the License. You may obtain a copy of the License at > > + * > > + * http://www.apache.org/licenses/LICENSE-2.0 > > + * > > + * Unless required by applicable law or agreed to in writing, > > + * software distributed under the License is distributed on an > > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > > + * KIND, either express or implied. See the License for the > > + * specific language governing permissions and limitations > > + * under the License. > > + */ > > +package org.apache.isis.viewer.wicket.viewer.services; > > + > > +import java.io.IOException; > > +import java.net.URL; > > +import java.util.List; > > +import javax.servlet.ServletContext; > > +import com.google.common.base.Charsets; > > +import com.google.common.io.CharSource; > > +import com.google.common.io.Resources; > > +import org.slf4j.Logger; > > +import org.slf4j.LoggerFactory; > > +import org.apache.isis.applib.annotation.DomainService; > > +import org.apache.isis.applib.annotation.Programmatic; > > +import org.apache.isis.applib.services.i18n.TranslationsResolver; > > +import org.apache.isis.viewer.wicket.viewer.IsisWicketApplication; > > + > > + > > +/** > > + * An implementation that reads from /WEB-INF/... > > + */ > > +@DomainService > > +public class TranslationsResolverWicket implements TranslationsResolver > { > > + > > + public static Logger LOG = > > LoggerFactory.getLogger(TranslationsResolverWicket.class); > > + > > + @Override > > + @Programmatic > > > > > > > + public List<String> readLines(final String file) { > > + try { > > + final ServletContext servletContext = > > getIsisWicketApplication().getServletContext(); > > + final URL url = servletContext.getResource("/WEB-INF/" + > > file); > > > > I think this should take into account "isis.config.dir" context param. > Otherwise it will break > http://isis.apache.org/reference/externalized-configuration.html > > > > + return readLines(url); > > + } catch (final RuntimeException | IOException ignored) { > > + return null; > > + } > > + } > > + > > + private static List<String> readLines(final URL url) throws > > IOException { > > + if(url == null) { > > + return null; > > + } > > + final CharSource charSource = Resources.asCharSource(url, > > Charsets.UTF_8); > > + return charSource.readLines(); > > + } > > + > > + protected IsisWicketApplication getIsisWicketApplication() { > > + return IsisWicketApplication.get(); > > + } > > + > > +} > > > > > > > http://git-wip-us.apache.org/repos/asf/isis/blob/1b9f7e8d/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/services/UrlResolverWicket.java > > ---------------------------------------------------------------------- > > diff --git > > > a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/services/UrlResolverWicket.java > > > b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/services/UrlResolverWicket.java > > deleted file mode 100644 > > index e735573..0000000 > > --- > > > a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/services/UrlResolverWicket.java > > +++ /dev/null > > @@ -1,68 +0,0 @@ > > -/* > > - * Licensed to the Apache Software Foundation (ASF) under one > > - * or more contributor license agreements. See the NOTICE file > > - * distributed with this work for additional information > > - * regarding copyright ownership. The ASF licenses this file > > - * to you under the Apache License, Version 2.0 (the > > - * "License"); you may not use this file except in compliance > > - * with the License. You may obtain a copy of the License at > > - * > > - * http://www.apache.org/licenses/LICENSE-2.0 > > - * > > - * Unless required by applicable law or agreed to in writing, > > - * software distributed under the License is distributed on an > > - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > > - * KIND, either express or implied. See the License for the > > - * specific language governing permissions and limitations > > - * under the License. > > - */ > > -package org.apache.isis.viewer.wicket.viewer.services; > > - > > -import java.io.IOException; > > -import java.net.URL; > > -import java.util.List; > > -import javax.servlet.ServletContext; > > -import com.google.common.base.Charsets; > > -import com.google.common.io.CharSource; > > -import com.google.common.io.Resources; > > -import org.slf4j.Logger; > > -import org.slf4j.LoggerFactory; > > -import org.apache.isis.applib.annotation.DomainService; > > -import org.apache.isis.applib.annotation.Programmatic; > > -import org.apache.isis.applib.services.i18n.UrlResolver; > > -import org.apache.isis.viewer.wicket.viewer.IsisWicketApplication; > > - > > - > > -/** > > - * An implementation that reads from /WEB-INF/... > > - */ > > -@DomainService > > -public class UrlResolverWicket implements UrlResolver { > > - > > - public static Logger LOG = > > LoggerFactory.getLogger(UrlResolverWicket.class); > > - > > - @Override > > - @Programmatic > > - public List<String> readLines(final String file) { > > - try { > > - final ServletContext servletContext = > > getIsisWicketApplication().getServletContext(); > > - final URL url = servletContext.getResource("/WEB-INF/" + > > file); > > - return readLines(url); > > - } catch (final RuntimeException | IOException ignored) { > > - return null; > > - } > > - } > > - > > - private static List<String> readLines(final URL url) throws > > IOException { > > - if(url == null) { > > - return null; > > - } > > - final CharSource charSource = Resources.asCharSource(url, > > Charsets.UTF_8); > > - return charSource.readLines(); > > - } > > - > > - protected IsisWicketApplication getIsisWicketApplication() { > > - return IsisWicketApplication.get(); > > - } > > - > > -} > > > > > > > http://git-wip-us.apache.org/repos/asf/isis/blob/1b9f7e8d/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationsResolver.java > > ---------------------------------------------------------------------- > > diff --git > > > a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationsResolver.java > > > b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationsResolver.java > > new file mode 100644 > > index 0000000..218725c > > --- /dev/null > > +++ > > > b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationsResolver.java > > @@ -0,0 +1,29 @@ > > +/* > > + * Licensed to the Apache Software Foundation (ASF) under one > > + * or more contributor license agreements. See the NOTICE file > > + * distributed with this work for additional information > > + * regarding copyright ownership. The ASF licenses this file > > + * to you under the Apache License, Version 2.0 (the > > + * "License"); you may not use this file except in compliance > > + * with the License. You may obtain a copy of the License at > > + * > > + * http://www.apache.org/licenses/LICENSE-2.0 > > + * > > + * Unless required by applicable law or agreed to in writing, > > + * software distributed under the License is distributed on an > > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > > + * KIND, either express or implied. See the License for the > > + * specific language governing permissions and limitations > > + * under the License. > > + */ > > +package org.apache.isis.applib.services.i18n; > > + > > +import java.util.List; > > +import org.apache.isis.applib.annotation.Programmatic; > > + > > +public interface TranslationsResolver { > > + > > + @Programmatic > > + public List<String> readLines(final String file); > > + > > +} > > > > > > > http://git-wip-us.apache.org/repos/asf/isis/blob/1b9f7e8d/core/applib/src/main/java/org/apache/isis/applib/services/i18n/UrlResolver.java > > ---------------------------------------------------------------------- > > diff --git > > > a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/UrlResolver.java > > > b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/UrlResolver.java > > deleted file mode 100644 > > index 5dcb614..0000000 > > --- > > > a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/UrlResolver.java > > +++ /dev/null > > @@ -1,29 +0,0 @@ > > -/* > > - * Licensed to the Apache Software Foundation (ASF) under one > > - * or more contributor license agreements. See the NOTICE file > > - * distributed with this work for additional information > > - * regarding copyright ownership. The ASF licenses this file > > - * to you under the Apache License, Version 2.0 (the > > - * "License"); you may not use this file except in compliance > > - * with the License. You may obtain a copy of the License at > > - * > > - * http://www.apache.org/licenses/LICENSE-2.0 > > - * > > - * Unless required by applicable law or agreed to in writing, > > - * software distributed under the License is distributed on an > > - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > > - * KIND, either express or implied. See the License for the > > - * specific language governing permissions and limitations > > - * under the License. > > - */ > > -package org.apache.isis.applib.services.i18n; > > - > > -import java.util.List; > > -import org.apache.isis.applib.annotation.Programmatic; > > - > > -public interface UrlResolver { > > - > > - @Programmatic > > - public List<String> readLines(final String file); > > - > > -} > > > > > > > http://git-wip-us.apache.org/repos/asf/isis/blob/1b9f7e8d/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoReader.java > > ---------------------------------------------------------------------- > > diff --git > > > a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoReader.java > > > b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoReader.java > > index 19776bc..e0bb2b7 100644 > > --- > > > a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoReader.java > > +++ > > > b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoReader.java > > @@ -28,7 +28,7 @@ import com.google.common.collect.Maps; > > import org.slf4j.Logger; > > import org.slf4j.LoggerFactory; > > import org.apache.isis.applib.services.i18n.TranslationService; > > -import org.apache.isis.applib.services.i18n.UrlResolver; > > +import org.apache.isis.applib.services.i18n.TranslationsResolver; > > > > class PoReader extends PoAbstract { > > > > @@ -42,7 +42,7 @@ class PoReader extends PoAbstract { > > * > > * <p> > > * This means that the reader will search for > > <tt>translations_en-US.po</tt>, <tt>translations_en.po</tt>, > > - * <tt>translations.po</tt>, according to the location that the > > provided {@link org.apache.isis.applib.services.i18n.UrlResolver} > > searches. For example, if using the Wicket implementation, then will > > search for these files > > + * <tt>translations.po</tt>, according to the location that the > > provided {@link > org.apache.isis.applib.services.i18n.TranslationsResolver} > > searches. For example, if using the Wicket implementation, then will > > search for these files > > * under <tt>/WEB-INF</tt> directory. > > * </p> > > */ > > @@ -180,11 +180,11 @@ class PoReader extends PoAbstract { > > } > > > > private List<String> readUrl(final String candidate) { > > - final UrlResolver urlResolver = > > translationServicePo.getUrlResolver(); > > - if(urlResolver == null) { > > + final TranslationsResolver translationsResolver = > > translationServicePo.getTranslationsResolver(); > > + if(translationsResolver == null) { > > return null; > > } > > - return urlResolver.readLines(candidate); > > + return translationsResolver.readLines(candidate); > > } > > > > } > > > > > > > http://git-wip-us.apache.org/repos/asf/isis/blob/1b9f7e8d/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/TranslationServicePo.java > > ---------------------------------------------------------------------- > > diff --git > > > a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/TranslationServicePo.java > > > b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/TranslationServicePo.java > > index d1f1630..abde47b 100644 > > --- > > > a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/TranslationServicePo.java > > +++ > > > b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/TranslationServicePo.java > > @@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory; > > import org.apache.isis.applib.annotation.Programmatic; > > import org.apache.isis.applib.services.i18n.LocaleProvider; > > import org.apache.isis.applib.services.i18n.TranslationService; > > -import org.apache.isis.applib.services.i18n.UrlResolver; > > +import org.apache.isis.applib.services.i18n.TranslationsResolver; > > > > /** > > * Not annotated with @DomainService, but is registered as a > fallback > > by <tt>ServicesInstallerFallback</tt>. > > @@ -113,22 +113,24 @@ public class TranslationServicePo implements > > TranslationService { > > return ((PoWriter)po).toPot(); > > } > > > > - @Inject > > - private > > - UrlResolver urlResolver; > > + // ////////////////////////////////////// > > > > @Inject > > private > > - LocaleProvider localeProvider; > > - > > + TranslationsResolver translationsResolver; > > > > @Programmatic > > - public UrlResolver getUrlResolver() { > > - return urlResolver; > > + TranslationsResolver getTranslationsResolver() { > > + return translationsResolver; > > } > > > > + @Inject > > + private > > + LocaleProvider localeProvider; > > + > > @Programmatic > > - public LocaleProvider getLocaleProvider() { > > + LocaleProvider getLocaleProvider() { > > return localeProvider; > > } > > + > > } > > > > >
