generated from cuioss/cui-java-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,289 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...tal-common-cdi/src/main/java/de/cuioss/portal/common/bundle/PortalResourceBundleBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* <p> | ||
* Licensed 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 | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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 de.cuioss.portal.common.bundle; | ||
|
||
import java.io.Serializable; | ||
import java.util.Collections; | ||
import java.util.Enumeration; | ||
import java.util.ResourceBundle; | ||
import java.util.Set; | ||
|
||
import javax.faces.application.Application; | ||
import javax.inject.Inject; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
|
||
/** | ||
* <p> | ||
* Portal variant of {@link ResourceBundle}. It delegates to | ||
* {@link ResourceBundleWrapper} that does the actual heavy lifting. | ||
* </p> | ||
* <p> | ||
* It usage is for cases where there is technically a {@link ResourceBundle} | ||
* needed. Sadly there is no corresponding interface, solely an Abstract-Class | ||
* that can not be proxied by CDI. Currently it's sole use is the context of the | ||
* PortalApplication, that it exposes it on | ||
* {@link Application#getResourceBundle(javax.faces.context.FacesContext, String)} | ||
* with the name "msgs" | ||
* | ||
* It can be used directly in jsf views: {@code #{msgs['page.401.title']}} | ||
* </p> | ||
* | ||
* @author Oliver Wolff | ||
*/ | ||
@EqualsAndHashCode(callSuper = false) | ||
@ToString | ||
public class PortalResourceBundleBean extends ResourceBundle implements Serializable { | ||
|
||
private static final long serialVersionUID = 3953649686127640297L; | ||
|
||
/** Lookup name for el-expression within views: "msgs" */ | ||
public static final String BUBDLE_NAME = "msgs"; | ||
|
||
@Inject | ||
private ResourceBundleWrapper resourceBundleWrapper; | ||
|
||
private String allBundleNames; | ||
|
||
@Override | ||
protected Object handleGetObject(final String key) { | ||
return resourceBundleWrapper.getString(key); | ||
} | ||
|
||
@Override | ||
public Enumeration<String> getKeys() { | ||
return Collections.enumeration(keySet()); | ||
} | ||
|
||
@Override | ||
public Set<String> keySet() { | ||
return resourceBundleWrapper.keySet(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 0 additions & 100 deletions
100
...l-common-cdi/src/main/java/de/cuioss/portal/common/bundle/ResourceBundleRegistryImpl.java
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
...portal-common-cdi/src/main/java/de/cuioss/portal/common/bundle/ResourceBundleWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* <p> | ||
* Licensed 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 | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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 de.cuioss.portal.common.bundle; | ||
|
||
import java.io.Serializable; | ||
import java.util.Collections; | ||
import java.util.Enumeration; | ||
import java.util.MissingResourceException; | ||
import java.util.ResourceBundle; | ||
import java.util.Set; | ||
|
||
/** | ||
* Defines the portal-contract dealing with UnifiedResourceBundle Technically it | ||
* provides an interface similar to {@link ResourceBundle} | ||
* | ||
* @author Oliver Wolff | ||
*/ | ||
public interface ResourceBundleWrapper extends Serializable { | ||
|
||
/** | ||
* Returns resolved message by given key. | ||
* | ||
* @param key to be looked up | ||
* @return the resolved message if key is defined, otherwise "??[key value]??" | ||
* will be returned and warning will be written | ||
* @throws MissingResourceException if key is unknown and application is in | ||
* development mode | ||
*/ | ||
String getString(String key); | ||
|
||
/** | ||
* Technical method for {@link ResourceBundle} caching the resolved keys and | ||
* values @see {@link ResourceBundle#getKeys()} | ||
* | ||
* @return an Enumeration of the keys contained in this ResourceBundle and its | ||
* parent bundles. | ||
*/ | ||
default Enumeration<String> getKeys() { | ||
return Collections.enumeration(keySet()); | ||
} | ||
|
||
/** | ||
* @return set of all supported keys of this bundle | ||
*/ | ||
Set<String> keySet(); | ||
|
||
/** | ||
* @return a list of all configured bundles to be used for debugging. | ||
*/ | ||
String getBundleContent(); | ||
|
||
} |
Oops, something went wrong.