Thanks Jos! Will make them web services and call them from the asp application.

brgds
Paul

Jos Snellings wrote:
You can wrap java in .asp objects.
Try http://www.4guysfromrolla.com/webtech/080999-1.shtml
(I have never used asp).
Second alternative: make your cocoon classes to webservices. That should not be very
difficult, as these classes will be nearly webservices: they produce
XML. Call webservices from your .asp application.
Jos

On Tue, 2009-09-29 at 10:55 -0400, Paul Joseph wrote:
Jos,

Thank you.

But I am not clear on how the method is made externally available to an application running in its own environment.

Ie. the environments (say Tomcat for Cocoon and some Microsoft environment for the ASP app) are different.

How, in the example you kindly provided below, would I call the new method that returns the array ie.

public void searchTerms(ContentHandler ch, byte[] nb, String language,
String smode, boolean nonpreferred)

thx.
Paul

Jos Snellings wrote:
Here is a snippet ... this is a method from an object
"ThesaurusBrowser". The method searches a number of terms from the
thesaurus, that, say, start with a given substring:
public void searchTerms(ContentHandler ch, byte[] nb, String language,
String smode, boolean nonpreferred)
{
AttributesImpl attr = new AttributesImpl();
int hits = 0;
ResultSet rs = null;
// here we are going to form a query and execute it. rs = p.executeQuery();
        ResultSetMetaData rsmd = rs.getMetaData();

        while (rs.next()) {
                hits++;

attr.addAttribute("","id","id","CDATA",rs.getString("id"));
                if (nonpreferred)
attr.addAttribute("","npt","npt","CDATA","1");
                ch.startElement("","term","term",attr);
                attr.clear();
                for (int i=1; i <= rsmd.getColumnCount(); i++) {
                        String tagname = rsmd.getColumnName(i);
                        ch.startElement("",tagname,tagname,attr);
                        String value = rs.getString(i);
                        if (value != null)
ch.characters(value.toCharArray(),0,value.length());
                        ch.endElement("",tagname,tagname);
                        }
                ch.endElement("","term","term");
                }

        rs.close();
        p.close();
}
------------------------------------------------
I just display the relevant part: This code produces XML
<term id="234" term="someterm" context="somecontext" nonPreferred="0"/>
...
Change it to an alternative that returns an array of Term
------------------------------------------------------
public Concept[] searchTerms(byte[]nb, String language, String smode,
boolean nonPreferred) {
int hits = 0;

ResultSet rs = null;
// here we are going to form a query and execute it. rs = p.executeQuery();
        ResultSetMetaData rsmd = rs.getMetaData();
        Vector<Concept> VTerms = new Vector<Concept>();
        while (rs.next()) {
                hits++;
                Concept T = new Concept T();
                T.setId(rs.getInt(1));
                T.setTerm(rs.getString(2));
                T.setContext(rs.getString(3));
                T.setNonPreferred(rs.getString(4));
                VTerms.addElement(T);
                }
        
        rs.close();
        p.close();

Concept[] concepts = new Concept[C.size()];
                for (int j=0; j<C.size();j++) concepts[j] = (Concept)
VTerms.elementAt(j);
                return concepts;
                }

}



}

And you could then modify your Cocoon method to:

public void searchTerms(ContentHandler ch, byte[] nb, String language,
String smode, boolean nonpreferred)
{
Concept[] hits = searchTerms(nb, language,  smode, nonpreferred);
AttributesImpl attr = new AttributesImpl();

for (hit : hits) {
        attr.addAttribute( ... );

        ...
ch.startElement("" attr.clear(); }

that way extending the use and insulating the SAX interface. One step
further is creating separate cocoon classes, that only do the SAX
production thus universalizing your business model.





On Tue, 2009-09-29 at 09:31 -0400, Paul Joseph wrote:
Thank Jos...I follow the general concept...would you know of any example that I could take a look at?

thx.
Paul

Jos Snellings wrote:
Hi Paul,

Classes that live in a Cocoon environment will typically send their
output via SAX events. They would take a "ContentHandler" or
"XMLConsumer" as a parameter and call
startElement/endElement/characters. There might exist an insulation layer between the SAX-world and the
objects properly.

If you extend these classes with methods that return objects, and arrays
of objects, they become available to other "Views".

Does this answer make sense to you?

Best,
Jos

On Tue, 2009-09-29 at 06:33 -0400, Paul Joseph wrote:
Hi there,

What is the best way to make business functionality available in the Java tier of my Cocoon application available available to another application written in say ASP?

Is sharing Cocoon applications java tier functionality with other apps. possible and are there any "easy" ways to do this?

thx.
Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to