-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Proposed Changes * In this PR we are upgrading to jersey 2.28 * We are changing DotRestApplication to use package discovery to load Resources and Providers * We're making some adjustments on some Mappers to preserve the present behavior * We're introducing CDI through Weld container --------- Co-authored-by: spbolton <steve.bolton@dotcms.com>
- Loading branch information
1 parent
acbd281
commit 11358b0
Showing
40 changed files
with
472 additions
and
1,956 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
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,35 @@ | ||
package com.dotcms.cdi; | ||
|
||
import com.dotmarketing.util.Logger; | ||
import java.util.Optional; | ||
import javax.enterprise.inject.spi.CDI; | ||
|
||
/** | ||
* Utility class to get beans from CDI container | ||
*/ | ||
public class CDIUtils { | ||
|
||
/** | ||
* Private constructor to avoid instantiation | ||
*/ | ||
private CDIUtils() { | ||
} | ||
|
||
/** | ||
* Get a bean from CDI container | ||
* @param clazz the class of the bean | ||
* @return an Optional with the bean if found, empty otherwise | ||
*/ | ||
public static <T> Optional<T> getBean(Class<T> clazz) { | ||
try { | ||
return Optional.of(CDI.current().select(clazz).get()); | ||
} catch (Exception e) { | ||
Logger.error(CDIUtils.class, | ||
String.format("Unable to find bean of class [%s] [%s]", clazz, e.getMessage()) | ||
); | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
|
||
} |
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
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
Oops, something went wrong.