Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ApplicationInitializer which checks CDI availability. Merged
VersionLoggerEventListener and FacesViewsInitializer into this as well. Updated Messages javadoc.
- Loading branch information
Bauke Scholtz
committed
Jul 9, 2014
1 parent
4442e3b
commit bce5f0c
Showing
7 changed files
with
174 additions
and
166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright 2013 OmniFaces. | ||
* | ||
* 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 | ||
* | ||
* 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.omnifaces; | ||
|
||
import java.util.Set; | ||
import java.util.logging.Logger; | ||
|
||
import javax.servlet.ServletContainerInitializer; | ||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
|
||
import org.omnifaces.facesviews.FacesViews; | ||
import org.omnifaces.util.Faces; | ||
|
||
/** | ||
* <p>OmniFaces application initializer. So far, this performs the following tasks: | ||
* <ul> | ||
* <li>Log the OmniFaces version. | ||
* <li>Check if CDI is present, otherwise log and fail. | ||
* <li>Initialize FacesViews. | ||
* </li> | ||
* | ||
* @author Bauke Scholtz | ||
* @since 2.0 | ||
*/ | ||
public class ApplicationInitializer implements ServletContainerInitializer { | ||
|
||
private static final Logger logger = Logger.getLogger(ApplicationInitializer.class.getName()); | ||
|
||
@Override | ||
public void onStartup(Set<Class<?>> c, ServletContext servletContext) throws ServletException { | ||
logOmniFacesVersion(); | ||
checkCDIAvailability(); | ||
FacesViews.initilaize(servletContext); | ||
} | ||
|
||
private static void logOmniFacesVersion() { | ||
logger.info("Using OmniFaces version " + Faces.class.getPackage().getSpecificationVersion()); | ||
} | ||
|
||
private static void checkCDIAvailability() throws ServletException { | ||
try { | ||
Class.forName("javax.enterprise.inject.spi.BeanManager"); | ||
} | ||
catch (Throwable e) { | ||
logger.severe("" | ||
+ "\n████████████████████████████████████████████████████████████████████████████████" | ||
+ "\n▌ ▐█ ▐ ▐" | ||
+ "\n▌ ▄ ▄█▓█▌ ▐ OmniFaces failed to initialize! ▐" | ||
+ "\n▌ ▐██▄ ▄▓░░▓▓ ▐ ▐" | ||
+ "\n▌ ▐█░██▓ ▓▓░░░▓▌ ▐ This OmniFaces version requires CDI, but ▐" | ||
+ "\n▌ ▐█▌░▓██ █▓░░░░▓ ▐ none was found on this environment. ▐" | ||
+ "\n▌ ▓█▌░░▓█▄███████▄███▓░▓█ ▐ ▐" | ||
+ "\n▌ ▓██▌░▓██░░░░░░░░░░▓█░▓▌ ▐ OmniFaces 2.x requires a minimum of JSF 2.2.▐" | ||
+ "\n▌ ▓█████░░░░░░░░░░░░▓██ ▐ Since this JSF version, the JSF managed bean▐" | ||
+ "\n▌ ▓██▓░░░░░░░░░░░░░░░▓█ ▐ facility @ManagedBean is semi-official ▐" | ||
+ "\n▌ ▐█▓░░░░░░█▓░░▓█░░░░▓█▌ ▐ deprecated in favour of CDI. JSF 2.2 users ▐" | ||
+ "\n▌ ▓█▌░▓█▓▓██▓░█▓▓▓▓▓░▓█▌ ▐ are strongly encouraged to move to CDI. ▐" | ||
+ "\n▌ ▓▓░▓██████▓░▓███▓▓▌░█▓ ▐ ▐" | ||
+ "\n▌ ▐▓▓░█▄▐▓▌█▓░░▓█▐▓▌▄▓░██ ▐ OmniFaces goes a step further by making CDI ▐" | ||
+ "\n▌ ▓█▓░▓█▄▄▄█▓░░▓█▄▄▄█▓░██▌ ▐ a REQUIRED dependency next to JSF 2.2. This ▐" | ||
+ "\n▌ ▓█▌░▓█████▓░░░▓███▓▀░▓█▓ ▐ not only ensures that your web application ▐" | ||
+ "\n▌ ▐▓█░░░▀▓██▀░░░░░ ▀▓▀░░▓█▓ ▐ represents the state of art, but this also ▐" | ||
+ "\n▌ ▓██░░░░░░░░▀▄▄▄▄▀░░░░░░▓▓ ▐ makes for us easier to develop OmniFaces, ▐" | ||
+ "\n▌ ▓█▌░░░░░░░░░░▐▌░░░░░░░░▓▓▌ ▐ without the need for all sorts of hacks in ▐" | ||
+ "\n▌ ▓█░░░░░░░░░▄▀▀▀▀▄░░░░░░░█▓ ▐ in order to get OmniFaces to deploy on ▐" | ||
+ "\n▌ ▐█▌░░░░░░░░▀░░░░░░▀░░░░░░█▓▌ ▐ environments without CDI. ▐" | ||
+ "\n▌ ▓█░░░░░░░░░░░░░░░░░░░░░░░██▓ ▐ ▐" | ||
+ "\n▌ ▓█░░░░░░░░░░░░░░░░░░░░░░░▓█▓ ▐ You have 3 options: ▐" | ||
+ "\n██████████████████████████████████ 1. Downgrade to OmniFaces 1.x. ▐" | ||
+ "\n█░▀░░░░▀█▀░░░░░░▀█░░░░░░▀█▀░░░░░▀█ 2. Install CDI in this environment. ▐" | ||
+ "\n█░░▐█▌░░█░░░██░░░█░░██░░░█░░░██░░█ 3. Switch to a CDI capable environment. ▐" | ||
+ "\n█░░▐█▌░░█░░░██░░░█░░██░░░█░░░██░░█ ▐" | ||
+ "\n█░░▐█▌░░█░░░██░░░█░░░░░░▄█░░▄▄▄▄▄█ For additional instructions, check ▐" | ||
+ "\n█░░▐█▌░░█░░░██░░░█░░░░████░░░░░░░█ http://omnifaces.org/cdi ▐" | ||
+ "\n█░░░█░░░█▄░░░░░░▄█░░░░████▄░░░░░▄█ ▐" | ||
+ "\n████████████████████████████████████████████████████████████████████████████████" | ||
); | ||
|
||
throw new ServletException(); | ||
} | ||
} | ||
|
||
} |
38 changes: 0 additions & 38 deletions
38
src/main/java/org/omnifaces/VersionLoggerEventListener.java
This file was deleted.
Oops, something went wrong.
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
119 changes: 0 additions & 119 deletions
119
src/main/java/org/omnifaces/facesviews/FacesViewsInitializer.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.