Skip to content

Instantly share code, notes, and snippets.

View johnament's full-sized avatar

John Ament johnament

View GitHub Profile
@johnament
johnament / CDIMethodVsFieldProducer
Created December 31, 2010 13:59
Should these two producers be the exact same?
@Produces
@ApplicationScoped
@Resource("/ConnectionFactory")
private ConnectionFactory cf;
vs.
@Resource("/ConnectionFactory")
private ConnectionFactory cf;
@johnament
johnament / CDIMessageListener.java
Created January 9, 2011 16:25
Should this work correctly with HornetQ?
@ApplicationScoped
@SomeQualifier
public class CDIMessageListener implements MessageListener {
@Inject Logger logger;
public void onMessage(Message m) {
logger.info("Received a message of type "+m.getClass().getCanonicalName());
}
}
@johnament
johnament / QueueHandlerMDB.java
Created February 5, 2011 16:36
Sample MDB that fires events.
package com.tad.jms.jmsmanagingapp;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.enterprise.event.Event;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
@johnament
johnament / SendEventResource.java
Created February 25, 2011 01:07
Demonstrates event firing, both observers get called when es3 is fired.
@RequestScoped
@Path("/send")
public class SendEventResource {
@Inject @QualOne Event<String> es1;
@Inject @QualTwo Event<String> es2;
@Inject @QualOne @QualTwo Event<String> es3;
@Inject Logger logger;
@Path("/{data}")
@GET
@Produces("text/plain")
@johnament
johnament / gist:850243
Created March 2, 2011 00:56
RepoOneRepository
@Qualifier
@Target( { FIELD, METHOD, TYPE, PARAMETER })
@Retention(RUNTIME)
@JcrSettings({
@JcrSetting(name="org.modeshape.config.URL",value="file:///path/to/modeshape-jcr.xml?repositoryName=RepoOne"),
@JcrSetting(name="org.modeshape.config.AnotherParam",value="happy")
})
public @interface RepoOneRepository {
}
@johnament
johnament / EventFiringBean.java
Created June 7, 2011 12:02
CDI Event Qualifiers
public class EventFiringBean {
@Inject @Outbound Event<String> stringJmsEvent;
@Inject @Inbound Event<String> stringJmsInboundEvent;
@Inject Event<String> stringEvent;
}
exception
javax.servlet.ServletException: No EjbLookup registry has been provided CDI @EJB injection [field] @EJB org.jboss.seam.jms.example.statuswatcher.session.ReceivingClient.statusManager
javax.faces.webapp.FacesServlet.service(FacesServlet.java:325)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
org.jboss.seam.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:62)
org.jboss.seam.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72)
root cause
<johnament> gastaldi: is it possible to create a service handler that could automatically bind a DAO for a node via an interface?
<gastaldi> johnament: I guess so, using Solder right ?
<johnament> gastaldi: yep
<johnament> gastaldi: basically, i think it would be easiest to provide jcr session capabilities as a service handler based on interface methods.
<gastaldi> hummm
<gastaldi> Seam JCR provides the impl
<gastaldi> And the App developer the interface
<gastaldi> right ?
<gastaldi> We should have some sort of annotations to make it happen
<gastaldi> So that info could be read on the Service handler impl
@johnament
johnament / gist:1103419
Created July 25, 2011 02:13
OWB Stacktrace
-------------------------------------------------------------------------------
Test set: org.jboss.seam.jms.test.activemq.inject.ActiveMQConnectionFactoryProducerTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 1.376 sec <<< FAILURE!
testJmsConnectionFactoryProducer(org.jboss.seam.jms.test.activemq.inject.ActiveMQConnectionFactoryProducerTest) Time elapsed: 0.516 sec <<< ERROR!
java.lang.RuntimeException: Could not inject members
at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:103)
at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.enrich(CDIInjectionEnricher.java:51)
at org.jboss.arquillian.impl.enricher.ClientTestEnricher.enrich(ClientTestEnricher.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
@johnament
johnament / ApplicationConsumer.java
Created September 18, 2011 13:40 — forked from pmuir/ApplicationConsumer.java
Resource Producer proposal for JMS 2.0
/**
* PLM: ApplicationConsumer is a class provided by the application, and injects and
* uses the resources defined in the central Resources class. An application would
* typically have multiple ApplicationConsumer-style classes - this is just an
* example
*/
public class ApplicationConsumer {
// regular destination.
@Inject @FooMyTopic