You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by John Woolsey <jw...@activation.net> on 2004/08/18 14:25:40 UTC
Re: Enterprise Bean Structure
Ok I will stop being a lurker. Mostly because I have started playing
with code :) I am working on writing my own bits of a j2ee engine from
scratch. At the moment it is more of a paralell self discovery project
to Geronimo. I was wondering what the preferred method to creating
objects for Enterprise Beans is. The obvious way is to use code
generation to wrap the interfaces. There might also be a way to do it
with reflection. I can see both ways as being effective. Which way do
you think is better?
- bfn - JAW
David Blevins wrote:
> On Tue, Aug 17, 2004 at 03:31:26PM -0400, jean-marc@spaggiari.org wrote:
>
>>Please let me know how can I help you.
>
>
> Open source works pretty much the opposite of corporate development.
> You find something you want to do, then let us know how we can help
> you.
>
> That's pretty much it.
>
> Finding something to do is too easy: grab a scratch pad and start
> using Geronimo; write down everything that doesn't meet your
> expectations, didn't work, didn't work as you though, or generally
> needs work; pick the easiest thing on the list and do it.
>
>
> -David
>
>
Re: [ot] JAXP Problems
Posted by John Woolsey <jw...@activation.net>.
After much futzing around I realized that the data is a child node and
then things got better. Thanx for the help.
- bfn - JAW
toby cabot wrote:
>On Tue, Aug 24, 2004 at 08:38:16AM -0400, John Woolsey wrote:
>
>
>>Okay I am having trouble with JAXP. I parse through the tree and find my
>>element_nodes easily. Then I go for getNodeValue and it always seems to
>>be null. I am using Xerces 2 to process. Any ideas what I am doing wrong?
>>
>>
>>
>snip...
>
>
>> Node child = childList.item(i);
>> if( child.getNodeType() == Node.ELEMENT_NODE){
>> Element element = (Element)child;
>> String name = element.getTagName();
>> NamedNodeMap namedNodeMap = element.getAttributes();
>> System.out.println( name + " " +
>>namedNodeMap.item(0).getNodeValue() );
>> result.put( name, child.getNodeValue() );
>>
>>
>
>I'm not a JAXP expert, but I play one on mailing lists. I checked the
>javadoc of the Node class and it looks as if it's behaving as
>documented: the nodeValue of an element node is null.
>
>http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Node.html
>
>see the table in the introduction.
>
>HTH,
>Toby
>
>
>
>
Re: [ot] JAXP Problems
Posted by toby cabot <to...@caboteria.org>.
On Tue, Aug 24, 2004 at 08:38:16AM -0400, John Woolsey wrote:
> Okay I am having trouble with JAXP. I parse through the tree and find my
> element_nodes easily. Then I go for getNodeValue and it always seems to
> be null. I am using Xerces 2 to process. Any ideas what I am doing wrong?
>
snip...
> Node child = childList.item(i);
> if( child.getNodeType() == Node.ELEMENT_NODE){
> Element element = (Element)child;
> String name = element.getTagName();
> NamedNodeMap namedNodeMap = element.getAttributes();
> System.out.println( name + " " +
> namedNodeMap.item(0).getNodeValue() );
> result.put( name, child.getNodeValue() );
I'm not a JAXP expert, but I play one on mailing lists. I checked the
javadoc of the Node class and it looks as if it's behaving as
documented: the nodeValue of an element node is null.
http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Node.html
see the table in the introduction.
HTH,
Toby
Re: [ot] JAXP Problems
Posted by Dain Sundstrom <da...@coredevelopers.net>.
John,
In the future when you want to start a new thread on the mailing list,
please create a new message in your email client instead of replying to
an existing message and clearing out the subject and body. On most
email clients this "thread hijacking" messes up messaged threading.
Thanks,
-dain
On Aug 24, 2004, at 5:38 AM, John Woolsey wrote:
> Okay I am having trouble with JAXP. I parse through the tree and find
> my element_nodes easily. Then I go for getNodeValue and it always
> seems to be null. I am using Xerces 2 to process. Any ideas what I am
> doing wrong?
>
>
> - thanx - JAW
>
> System.setProperty(
> "javax.xml.parsers.DocumentBuilderFactory",
> "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
> return dfactory = DocumentBuilderFactory.newInstance();
> HashMap result = new HashMap();
>
> Document doc = XML.getFactory().newDocumentBuilder().parse(
> new InputSource( new FileInputStream(deployPath +
> "META-INF/ejb-jar.xml")));
> Node node = XPathAPI.selectSingleNode( doc,
> "ejb-jar/enterprise-beans");
>
> NodeList childList = node.getChildNodes();
> for( int i=0;i<childList.getLength();i++){
> Node child = childList.item(i);
> if( child.getNodeType() == Node.ELEMENT_NODE){
> Element element = (Element)child;
> String name = element.getTagName();
> NamedNodeMap namedNodeMap = element.getAttributes();
> System.out.println( name + " " +
> namedNodeMap.item(0).getNodeValue() );
> result.put( name, child.getNodeValue() );
> }
> }
> return result;
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
> JavaBeans 2.0//EN"
> "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
> <ejb-jar>
> <enterprise-beans>
> <!-- Session Beans -->
> <session>
> <description>Mail Processing Session Bean.</description>
> <display-name>MailProcessingServerDisplayName</display-name>
> <ejb-name>MailProcessingServer</ejb-name> <!-- Matches with
> JBoss.xml -->
> <home>honour.session.MailProcessHome</home>
> <remote>honour.session.MailProcess</remote>
> <ejb-class>honour.session.MailProcessBean</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Container</transaction-type>
> </session>
> </enterprise-beans>
> </ejb-jar>
JAXP Problems
Posted by John Woolsey <jw...@activation.net>.
Okay I am having trouble with JAXP. I parse through the tree and find my
element_nodes easily. Then I go for getNodeValue and it always seems to
be null. I am using Xerces 2 to process. Any ideas what I am doing wrong?
- thanx - JAW
System.setProperty(
"javax.xml.parsers.DocumentBuilderFactory",
"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
return dfactory = DocumentBuilderFactory.newInstance();
HashMap result = new HashMap();
Document doc = XML.getFactory().newDocumentBuilder().parse(
new InputSource( new FileInputStream(deployPath +
"META-INF/ejb-jar.xml")));
Node node = XPathAPI.selectSingleNode( doc,
"ejb-jar/enterprise-beans");
NodeList childList = node.getChildNodes();
for( int i=0;i<childList.getLength();i++){
Node child = childList.item(i);
if( child.getNodeType() == Node.ELEMENT_NODE){
Element element = (Element)child;
String name = element.getTagName();
NamedNodeMap namedNodeMap = element.getAttributes();
System.out.println( name + " " +
namedNodeMap.item(0).getNodeValue() );
result.put( name, child.getNodeValue() );
}
}
return result;
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<!-- Session Beans -->
<session>
<description>Mail Processing Session Bean.</description>
<display-name>MailProcessingServerDisplayName</display-name>
<ejb-name>MailProcessingServer</ejb-name> <!-- Matches with
JBoss.xml -->
<home>honour.session.MailProcessHome</home>
<remote>honour.session.MailProcess</remote>
<ejb-class>honour.session.MailProcessBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
Re: Enterprise Bean Structure
Posted by ja...@mac.com.
On 19 Aug 2004, at 13:28, John Woolsey wrote:
> Thank you for your reply. It is a neat feeling to be part of the
> community. I am going to move forward with text code generation.
> Mostly because this is an educational project. For me and anyone else
> who wants to learn from it. I figure readable java files are easier to
> learn from and debug. I might even add autogen docs to them :) On to
> working on my deployer. I think I am going to start with a JMS bean.
FWIW if you're thinking of playing with JMS, I'd highly recommend the
JMS helper abstractions that were added recently to Spring 1.1...
http://www.springframework.org/docs/reference/ch14.html
James
-------
http://radio.weblogs.com/0112098/
Re: Enterprise Bean Structure
Posted by John Woolsey <jw...@activation.net>.
Thank you for your reply. It is a neat feeling to be part of the
community. I am going to move forward with text code generation. Mostly
because this is an educational project. For me and anyone else who wants
to learn from it. I figure readable java files are easier to learn from
and debug. I might even add autogen docs to them :) On to working on my
deployer. I think I am going to start with a JMS bean.
- bfn - JAW
Dain Sundstrom wrote:
> On Aug 18, 2004, at 5:25 AM, John Woolsey wrote:
>
>> Ok I will stop being a lurker. Mostly because I have started playing
>> with code :) I am working on writing my own bits of a j2ee engine from
>> scratch. At the moment it is more of a paralell self discovery project
>> to Geronimo.
>
>
> cool
>
>> I was wondering what the preferred method to creating objects for
>> Enterprise Beans is. The obvious way is to use code generation to wrap
>> the interfaces. There might also be a way to do it with reflection. I
>> can see both ways as being effective. Which way do you think is better?
>
>
> I assume you mean what is the best way to create the client stub (i.e.,
> the class that implements either the remote or local interface). There
> are really only two ways to do this, generate java code and compile it
> into byte code, or generate the byte code directly. Generating java
> code is pain because you must have a java compiler in you server, and
> for the most common compiler, javac, you have to have the source saved
> to disk, and all jars needed during the compile on disk.
>
> The preferred method to generate the stub is to generate the byte code
> directly. Normally people use java.lang.reflect.Proxy to generate the
> byte code implementation of the interface. In Geronimo, we use cglib to
> generate the byte code, because it gives us much more control over the
> generated code. CGLib is much more complex then reflection proxy, so if
> you are just hacking some example code, I suggest you just stick with
> reflection Proxy.
>
> -dain
>
>
>
Re: Enterprise Bean Structure
Posted by Dain Sundstrom <da...@coredevelopers.net>.
On Aug 18, 2004, at 5:25 AM, John Woolsey wrote:
> Ok I will stop being a lurker. Mostly because I have started playing
> with code :) I am working on writing my own bits of a j2ee engine from
> scratch. At the moment it is more of a paralell self discovery project
> to Geronimo.
cool
> I was wondering what the preferred method to creating objects for
> Enterprise Beans is. The obvious way is to use code generation to wrap
> the interfaces. There might also be a way to do it with reflection. I
> can see both ways as being effective. Which way do you think is
> better?
I assume you mean what is the best way to create the client stub (i.e.,
the class that implements either the remote or local interface). There
are really only two ways to do this, generate java code and compile it
into byte code, or generate the byte code directly. Generating java
code is pain because you must have a java compiler in you server, and
for the most common compiler, javac, you have to have the source saved
to disk, and all jars needed during the compile on disk.
The preferred method to generate the stub is to generate the byte code
directly. Normally people use java.lang.reflect.Proxy to generate the
byte code implementation of the interface. In Geronimo, we use cglib
to generate the byte code, because it gives us much more control over
the generated code. CGLib is much more complex then reflection proxy,
so if you are just hacking some example code, I suggest you just stick
with reflection Proxy.
-dain