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
1 parent
d9aee10
commit 0fd76f0
Showing
9 changed files
with
318 additions
and
36 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
44 changes: 44 additions & 0 deletions
44
impl/src/main/java/org/jboss/forge/furnace/container/cdi/events/EventManagerImpl.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,44 @@ | ||
/* | ||
* Copyright 2013 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.jboss.forge.furnace.container.cdi.events; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
import javax.enterprise.inject.spi.BeanManager; | ||
|
||
import org.jboss.forge.furnace.addons.Addon; | ||
import org.jboss.forge.furnace.event.EventException; | ||
import org.jboss.forge.furnace.event.EventManager; | ||
|
||
/** | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
* | ||
*/ | ||
public class EventManagerImpl implements EventManager | ||
{ | ||
private Addon addon; | ||
private BeanManager manager; | ||
|
||
public EventManagerImpl(Addon addon, BeanManager manager) | ||
{ | ||
this.addon = addon; | ||
this.manager = manager; | ||
} | ||
|
||
@Override | ||
public void fireEvent(Object event, Annotation... qualifiers) throws EventException | ||
{ | ||
try | ||
{ | ||
manager.fireEvent(new InboundEvent(event, qualifiers)); | ||
} | ||
catch (Throwable e) | ||
{ | ||
throw new EventException("Could not propagate event to addon [" + addon + "]", e); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
impl/src/main/java/org/jboss/forge/furnace/container/cdi/events/EventManagerProducer.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,22 @@ | ||
package org.jboss.forge.furnace.container.cdi.events; | ||
|
||
import javax.enterprise.inject.Produces; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
public class EventManagerProducer | ||
{ | ||
private EventManagerImpl manager; | ||
|
||
@Produces | ||
@Singleton | ||
public EventManagerImpl produce() | ||
{ | ||
return manager; | ||
} | ||
|
||
public void setEventManager(EventManagerImpl manager) | ||
{ | ||
this.manager = manager; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
impl/src/main/java/org/jboss/forge/furnace/container/cdi/events/InboundEvent.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,69 @@ | ||
/* | ||
* Copyright 2013 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.jboss.forge.furnace.container.cdi.events; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
* | ||
*/ | ||
public class InboundEvent | ||
{ | ||
private Object event; | ||
private Annotation[] qualifiers; | ||
|
||
public InboundEvent(Object event, Annotation[] qualifiers) | ||
{ | ||
this.event = event; | ||
this.qualifiers = qualifiers; | ||
} | ||
|
||
public Object getEvent() | ||
{ | ||
return event; | ||
} | ||
|
||
public Annotation[] getQualifiers() | ||
{ | ||
return qualifiers; | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((event == null) ? 0 : event.hashCode()); | ||
result = prime * result + Arrays.hashCode(qualifiers); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) | ||
{ | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
InboundEvent other = (InboundEvent) obj; | ||
if (event == null) | ||
{ | ||
if (other.event != null) | ||
return false; | ||
} | ||
else if (!event.equals(other.event)) | ||
return false; | ||
if (!Arrays.equals(qualifiers, other.qualifiers)) | ||
return false; | ||
return true; | ||
} | ||
|
||
} |
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.