0 Replies Latest reply on Oct 12, 2006 10:50 AM by Alexander Hachmann

    Speed Issue EJB3.0 vs. AXIS

    Alexander Hachmann Newbie

      Hi there,

      I am having a question about the decision whether to use Axis or EJB3.0 Annotations for Webservices.

      Now my point is, that in one of my tests EJB has a really hard Speedproblem.

      I am having the EpgDataService at the the end of this thread.

      I made this public with EJB 3.0 annotations, as you can see in the code and with Axis through normal Axis Pojo beployment.

      No i am calling the simple small method getBroadcasts() that simply returns the Broadcast beans which then have to be serialized to XML data for SOAP-Transportation.

      Here is the Problem. Axis from the scratch with simply deploying this Class through the wsdd files takes nearly onle one second to respond to the Client.

      EJB decides to take up to 20 Seconds for serializing the Broadcast beans.
      To desirialize them on the other side .Net needs an eye shut.

      Both applications ran on the JBoss 4.0.4

      Where could be the Problem? I'd be very astonished if this would really be to algorithmproblems with EJB 3.0. Am I missing somegthing important?

      P.S.
      It is not the Problem, that EJB perhaps more often runs the Static code due to the amount of the Classloaders. This is done quite fast and are no reason for the 20 Seconds delay that apear after a breakpoint putec in the called Webmethod.

      Any Idea? Thanks,
      Alexander

      @Stateless
      @WebService
      public class EpgDataService implements BroadCastService {
      
       public static Document d;
       public static Set<BroadCastImpl> s = new HashSet<BroadCastImpl>();
       public static BroadCastImpl[] broadCasts = null;
      
      
       static {
       String name = "";
       String content = null;
       try{
       DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
       d = builder.parse("C:\\20060926_20060926_de_qy.xml");
      
       NodeList nl = d.getElementsByTagName("data"), nl2;
       for (int i=0; i < nl.getLength(); i++){
       Node n = nl.item(i);
       Node n2 = null;
       nl2 = n.getChildNodes();
       int text;
       BroadCastImpl b = new BroadCastImpl();
       for (int j=0; j < nl2.getLength(); j++){
       n2 = nl2.item(j);
       text = n2.getNodeType();
       if (text == Node.ELEMENT_NODE && n2.getNodeName() != "data"){
       try{
       content = n2.getTextContent();
       name = n2.getNodeName();
       if (name == "d0"){ b.setBroadCastId(Integer.valueOf(content));}
       else if(name == "d1"){b.setTvShowId(Integer.valueOf(content));}
       else if(name == "d2"){b.setChannelId(Integer.valueOf(content));}
       else if(name == "d21"){b.setLongComment(content);}
       else if(name == "d22"){b.setMiddleComment(content);}
       else if(name == "d23"){b.setShortComment(content);}
       else if(name == "d19"){b.setTitle(content);}
       else if(name == "d20"){b.setSubTitle(content);}
       }catch (Exception e){
       System.out.println("Aufbereitung : " + e);
       }
       }
       }
       s.add(b);
       }
       broadCasts = new BroadCastImpl[s.size()];
       s.toArray(broadCasts);
       }catch (ParserConfigurationException e){
       System.out.println(e);
       }catch (IOException e){
       System.out.println(e);
       }catch (SAXException e){
       System.out.println(e);
       }
       }
      
       @WebMethod
       public synchronized BroadCast[] getBroadcasts(){
       return broadCasts;
       }
      
       @WebMethod
       public BroadCast[] getBroadcastsByChannelId(int channelId){
       BroadCastImpl[] a = null;
       Map keys = new TreeMap();
       XPath xp = XPathFactory.newInstance().newXPath();
       try{
      // InputSource inputSource = new InputSource(Context.Path+"20060926_20060926_de_qy.xml");
       DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
       long vor = System.currentTimeMillis();
       d = builder.parse("c:\\20060926_20060926_de_qy.xml");
       long nach = System.currentTimeMillis();
       long dauer = nach - vor;
       System.out.println("Parsen: "+ dauer);
       vor = System.currentTimeMillis();
       NodeList nodes = (NodeList) xp.evaluate("/pack/data[d2="+channelId+"]", d, XPathConstants.NODESET);
       nach = System.currentTimeMillis();
       dauer = nach - vor;
       System.out.println("Suche: "+ dauer);
       a = new BroadCastImpl[nodes.getLength()];
       Node n = null,firstChildNode = null, childNode = null;
       for(int i=0; i < a.length;i++){
       System.out.println("----------------------New Entry----------------------");
       n = nodes.item(i);
       firstChildNode = n.getFirstChild();
       childNode = n.getFirstChild();
       // Iteration über die Felder einer Sendung
       while(childNode != null){
       if (childNode.getNodeType() != Node.TEXT_NODE){
       //System.out.println(childNode.getNodeName()+": "+childNode.getTextContent());
       keys.put(childNode.getNodeName(), childNode.getTextContent());
       }
       childNode = childNode.getNextSibling();
       }
       a = new BroadCastImpl(Integer.valueOf((String)keys.get("d0")),
       Integer.valueOf((String)keys.get("d1")),
       Integer.valueOf((String)keys.get("d2")),
       (String)keys.get("d19"),
       (String)keys.get("d20"),
       (String)keys.get("d21"),
       (String)keys.get("d23"),
       (String)keys.get("d22"));
       }
       //System.out.println(nodes.getLength());
       }catch (Exception e){
       System.out.println(e);
       }
       return a;
       }
      
       }