forked from thorntail/thorntail
-
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.
SWARM-1114: JSF auto-detection when faces-config.xml is present (thor…
…ntail#413) * SWARM-1114: JSF auto-detection when faces-config.xml is present Motivation ---------- Auto-detection did not kick in when faces-config.xml was present Modifications ------------- Added new scanner and detector Result ------ The JSF fraction and it's dependents (i.e. undertow) will be added to the uberJar build * The class wasn’t really abstract
- Loading branch information
1 parent
d4b241d
commit 7296495
Showing
4 changed files
with
128 additions
and
3 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
fractions/javaee/jsf/src/main/java/org/wildfly/swarm/jsf/detect/FacesXmlDetector.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 2017 Red Hat, Inc, and individual contributors. | ||
* | ||
* 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.wildfly.swarm.jsf.detect; | ||
|
||
import org.wildfly.swarm.spi.meta.FileDetector; | ||
|
||
/** | ||
* @author Heiko Braun | ||
*/ | ||
public class FacesXmlDetector extends FileDetector { | ||
|
||
@Override | ||
public String extensionToDetect() { | ||
return XML; | ||
} | ||
|
||
@Override | ||
public boolean detectionComplete() { | ||
return detectionComplete; | ||
} | ||
|
||
@Override | ||
public boolean wasDetected() { | ||
return detected; | ||
} | ||
|
||
@Override | ||
public void detect(String fileName) { | ||
if (!detectionComplete() && fileName.endsWith(FACES_CONFIG_XML)) { | ||
detected = true; | ||
detectionComplete = true; | ||
} | ||
} | ||
|
||
@Override | ||
public String artifactId() { | ||
return JSF; | ||
} | ||
|
||
private static final String XML = "xml"; | ||
|
||
private static final String FACES_CONFIG_XML = "faces-config.xml"; | ||
|
||
private static final String JSF = "jsf"; | ||
|
||
private boolean detected = false; | ||
|
||
private boolean detectionComplete = false; | ||
|
||
} | ||
|
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
48 changes: 48 additions & 0 deletions
48
...ction-metadata/src/main/java/org/wildfly/swarm/fractions/scanner/FilePresenceScanner.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,48 @@ | ||
/** | ||
* Copyright 2017 Red Hat, Inc, and individual contributors. | ||
* | ||
* 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.wildfly.swarm.fractions.scanner; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Collection; | ||
import java.util.function.Consumer; | ||
|
||
import org.wildfly.swarm.spi.meta.FileDetector; | ||
import org.wildfly.swarm.spi.meta.FractionDetector; | ||
|
||
/** | ||
* @author Heiko Braun | ||
*/ | ||
public class FilePresenceScanner implements Scanner<String> { | ||
@Override | ||
public String extension() { | ||
return XML; | ||
} | ||
|
||
/** | ||
* scans all xml files | ||
*/ | ||
@Override | ||
public void scan(String name, final InputStream input, Collection<FractionDetector<String>> detectors, Consumer<File> handleFileAsZip) throws IOException { | ||
detectors.stream() | ||
.filter(d -> FileDetector.class.isAssignableFrom(d.getClass())) | ||
.forEach(d -> d.detect(name)); | ||
} | ||
|
||
private static final String XML = "xml"; | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
meta/meta-spi/src/main/java/org/wildfly/swarm/spi/meta/FileDetector.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,10 @@ | ||
package org.wildfly.swarm.spi.meta; | ||
|
||
/** | ||
* @author Heiko Braun | ||
* @since 09/03/2017 | ||
*/ | ||
public abstract class FileDetector implements FractionDetector<String> { | ||
@Override | ||
public abstract void detect(String fileName); | ||
} |