-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/schedule-java-ee-timer
- Loading branch information
Showing
36 changed files
with
410 additions
and
219 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
25 changes: 25 additions & 0 deletions
25
JBossServicePlusTimerTest/src/main/java/timertest/AppConfig.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,25 @@ | ||
package timertest; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
/** | ||
* | ||
* @author pete | ||
*/ | ||
@ApplicationScoped | ||
public class AppConfig { | ||
|
||
private String schedule; | ||
|
||
public AppConfig() { | ||
} | ||
|
||
public String getSchedule() { | ||
return schedule; | ||
} | ||
|
||
public void setSchedule(String schedule) { | ||
this.schedule = schedule; | ||
} | ||
|
||
} |
53 changes: 5 additions & 48 deletions
53
JBossServicePlusTimerTest/src/main/java/timertest/DummyExtension.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 |
---|---|---|
@@ -1,64 +1,21 @@ | ||
package timertest; | ||
|
||
import java.lang.annotation.Annotation; | ||
import javax.enterprise.context.spi.CreationalContext; | ||
import javax.enterprise.event.Observes; | ||
import javax.enterprise.inject.spi.AfterDeploymentValidation; | ||
import javax.enterprise.inject.spi.Bean; | ||
import javax.enterprise.inject.spi.BeanManager; | ||
import javax.enterprise.inject.spi.BeforeShutdown; | ||
import javax.enterprise.inject.spi.Extension; | ||
import javax.enterprise.inject.spi.ProcessObserverMethod; | ||
|
||
/** | ||
* | ||
* @author peteroyle | ||
*/ | ||
public class DummyExtension implements Extension { | ||
|
||
/** | ||
* Because "Extension classes should be public and have a public constructor for maximum portability" | ||
*/ | ||
public DummyExtension() { | ||
System.out.println("Initiailised DummyService"); | ||
public void afterValidation(@Observes AfterDeploymentValidation afterValid, final BeanManager manager, | ||
AppConfig appConfig) { | ||
System.out.println("After validation running ..."); | ||
appConfig.setSchedule("0 5 * * * *"); | ||
System.out.println("After validation complete"); | ||
} | ||
|
||
public void registerDummyServiceObserver(@Observes ProcessObserverMethod pom, DummyService dummyService) { | ||
System.out.println("processing observer method"); | ||
dummyService.init(); | ||
} | ||
|
||
public void afterValidation(@Observes AfterDeploymentValidation afterValid, final BeanManager manager | ||
) { | ||
DummyService dummyService = getInstanceByType(manager, DummyService.class); | ||
System.out.println("After validation"); | ||
dummyService.init(); | ||
} | ||
|
||
public void stopProviders(@Observes BeforeShutdown event, final BeanManager manager) { | ||
|
||
} | ||
|
||
|
||
/** | ||
* Utility method allowing managed instances of beans to provide entry points | ||
* for non-managed beans (such as {@link WeldContainer}). Should only called | ||
* once CDI has finished booting. | ||
* | ||
* @param manager the BeanManager to use to access the managed instance | ||
* @param type the type of the Bean | ||
* @param bindings the bean's qualifiers | ||
* @return a managed instance of the bean | ||
* | ||
*/ | ||
public static <T> T getInstanceByType(final BeanManager manager, final Class<T> type, final Annotation... bindings) { | ||
// TODO: (PR): fix this catch and swallow hackery | ||
try { | ||
final Bean<?> bean = manager.resolve(manager.getBeans(type)); | ||
final CreationalContext<?> cc = manager.createCreationalContext(bean); | ||
return type.cast(manager.getReference(bean, type, cc)); | ||
} catch (Throwable t) { | ||
return null; | ||
} | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
JBossServicePlusTimerTest/src/main/java/timertest/DummyService.java
This file was deleted.
Oops, something went wrong.
19 changes: 15 additions & 4 deletions
19
JBossServicePlusTimerTest/src/main/java/timertest/DummyServiceEjb.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 |
---|---|---|
@@ -1,18 +1,29 @@ | ||
package timertest; | ||
|
||
import javax.ejb.LocalBean; | ||
import javax.annotation.PostConstruct; | ||
import javax.annotation.Resource; | ||
import javax.ejb.Singleton; | ||
import javax.ejb.Startup; | ||
import javax.ejb.TimerService; | ||
import javax.inject.Inject; | ||
|
||
/** | ||
* | ||
* @author peteroyle | ||
*/ | ||
@Singleton | ||
@LocalBean | ||
public class DummyServiceEjb implements DummyService { | ||
@Startup | ||
public class DummyServiceEjb { | ||
|
||
@Inject | ||
private AppConfig appConfig; | ||
@Resource | ||
private TimerService timerService; | ||
|
||
@PostConstruct | ||
public void init() { | ||
System.out.println("Initialising dummy service implementation"); | ||
System.out.println("App Config Schedule: " + appConfig.getSchedule()); | ||
} | ||
|
||
} |
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
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,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project-shared-configuration> | ||
<!-- | ||
This file contains additional configuration written by modules in the NetBeans IDE. | ||
The configuration is intended to be shared among all the users of project and | ||
therefore it is assumed to be part of version control checkout. | ||
Without this configuration present, some functionality in the IDE may be limited or fail altogether. | ||
--> | ||
<config-data xmlns="http://www.netbeans.org/ns/maven-config-data/1"> | ||
<configurations> | ||
<configuration id="longtests-provider-type-java-ee" profiles=""> | ||
<property name="longtests">true</property> | ||
<property name="provider.type">java-ee</property> | ||
</configuration> | ||
<configuration id="provider-type-java-ee" profiles=""> | ||
<property name="provider.type">java-ee</property> | ||
</configuration> | ||
</configurations> | ||
</config-data> | ||
</project-shared-configuration> |
Oops, something went wrong.