[JBoss AOP] - calling aspect from netty thread inside jboss 5.1
by Gabriel Bermudez
Gabriel Bermudez [http://community.jboss.org/people/elgabo] created the discussion
"calling aspect from netty thread inside jboss 5.1"
To view the discussion, visit: http://community.jboss.org/message/550087#550087
--------------------------------------------------------------
Hi,
We are using netty to send and receive network messages. But for some reason advices are not being called when messages are received.
All classes and xml files involved on the project are _not_ inside the same jar, basically I have 2 jar, basic.jar with common code like the aspect, the jboss-beans.xml file where the netty SocketChannelFactory is defined (a exact copy of the file found inside netty.jar/META-INF/jboss-beans.xml) and other common beans defined inside jboss-beans.xml file
basic.jar
+com.test.* (common classes)
+com.test.TestAspect
+META-INF
+jboss-beans.xml
+netty-jboss-beans.xml
And network.jar with network specific code like MyNetworkListener, netty ChannleHandlers, and of course the jboss-beans.xml file that defines beans and aspects
network.jar
+com.test.MyNetworkListener
+META-INF
+jboss-beans.xml
For example I have the following aspect:
public class TestAspect {
createSomething(MethodInvocation inv) {...}
updateSomething(MethodInvocation inv) {...}
}
updateSomething must be called after a message is received from network so inside jboss-beans.xml I put
<aop:aspect xmlns:aop="urn:jboss:aop-beans:1.0"
xsi:schemaLocation="urn:jboss:aop-beans:1.0 aop-beans_1_0.xsd"
class="com.test.TestAspect" name="TestAspect"/>
<aop:bind xmlns:aop="urn:jboss:aop-beans:1.0"
xsi:schemaLocation="urn:jboss:aop-beans:1.0 aop-beans_1_0.xsd"
pointcut="execution(public void com.test.MyNetworkListener->responseReceived(..))">
<aop:after aspect="TestAspect" name="updateSomething"/>
</aop:bind>
the MyNetworkListener.responseReceived method is called by a netty ChannelHandler (obviosly running inside a IO thread) so I'm guessing that MyNetworkListener is not being weived properly because is being called from a thread not managed by the jboss server/aop libs? or maybe is a classloading issue?
Thanks for your help on this issue
Regards,
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/550087#550087]
Start a new discussion in JBoss AOP at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 11 months
[JBoss Web Services] - Web Service annotated with @PostConstruct - wrong order w.r.t Listener
by Mike Norman
Mike Norman [http://community.jboss.org/people/mwnorman] created the discussion
"Web Service annotated with @PostConstruct - wrong order w.r.t Listener"
To view the discussion, visit: http://community.jboss.org/message/550061#550061
--------------------------------------------------------------
I have a Web Service:
//javase imports
import java.io.InputStream;
import java.io.StringReader;
import org.xml.sax.InputSource;
//java eXtension imports
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.servlet.ServletContext;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.transform.dom.DOMSource;
import javax.xml.ws.Provider;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;
import javax.xml.ws.soap.SOAPFaultException;
import static javax.xml.ws.Service.Mode.MESSAGE;@WebServiceProvider(
wsdlLocation = "WEB-INF/wsdl/eclipselink-dbws.wsdl",
serviceName = "simpleService",
portName = "simpleServicePort",
targetNamespace = "urn:simpleService"
)
@ServiceMode(MESSAGE)
public class SimpleProvider implements Provider<SOAPMessage> {
@PostConstruct
public void init() {
System.out.println("*****************init");
ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader();
InputStream eclipseLinkStream = parentClassLoader.getResourceAsStream(
"/META-INF/eclipselink-dbws-or.xml");
if (eclipseLinkStream != null) {
System.out.println("/META-INF/eclipselink-dbws-or.xml = " +
eclipseLinkStream.toString());
}
ServletContext sc = ProviderListener.SC;
if (sc == null) {
System.out.println("servlet context is null");
}
else {
InputStream schemaStream =
sc.getResourceAsStream("/WEB-INF/wsdl/eclipselink-dbws-schema.xsd");
System.out.println("WEB-INF/wsdl/eclipselink-dbws-schema.xsd = " +
schemaStream.toString());
}
}
...
I also have a ServletContextListener:
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class ProviderListener implements ServletContextListener {
public static ServletContext SC = null;
public ProviderListener() {
super();
}
public void contextInitialized(ServletContextEvent sce) {
System.out.println("*****************ServletContext initialized");
SC = sce.getServletContext();
}
public void contextDestroyed(ServletContextEvent sce) {
// no-op }
}
When I deploy to Glassfish, WebLogic and WebSphere, the order of execution is: Listener, then @PostConstruct
However, when I deploy to JBoss 5.10 (w Metro), the order is @PostConstruct then Listener.
Is this a known issue, or is there a workaround?
Thanks in advance,
Mike Norman
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/550061#550061]
Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 11 months