You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(115) |
Jun
(51) |
Jul
(102) |
Aug
(232) |
Sep
(75) |
Oct
(19) |
Nov
(11) |
Dec
(7) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(20) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <th...@us...> - 2004-01-21 15:43:46
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino
In directory sc8-pr-cvs1:/tmp/cvs-serv4781/src/runtime/de/ispsoft/jaxme/tamino
Modified Files:
InoManagerNoNs.java
Log Message:
bugfix
Index: InoManagerNoNs.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino/InoManagerNoNs.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- InoManagerNoNs.java 13 Jan 2004 12:00:16 -0000 1.4
+++ InoManagerNoNs.java 21 Jan 2004 15:43:37 -0000 1.5
@@ -487,7 +487,11 @@
if (id == null || id.length() == 0) {
throw new SAXException("The element being updated doesn't have an ID.");
}
- return "_process=" + URLEncoder.encode(pElement.toXMLNoNS());
+ String query = "_process=" + URLEncoder.encode(pElement.toXMLNoNS());
+ if (idAttribute != null) {
+ pElement.setAttribute(idAttributeNS, idAttribute, id, null);
+ }
+ return query;
}
/** <p>Returns a query suited for inserting the element.</p>
|
|
From: <th...@us...> - 2004-01-15 16:46:51
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme
In directory sc8-pr-cvs1:/tmp/cvs-serv21626/src/runtime/de/ispsoft/jaxme
Modified Files:
ResultInfo.java
Log Message:
bugfix
Index: ResultInfo.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/ResultInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ResultInfo.java 12 Jan 2004 18:18:55 -0000 1.2
+++ ResultInfo.java 15 Jan 2004 16:46:48 -0000 1.3
@@ -24,6 +24,7 @@
}
public String getResultInfo(String key) {
- return infoMap.get(key).toString();
+ Object value = infoMap.get(key);
+ return (value == null) ? null : value.toString();
}
}
|
|
From: <th...@us...> - 2004-01-15 15:48:19
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino
In directory sc8-pr-cvs1:/tmp/cvs-serv9174/src/runtime/de/ispsoft/jaxme/tamino
Modified Files:
InoResponseHandlerNoNs.java
Log Message:
bugfix in cursor based tamino query (ignoring errorcode8306)
Index: InoResponseHandlerNoNs.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino/InoResponseHandlerNoNs.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- InoResponseHandlerNoNs.java 13 Jan 2004 12:00:16 -0000 1.4
+++ InoResponseHandlerNoNs.java 15 Jan 2004 15:48:13 -0000 1.5
@@ -158,7 +158,10 @@
} else if (INO_RESPONSE2_URI.equals(namespaceUri)) {
if ("message".equals(localName)) {
String retval = attr.getValue(INO_RESPONSE2_URI, "returnvalue");
- if (retval == null || !retval.equals("0")) {
+ // The errorcode 8306 means that the cursor position is wrong
+ // ==> no data are found. This is not terrible therefore no exception
+ // is to be thrown
+ if (retval == null || !(retval.equals("0") || retval.equals("8306"))) {
inoErrorCode = retval;
inoErrorMessage = new StringBuffer();
inInoMessage = true;
|
|
From: <th...@us...> - 2004-01-13 12:00:19
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme
In directory sc8-pr-cvs1:/tmp/cvs-serv20851/src/runtime/de/ispsoft/jaxme
Modified Files:
XMLSerializerNoNS.java
Log Message:
tamino session handling bugfixed
Index: XMLSerializerNoNS.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/XMLSerializerNoNS.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- XMLSerializerNoNS.java 6 Jan 2004 10:24:58 -0000 1.1
+++ XMLSerializerNoNS.java 13 Jan 2004 12:00:16 -0000 1.2
@@ -86,10 +86,6 @@
*/
public void startElement(String namespaceURI, String localName,
String qName, Attributes attr) throws SAXException {
- cat.debug("startElement ->");
- cat.debug("namespaceURI: " + namespaceURI);
- cat.debug("localName: " + localName);
- cat.debug("qName: " + qName);
try {
stopTerminator();
if (curIndent > 0) {
@@ -104,7 +100,6 @@
for (int i = attr.getLength(); i > 0;) {
w.write(' ');
String name = attr.getQName(--i);
- cat.debug("name: " + name);
if (delayedPrefixes != null) {
delayedPrefixes.remove(name);
}
|
|
From: <th...@us...> - 2004-01-13 12:00:19
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino
In directory sc8-pr-cvs1:/tmp/cvs-serv20851/src/runtime/de/ispsoft/jaxme/tamino
Modified Files:
InoSession.java InoResponseHandlerNoNs.java
InoManagerNoNs.java
Log Message:
tamino session handling bugfixed
Index: InoSession.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino/InoSession.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- InoSession.java 12 Jan 2004 18:18:55 -0000 1.1
+++ InoSession.java 13 Jan 2004 12:00:16 -0000 1.2
@@ -40,5 +40,10 @@
public void setSessionkey(String string) {
sessionkey = string;
}
+
+ public String toString() {
+ return "sessionid: " + ((sessionid == null) ? "null" : sessionid) + "\n" +
+ "sessionkey: " + ((sessionkey == null) ? "null" : sessionkey) + "\n";
+ }
}
Index: InoResponseHandlerNoNs.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino/InoResponseHandlerNoNs.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- InoResponseHandlerNoNs.java 12 Jan 2004 18:18:55 -0000 1.3
+++ InoResponseHandlerNoNs.java 13 Jan 2004 12:00:16 -0000 1.4
@@ -135,19 +135,20 @@
}
}
} else if (level == 0) {
- if (resultInfo != null && INO_RESPONSE2_URI.equals(namespaceUri) &&
- "response".equals(localName)) {
+ if (INO_RESPONSE2_URI.equals(namespaceUri) && "response".equals(localName)) {
cat.debug("Level 0 is response element");
String sid = attr.getValue(INO_RESPONSE2_URI, "sessionid");
if(sid != null && sid.length() > 0) {
sessionid = sid;
- resultInfo.putResultInfo("sessionid", sessionid);
+ if(resultInfo != null)
+ resultInfo.putResultInfo("sessionid", sessionid);
}
cat.debug("sessionid: " + sessionid);
String sk = attr.getValue(INO_RESPONSE2_URI, "sessionkey");
if(sk != null && sk.length() > 0) {
sessionkey = sk;
- resultInfo.putResultInfo("sessionkey", sessionkey);
+ if(resultInfo != null)
+ resultInfo.putResultInfo("sessionkey", sessionkey);
}
cat.debug("sessionkey: " + sessionkey);
}
Index: InoManagerNoNs.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino/InoManagerNoNs.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- InoManagerNoNs.java 12 Jan 2004 18:18:55 -0000 1.3
+++ InoManagerNoNs.java 13 Jan 2004 12:00:16 -0000 1.4
@@ -573,9 +573,11 @@
protected void performQueryUseSession(String pQuery, InoResponseHandlerNoNs pHandler,
InoSession pInoSession) throws SAXException {
pQuery = appendSession(pQuery, pInoSession);
+ cat.debug("performQueryUseSession pQuery: " + pQuery);
performQuery(pQuery, pHandler);
pInoSession.setSessionid(pHandler.getSessionid());
pInoSession.setSessionkey(pHandler.getSessionkey());
+ cat.debug("performQueryUseSession pInoSession: " + pInoSession);
}
/** <p>Parses a single INO response document.</p>
|
|
From: <th...@us...> - 2004-01-12 18:18:58
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino
In directory sc8-pr-cvs1:/tmp/cvs-serv6940/src/runtime/de/ispsoft/jaxme/tamino
Modified Files:
InoResponseHandlerNoNs.java InoManagerNoNs.java
Added Files:
InoSession.java
Log Message:
tamino session handling added
--- NEW FILE: InoSession.java ---
/*
* Created on 07.01.2004
*
*/
package de.ispsoft.jaxme.tamino;
/**
* @author Thomas Haenel, ATC GmbH
* @version $Id: InoSession.java,v 1.1 2004/01/12 18:18:55 thaenel Exp $
*/
public class InoSession {
private String sessionid = null;
private String sessionkey = null;
/**
* @return
*/
public String getSessionid() {
return sessionid;
}
/**
* @return
*/
public String getSessionkey() {
return sessionkey;
}
/**
* @param string
*/
public void setSessionid(String string) {
sessionid = string;
}
/**
* @param string
*/
public void setSessionkey(String string) {
sessionkey = string;
}
}
Index: InoResponseHandlerNoNs.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino/InoResponseHandlerNoNs.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- InoResponseHandlerNoNs.java 7 Jan 2004 10:59:28 -0000 1.2
+++ InoResponseHandlerNoNs.java 12 Jan 2004 18:18:55 -0000 1.3
@@ -53,6 +53,9 @@
private int i;
private ResultInfo resultInfo = null;
+
+ private String sessionid = null;
+ private String sessionkey = null;
/** Creates a new InoResponseHandler */
public InoResponseHandlerNoNs() {}
@@ -131,6 +134,23 @@
inInoMessageText = true;
}
}
+ } else if (level == 0) {
+ if (resultInfo != null && INO_RESPONSE2_URI.equals(namespaceUri) &&
+ "response".equals(localName)) {
+ cat.debug("Level 0 is response element");
+ String sid = attr.getValue(INO_RESPONSE2_URI, "sessionid");
+ if(sid != null && sid.length() > 0) {
+ sessionid = sid;
+ resultInfo.putResultInfo("sessionid", sessionid);
+ }
+ cat.debug("sessionid: " + sessionid);
+ String sk = attr.getValue(INO_RESPONSE2_URI, "sessionkey");
+ if(sk != null && sk.length() > 0) {
+ sessionkey = sk;
+ resultInfo.putResultInfo("sessionkey", sessionkey);
+ }
+ cat.debug("sessionkey: " + sessionkey);
+ }
} else if (level == 1) {
if (XQL_URI.equals(namespaceUri) && "result".equals(localName)) {
inXqlResult = true;
@@ -147,7 +167,7 @@
} if ("cursor".equals(localName)) {
String cc = attr.getValue(INO_RESPONSE2_URI, "count");
if(resultInfo != null && cc != null && cc.length() > 0)
- resultInfo.setCursorCount(Integer.parseInt(cc));
+ resultInfo.putResultInfo("cursorCount", cc);
}
}
}
@@ -299,6 +319,34 @@
*/
public void setResultInfo(ResultInfo info) {
resultInfo = info;
+ }
+
+ /**
+ * @return
+ */
+ public String getSessionid() {
+ return sessionid;
+ }
+
+ /**
+ * @return
+ */
+ public String getSessionkey() {
+ return sessionkey;
+ }
+
+ /**
+ * @param string
+ */
+ public void setSessionid(String string) {
+ sessionid = string;
+ }
+
+ /**
+ * @param string
+ */
+ public void setSessionkey(String string) {
+ sessionkey = string;
}
}
Index: InoManagerNoNs.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino/InoManagerNoNs.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- InoManagerNoNs.java 7 Jan 2004 10:59:28 -0000 1.2
+++ InoManagerNoNs.java 12 Jan 2004 18:18:55 -0000 1.3
@@ -93,6 +93,12 @@
private String idAttributeNS = null;
private String targetNamespaceIn = null;
private boolean useCursoring = false;
+
+ private String isolationLevel = "stableDocument";
+ private String lockMode = "protected";
+ private String lockWait = "no";
+ private String transactionTimeout = "30";
+ private String nonActivityTimeout = "60";
/** <p>Name of our private configuration node (<samp>InoManager</samp> in
* namespace <code>JMManagerFactoryImpl.NAMESPACE_URI</code>)</p>
@@ -130,6 +136,47 @@
*/
public static final String USE_CURSORING = "Use-Cursoring";
+ /** <p>Use the request param _isolationLevel for special cursoring as described above.</p>
+ * <p>Possible values are:
+ * - uncommittedDocument
+ * - committedCommand
+ * - stableCursor
+ * - stableDocument
+ * - serializable
+ * </p>
+ */
+ public static final String ISOLATION_LEVEL = "ISOLATION-LEVEL";
+
+ /** <p>Use the request param _lockMode for special cursoring as described above.</p>
+ * <p>Possible values are:
+ * - unprotected
+ * - shared
+ * - protected
+ * </p>
+ */
+ public static final String LOCK_MODE = "LOCK-MODE";
+
+ /** <p>Use the request param _lockWait for special cursoring as described above.</p>
+ * <p>Possible values are:
+ * - yes/no
+ * </p>
+ */
+ public static final String LOCK_WAIT = "LOCK-WAIT";
+
+ /** <p>Use the request param _transactionTimeout for special cursoring as described above.</p>
+ * <p>Possible values are:
+ * - seconds as a number value
+ * </p>
+ */
+ public static final String TRANSACTION_TIMEOUT = "TRANSACTION-TIMEOUT";
+
+ /** <p>Use the request param _nonActivityTimeout for special cursoring as described above.</p>
+ * <p>Possible values are:
+ * - seconds as a number value
+ * </p>
+ */
+ public static final String NONACTIVITY_TIMEOUT = "NONACTIVITY-TIMEOUT";
+
/**
* @return
*/
@@ -169,24 +216,29 @@
throw new IllegalArgumentException(
"Invalid database URL: " + url);
}
- } else if (
- USER_NODE_NAME.equals(child.getLocalName())) {
+ } else if (USER_NODE_NAME.equals(child.getLocalName())) {
user = JMManagerFactoryImpl.getNodeText(child);
- } else if (
- PASSWORD_NODE_NAME.equals(child.getLocalName())) {
+ } else if (PASSWORD_NODE_NAME.equals(child.getLocalName())) {
password = JMManagerFactoryImpl.getNodeText(child);
- } else if (
- ID_ATTRIBUTE.equals(child.getLocalName())) {
+ } else if (ID_ATTRIBUTE.equals(child.getLocalName())) {
idAttribute = JMManagerFactoryImpl.getNodeText(child);
- } else if (
- ID_ATTRIBUTE_NS.equals(child.getLocalName())) {
+ } else if (ID_ATTRIBUTE_NS.equals(child.getLocalName())) {
idAttributeNS = JMManagerFactoryImpl.getNodeText(child);
- } else if (
- TARGETNAMESPACE_IN.equals(child.getLocalName())) {
+ } else if (TARGETNAMESPACE_IN.equals(child.getLocalName())) {
targetNamespaceIn = JMManagerFactoryImpl.getNodeText(child);
} else if (USE_CURSORING.equals(child.getLocalName())) {
String uc = JMManagerFactoryImpl.getNodeText(child);
useCursoring = (uc != null && "yes".equals(uc));
+ } else if (ISOLATION_LEVEL.equals(child.getLocalName())) {
+ isolationLevel = JMManagerFactoryImpl.getNodeText(child);
+ } else if (LOCK_MODE.equals(child.getLocalName())) {
+ lockMode = JMManagerFactoryImpl.getNodeText(child);
+ } else if (LOCK_WAIT.equals(child.getLocalName())) {
+ lockWait = JMManagerFactoryImpl.getNodeText(child);
+ } else if (TRANSACTION_TIMEOUT.equals(child.getLocalName())) {
+ transactionTimeout = JMManagerFactoryImpl.getNodeText(child);
+ } else if (NONACTIVITY_TIMEOUT.equals(child.getLocalName())) {
+ nonActivityTimeout = JMManagerFactoryImpl.getNodeText(child);
}
}
}
@@ -204,6 +256,13 @@
spf.setValidating(false);
}
+ /** <p>Deletes the given document from the database using the given session.</p>
+ */
+ public void deleteUseSession(JMAnyElement pElement, InoSession pInoSession) throws SAXException {
+ String query = getDeleteQuery(pElement);
+ performQueryUseSession(query, (List) null, pInoSession);
+ }
+
/** <p>Deletes the given document from the database.</p>
*/
public void delete(JMAnyElement pElement) throws SAXException {
@@ -213,6 +272,18 @@
/** <p>Inserts the given document into the database.</p>
*/
+ public void insertUseSession(JMAnyElement pElement, InoSession pInoSession) throws SAXException {
+ String query = getInsertQuery(pElement);
+ List idList = new ArrayList();
+ InoResponseHandlerNoNs irh = performQueryUseSession(query, idList, pInoSession);
+ if (idList.size() == 0) {
+ throw new SAXException("Query did not return an ino:id");
+ }
+ setElementId(pElement, (String) idList.get(0));
+ }
+
+ /** <p>Inserts the given document into the database.</p>
+ */
public void insert(JMAnyElement pElement) throws SAXException {
String query = getInsertQuery(pElement);
List idList = new ArrayList();
@@ -225,6 +296,13 @@
/** <p>Updates the given document in the database.</p>
*/
+ public void updateUseSession(JMAnyElement pElement, InoSession pInoSession) throws SAXException {
+ String query = getUpdateQuery(pElement);
+ performQueryUseSession(query, (List) null, pInoSession);
+ }
+
+ /** <p>Updates the given document in the database.</p>
+ */
public void update(JMAnyElement pElement) throws SAXException {
String query = getUpdateQuery(pElement);
performQuery(query, (List) null);
@@ -270,6 +348,17 @@
/* (non-Javadoc)
* @see de.ispsoft.jaxme.JMManager#select(java.lang.String, java.lang.Object[], int, int, de.ispsoft.jaxme.ResultInfo)
*/
+ public Iterator selectUseSession(String pQuery, Object[] pPlaceHolderArgs,
+ int pStart, int pMax, ResultInfo pResultInfo,
+ InoSession pInoSession) throws SAXException {
+ MyObserver o = new MyObserver();
+ selectUseSession(o, pQuery, pPlaceHolderArgs, pStart, pMax, pResultInfo, pInoSession);
+ return o.resultList.iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see de.ispsoft.jaxme.JMManager#select(java.lang.String, java.lang.Object[], int, int, de.ispsoft.jaxme.ResultInfo)
+ */
public Iterator select(String pQuery, Object[] pPlaceHolderArgs, int pStart,
int pMax, ResultInfo pResultInfo) throws SAXException {
MyObserver o = new MyObserver();
@@ -280,29 +369,30 @@
/* (non-Javadoc)
* @see de.ispsoft.jaxme.JMManager#select(de.ispsoft.jaxme.Observer, java.lang.String, java.lang.Object[], int, int, de.ispsoft.jaxme.ResultInfo)
*/
+ public void selectUseSession(Observer pObserver, String pQuery, Object[] pPlaceHolderArgs,
+ int pStart, int pMax, ResultInfo pResultInfo,
+ InoSession pInoSession) throws SAXException {
+ if (pPlaceHolderArgs != null && pPlaceHolderArgs.length > 0) {
+ throw new SAXException("Placeholders are not yet supported");
+ }
+ String q = getSelectQuery(pQuery, pStart, pMax);
+ InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
+ irh.setResultInfo(pResultInfo);
+ JMContentHandler ch = getJMContentHandler();
+ ch.setObserver(pObserver);
+ irh.setResultHandler(ch);
+ performQueryUseSession(q, irh, pInoSession);
+ }
+
+ /* (non-Javadoc)
+ * @see de.ispsoft.jaxme.JMManager#select(de.ispsoft.jaxme.Observer, java.lang.String, java.lang.Object[], int, int, de.ispsoft.jaxme.ResultInfo)
+ */
public void select(Observer pObserver, String pQuery, Object[] pPlaceHolderArgs,
int pStart, int pMax, ResultInfo pResultInfo) throws SAXException {
if (pPlaceHolderArgs != null && pPlaceHolderArgs.length > 0) {
throw new SAXException("Placeholders are not yet supported");
}
- String q;
- if (useCursoring) {
- if(pStart == 0 && pMax == 0) {
- q = "_xql(1,0)=" + URLEncoder.encode(pQuery);
- } else {
- q = "_cursor=open&_count=cheap&_xql=" + URLEncoder.encode(pQuery);
- if (pStart != 0 || pMax != 0) {
- q += "&_position=" + (pStart + 1) + "&_quantity=" + pMax;
- }
- }
- } else {
- if (pStart != 0 || pMax != 0) {
- q = "_xql(" + (pStart + 1) + "," + pMax + ")=";
- } else {
- q = "_xql=";
- }
- q += URLEncoder.encode(pQuery);
- }
+ String q = getSelectQuery(pQuery, pStart, pMax);
InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
irh.setResultInfo(pResultInfo);
JMContentHandler ch = getJMContentHandler();
@@ -311,6 +401,46 @@
performQuery(q, irh);
}
+ /**
+ * Creates a new tamino session. The _connect request is called using the
+ * session parameters.
+ * @return a new inoSession containing sessionid and sessionkey
+ * @throws SAXException
+ */
+ public InoSession createInoSession() throws SAXException {
+ StringBuffer q = new StringBuffer("_connect=*");
+ q.append("&_isolationLevel="+isolationLevel);
+ q.append("&_lockMode="+lockMode);
+ q.append("&_lockWait="+lockWait);
+ q.append("&_transactionTimeout="+transactionTimeout);
+ q.append("&_nonActivityTimeout="+nonActivityTimeout);
+ ResultInfo ri = new ResultInfo();
+ InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
+ irh.setResultInfo(ri);
+ JMContentHandler ch = getJMContentHandler();
+ ch.setObserver(null);
+ irh.setResultHandler(ch);
+ performQuery(q.toString(), irh);
+ InoSession is = new InoSession();
+ is.setSessionid(ri.getResultInfo("sessionid"));
+ is.setSessionkey(ri.getResultInfo("sessionkey"));
+ return is;
+ }
+
+ /**
+ * Closes the tamino session of sessionid given in InoSession.
+ * @param inoSession
+ * @throws SAXException
+ */
+ public void closeInoSession(InoSession inoSession) throws SAXException {
+ String q = "_disconnect=*&_sessionid="+inoSession.getSessionid();
+ InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
+ JMContentHandler ch = getJMContentHandler();
+ ch.setObserver(null);
+ irh.setResultHandler(ch);
+ performQuery(q, irh);
+ }
+
/** <p>Returns the element ID. The default implementation
* returns
* <code>getAttribute(InoResponseHandler.INO_RESPONSE2_URI, "id")</code>.
@@ -409,6 +539,18 @@
/** <p>Performs a single database query.</p>
*/
+ protected InoResponseHandlerNoNs performQueryUseSession(String pQuery,
+ List pList, InoSession pInoSession) throws SAXException {
+ InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
+ if (pList != null) {
+ irh.setInoObjectIdList(pList);
+ }
+ performQueryUseSession(pQuery, irh, pInoSession);
+ return irh;
+ }
+
+ /** <p>Performs a single database query.</p>
+ */
protected InoResponseHandlerNoNs performQuery(String pQuery, List pList)
throws SAXException {
InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
@@ -419,6 +561,23 @@
return irh;
}
+ /** <p>Starts session based db query. First append the sessionid and sessionkey
+ * params at the query, then calls performQuery(pQuery, pHandler) and finally
+ * put the sessionid and sessionkey from InoResponseHandlerNoNs into InoSession
+ * (this is because of the new returned sessionkey from the tamino response during
+ * an active session).</p>
+ * @param String pQuery
+ * @param InoResponseHandlerNoNs pHandler
+ * @throws SAXException
+ */
+ protected void performQueryUseSession(String pQuery, InoResponseHandlerNoNs pHandler,
+ InoSession pInoSession) throws SAXException {
+ pQuery = appendSession(pQuery, pInoSession);
+ performQuery(pQuery, pHandler);
+ pInoSession.setSessionid(pHandler.getSessionid());
+ pInoSession.setSessionkey(pHandler.getSessionkey());
+ }
+
/** <p>Parses a single INO response document.</p>
*/
protected void performQuery(String pQuery, InoResponseHandlerNoNs pHandler)
@@ -437,12 +596,39 @@
xr.setContentHandler(pHandler);
xr.parse(isource);
} catch (ParserConfigurationException e) {
- throw new SAXException(
- "ParserConfigurationException: " + e.getMessage(),
- e);
+ throw new SAXException("ParserConfigurationException: " + e.getMessage(), e);
} catch (IOException e) {
throw new SAXException("I/O Exception: " + e.getMessage(), e);
}
}
+
+ protected String getSelectQuery(String pQuery, int pStart, int pMax) {
+ String q = null;
+ if (useCursoring) {
+ if(pStart == 0 && pMax == 0) {
+ q = "_xql(1,0)=" + URLEncoder.encode(pQuery);
+ } else {
+ q = "_cursor=open&_count=cheap&_xql=" + URLEncoder.encode(pQuery);
+ if (pStart != 0 || pMax != 0) {
+ q += "&_position=" + (pStart + 1) + "&_quantity=" + pMax;
+ }
+ }
+ } else {
+ if (pStart != 0 || pMax != 0) {
+ q = "_xql(" + (pStart + 1) + "," + pMax + ")=";
+ } else {
+ q = "_xql=";
+ }
+ q += URLEncoder.encode(pQuery);
+ }
+ return q;
+ }
+
+ protected String appendSession(String query, InoSession pInoSession) {
+ query += "&_sessionid="+pInoSession.getSessionid();
+ query += "&_sessionkey="+pInoSession.getSessionkey();
+ return query;
+ }
+
}
|
|
From: <th...@us...> - 2004-01-12 18:18:58
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme
In directory sc8-pr-cvs1:/tmp/cvs-serv6940/src/runtime/de/ispsoft/jaxme
Modified Files:
ResultInfo.java
Log Message:
tamino session handling added
Index: ResultInfo.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/ResultInfo.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ResultInfo.java 7 Jan 2004 10:58:57 -0000 1.1
+++ ResultInfo.java 12 Jan 2004 18:18:55 -0000 1.2
@@ -4,27 +4,26 @@
*/
package de.ispsoft.jaxme;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author Thomas Haenel, ATC GmbH
* @version $Id$
*/
public class ResultInfo {
- // the count of elements found
- private int cursorCount = -1;
-
- /**
- * @return
- */
- public int getCursorCount() {
- return cursorCount;
+ private Map infoMap;
+
+ public ResultInfo() {
+ infoMap = new HashMap();
}
- /**
- * @param i
- */
- public void setCursorCount(int i) {
- cursorCount = i;
+ public void putResultInfo(String key, String value) {
+ infoMap.put(key, value);
+ }
+
+ public String getResultInfo(String key) {
+ return infoMap.get(key).toString();
}
-
}
|
|
From: <jo...@us...> - 2004-01-07 13:26:10
|
Update of /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/types
In directory sc8-pr-cvs1:/tmp/cvs-serv8480/src/generator/de/ispsoft/jaxme/generator/types
Modified Files:
ResourceBundleFormattedType.java
Log Message:
Patterns have not been handled properly.
Index: ResourceBundleFormattedType.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/types/ResourceBundleFormattedType.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ResourceBundleFormattedType.java 17 Dec 2002 20:59:09 -0000 1.6
+++ ResourceBundleFormattedType.java 7 Jan 2004 13:26:07 -0000 1.7
@@ -216,6 +216,7 @@
*/
protected String getFormatter(String pResourceBundleOwner) {
String pattern = getPattern();
+ boolean usePattern;
if (pattern == null) {
String key = getKey();
if (key == null) {
@@ -250,8 +251,10 @@
JavaSource.getQuoted(key) + ", " + JavaSource.getQuoted(defaultPattern) + ")";
}
}
+ usePattern = false;
} else {
pattern = JavaSource.getQuoted(pattern);
+ usePattern = true;
}
if (type == null) {
String className = getFormatClass();
@@ -260,7 +263,8 @@
}
return className + ".getInstance(" + pattern + ")";
} else if ("date".equals(type)) {
- return pResourceBundleOwner + ".getDateFormat(" + pattern + ")";
+ String method = usePattern ? "getDateFormatForPattern" : "getDateFormat";
+ return pResourceBundleOwner + "." + method + "(" + pattern + ")";
} else if ("decimal".equals(type)) {
return pResourceBundleOwner + ".getNumberFormat(" + pattern + ")";
} else if ("message".equals(type)) {
|
|
From: <th...@us...> - 2004-01-07 10:59:31
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino
In directory sc8-pr-cvs1:/tmp/cvs-serv18038/src/runtime/de/ispsoft/jaxme/tamino
Modified Files:
InoResponseHandlerNoNs.java InoManagerNoNs.java
Log Message:
extended cursoring and bugfixes
Index: InoResponseHandlerNoNs.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino/InoResponseHandlerNoNs.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- InoResponseHandlerNoNs.java 6 Jan 2004 10:24:58 -0000 1.1
+++ InoResponseHandlerNoNs.java 7 Jan 2004 10:59:28 -0000 1.2
@@ -10,6 +10,8 @@
import org.apache.log4j.Category;
+import de.ispsoft.jaxme.ResultInfo;
+
/** <p>This is a SAX content handler for an ino:response document. It
* provides a special handling for mapping the ino:id attribute to a
* configurable attribute of the element class. This can be useful if the
@@ -49,10 +51,13 @@
private String targetNamespace = null;
private int i;
+
+ private ResultInfo resultInfo = null;
/** Creates a new InoResponseHandler */
public InoResponseHandlerNoNs() {}
+
/**
* Configure an ino:id mapping attribute. The first param idAttribute
* provides the attributes name used in the JMAnyElement instance as id.
@@ -139,6 +144,10 @@
}
} else if (inoObjectIdList != null && "object".equals(localName)) {
inoObjectIdList.add(attr.getValue(INO_RESPONSE2_URI, "id"));
+ } if ("cursor".equals(localName)) {
+ String cc = attr.getValue(INO_RESPONSE2_URI, "count");
+ if(resultInfo != null && cc != null && cc.length() > 0)
+ resultInfo.setCursorCount(Integer.parseInt(cc));
}
}
}
@@ -278,4 +287,18 @@
* @see #setInoObjectIdList
*/
public List getInoObjectIdList() { return inoObjectIdList; }
+ /**
+ * @return
+ */
+ public ResultInfo getResultInfo() {
+ return resultInfo;
+ }
+
+ /**
+ * @param info
+ */
+ public void setResultInfo(ResultInfo info) {
+ resultInfo = info;
+ }
+
}
Index: InoManagerNoNs.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino/InoManagerNoNs.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- InoManagerNoNs.java 6 Jan 2004 10:24:58 -0000 1.1
+++ InoManagerNoNs.java 7 Jan 2004 10:59:28 -0000 1.2
@@ -9,6 +9,7 @@
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
@@ -28,7 +29,7 @@
import de.ispsoft.jaxme.JMManagerImpl;
import de.ispsoft.jaxme.JMManagerFactoryImpl;
import de.ispsoft.jaxme.Observer;
-
+import de.ispsoft.jaxme.ResultInfo;
/** <p>An implementation of a JMManager for a Tamino database. This
* InoManager handles the tamino db access without namespace support.
@@ -49,6 +50,30 @@
* and map the ino:id attribute to inoid without an attribute namespace. The
* targetnamespace for incomming xml documents from database is set to
* http://my.namespace.com/data.
+ *
+ * Cursoring is possible in two ways:
+ *
+ * (a)
+ * 1. Open session:
+ * http://host:port/tamino/DB/col?_connect=*
+ * 2. Query:
+ * http://host:port/tamino/DB/col?_cursor=open&_count=cheap&_sessionid=XYZ&_sessionkey=ABCD&_xql=Query
+ * 3. Daten abfragen:
+ * http://host:port/tamino/DB/col?_cursor=fetch&_handle=1&_position=10&_quantity=5&_sessionid=XYZ_sessionkey=HIJK
+ * 4. Close Session:
+ * http://host:port/tamino/DB/col?_disconnect=*&_sessionid=XYZ&sessionkey=STUV
+ *
+ * (b)
+ * By combining the _cursor=open command with the query, the query is executed
+ * outside a tamino session and the (cursoring) command can be executed without
+ * session handling and/or closing cursor.
+ *
+ * http://host:port/tamino/DB/col?_cursor=open&_count=cheap&_xql=Query&_position=POS&_quantity=QU
+ *
+ * Because of it's simplicity the second option is used and can be activated
+ * by the configuration flag <Use-Cursoring>yes</Use-Cursoring>. By default this
+ * special cursoring is not used.
+ *
*</p>
* @see de.ispsoft.jaxme.XMLSerializerNoNS
* @see de.ispsoft.jaxme.InoResponseHandlerNoNS
@@ -56,318 +81,368 @@
* @author <a href="mailto:hae...@gm...">Thomas Haenel</a>
*/
public class InoManagerNoNs extends JMManagerImpl {
-
- private static final Category cat = Category.getInstance(InoManagerNoNs.class.getName());
- private URL dbURL;
- private String user;
- private String password;
- private boolean useGet;
- private SAXParserFactory spf;
- private String idAttribute = null;
- private String idAttributeNS = null;
- private String targetNamespaceIn = null;
+ private static final Category cat = Category.getInstance(InoManagerNoNs.class.getName());
- /** <p>Name of our private configuration node (<samp>InoManager</samp> in
- * namespace <code>JMManagerFactoryImpl.NAMESPACE_URI</code>)</p>
- */
- public static final String CONFIGURATION_NODE_NAME = "InoManager";
- /** <p>Name of the database URL node, including the collection name.</p>
- */
- public static final String DBURL_NODE_NAME = "DbURL";
- /** <p>Name of the User node</p>
- */
- public static final String USER_NODE_NAME = "User";
- /** <p>Name of the Password node</p>
- */
- public static final String PASSWORD_NODE_NAME = "Password";
- /** <p>Name of the attribute Id mapping. By default
- * no mapping is used.</p>
- */
- public static final String ID_ATTRIBUTE = "Id-Attribute";
- /** <p>The namespace for the mapped attribute. By default
- * no mapping is used.</p>
- */
- public static final String ID_ATTRIBUTE_NS = "Id-Attribute-NS";
- /** <p>The namespace to use for incomming documents from tamino db.
- * By default no namespace is used.</p>
- */
- public static final String TARGETNAMESPACE_IN = "TargetNamespace-IN";
+ private URL dbURL;
+ private String user;
+ private String password;
+ private boolean useGet;
+ private SAXParserFactory spf;
+ private String idAttribute = null;
+ private String idAttributeNS = null;
+ private String targetNamespaceIn = null;
+ private boolean useCursoring = false;
+
+ /** <p>Name of our private configuration node (<samp>InoManager</samp> in
+ * namespace <code>JMManagerFactoryImpl.NAMESPACE_URI</code>)</p>
+ */
+ public static final String CONFIGURATION_NODE_NAME = "InoManager";
+
+ /** <p>Name of the database URL node, including the collection name.</p>
+ */
+ public static final String DBURL_NODE_NAME = "DbURL";
+ /** <p>Name of the User node</p>
+ */
+ public static final String USER_NODE_NAME = "User";
+ /** <p>Name of the Password node</p>
+ */
+ public static final String PASSWORD_NODE_NAME = "Password";
- /** <p>Returns the element ID. The default implementation
- * returns
- * <code>getAttribute(InoResponseHandler.INO_RESPONSE2_URI, "id")</code>.
- * If you use another element as the ID, change this.</p>
- */
- protected String getElementId(JMAnyElement pElement) throws SAXException {
- if(idAttribute != null) {
- String id = pElement.getAttribute(idAttributeNS, idAttribute, null);
- pElement.removeAttribute(idAttributeNS, idAttribute);
- return id;
- } else
- return pElement.getAttribute(InoResponseHandlerNoNs.INO_RESPONSE2_URI, "id", null);
- }
+ /** <p>Name of the attribute Id mapping. By default
+ * no mapping is used.</p>
+ */
+ public static final String ID_ATTRIBUTE = "Id-Attribute";
- /** <p>After an insert, sets the elements ID. The default
- * implementation performs
- * <code>setAttribute(InoResponseHandler.INO_RESPONSE2_URI, "id", pId)</code>.
- * If you use another element as the ID, change this. You probably need
- * to read the inserted document by using the supplied ino:id.</p>
- */
- protected void setElementId(JMAnyElement pElement, String pId) throws SAXException {
- pElement.setAttribute(InoResponseHandlerNoNs.INO_RESPONSE2_URI, "id", pId, null);
- if(idAttribute != null) {
- pElement.setAttribute(idAttributeNS, idAttribute, pId, null);
- }
- }
+ /** <p>The namespace for the mapped attribute. By default
+ * no mapping is used.</p>
+ */
+ public static final String ID_ATTRIBUTE_NS = "Id-Attribute-NS";
- /** <p>Returns a query suited for deleting the element.</p>
- */
- protected String getDeleteQuery(JMAnyElement pElement) throws SAXException {
- String id = getElementId(pElement);
- if (id == null || id.length() == 0) {
- throw new SAXException("The element being deleted doesn't have an ID.");
- }
- return "_delete=" +
- URLEncoder.encode(pElement.getLocalName() + "[@ino:id=" + id + "]");
- }
+ /** <p>The namespace to use for incomming documents from tamino db.
+ * By default no namespace is used.</p>
+ */
+ public static final String TARGETNAMESPACE_IN = "TargetNamespace-IN";
- /** <p>Returns a query suited for updating the element.</p>
- */
- protected String getUpdateQuery(JMAnyElement pElement) throws SAXException {
- String id = getElementId(pElement);
- if (id == null || id.length() == 0) {
- throw new SAXException("The element being updated doesn't have an ID.");
+ /** <p>Use the special cursoring as described above.</p>
+ */
+ public static final String USE_CURSORING = "Use-Cursoring";
+
+ /**
+ * @return
+ */
+ public URL getDbURL() {
+ return dbURL;
}
- return "_process=" + URLEncoder.encode(pElement.toXMLNoNS());
- }
- /** <p>Returns a query suited for inserting the element.</p>
- */
- protected String getInsertQuery(JMAnyElement pElement) throws SAXException {
- String id = getElementId(pElement);
- if (id != null && id.length() > 0) {
- throw new SAXException("The element being inserted already has an ID.");
+ /**
+ * @param url
+ */
+ public void setDbURL(URL url) {
+ dbURL = url;
}
- return "_process=" + URLEncoder.encode(pElement.toXMLNoNS());
- }
- /** <p>Parses a configuration element. This method is called twice:
- * Once for the default configuration and once for the specific
- * configuration.</p>
- */
- public void parseConfiguration(Element pElement) {
- super.parseConfiguration(pElement);
- for (Node node = pElement.getFirstChild();
- node != null;
- node = node.getNextSibling()) {
- if (node.getNodeType() == Node.ELEMENT_NODE &&
- JMManagerFactoryImpl.NAMESPACE_URI.equals(node.getNamespaceURI())) {
- if (CONFIGURATION_NODE_NAME.equals(node.getLocalName())) {
- for (Node child = node.getFirstChild();
- child != null;
- child = child.getNextSibling()) {
- if (child.getNodeType() == Node.ELEMENT_NODE &&
- JMManagerFactoryImpl.NAMESPACE_URI.equals(child.getNamespaceURI())) {
- if (DBURL_NODE_NAME.equals(child.getLocalName())) {
- String url = JMManagerFactoryImpl.getNodeText(child);
- try {
- dbURL = new java.net.URL(url);
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException("Invalid database URL: " + url);
+ /** <p>Parses a configuration element. This method is called twice:
+ * Once for the default configuration and once for the specific
+ * configuration.</p>
+ */
+ public void parseConfiguration(Element pElement) {
+ super.parseConfiguration(pElement);
+ for (Node node = pElement.getFirstChild();
+ node != null;
+ node = node.getNextSibling()) {
+ if (node.getNodeType() == Node.ELEMENT_NODE
+ && JMManagerFactoryImpl.NAMESPACE_URI.equals(node.getNamespaceURI())) {
+ if (CONFIGURATION_NODE_NAME.equals(node.getLocalName())) {
+ for (Node child = node.getFirstChild(); child != null;
+ child = child.getNextSibling()) {
+ if (child.getNodeType() == Node.ELEMENT_NODE
+ && JMManagerFactoryImpl.NAMESPACE_URI.equals(
+ child.getNamespaceURI())) {
+ if (DBURL_NODE_NAME.equals(child.getLocalName())) {
+ String url = JMManagerFactoryImpl.getNodeText(child);
+ try {
+ dbURL = new URL(url);
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(
+ "Invalid database URL: " + url);
+ }
+ } else if (
+ USER_NODE_NAME.equals(child.getLocalName())) {
+ user = JMManagerFactoryImpl.getNodeText(child);
+ } else if (
+ PASSWORD_NODE_NAME.equals(child.getLocalName())) {
+ password = JMManagerFactoryImpl.getNodeText(child);
+ } else if (
+ ID_ATTRIBUTE.equals(child.getLocalName())) {
+ idAttribute = JMManagerFactoryImpl.getNodeText(child);
+ } else if (
+ ID_ATTRIBUTE_NS.equals(child.getLocalName())) {
+ idAttributeNS = JMManagerFactoryImpl.getNodeText(child);
+ } else if (
+ TARGETNAMESPACE_IN.equals(child.getLocalName())) {
+ targetNamespaceIn = JMManagerFactoryImpl.getNodeText(child);
+ } else if (USE_CURSORING.equals(child.getLocalName())) {
+ String uc = JMManagerFactoryImpl.getNodeText(child);
+ useCursoring = (uc != null && "yes".equals(uc));
+ }
+ }
+ }
+ if (idAttribute != null && idAttributeNS == null)
+ idAttributeNS = "";
}
- } else if (USER_NODE_NAME.equals(child.getLocalName())) {
- user = JMManagerFactoryImpl.getNodeText(child);
- } else if (PASSWORD_NODE_NAME.equals(child.getLocalName())) {
- password = JMManagerFactoryImpl.getNodeText(child);
- } else if (ID_ATTRIBUTE.equals(child.getLocalName())) {
- idAttribute = JMManagerFactoryImpl.getNodeText(child);
- } else if (ID_ATTRIBUTE_NS.equals(child.getLocalName())) {
- idAttributeNS = JMManagerFactoryImpl.getNodeText(child);
- } else if (TARGETNAMESPACE_IN.equals(child.getLocalName())) {
- targetNamespaceIn = JMManagerFactoryImpl.getNodeText(child);
- }
}
- }
- if(idAttribute != null && idAttributeNS == null)
- idAttributeNS = "";
}
- }
}
- }
- /** Creates a new instance of InoManager */
- public InoManagerNoNs() {
- spf = SAXParserFactory.newInstance();
- spf.setNamespaceAware(true);
- spf.setValidating(false);
- }
+ /** Creates a new instance of InoManager */
+ public InoManagerNoNs() {
+ spf = SAXParserFactory.newInstance();
+ spf.setNamespaceAware(true);
+ spf.setValidating(false);
+ }
- /** <p>Deletes the given document from the database.</p>
- */
- public void delete(JMAnyElement pElement) throws SAXException {
- String query = getDeleteQuery(pElement);
- performQuery(query, (List) null);
- }
+ /** <p>Deletes the given document from the database.</p>
+ */
+ public void delete(JMAnyElement pElement) throws SAXException {
+ String query = getDeleteQuery(pElement);
+ performQuery(query, (List) null);
+ }
- /** <p>Inserts the given document into the database.</p>
- */
- public void insert(JMAnyElement pElement) throws SAXException {
- String query = getInsertQuery(pElement);
- List idList = new ArrayList();
- InoResponseHandlerNoNs irh = performQuery(query, idList);
- if (idList.size() == 0) {
- throw new SAXException("Query did not return an ino:id");
+ /** <p>Inserts the given document into the database.</p>
+ */
+ public void insert(JMAnyElement pElement) throws SAXException {
+ String query = getInsertQuery(pElement);
+ List idList = new ArrayList();
+ InoResponseHandlerNoNs irh = performQuery(query, idList);
+ if (idList.size() == 0) {
+ throw new SAXException("Query did not return an ino:id");
+ }
+ setElementId(pElement, (String) idList.get(0));
}
- setElementId(pElement, (String) idList.get(0));
- }
- /** <p>Updates the given document in the database.</p>
- */
- public void update(JMAnyElement pElement) throws SAXException {
- String query = getUpdateQuery(pElement);
- performQuery(query, (List) null);
- }
+ /** <p>Updates the given document in the database.</p>
+ */
+ public void update(JMAnyElement pElement) throws SAXException {
+ String query = getUpdateQuery(pElement);
+ performQuery(query, (List) null);
+ }
- /** <p>Defines the given schema in the database.</p>
- */
- public void define(String pSchema) throws SAXException {
- String query = "_define=" + URLEncoder.encode(pSchema);
- performQuery(query, (java.util.List) null);
- }
+ /** <p>Defines the given schema in the database.</p>
+ */
+ public void define(String pSchema) throws SAXException {
+ String query = "_define=" + URLEncoder.encode(pSchema);
+ performQuery(query, (List) null);
+ }
- /** <p>Performs a single database query.</p>
- */
- protected HttpURLConnection getResponse(String pQuery) throws SAXException {
- URL connectionURL = dbURL;
- try {
- if (useGet) {
- String dburl = connectionURL.toString();
- String url;
- if (dburl.indexOf('?') > 0) {
- url = dburl + "&" + pQuery;
- } else {
- url = dburl + "?" + pQuery;
- }
- try {
- connectionURL = new URL(url);
- HttpURLConnection conn = (HttpURLConnection) connectionURL.openConnection();
- conn.setDoOutput(false);
- conn.setDoInput(true);
- return conn;
- } catch (MalformedURLException e) {
- throw new SAXException("Malformed database URL: " + url);
- }
- } else {
- HttpURLConnection conn = (HttpURLConnection) connectionURL.openConnection();
- conn.setDoOutput(true);
- conn.setDoInput(true);
+ /** <p>Reads documents matching the given query. For any document
+ * matching, the Observer's notify method is executed with the
+ * matching document as an argument.</p>
+ * <p>The query may contain placeholders. If it does, you have
+ * to supply an object array with two elements per placeholder:
+ * An Integer with a java.sql.Types type and the actual placeholder
+ * value. Example:
+ * <pre>
+ * manager.select("Name = ? and Id = ?",
+ * new Object[]{JMManager.VARCHAR,
+ * "Someone",
+ * JMManager.INTEGER,
+ * 4}, 0, 0);
+ * </pre></p>
+ *
+ * @param pObserver This Observer is notified for any matching document.
+ * The document is added as an argument.
+ * @param pQuery The query to perform. May contain placeholders.
+ * @param pPlaceHolderArgs An array of objects or null, if the
+ * query doesn't contain any placeholders.
+ * @param pStart Ignore the given number of result documents at the
+ * beginning. A value of zero will return all documents.
+ * @param pMax Return at most the given number of documents. A value
+ * of zero will return all documents.
+ */
+ public void select(Observer pObserver, String pQuery, Object[] pPlaceHolderArgs,
+ int pStart, int pMax) throws SAXException {
+ select(pObserver, pQuery, pPlaceHolderArgs, pStart, pMax, (ResultInfo) null);
+ }
- OutputStream ostream = conn.getOutputStream();
- Writer w = new OutputStreamWriter(ostream);
- w.write(pQuery);
- w.close();
- return conn;
- }
- } catch (IOException e) {
- throw new SAXException("I/O Error: " + e.getMessage(), e);
+ /* (non-Javadoc)
+ * @see de.ispsoft.jaxme.JMManager#select(java.lang.String, java.lang.Object[], int, int, de.ispsoft.jaxme.ResultInfo)
+ */
+ public Iterator select(String pQuery, Object[] pPlaceHolderArgs, int pStart,
+ int pMax, ResultInfo pResultInfo) throws SAXException {
+ MyObserver o = new MyObserver();
+ select(o, pQuery, pPlaceHolderArgs, pStart, pMax, pResultInfo);
+ return o.resultList.iterator();
}
- }
- /** <p>Performs a single database query.</p>
- */
- protected InoResponseHandlerNoNs performQuery(String pQuery, java.util.List pList)
- throws SAXException {
- InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
- if (pList != null) {
- irh.setInoObjectIdList(pList);
+ /* (non-Javadoc)
+ * @see de.ispsoft.jaxme.JMManager#select(de.ispsoft.jaxme.Observer, java.lang.String, java.lang.Object[], int, int, de.ispsoft.jaxme.ResultInfo)
+ */
+ public void select(Observer pObserver, String pQuery, Object[] pPlaceHolderArgs,
+ int pStart, int pMax, ResultInfo pResultInfo) throws SAXException {
+ if (pPlaceHolderArgs != null && pPlaceHolderArgs.length > 0) {
+ throw new SAXException("Placeholders are not yet supported");
+ }
+ String q;
+ if (useCursoring) {
+ if(pStart == 0 && pMax == 0) {
+ q = "_xql(1,0)=" + URLEncoder.encode(pQuery);
+ } else {
+ q = "_cursor=open&_count=cheap&_xql=" + URLEncoder.encode(pQuery);
+ if (pStart != 0 || pMax != 0) {
+ q += "&_position=" + (pStart + 1) + "&_quantity=" + pMax;
+ }
+ }
+ } else {
+ if (pStart != 0 || pMax != 0) {
+ q = "_xql(" + (pStart + 1) + "," + pMax + ")=";
+ } else {
+ q = "_xql=";
+ }
+ q += URLEncoder.encode(pQuery);
+ }
+ InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
+ irh.setResultInfo(pResultInfo);
+ JMContentHandler ch = getJMContentHandler();
+ ch.setObserver(pObserver);
+ irh.setResultHandler(ch);
+ performQuery(q, irh);
}
- performQuery(pQuery, irh);
- return irh;
- }
- /** <p>Parses a single INO response document.</p>
- */
- protected void performQuery(String pQuery, InoResponseHandlerNoNs pHandler)
- throws SAXException {
- if(idAttribute != null)
- pHandler.setAttributeMappingId(idAttribute, idAttributeNS);
- if(targetNamespaceIn != null)
- pHandler.setTargetNamespace(targetNamespaceIn);
- HttpURLConnection conn = getResponse(pQuery);
- try {
- InputSource isource = new InputSource(conn.getInputStream());
- isource.setEncoding(conn.getContentEncoding());
- XMLReader xr;
- SAXParser sp = spf.newSAXParser();
- xr = sp.getXMLReader();
- xr.setContentHandler(pHandler);
- xr.parse(isource);
- } catch (ParserConfigurationException e) {
- throw new SAXException("ParserConfigurationException: " + e.getMessage(), e);
- } catch (IOException e) {
- throw new SAXException("I/O Exception: " + e.getMessage(), e);
+ /** <p>Returns the element ID. The default implementation
+ * returns
+ * <code>getAttribute(InoResponseHandler.INO_RESPONSE2_URI, "id")</code>.
+ * If you use another element as the ID, change this.</p>
+ */
+ protected String getElementId(JMAnyElement pElement) throws SAXException {
+ if (idAttribute != null) {
+ String id = pElement.getAttribute(idAttributeNS, idAttribute, null);
+ pElement.removeAttribute(idAttributeNS, idAttribute);
+ return id;
+ } else
+ return pElement.getAttribute(InoResponseHandlerNoNs.INO_RESPONSE2_URI,
+ "id", null);
}
- }
- /** <p>Reads documents matching the given query. For any document
- * matching, the Observer's notify method is executed with the
- * matching document as an argument.</p>
- * <p>The query may contain placeholders. If it does, you have
- * to supply an object array with two elements per placeholder:
- * An Integer with a java.sql.Types type and the actual placeholder
- * value. Example:
- * <pre>
- * manager.select("Name = ? and Id = ?",
- * new Object[]{JMManager.VARCHAR,
- * "Someone",
- * JMManager.INTEGER,
- * 4}, 0, 0);
- * </pre></p>
- *
- * @param pObserver This Observer is notified for any matching document.
- * The document is added as an argument.
- * @param pQuery The query to perform. May contain placeholders.
- * @param pPlaceHolderArgs An array of objects or null, if the
- * query doesn't contain any placeholders.
- * @param pStart Ignore the given number of result documents at the
- * beginning. A value of zero will return all documents.
- * @param pMax Return at most the given number of documents. A value
- * of zero will return all documents.
- */
- public void select(Observer pObserver, String pQuery, Object[] pPlaceHolderArgs, int pStart, int pMax) throws SAXException {
- if (pPlaceHolderArgs != null && pPlaceHolderArgs.length > 0) {
- throw new SAXException("Placeholders are not yet supported");
+ /** <p>After an insert, sets the elements ID. The default
+ * implementation performs
+ * <code>setAttribute(InoResponseHandler.INO_RESPONSE2_URI, "id", pId)</code>.
+ * If you use another element as the ID, change this. You probably need
+ * to read the inserted document by using the supplied ino:id.</p>
+ */
+ protected void setElementId(JMAnyElement pElement, String pId) throws SAXException {
+ pElement.setAttribute(InoResponseHandlerNoNs.INO_RESPONSE2_URI, "id",
+ pId, null);
+ if (idAttribute != null) {
+ pElement.setAttribute(idAttributeNS, idAttribute, pId, null);
+ }
}
- String q;
- if (pStart != 0 || pMax != 0) {
- q = "_xql(" + (pStart+1) + "," + pMax + ")=";
- } else {
- q = "_xql=";
+
+ /** <p>Returns a query suited for deleting the element.</p>
+ */
+ protected String getDeleteQuery(JMAnyElement pElement) throws SAXException {
+ String id = getElementId(pElement);
+ if (id == null || id.length() == 0) {
+ throw new SAXException("The element being deleted doesn't have an ID.");
+ }
+ return "_delete=" + URLEncoder.encode(pElement.getLocalName() + "[@ino:id=" + id + "]");
}
- q += URLEncoder.encode(pQuery);
- InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
- JMContentHandler ch = getJMContentHandler();
- ch.setObserver(pObserver);
- irh.setResultHandler(ch);
- performQuery(q, irh);
- }
-
- /**
- * @return
+ /** <p>Returns a query suited for updating the element.</p>
*/
- public URL getDbURL() {
- return dbURL;
+ protected String getUpdateQuery(JMAnyElement pElement) throws SAXException {
+ String id = getElementId(pElement);
+ if (id == null || id.length() == 0) {
+ throw new SAXException("The element being updated doesn't have an ID.");
+ }
+ return "_process=" + URLEncoder.encode(pElement.toXMLNoNS());
}
-
- /**
- * @param url
+
+ /** <p>Returns a query suited for inserting the element.</p>
*/
- public void setDbURL(URL url) {
- dbURL = url;
+ protected String getInsertQuery(JMAnyElement pElement) throws SAXException {
+ String id = getElementId(pElement);
+ if (id != null && id.length() > 0) {
+ throw new SAXException("The element being inserted already has an ID.");
+ }
+ return "_process=" + URLEncoder.encode(pElement.toXMLNoNS());
+ }
+
+ /** <p>Performs a single database query.</p>
+ */
+ protected HttpURLConnection getResponse(String pQuery) throws SAXException {
+ URL connectionURL = dbURL;
+ try {
+ if (useGet) {
+ String dburl = connectionURL.toString();
+ String url;
+ if (dburl.indexOf('?') > 0) {
+ url = dburl + "&" + pQuery;
+ } else {
+ url = dburl + "?" + pQuery;
+ }
+ try {
+ connectionURL = new URL(url);
+ HttpURLConnection conn = (HttpURLConnection) connectionURL.openConnection();
+ conn.setDoOutput(false);
+ conn.setDoInput(true);
+ return conn;
+ } catch (MalformedURLException e) {
+ throw new SAXException("Malformed database URL: " + url);
+ }
+ } else {
+ HttpURLConnection conn = (HttpURLConnection) connectionURL.openConnection();
+ conn.setDoOutput(true);
+ conn.setDoInput(true);
+ OutputStream ostream = conn.getOutputStream();
+ Writer w = new OutputStreamWriter(ostream);
+ w.write(pQuery);
+ w.close();
+ return conn;
+ }
+ } catch (IOException e) {
+ throw new SAXException("I/O Error: " + e.getMessage(), e);
+ }
+ }
+
+ /** <p>Performs a single database query.</p>
+ */
+ protected InoResponseHandlerNoNs performQuery(String pQuery, List pList)
+ throws SAXException {
+ InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
+ if (pList != null) {
+ irh.setInoObjectIdList(pList);
+ }
+ performQuery(pQuery, irh);
+ return irh;
+ }
+
+ /** <p>Parses a single INO response document.</p>
+ */
+ protected void performQuery(String pQuery, InoResponseHandlerNoNs pHandler)
+ throws SAXException {
+ if (idAttribute != null)
+ pHandler.setAttributeMappingId(idAttribute, idAttributeNS);
+ if (targetNamespaceIn != null)
+ pHandler.setTargetNamespace(targetNamespaceIn);
+ HttpURLConnection conn = getResponse(pQuery);
+ try {
+ InputSource isource = new InputSource(conn.getInputStream());
+ isource.setEncoding(conn.getContentEncoding());
+ XMLReader xr;
+ SAXParser sp = spf.newSAXParser();
+ xr = sp.getXMLReader();
+ xr.setContentHandler(pHandler);
+ xr.parse(isource);
+ } catch (ParserConfigurationException e) {
+ throw new SAXException(
+ "ParserConfigurationException: " + e.getMessage(),
+ e);
+ } catch (IOException e) {
+ throw new SAXException("I/O Exception: " + e.getMessage(), e);
+ }
}
}
|
|
From: <th...@us...> - 2004-01-07 10:59:31
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme
In directory sc8-pr-cvs1:/tmp/cvs-serv18038/src/runtime/de/ispsoft/jaxme
Modified Files:
JMManagerImpl.java JMManager.java
Log Message:
extended cursoring and bugfixes
Index: JMManagerImpl.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/JMManagerImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- JMManagerImpl.java 11 Jul 2002 22:20:07 -0000 1.8
+++ JMManagerImpl.java 7 Jan 2004 10:59:28 -0000 1.9
@@ -1,5 +1,12 @@
package de.ispsoft.jaxme;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
@@ -10,6 +17,7 @@
* @author <a href="mailto:jo...@is...">Jochen Wiedmann</a>
*/
public class JMManagerImpl implements JMManager {
+
/** <p>The local name of the ElementClass element.</p>
*/
public static final String ELEMENT_CLASS_NAME = "ElementClass";
@@ -26,14 +34,14 @@
private static final String propertyBase = JMManager.class.getName();
private String propTree;
private String localPropTree;
- private java.util.List prefixList;
+ private List prefixList;
protected class MyObserver implements Observer {
private int maxResultSize = -1;
private int resultSize = 0;
- public java.util.List resultList = new java.util.ArrayList();
+ public List resultList = new ArrayList();
public MyObserver() {}
- public void notify(Object o) throws org.xml.sax.SAXException {
+ public void notify(Object o) throws SAXException {
if (maxResultSize != -1) {
if (++resultSize > maxResultSize) {
throw new SAXException("Maximum result size of " + maxResultSize +
@@ -83,7 +91,7 @@
throw new NullPointerException("Namespace element must have a prefix attribute");
}
if (prefixList == null) {
- prefixList = new java.util.ArrayList();
+ prefixList = new ArrayList();
}
prefixList.add(uriNode.getNodeValue());
prefixList.add(prefixNode.getNodeValue());
@@ -193,7 +201,6 @@
select(pObserver, pQuery, null, 0 , 0);
}
-
/** <p>Reads documents matching the given query. For any document
* matching, the Observer's notify method is executed with the
* matching document as an argument.</p>
@@ -245,7 +252,7 @@
* @param pMax Return at most the given number of documents. A value
* of zero will return all documents.
*/
- public java.util.Iterator select(String pQuery, int pStart, int pMax)
+ public Iterator select(String pQuery, int pStart, int pMax)
throws SAXException {
return select(pQuery, null, pStart, pMax);
}
@@ -271,9 +278,8 @@
* @param pMax Return at most the given number of documents. A value
* of zero will return all documents.
*/
- public java.util.Iterator select(String pQuery,
- Object[] pPlaceHolderArgs,
- int pStart, int pMax) throws SAXException {
+ public Iterator select(String pQuery, Object[] pPlaceHolderArgs,
+ int pStart, int pMax) throws SAXException {
MyObserver o = new MyObserver();
select(o, pQuery, pPlaceHolderArgs, pStart, pMax);
return o.resultList.iterator();
@@ -283,7 +289,7 @@
*
* @param pQuery The query to perform.
*/
- public java.util.Iterator select(String pQuery) throws SAXException {
+ public Iterator select(String pQuery) throws SAXException {
return select(pQuery, null, 0, 0);
}
@@ -304,9 +310,8 @@
* @param pPlaceHolderArgs An array of objects or null, if the
* query doesn't contain any placeholders.
*/
- public java.util.Iterator select(String pQuery,
- Object[] pPlaceHolderArgs)
- throws SAXException {
+ public Iterator select(String pQuery, Object[] pPlaceHolderArgs)
+ throws SAXException {
return select(pQuery, pPlaceHolderArgs, 0, 0);
}
@@ -328,18 +333,16 @@
/** <p>Serializes an element to a SAX ContentHandler using the configured
* prefix settings.</p>
*/
- public void toSAX(JMAnyElement pElement,
- org.xml.sax.ContentHandler pContentHandler)
- throws SAXException {
+ public void toSAX(JMAnyElement pElement, ContentHandler pContentHandler)
+ throws SAXException {
pElement.toSAX(pContentHandler, getNamespaceSupport());
}
/** <p>Serializes an element to a SAX ContentHandler using the configured
* prefix settings.</p>
*/
- public void toWriter(JMAnyElement pElement,
- java.io.Writer pWriter)
- throws SAXException, java.io.IOException {
+ public void toWriter(JMAnyElement pElement, Writer pWriter)
+ throws SAXException, IOException {
pElement.toWriter(pWriter, getNamespaceSupport());
}
@@ -351,7 +354,7 @@
}
public void select(Observer pObserver, String pQuery, Object[] pPlaceHolders,
- int pStart, int pMax) throws SAXException {
+ int pStart, int pMax) throws SAXException {
throw new SAXException("Not implemented");
}
@@ -366,4 +369,21 @@
public void insert(JMAnyElement pElement) throws SAXException {
throw new SAXException("Not implemented");
}
+
+ /* (non-Javadoc)
+ * @see de.ispsoft.jaxme.JMManager#select(de.ispsoft.jaxme.Observer, java.lang.String, java.lang.Object[], int, int, de.ispsoft.jaxme.ResultInfo)
+ */
+ public void select(Observer pObserver, String pQuery, Object[] pPlaceHolderArgs,
+ int pStart, int pMax, ResultInfo pResultInfo) throws SAXException {
+ throw new SAXException("Not implemented");
+ }
+
+ /* (non-Javadoc)
+ * @see de.ispsoft.jaxme.JMManager#select(java.lang.String, java.lang.Object[], int, int, de.ispsoft.jaxme.ResultInfo)
+ */
+ public Iterator select(String pQuery, Object[] pPlaceHolderArgs, int pStart,
+ int pMax, ResultInfo pResultInfo) throws SAXException {
+ throw new SAXException("Not implemented");
+ }
+
}
Index: JMManager.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/JMManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- JMManager.java 25 Apr 2003 19:57:46 -0000 1.4
+++ JMManager.java 7 Jan 2004 10:59:28 -0000 1.5
@@ -1,5 +1,7 @@
package de.ispsoft.jaxme;
+import java.util.Iterator;
+
import org.xml.sax.SAXException;
@@ -147,6 +149,38 @@
Object[] pPlaceHolderArgs,
int pStart, int pMax) throws SAXException;
+ /**
+ * <p>Reads documents matching the given query. For any document
+ * matching, the Observer's notify method is executed with the
+ * matching document as an argument.</p>
+ * <p>The query may contain placeholders. If it does, you have
+ * to supply an object array with two elements per placeholder:
+ * An Integer with a java.sql.Types type and the actual placeholder
+ * value. Example:
+ * <pre>
+ * manager.select("Name = ? and Id = ?",
+ * new Object[]{JMManager.VARCHAR,
+ * "Someone",
+ * JMManager.INTEGER,
+ * 4}, 0, 0);
+ * </pre></p>
+ *
+ * @param pObserver This Observer is notified for any matching document.
+ * The document is added as an argument.
+ * @param pQuery The query to perform. May contain placeholders.
+ * @param pPlaceHolderArgs An array of objects or null, if the
+ * query doesn't contain any placeholders.
+ * @param pStart Ignore the given number of result documents at the
+ * beginning. A value of zero will return all documents.
+ * @param pMax Return at most the given number of documents. A value
+ * of zero will return all documents.
+ * @param pResultInfo A container to place the information from query resultset, e.g. the resultset count
+ * @throws SAXException
+ */
+ public void select(Observer pObserver, String pQuery,
+ Object[] pPlaceHolderArgs,
+ int pStart, int pMax, ResultInfo pResultInfo) throws SAXException;
+
/** <p>Returns an iterator to all documents matching the given query.</p>
*
* @param pQuery The query to perform.
@@ -155,8 +189,7 @@
* @param pMax Return at most the given number of documents. A value
* of zero will return all documents.
*/
- public java.util.Iterator select(String pQuery, int pStart, int pMax)
- throws SAXException;
+ public Iterator select(String pQuery, int pStart, int pMax) throws SAXException;
/** <p>Returns an iterator to all documents matching the given query.
@@ -180,15 +213,39 @@
* @param pMax Return at most the given number of documents. A value
* of zero will return all documents.
*/
- public java.util.Iterator select(String pQuery,
- Object[] pPlaceHolderArgs,
+ public java.util.Iterator select(String pQuery, Object[] pPlaceHolderArgs,
int pStart, int pMax) throws SAXException;
+ /** <p>Returns an iterator to all documents matching the given query.
+ * The query may contain placeholders. If it does, you have
+ * to supply an object array with two elements per placeholder:
+ * An Integer with a java.sql.Types type and the actual placeholder
+ * value. Example:
+ * <pre>
+ * manager.select("Name = ? and Id = ?",
+ * new Object[]{JMManager.VARCHAR,
+ * "Someone",
+ * JMManager.INTEGER,
+ * 4}, 0, 0);
+ * </pre></p>
+ *
+ * @param pQuery The query to perform. May contain placeholders.
+ * @param pPlaceHolderArgs An array of objects or null, if the
+ * query doesn't contain any placeholders.
+ * @param pStart Ignore the given number of result documents at the
+ * beginning. A value of zero will return all documents.
+ * @param pMax Return at most the given number of documents. A value
+ * of zero will return all documents.
+ * @param pResultInfo A container to place the information from query resultset, e.g. the resultset count
+ */
+ public Iterator select(String pQuery, Object[] pPlaceHolderArgs, int pStart,
+ int pMax, ResultInfo pResultInfo) throws SAXException;
+
/** <p>Returns an iterator to all documents matching the given query.</p>
*
* @param pQuery The query to perform.
*/
- public java.util.Iterator select(String pQuery) throws SAXException;
+ public Iterator select(String pQuery) throws SAXException;
/** <p>Returns an iterator to all documents matching the given query.
* The query may contain placeholders. If it does, you have
@@ -207,9 +264,7 @@
* @param pPlaceHolderArgs An array of objects or null, if the
* query doesn't contain any placeholders.
*/
- public java.util.Iterator select(String pQuery,
- Object[] pPlaceHolderArgs)
- throws SAXException;
+ public Iterator select(String pQuery, Object[] pPlaceHolderArgs) throws SAXException;
/** <p>Inserts the given document into the database.</p>
*/
|
|
From: <th...@us...> - 2004-01-07 10:59:10
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme
In directory sc8-pr-cvs1:/tmp/cvs-serv17937/src/runtime/de/ispsoft/jaxme
Added Files:
ResultInfo.java
Log Message:
provide informations from tamino db result, e.g. cursor count
--- NEW FILE: ResultInfo.java ---
/*
* Created on 06.01.2004
*
*/
package de.ispsoft.jaxme;
/**
* @author Thomas Haenel, ATC GmbH
* @version $Id: ResultInfo.java,v 1.1 2004/01/07 10:58:57 thaenel Exp $
*/
public class ResultInfo {
// the count of elements found
private int cursorCount = -1;
/**
* @return
*/
public int getCursorCount() {
return cursorCount;
}
/**
* @param i
*/
public void setCursorCount(int i) {
cursorCount = i;
}
}
|
|
From: <th...@us...> - 2004-01-07 09:37:02
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme In directory sc8-pr-cvs1:/tmp/cvs-serv5169/src/runtime/de/ispsoft/jaxme Added Files: TransactionRetryException.java Log Message: special handling of transaction exceptions needed --- NEW FILE: TransactionRetryException.java --- // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: packimports(3) // Source File Name: TransactionRetryException.java package de.ispsoft.jaxme; import javax.ejb.EJBException; public class TransactionRetryException extends EJBException { public TransactionRetryException(Exception e) { this.e = e; } public Exception getLinkedException() { return e; } Exception e; } |
|
From: <th...@us...> - 2004-01-07 09:36:16
|
Update of /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/beanwriter In directory sc8-pr-cvs1:/tmp/cvs-serv5077/src/generator/de/ispsoft/jaxme/generator/beanwriter Modified Files: EntityBeanClassWriter.java Log Message: special handling of transaction exceptions needed Index: EntityBeanClassWriter.java =================================================================== RCS file: /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/beanwriter/EntityBeanClassWriter.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- EntityBeanClassWriter.java 6 Jan 2004 10:06:55 -0000 1.13 +++ EntityBeanClassWriter.java 7 Jan 2004 09:36:13 -0000 1.14 @@ -1,1022 +1,1161 @@ -// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.geocities.com/kpdus/jad.html -// Decompiler options: packimports(3) -// Source File Name: EntityBeanClassWriter.java - package de.ispsoft.jaxme.generator.beanwriter; -import de.ispsoft.jaxme.generator.*; +import de.ispsoft.jaxme.JMFactory; +import de.ispsoft.jaxme.generator.BeanWriter; +import de.ispsoft.jaxme.generator.SchemaException; [...2029 lines suppressed...] + jm.addLine(" }"); + jm.addLine(" return result;"); + } else { + jm.addLine(" return " + + generatePrimaryKeyResult("((" + + element.getManagerClassName() + + ") manager)." + pMethod.getName() + + "(" + buffer + ")") + ";"); + } + jm.addLine("} catch (SAXException e) {"); + if(getTreatWASStaleConnection()){ + jm.addLine(" Exception ex=e.getException();"); + jm.addLine(" if(ex instanceof com.ibm.websphere.ce.cm.StaleConnectionException)"); + jm.addLine(" throw new EJBException(ex);"); + } + jm.addLine(" throw new FinderException(e.getClass().getName() + \": \" + e.getMessage());"); + jm.addLine("}"); + return jm; + } } |
|
From: <th...@us...> - 2004-01-06 10:26:14
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme
In directory sc8-pr-cvs1:/tmp/cvs-serv21221/src/runtime/de/ispsoft/jaxme
Modified Files:
JMFileManager.java XmlDbManager.java ObservedHandlerImpl.java
Log Message:
notify-mechanism now returns a JMAnyElement instance instead of JMContentHandler (in jdbc handling and javadoc already done)
Index: JMFileManager.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/JMFileManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- JMFileManager.java 20 Feb 2003 20:50:49 -0000 1.3
+++ JMFileManager.java 6 Jan 2004 10:26:11 -0000 1.4
@@ -42,7 +42,7 @@
myObserver = pObserver;
}
public void notify(Object o) throws SAXException {
- myObserver.notify(((JMContentHandler) o).getResultNode());
+ myObserver.notify(o);
}
}
Index: XmlDbManager.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/XmlDbManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- XmlDbManager.java 22 Jan 2003 17:25:28 -0000 1.4
+++ XmlDbManager.java 6 Jan 2004 10:26:11 -0000 1.5
@@ -396,7 +396,7 @@
myObserver = pObserver;
}
public void notify(Object o) throws SAXException {
- myObserver.notify(((JMContentHandler) o).getResultNode());
+ myObserver.notify(o);
}
}
}
Index: ObservedHandlerImpl.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/ObservedHandlerImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ObservedHandlerImpl.java 17 Jan 2002 09:05:28 -0000 1.1
+++ ObservedHandlerImpl.java 6 Jan 2004 10:26:11 -0000 1.2
@@ -125,7 +125,7 @@
resultCollection.add(o);
}
if (observer != null) {
- observer.notify(this);
+ observer.notify(o);
}
}
|
|
From: <th...@us...> - 2004-01-06 10:25:01
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino
In directory sc8-pr-cvs1:/tmp/cvs-serv20967/src/runtime/de/ispsoft/jaxme/tamino
Added Files:
InoResponseHandlerNoNs.java InoManagerNoNs.java
Log Message:
handling of writing and receiving documents without namespace and map them into namespace aware docs
(tamino workaround)
--- NEW FILE: InoResponseHandlerNoNs.java ---
package de.ispsoft.jaxme.tamino;
import java.util.List;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import org.apache.log4j.Category;
/** <p>This is a SAX content handler for an ino:response document. It
* provides a special handling for mapping the ino:id attribute to a
* configurable attribute of the element class. This can be useful if the
* applicationwide needed id attribute has to be mapped to the TaminoDB generated
* ino:id, e.g. inoid. The mapping attribute name is set through the method
* setAttributeMappingId.</p>
*
* @author <a href="mailto:jo...@is...">Jochen Wiedmann</a>
* @author <a href="mailto:hae...@gm...">Jochen Wiedmann</a>
*/
public class InoResponseHandlerNoNs implements ContentHandler {
private static final Category cat = Category.getInstance(InoResponseHandler.class.getName());
/** <p>The namespace of an INO response document:
* <samp>http://namespaces.softwareag.com/tamino/response2</samp>.</p>
*/
public static final String INO_RESPONSE2_URI =
"http://namespaces.softwareag.com/tamino/response2";
/** <p>The namespace of the XQL section in an INO response
* document: <samp>http://metalab.unc.edu/xql/</samp>.</p>
*/
public static final String XQL_URI = "http://metalab.unc.edu/xql/";
private boolean inInoMessage = false;
private boolean inInoMessageText;
private boolean inXqlResult;
private int level;
private String inoErrorCode;
private StringBuffer inoErrorMessage;
private Locator locator;
private ContentHandler resultHandler;
private String idAttribute = null;
private String idAttributeNS = null;
private String targetNamespace = null;
private int i;
/** Creates a new InoResponseHandler */
public InoResponseHandlerNoNs() {}
/**
* Configure an ino:id mapping attribute. The first param idAttribute
* provides the attributes name used in the JMAnyElement instance as id.
* The idAttributeNS provides the namespace to be used for idAttribute.
* @param idAttribute
* @param idAttributeNS
*/
public void setAttributeMappingId(String idAttribute, String idAttributeNS) {
this.idAttribute = idAttribute;
this.idAttributeNS = idAttributeNS;
//cat.debug("idAttribute: " + idAttribute);
//cat.debug("idAttributeNS: " + idAttributeNS);
}
public void setTargetNamespace(String namespace) {
targetNamespace = namespace;
}
public void setDocumentLocator(Locator l) {
locator = l;
}
public void startDocument() throws org.xml.sax.SAXException {
inInoMessage = false;
inInoMessageText = false;
inXqlResult = false;
level = 0;
if (inoObjectIdList != null) {
inoObjectIdList.clear();
}
}
public void endDocument() throws org.xml.sax.SAXException {
}
public void startElement(String namespaceUri, String localName,
String qName, Attributes attr) throws SAXException {
if (inXqlResult) {
if (resultHandler != null) {
if (level == 2) {
resultHandler.startDocument();
}
// if idAttribute is configured
if(idAttribute != null) {
// is there an ino:id attribute?
i = attr.getIndex(INO_RESPONSE2_URI, "id");
if(i > -1) {
// there is an ino:id, map it to the configured one
AttributesImpl attrs = new AttributesImpl();
attrs.setAttributes(attr);
attrs.addAttribute(idAttributeNS, idAttribute,
idAttribute,
"CDATA", attr.getValue(i));
attr = attrs;
int ix = attr.getIndex(idAttributeNS, idAttribute);
}
}
if(targetNamespace != null) {
namespaceUri = targetNamespace;
}
resultHandler.startElement(namespaceUri, localName, qName, attr);
}
} else if (inInoMessage) {
if (level == 2) {
if (INO_RESPONSE2_URI.equals(namespaceUri) &&
"messagetext".equals(localName)) {
String c = attr.getValue(INO_RESPONSE2_URI, "code");
if (c != null) {
inoErrorCode = c;
}
inInoMessageText = true;
}
}
} else if (level == 1) {
if (XQL_URI.equals(namespaceUri) && "result".equals(localName)) {
inXqlResult = true;
} else if (INO_RESPONSE2_URI.equals(namespaceUri)) {
if ("message".equals(localName)) {
String retval = attr.getValue(INO_RESPONSE2_URI, "returnvalue");
if (retval == null || !retval.equals("0")) {
inoErrorCode = retval;
inoErrorMessage = new StringBuffer();
inInoMessage = true;
}
} else if (inoObjectIdList != null && "object".equals(localName)) {
inoObjectIdList.add(attr.getValue(INO_RESPONSE2_URI, "id"));
}
}
}
++level;
}
public void endElement(String namespaceUri, String localName,
String qName) throws SAXException {
level--;
if (inXqlResult) {
if (level == 1) {
inXqlResult = false;
} else {
if (resultHandler != null) {
resultHandler.endElement(namespaceUri, localName, qName);
if (level == 2) {
resultHandler.endDocument();
}
}
}
} else if (inInoMessage) {
if (level == 1) {
if (inoErrorCode == null) {
inoErrorCode = "INOUNKNOWN";
}
throw new InoException(inoErrorCode, inoErrorMessage.toString());
} else if (level == 2) {
if (inInoMessageText) {
inInoMessageText = false;
}
}
}
}
public void startPrefixMapping(String namespaceUri,
String prefix) throws SAXException {
if (inXqlResult) {
if (resultHandler != null) {
resultHandler.startPrefixMapping(namespaceUri, prefix);
}
}
}
public void endPrefixMapping(String prefix) throws SAXException {
if (inXqlResult) {
if (resultHandler != null) {
resultHandler.endPrefixMapping(prefix);
}
}
}
public void ignorableWhitespace(char[] ch, int start, int len) throws SAXException {
if (inXqlResult) {
if (resultHandler != null) {
resultHandler.ignorableWhitespace(ch, start, len);
}
}
}
public void skippedEntity(String entity) throws SAXException {
if (inXqlResult) {
if (resultHandler != null) {
resultHandler.skippedEntity(entity);
}
}
}
public void processingInstruction(String target, String data) throws SAXException {
if (inXqlResult) {
if (resultHandler != null) {
resultHandler.processingInstruction(target, data);
}
}
}
public void characters(char[] ch, int start, int len) throws SAXException {
if (inXqlResult) {
if (resultHandler != null) {
resultHandler.characters(ch, start, len);
}
} else if (inInoMessageText) {
inoErrorMessage.append(ch, start, len);
}
}
/** <p>Sets the result handler. The result handler is another SAX ContentHandler.
* For any result document the InoResponseHandler finds, that is, for any
* subelement of xql:result, a stream of SAX events is generated for the
* result handler.</p>
* <p>If the response document contains more than one result object, then the
* result handler must be "restartable". In other words, it must be able to
* process multiple startDocument ... endDocument startDocument ...
* endDocument sequences.</p>
*
* @param handler The result handler to use or null to disable SAX events
* @see #getResultHandler
*/
public void setResultHandler(ContentHandler handler) {
resultHandler = handler;
}
/** <p>Returns a result handler, that was previously set with setResultHandler,
* or null.</p>
* <p>The result handler is another SAX ContentHandler.
* For any result document the InoResponseHandler finds, that is, for any
* subelement of xql:result, a stream of SAX events is generated for the
* result handler.</p>
* <p>If the response document contains more than one result object, then the
* result handler must be "restartable". In other words, it must be able to
* process multiple startDocument ... endDocument startDocument ...
* endDocument sequences.</p>
*
* @return The result handler or null, if generating SAX events is disabled.
*/
public ContentHandler getResultHandler() {
return resultHandler;
}
private List inoObjectIdList;
/** <p>The Tamino response document contains object ID's of inserted
* or updated objects. If you use this method, then the ID's are
* collected in the given List. A null value disables ID
* collection. The list will be cleared within <code>startDocument</code>,
* so it's safe to reuse the list over multiple uses of the handler.</p>
* <p>More precise, the list will contain all occurences of
* ino:response/ino:object/@ino:id.</p>
*
* @param pList A list where ID's are being collected or null to disable
* ID collection.
* @see #getInoObjectIdList
*/
public void setInoObjectIdList(List pList) {
inoObjectIdList = pList;
}
/** <p>Returns the current list for collection of generated ino:id's.</p>
*
* @see #setInoObjectIdList
*/
public List getInoObjectIdList() { return inoObjectIdList; }
}
--- NEW FILE: InoManagerNoNs.java ---
package de.ispsoft.jaxme.tamino;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.log4j.Category;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import de.ispsoft.jaxme.JMAnyElement;
import de.ispsoft.jaxme.JMContentHandler;
import de.ispsoft.jaxme.JMManagerImpl;
import de.ispsoft.jaxme.JMManagerFactoryImpl;
import de.ispsoft.jaxme.Observer;
/** <p>An implementation of a JMManager for a Tamino database. This
* InoManager handles the tamino db access without namespace support.
* The targetnamespace of outgoing xml documents is removed (XMLSerializerNoNS)
* before writing it out. For incomming xml documents from tamino db the
* targetnamespace is set through InoResponseHandlerNoNS.
* A configuration example is provided below:
* <JMManagerConfiguration xmlns="http://jaxme.ispsoft.de/namespaces/JMManagerConfiguration">
* <Defaults>
* <InoManager>
* <DbURL>http://localhost/tamino/DB/col</DbURL>
* <ManagerClass>de.ispsoft.jaxme.tamino.InoManagerNoNS</ManagerClass>
* <Id-Attribute>inoid</Id-Attribute>
* <Id-Attribute-NS></Id-Attribute-NS>
* <TargetNamespace-IN>http://my.namespace.com/data</TargetNamespace-IN>
* </InoManager>
* This example configures the tamino db access to use the InoManagerNoNS class
* and map the ino:id attribute to inoid without an attribute namespace. The
* targetnamespace for incomming xml documents from database is set to
* http://my.namespace.com/data.
*</p>
* @see de.ispsoft.jaxme.XMLSerializerNoNS
* @see de.ispsoft.jaxme.InoResponseHandlerNoNS
* @author <a href="mailto:jo...@is...">Jochen Wiedmann</a>
* @author <a href="mailto:hae...@gm...">Thomas Haenel</a>
*/
public class InoManagerNoNs extends JMManagerImpl {
private static final Category cat = Category.getInstance(InoManagerNoNs.class.getName());
private URL dbURL;
private String user;
private String password;
private boolean useGet;
private SAXParserFactory spf;
private String idAttribute = null;
private String idAttributeNS = null;
private String targetNamespaceIn = null;
/** <p>Name of our private configuration node (<samp>InoManager</samp> in
* namespace <code>JMManagerFactoryImpl.NAMESPACE_URI</code>)</p>
*/
public static final String CONFIGURATION_NODE_NAME = "InoManager";
/** <p>Name of the database URL node, including the collection name.</p>
*/
public static final String DBURL_NODE_NAME = "DbURL";
/** <p>Name of the User node</p>
*/
public static final String USER_NODE_NAME = "User";
/** <p>Name of the Password node</p>
*/
public static final String PASSWORD_NODE_NAME = "Password";
/** <p>Name of the attribute Id mapping. By default
* no mapping is used.</p>
*/
public static final String ID_ATTRIBUTE = "Id-Attribute";
/** <p>The namespace for the mapped attribute. By default
* no mapping is used.</p>
*/
public static final String ID_ATTRIBUTE_NS = "Id-Attribute-NS";
/** <p>The namespace to use for incomming documents from tamino db.
* By default no namespace is used.</p>
*/
public static final String TARGETNAMESPACE_IN = "TargetNamespace-IN";
/** <p>Returns the element ID. The default implementation
* returns
* <code>getAttribute(InoResponseHandler.INO_RESPONSE2_URI, "id")</code>.
* If you use another element as the ID, change this.</p>
*/
protected String getElementId(JMAnyElement pElement) throws SAXException {
if(idAttribute != null) {
String id = pElement.getAttribute(idAttributeNS, idAttribute, null);
pElement.removeAttribute(idAttributeNS, idAttribute);
return id;
} else
return pElement.getAttribute(InoResponseHandlerNoNs.INO_RESPONSE2_URI, "id", null);
}
/** <p>After an insert, sets the elements ID. The default
* implementation performs
* <code>setAttribute(InoResponseHandler.INO_RESPONSE2_URI, "id", pId)</code>.
* If you use another element as the ID, change this. You probably need
* to read the inserted document by using the supplied ino:id.</p>
*/
protected void setElementId(JMAnyElement pElement, String pId) throws SAXException {
pElement.setAttribute(InoResponseHandlerNoNs.INO_RESPONSE2_URI, "id", pId, null);
if(idAttribute != null) {
pElement.setAttribute(idAttributeNS, idAttribute, pId, null);
}
}
/** <p>Returns a query suited for deleting the element.</p>
*/
protected String getDeleteQuery(JMAnyElement pElement) throws SAXException {
String id = getElementId(pElement);
if (id == null || id.length() == 0) {
throw new SAXException("The element being deleted doesn't have an ID.");
}
return "_delete=" +
URLEncoder.encode(pElement.getLocalName() + "[@ino:id=" + id + "]");
}
/** <p>Returns a query suited for updating the element.</p>
*/
protected String getUpdateQuery(JMAnyElement pElement) throws SAXException {
String id = getElementId(pElement);
if (id == null || id.length() == 0) {
throw new SAXException("The element being updated doesn't have an ID.");
}
return "_process=" + URLEncoder.encode(pElement.toXMLNoNS());
}
/** <p>Returns a query suited for inserting the element.</p>
*/
protected String getInsertQuery(JMAnyElement pElement) throws SAXException {
String id = getElementId(pElement);
if (id != null && id.length() > 0) {
throw new SAXException("The element being inserted already has an ID.");
}
return "_process=" + URLEncoder.encode(pElement.toXMLNoNS());
}
/** <p>Parses a configuration element. This method is called twice:
* Once for the default configuration and once for the specific
* configuration.</p>
*/
public void parseConfiguration(Element pElement) {
super.parseConfiguration(pElement);
for (Node node = pElement.getFirstChild();
node != null;
node = node.getNextSibling()) {
if (node.getNodeType() == Node.ELEMENT_NODE &&
JMManagerFactoryImpl.NAMESPACE_URI.equals(node.getNamespaceURI())) {
if (CONFIGURATION_NODE_NAME.equals(node.getLocalName())) {
for (Node child = node.getFirstChild();
child != null;
child = child.getNextSibling()) {
if (child.getNodeType() == Node.ELEMENT_NODE &&
JMManagerFactoryImpl.NAMESPACE_URI.equals(child.getNamespaceURI())) {
if (DBURL_NODE_NAME.equals(child.getLocalName())) {
String url = JMManagerFactoryImpl.getNodeText(child);
try {
dbURL = new java.net.URL(url);
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Invalid database URL: " + url);
}
} else if (USER_NODE_NAME.equals(child.getLocalName())) {
user = JMManagerFactoryImpl.getNodeText(child);
} else if (PASSWORD_NODE_NAME.equals(child.getLocalName())) {
password = JMManagerFactoryImpl.getNodeText(child);
} else if (ID_ATTRIBUTE.equals(child.getLocalName())) {
idAttribute = JMManagerFactoryImpl.getNodeText(child);
} else if (ID_ATTRIBUTE_NS.equals(child.getLocalName())) {
idAttributeNS = JMManagerFactoryImpl.getNodeText(child);
} else if (TARGETNAMESPACE_IN.equals(child.getLocalName())) {
targetNamespaceIn = JMManagerFactoryImpl.getNodeText(child);
}
}
}
if(idAttribute != null && idAttributeNS == null)
idAttributeNS = "";
}
}
}
}
/** Creates a new instance of InoManager */
public InoManagerNoNs() {
spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(false);
}
/** <p>Deletes the given document from the database.</p>
*/
public void delete(JMAnyElement pElement) throws SAXException {
String query = getDeleteQuery(pElement);
performQuery(query, (List) null);
}
/** <p>Inserts the given document into the database.</p>
*/
public void insert(JMAnyElement pElement) throws SAXException {
String query = getInsertQuery(pElement);
List idList = new ArrayList();
InoResponseHandlerNoNs irh = performQuery(query, idList);
if (idList.size() == 0) {
throw new SAXException("Query did not return an ino:id");
}
setElementId(pElement, (String) idList.get(0));
}
/** <p>Updates the given document in the database.</p>
*/
public void update(JMAnyElement pElement) throws SAXException {
String query = getUpdateQuery(pElement);
performQuery(query, (List) null);
}
/** <p>Defines the given schema in the database.</p>
*/
public void define(String pSchema) throws SAXException {
String query = "_define=" + URLEncoder.encode(pSchema);
performQuery(query, (java.util.List) null);
}
/** <p>Performs a single database query.</p>
*/
protected HttpURLConnection getResponse(String pQuery) throws SAXException {
URL connectionURL = dbURL;
try {
if (useGet) {
String dburl = connectionURL.toString();
String url;
if (dburl.indexOf('?') > 0) {
url = dburl + "&" + pQuery;
} else {
url = dburl + "?" + pQuery;
}
try {
connectionURL = new URL(url);
HttpURLConnection conn = (HttpURLConnection) connectionURL.openConnection();
conn.setDoOutput(false);
conn.setDoInput(true);
return conn;
} catch (MalformedURLException e) {
throw new SAXException("Malformed database URL: " + url);
}
} else {
HttpURLConnection conn = (HttpURLConnection) connectionURL.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
OutputStream ostream = conn.getOutputStream();
Writer w = new OutputStreamWriter(ostream);
w.write(pQuery);
w.close();
return conn;
}
} catch (IOException e) {
throw new SAXException("I/O Error: " + e.getMessage(), e);
}
}
/** <p>Performs a single database query.</p>
*/
protected InoResponseHandlerNoNs performQuery(String pQuery, java.util.List pList)
throws SAXException {
InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
if (pList != null) {
irh.setInoObjectIdList(pList);
}
performQuery(pQuery, irh);
return irh;
}
/** <p>Parses a single INO response document.</p>
*/
protected void performQuery(String pQuery, InoResponseHandlerNoNs pHandler)
throws SAXException {
if(idAttribute != null)
pHandler.setAttributeMappingId(idAttribute, idAttributeNS);
if(targetNamespaceIn != null)
pHandler.setTargetNamespace(targetNamespaceIn);
HttpURLConnection conn = getResponse(pQuery);
try {
InputSource isource = new InputSource(conn.getInputStream());
isource.setEncoding(conn.getContentEncoding());
XMLReader xr;
SAXParser sp = spf.newSAXParser();
xr = sp.getXMLReader();
xr.setContentHandler(pHandler);
xr.parse(isource);
} catch (ParserConfigurationException e) {
throw new SAXException("ParserConfigurationException: " + e.getMessage(), e);
} catch (IOException e) {
throw new SAXException("I/O Exception: " + e.getMessage(), e);
}
}
/** <p>Reads documents matching the given query. For any document
* matching, the Observer's notify method is executed with the
* matching document as an argument.</p>
* <p>The query may contain placeholders. If it does, you have
* to supply an object array with two elements per placeholder:
* An Integer with a java.sql.Types type and the actual placeholder
* value. Example:
* <pre>
* manager.select("Name = ? and Id = ?",
* new Object[]{JMManager.VARCHAR,
* "Someone",
* JMManager.INTEGER,
* 4}, 0, 0);
* </pre></p>
*
* @param pObserver This Observer is notified for any matching document.
* The document is added as an argument.
* @param pQuery The query to perform. May contain placeholders.
* @param pPlaceHolderArgs An array of objects or null, if the
* query doesn't contain any placeholders.
* @param pStart Ignore the given number of result documents at the
* beginning. A value of zero will return all documents.
* @param pMax Return at most the given number of documents. A value
* of zero will return all documents.
*/
public void select(Observer pObserver, String pQuery, Object[] pPlaceHolderArgs, int pStart, int pMax) throws SAXException {
if (pPlaceHolderArgs != null && pPlaceHolderArgs.length > 0) {
throw new SAXException("Placeholders are not yet supported");
}
String q;
if (pStart != 0 || pMax != 0) {
q = "_xql(" + (pStart+1) + "," + pMax + ")=";
} else {
q = "_xql=";
}
q += URLEncoder.encode(pQuery);
InoResponseHandlerNoNs irh = new InoResponseHandlerNoNs();
JMContentHandler ch = getJMContentHandler();
ch.setObserver(pObserver);
irh.setResultHandler(ch);
performQuery(q, irh);
}
/**
* @return
*/
public URL getDbURL() {
return dbURL;
}
/**
* @param url
*/
public void setDbURL(URL url) {
dbURL = url;
}
}
|
|
From: <th...@us...> - 2004-01-06 10:25:01
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme
In directory sc8-pr-cvs1:/tmp/cvs-serv20967/src/runtime/de/ispsoft/jaxme
Modified Files:
XMLSerializer.java
Added Files:
XMLSerializerNoNS.java
Log Message:
handling of writing and receiving documents without namespace and map them into namespace aware docs
(tamino workaround)
--- NEW FILE: XMLSerializerNoNS.java ---
package de.ispsoft.jaxme;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
import java.util.Map;
import org.apache.log4j.Category;
/** <p>A simple serializer for XML documents. This serializer
* overrides the common XMLSerializer to prevent the output of namespaces.
* All namespaces are cut of.</p>
*
* @author <a href="mailto:jo...@is...">Jochen Wiedmann</a>
* @author <a href="mailto:Bur...@gm...">Burkhard Vogel</a>
* @author <a href="mailto:hae...@gm...">Thomas Haenel</a>
*/
public class XMLSerializerNoNS extends XMLSerializer {
private static final Category cat = Category.getInstance(XMLSerializerNoNS.class.getName());
/** Creates a new XmlSerializer */
public XMLSerializerNoNS() {
super();
}
/** Creates a new XMLSerializer using the given Writer.
*
* @param pWriter A Writer for which setWriter is being called.
* @see #setWriter
*/
public XMLSerializerNoNS(Writer pWriter) {
super(pWriter);
}
/** Creates a new XMLSerializer using the given Writer and
* indentation.
*
* @param pWriter A Writer for which setWriter is being called.
* @param pIndent The indent level to use for elements.
*/
public XMLSerializerNoNS(Writer pWriter, int pIndent) {
super(pWriter, pIndent);
}
/** <p>Terminates an element.</p>
*
* @param namespaceURI The namespace URI, if any, or null
* @param localName The local name, without prefix, or null
* @param qName The qualified name, including a prefix, or null
* @throws SAXException Thrown in case of an IOException.
*/
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException {
if (baseIndent != 0) curIndent -= baseIndent;
if (w != null) {
try {
if (state == STATE_IN_START_ELEMENT) {
w.write("/>");
state = STATE_OUTSIDE;
} else {
if (state == STATE_OUTSIDE) {
indentMe();
}
w.write("</");
w.write(localName);
w.write('>');
}
state = STATE_OUTSIDE;
} catch (java.io.IOException e) {
throw new SAXException(e);
}
}
}
/** Starts a new element.
*
* @param namespaceURI The namespace URI, if any, or null
* @param localName The local name, without prefix, or null
* @param qName The qualified name, including a prefix, or null
* @param attr The element attributes
* @throws SAXException Thrown in case of an IOException.
*/
public void startElement(String namespaceURI, String localName,
String qName, Attributes attr) throws SAXException {
cat.debug("startElement ->");
cat.debug("namespaceURI: " + namespaceURI);
cat.debug("localName: " + localName);
cat.debug("qName: " + qName);
try {
stopTerminator();
if (curIndent > 0) {
indentMe();
}
curIndent += baseIndent;
if (w != null) {
w.write('<');
w.write(localName);
if (attr != null) {
for (int i = attr.getLength(); i > 0;) {
w.write(' ');
String name = attr.getQName(--i);
cat.debug("name: " + name);
if (delayedPrefixes != null) {
delayedPrefixes.remove(name);
}
if(name != null && name.startsWith("xmlns")) {
continue;
} else {
w.write(name);
w.write("=\"");
writeCData(attr.getValue(i));
w.write('"');
}
}
}
if (delayedPrefixes != null && delayedPrefixes.size() > 0) {
for (Iterator iter = delayedPrefixes.entrySet().iterator();
iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
if(entry.getKey().toString().startsWith("xmlns")) {
continue;
} else {
w.write(' ');
w.write((String) entry.getKey());
w.write("=\"");
w.write((String) entry.getValue());
w.write('"');
}
}
delayedPrefixes.clear();
}
}
state = STATE_IN_START_ELEMENT;
} catch (IOException e) {
throw new SAXException(e);
}
}
}
Index: XMLSerializer.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/XMLSerializer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- XMLSerializer.java 8 Oct 2003 10:58:41 -0000 1.5
+++ XMLSerializer.java 6 Jan 2004 10:24:58 -0000 1.6
@@ -12,19 +12,19 @@
* @author <a href="mailto:Bur...@gm...">Burkhard Vogel</a>
*/
public class XMLSerializer implements org.xml.sax.ContentHandler {
- private int baseIndent;
- private int curIndent;
- private String lineFeed;
- private Writer w;
- private Locator l;
- private java.util.Map delayedPrefixes;
+ protected int baseIndent;
+ protected int curIndent;
+ protected String lineFeed;
+ protected Writer w;
+ protected Locator l;
+ protected java.util.Map delayedPrefixes;
- private static final int STATE_OUTSIDE = 0;
- private static final int STATE_IN_START_ELEMENT = 1;
- private static final int STATE_IN_ELEMENT = 2;
- private int state;
+ protected static final int STATE_OUTSIDE = 0;
+ protected static final int STATE_IN_START_ELEMENT = 1;
+ protected static final int STATE_IN_ELEMENT = 2;
+ protected int state;
- private static final String BLANKS_64;
+ protected static final String BLANKS_64;
static {
StringBuffer s = new StringBuffer();
for (int i = 0; i < 64; i++) {
@@ -220,7 +220,7 @@
characters(ch, start, length);
}
- private void stopTerminator() throws java.io.IOException {
+ protected void stopTerminator() throws java.io.IOException {
if (state == STATE_IN_START_ELEMENT) {
if (w != null) {
w.write('>');
@@ -297,7 +297,7 @@
}
}
- private void indentMe() throws java.io.IOException {
+ protected void indentMe() throws java.io.IOException {
if (w != null) {
if (lineFeed != null) {
w.write(lineFeed);
@@ -312,7 +312,7 @@
}
}
- private void writeCData(String v) throws java.io.IOException {
+ protected void writeCData(String v) throws java.io.IOException {
int len = v.length();
for (int j = 0; j < len; j++) {
char c = v.charAt(j);
@@ -419,7 +419,7 @@
}
}
- private int emptyElementStyle = EMPTY_ELEMENT_STYLE_XML;
+ protected int emptyElementStyle = EMPTY_ELEMENT_STYLE_XML;
/** <p>Returns how empty elements will be serialized.</p>
*
* @see #setEmptyElementStyle
|
|
From: <th...@us...> - 2004-01-06 10:09:16
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme
In directory sc8-pr-cvs1:/tmp/cvs-serv18280/src/runtime/de/ispsoft/jaxme
Modified Files:
JMAnyElement.java
Log Message:
added toXMLNoNS method to write XML without namespaces
Index: JMAnyElement.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/JMAnyElement.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- JMAnyElement.java 8 Oct 2003 10:57:01 -0000 1.9
+++ JMAnyElement.java 6 Jan 2004 10:09:11 -0000 1.10
@@ -1,13 +1,24 @@
package de.ispsoft.jaxme;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import de.ispsoft.jaxme.jaxb.MarshallerImpl;
import de.ispsoft.jaxme.jaxb.UnmarshallerImpl;
+import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
/** <p>An implementation for an abstract element. This is
@@ -16,7 +27,8 @@
* @author <a href="mailto:jo...@is...">Jochen Wiedmann</a>
*/
public class JMAnyElement implements java.io.Serializable, Cloneable, JMNode {
- protected static final org.xml.sax.Attributes emptyAttributes = new org.xml.sax.helpers.AttributesImpl();
+
+ protected static final Attributes emptyAttributes = new AttributesImpl();
private static MarshallerImpl invisibleMarshaller = new MarshallerImpl();
private static UnmarshallerImpl invisibleUnmarshaller = new UnmarshallerImpl();
@@ -25,8 +37,7 @@
protected String namespaceURI;
List attributes;
List childs;
- private static java.text.DateFormat defaultDateFormat =
- new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
+ private static DateFormat defaultDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
/** Creates a new JMAnyElement with the given namespace URI
* and local name.
@@ -82,8 +93,7 @@
* actual values
*/
public void setAttribute(String pNamespaceURI, String pLocalName, String pValue,
- UnmarshallerImpl pUnmarshaller)
- throws SAXException {
+ UnmarshallerImpl pUnmarshaller) throws SAXException {
if (attributes != null) {
int s = attributes.size();
for (int i = 0; i < s; i++) {
@@ -152,12 +162,15 @@
public Object getElement(String pNamespaceURI, String pLocalName) {
String uri = (pNamespaceURI == null) ? "" : pNamespaceURI;
List myChilds = getChilds();
- for (java.util.Iterator iter = myChilds.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ Object o = null;
+ JMAnyElement elem = null;
+ String elemUri = null;
+ for (Iterator iter = myChilds.iterator(); iter.hasNext();) {
+ o = iter.next();
if (o instanceof JMAnyElement) {
- JMAnyElement elem = (JMAnyElement) o;
+ elem = (JMAnyElement) o;
if (pLocalName.equals(elem.getLocalName())) {
- String elemUri = elem.getNamespaceURI();
+ elemUri = elem.getNamespaceURI();
if (elemUri == null) {
elemUri = "";
}
@@ -181,7 +194,7 @@
*/
public void addChild(Object pChild) {
if (childs == null) {
- childs = new java.util.ArrayList();
+ childs = new ArrayList();
}
childs.add(pChild);
}
@@ -201,7 +214,7 @@
* If you wish to define your own prefixes, use the two
* arguments form of this method.</p>
*/
- public void toSAX(org.xml.sax.ContentHandler contentHandler)
+ public void toSAX(ContentHandler contentHandler)
throws SAXException {
toSAX(contentHandler, null);
}
@@ -219,9 +232,8 @@
* for prefixes; may be null, in which case default mappings
* are established.
*/
- public void toSAX(org.xml.sax.ContentHandler pContentHandler,
- NamespaceSupport pNamespaceSupport)
- throws SAXException {
+ public void toSAX(ContentHandler pContentHandler, NamespaceSupport pNamespaceSupport)
+ throws SAXException {
toSAX(pContentHandler, pNamespaceSupport, false);
}
@@ -240,10 +252,8 @@
* @param pNamespaceInitialized True, if <code>initNamespaceSupport()</code>
* has been called.
*/
- public void toSAX(org.xml.sax.ContentHandler pContentHandler,
- NamespaceSupport pNamespaceSupport,
- boolean pNamespaceInitialized)
- throws SAXException {
+ public void toSAX(ContentHandler pContentHandler, NamespaceSupport pNamespaceSupport,
+ boolean pNamespaceInitialized) throws SAXException {
if (pNamespaceSupport == null) {
pNamespaceSupport = new NamespaceSupport();
pNamespaceSupport.setMarshaller(invisibleMarshaller);
@@ -273,11 +283,9 @@
/** <p>Returns the elements attribute list suitable for a
* SAX ContentHandler.</p>
*/
- public org.xml.sax.helpers.AttributesImpl
- getAttributes(org.xml.sax.ContentHandler pContentHandler,
- NamespaceSupport pNamespaceSupport)
- throws org.xml.sax.SAXException {
- org.xml.sax.helpers.AttributesImpl attr = new org.xml.sax.helpers.AttributesImpl();
+ public AttributesImpl getAttributes(ContentHandler pContentHandler,
+ NamespaceSupport pNamespaceSupport) throws SAXException {
+ AttributesImpl attr = new AttributesImpl();
if (attributes != null) {
int s = attributes.size();
for (int i = 0; i < s; i++) {
@@ -318,12 +326,12 @@
* URL, then a default mapping is established.</p>
*/
protected void childsToSAX(ContentHandler pContentHandler,
- NamespaceSupport pNamespaceSupport)
- throws SAXException {
+ NamespaceSupport pNamespaceSupport) throws SAXException {
if (childs != null) {
int s = childs.size();
+ Object o = null;
for (int i = 0; i < s; i++) {
- Object o = childs.get(i);
+ o = childs.get(i);
if (o instanceof String) {
char[] chars = o.toString().toCharArray();
pContentHandler.characters(chars, 0, chars.length);
@@ -349,16 +357,17 @@
JMAnyElement jmae = (JMAnyElement) super.clone();
if (attributes != null) {
int s = attributes.size();
- jmae.attributes = new java.util.ArrayList(s);
+ jmae.attributes = new ArrayList(s);
for (int i = 0; i < s; i++) {
jmae.attributes.add(((JMAttribute) attributes.get(i)).clone());
}
}
if (childs != null) {
int s = childs.size();
- jmae.childs = new java.util.ArrayList(s);
+ jmae.childs = new ArrayList(s);
+ Object o = null;
for (int i = 0; i < s; i++) {
- Object o = childs.get(i);
+ o = childs.get(i);
if (o instanceof String) {
jmae.childs.add(o.toString());
} else {
@@ -382,22 +391,21 @@
* If you want to use your own mappings, create a NamespaceSupport
* and use the two arguments version of this method.</p>
*/
- public void toWriter(java.io.Writer pWriter)
- throws org.xml.sax.SAXException, java.io.IOException {
+ public void toWriter(Writer pWriter) throws SAXException, IOException {
toWriter(pWriter, null);
}
/** <p>Serializes the element into the given writer. The given
* NamespaceSupport is used to create prefix mappings.</p>
*/
- public void toWriter(java.io.Writer pWriter, NamespaceSupport pNamespaceSupport)
- throws org.xml.sax.SAXException, java.io.IOException {
+ public void toWriter(Writer pWriter, NamespaceSupport pNamespaceSupport)
+ throws SAXException, IOException {
try {
- toSAX(new de.ispsoft.jaxme.XMLSerializer(pWriter), pNamespaceSupport, false);
- } catch (org.xml.sax.SAXException e) {
+ toSAX(new XMLSerializer(pWriter), pNamespaceSupport, false);
+ } catch (SAXException e) {
Exception f = e.getException();
- if (f != null && f instanceof java.io.IOException) {
- throw (java.io.IOException) f;
+ if (f != null && f instanceof IOException) {
+ throw (IOException) f;
}
throw e;
}
@@ -420,16 +428,46 @@
*/
public String toXML(NamespaceSupport pNamespaceSupport) {
try {
- java.io.StringWriter sw = new java.io.StringWriter();
+ StringWriter sw = new StringWriter();
toWriter(sw, pNamespaceSupport);
return sw.toString();
- } catch (org.xml.sax.SAXException e) {
+ } catch (SAXException e) {
throw new NullPointerException("Unexpected SAX exception: " + e.getMessage());
- } catch (java.io.IOException e) {
+ } catch (IOException e) {
throw new NullPointerException("Unexpected IO exception: " + e.getMessage());
}
}
+ /** <p>Serializes the element <b>WITHOUT NAMESPACES</b> into the given writer.</p>
+ */
+ public String toXMLNoNS() {
+ try {
+ StringWriter sw = new StringWriter();
+ toWriterNoNS(sw, null);
+ return sw.toString();
+ } catch (SAXException e) {
+ throw new NullPointerException("Unexpected SAX exception: " + e.getMessage());
+ } catch (IOException e) {
+ throw new NullPointerException("Unexpected IO exception: " + e.getMessage());
+ }
+ }
+
+ /** <p>Serializes the element <b>WITHOUT NAMESPACES</b> into the given writer.
+ * Therefore the XMLSerializerNoNS is used.</p>
+ */
+ public void toWriterNoNS(Writer pWriter, NamespaceSupport pNamespaceSupport)
+ throws SAXException, IOException {
+ try {
+ toSAX(new XMLSerializerNoNS(pWriter), pNamespaceSupport, false);
+ } catch (SAXException e) {
+ Exception f = e.getException();
+ if (f != null && f instanceof IOException) {
+ throw (IOException) f;
+ }
+ throw e;
+ }
+ }
+
/** <p>Validates this elements contents. Doesn't work recursively.</p>
*
* @param pContext A possible context to use in error messages or null
@@ -437,7 +475,7 @@
* @throws ValidationException The element is invalid; details are
* specified in the error message
*/
- protected void validateMe(String pContext, org.xml.sax.Locator pLocator)
+ protected void validateMe(String pContext, Locator pLocator)
throws ValidationException {
}
@@ -465,12 +503,12 @@
* its property jaxme.format.datetime to achieve the same
* functionality.
*/
- public static java.util.Date parseDate(String pDate) {
+ public static Date parseDate(String pDate) {
try {
synchronized (defaultDateFormat) {
return defaultDateFormat.parse(pDate);
}
- } catch (java.text.ParseException e) {
+ } catch (ParseException e) {
throw new IllegalArgumentException("Invalid date string: " + pDate);
}
}
@@ -479,7 +517,7 @@
* its property jaxme.format.datetime to achieve the same
* functionality.
*/
- public static String formatDate(java.util.Date pDate) {
+ public static String formatDate(Date pDate) {
synchronized (defaultDateFormat) {
return defaultDateFormat.format(pDate);
}
|
|
From: <th...@us...> - 2004-01-06 10:08:11
|
Update of /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/javaclasswriter
In directory sc8-pr-cvs1:/tmp/cvs-serv18104/src/generator/de/ispsoft/jaxme/generator/javaclasswriter
Modified Files:
BasicJavaClassWriter.java
Log Message:
bug fixed
Index: BasicJavaClassWriter.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/javaclasswriter/BasicJavaClassWriter.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- BasicJavaClassWriter.java 8 Dec 2003 09:52:47 -0000 1.29
+++ BasicJavaClassWriter.java 6 Jan 2004 10:08:08 -0000 1.30
@@ -380,6 +380,7 @@
if (!(attr.getSchemaType() instanceof StringType) &&
attr.getRestrictions().getErrorCode() != null) {
jmSet.addLine(" try {");
+ jmSet.addLine(" " + attr.getAssignmentTo(sst.castFromString("pValue", "pUnmarshaller")));
jmSet.addLine(" } catch(Exception e) {");
jmSet.addLine(" " + ValidationException.class.getName()
+ " ve = new " + ValidationException.class.getName()
|
|
From: <th...@us...> - 2004-01-06 10:06:58
|
Update of /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/beanwriter In directory sc8-pr-cvs1:/tmp/cvs-serv17877/src/generator/de/ispsoft/jaxme/generator/beanwriter Modified Files: EntityBeanClassWriter.java Log Message: special handling of transaction exceptions needed Index: EntityBeanClassWriter.java =================================================================== RCS file: /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/beanwriter/EntityBeanClassWriter.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- EntityBeanClassWriter.java 8 Jul 2003 21:01:56 -0000 1.12 +++ EntityBeanClassWriter.java 6 Jan 2004 10:06:55 -0000 1.13 @@ -1,1109 +1,1022 @@ +// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. +// Jad home page: http://www.geocities.com/kpdus/jad.html +// Decompiler options: packimports(3) +// Source File Name: EntityBeanClassWriter.java + package de.ispsoft.jaxme.generator.beanwriter; -import de.ispsoft.jaxme.JMFactory; -import de.ispsoft.jaxme.generator.BeanWriter; -import de.ispsoft.jaxme.generator.SchemaException; -import de.ispsoft.jaxme.generator.JavaSourceWriter; [...1977 lines suppressed...] + { + jm.addLine(" Exception ex=e.getException();"); + jm.addLine(" if(ex instanceof com.ibm.websphere.ce.cm.StaleConnectionException)"); + jm.addLine(" throw new EJBException(ex);"); + } + jm.addLine(" throw new FinderException(e.getClass().getName() + \": \" + e.getMessage());"); + jm.addLine("}"); + return jm; } - jm.addLine("} catch (SAXException e) {"); - jm.addLine(" throw new FinderException(e.getClass().getName() + \": \" + e.getMessage());"); - jm.addLine("}"); - return jm; - } + + protected SchemaComplexElement element; + protected static Attributes emptyAttributes = new AttributesImpl(); + protected static SourceWriterImpl sourceWriter; + } |
|
From: <th...@us...> - 2004-01-06 10:06:00
|
Update of /cvsroot/jaxme/JaxMe/src/examples/de/ispsoft/jaxme/junit
In directory sc8-pr-cvs1:/tmp/cvs-serv17703/src/examples/de/ispsoft/jaxme/junit
Modified Files:
JMAnyElementTest.java
Log Message:
changes needed because of the fixed observer handling
Index: JMAnyElementTest.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/examples/de/ispsoft/jaxme/junit/JMAnyElementTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- JMAnyElementTest.java 22 Jul 2002 17:03:47 -0000 1.2
+++ JMAnyElementTest.java 6 Jan 2004 10:05:52 -0000 1.3
@@ -80,7 +80,7 @@
/** Notifies the observer that an event happened on the notified object.
*/
public void notify(Object o) {
- Object obj = ((de.ispsoft.jaxme.JMContentHandler) o).getResultNode();
+ Object obj = o;
element = (de.ispsoft.jaxme.JMAnyElement) obj;
}
|
|
From: <th...@us...> - 2003-12-17 08:52:29
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino
In directory sc8-pr-cvs1:/tmp/cvs-serv29014/src/runtime/de/ispsoft/jaxme/tamino
Modified Files:
InoManager.java
Log Message:
terrible nullpointer target in line 276 removed ;-)
Index: InoManager.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/tamino/InoManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- InoManager.java 25 Jun 2002 20:59:21 -0000 1.2
+++ InoManager.java 17 Dec 2003 08:52:26 -0000 1.3
@@ -273,7 +273,7 @@
* of zero will return all documents.
*/
public void select(Observer pObserver, String pQuery, Object[] pPlaceHolderArgs, int pStart, int pMax) throws SAXException {
- if (pPlaceHolderArgs != null || pPlaceHolderArgs.length > 0) {
+ if (pPlaceHolderArgs != null && pPlaceHolderArgs.length > 0) {
throw new SAXException("Placeholders are not yet supported");
}
String q;
|
|
From: <th...@us...> - 2003-12-08 10:03:32
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme
In directory sc8-pr-cvs1:/tmp/cvs-serv2997/src/runtime/de/ispsoft/jaxme
Modified Files:
JMJdbcManager.java
Log Message:
added some import statements and some debug output for time
consumtion of sql statements
Index: JMJdbcManager.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/JMJdbcManager.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- JMJdbcManager.java 11 Nov 2003 12:43:45 -0000 1.10
+++ JMJdbcManager.java 8 Dec 2003 10:03:29 -0000 1.11
@@ -4,9 +4,15 @@
import java.io.CharArrayReader;
import java.io.StringReader;
import java.sql.Connection;
+import java.sql.DriverManager;
import java.sql.PreparedStatement;
+import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Timestamp;
import java.sql.Types;
+import java.util.Date;
+
+import org.apache.log4j.Category;
import org.xml.sax.SAXException;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
@@ -18,6 +24,9 @@
* @author <a href="mailto:jo...@is...">Jochen Wiedmann</a>
*/
public abstract class JMJdbcManager extends JMManagerImpl {
+
+ protected Category cat = Category.getInstance(JMJdbcManager.class.getName());
+
/** <p>Name of our private configuration node (<samp>JMJdbcManager</samp> in
* namespace <code>JMManagerFactoryImpl.NAMESPACE_URI</code>)</p>
*/
@@ -108,11 +117,11 @@
try {
Class.forName(driver);
// Verify the connection
- java.sql.Connection conn = getConnection();
+ Connection conn = getConnection();
conn.close();
} catch (ClassNotFoundException e) {
throw new SAXException("Class " + driver + " could not be loaded", e);
- } catch (java.sql.SQLException e) {
+ } catch (SQLException e) {
throw new SAXException("Could not verify the JDBC connection " + url, e);
}
}
@@ -120,12 +129,12 @@
/** <p>Returns an open JDBC connection</p>
*/
- public java.sql.Connection getConnection()
- throws java.sql.SQLException, org.xml.sax.SAXException {
+ public Connection getConnection()
+ throws SQLException, SAXException {
if (user != null && user.length() > 0) {
- return java.sql.DriverManager.getConnection(url, user, password);
+ return DriverManager.getConnection(url, user, password);
} else {
- return java.sql.DriverManager.getConnection(url);
+ return DriverManager.getConnection(url);
}
}
@@ -135,14 +144,19 @@
pConn.close();
}
- protected void executeQueries(java.sql.Connection pConn,
- java.sql.PreparedStatement[] pStmt)
- throws java.sql.SQLException {
+ protected void executeQueries(Connection pConn, PreparedStatement[] pStmt)
+ throws SQLException {
for (int i = 0; i < pStmt.length; i++) {
- java.sql.PreparedStatement stmt = pStmt[i];
+ Date start = new Date();
+ PreparedStatement stmt = pStmt[i];
stmt.executeUpdate();
pStmt[i] = null;
stmt.close();
+ if(cat.isDebugEnabled()){
+ Date end = new Date();
+ cat.debug("Statement succesfully executed (took "+
+ (end.getTime()-start.getTime())+" ms)");
+ }
}
}
@@ -172,9 +186,8 @@
/** <p>Creates a new primary key for the element. Does nothing,
* to be overwritten by subclasses.</p>
*/
- protected void newPrimaryKey(java.sql.Connection pConn,
- JMAnyElement pElement)
- throws java.sql.SQLException {
+ protected void newPrimaryKey(Connection pConn, JMAnyElement pElement)
+ throws SQLException {
}
/** <p>Calls <code>newPrimaryKey()</code> and inserts the given
@@ -189,8 +202,8 @@
private static final int CRUD_DELETE = 2;
private void crud(JMAnyElement pElement, int pOp) throws SAXException {
int createPrimaryKey = CREATE_KEY_DONT;
- java.sql.Connection conn = null;
- java.sql.PreparedStatement[] stmts = null;
+ Connection conn = null;
+ PreparedStatement[] stmts = null;
try {
conn = getConnection();
switch (pOp) {
@@ -215,17 +228,17 @@
if (createPrimaryKey == CREATE_KEY_POST_INSERT) {
newPrimaryKey(conn, pElement);
}
- java.sql.Connection myconn = conn;
+ Connection myconn = conn;
conn = null;
releaseConnection(myconn);
- } catch (java.sql.SQLException e) {
+ } catch (SQLException e) {
throw new SAXException("SQL Exception: Error code = " + e.getErrorCode() +
", error state = " + e.getSQLState() +
", error message = " + e.getMessage(), e);
} finally {
if (stmts != null) {
for (int i = 0; i < stmts.length; i++) {
- java.sql.PreparedStatement pstmt = stmts[i];
+ PreparedStatement pstmt = stmts[i];
if (pstmt != null) {
try { pstmt.close(); } catch (Exception e) {}
}
@@ -276,9 +289,10 @@
Object[] pPlaceHolderArgs,
int pStart, int pMax) throws SAXException {
String query = getQuery(pQuery);
- java.sql.Connection conn = null;
- java.sql.PreparedStatement stmt = null;
- java.sql.ResultSet rs = null;
+ Connection conn = null;
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ Date start = new Date();
try {
conn = getConnection();
stmt = getPreparedStatement(conn, query, pPlaceHolderArgs);
@@ -288,16 +302,21 @@
init(rs, element);
pObserver.notify(element);
}
- java.sql.ResultSet myrs = rs;
+ ResultSet myrs = rs;
rs = null;
myrs.close();
- java.sql.PreparedStatement mystmt = stmt;
+ PreparedStatement mystmt = stmt;
stmt = null;
mystmt.close();
- java.sql.Connection myconn = conn;
+ Connection myconn = conn;
conn = null;
releaseConnection(myconn);
- } catch (java.sql.SQLException e) {
+ if(cat.isInfoEnabled()){
+ Date end = new Date();
+ cat.debug("Statement succesfully executed (DURATION="+
+ (end.getTime()-start.getTime())+"ms)");
+ }
+ } catch (SQLException e) {
throw new SAXException("Failed to perform query " + query, e);
} finally {
if (rs != null) { try { rs.close(); } catch (Exception e) {} }
@@ -345,8 +364,8 @@
/** <p>Initializes the element from the resultset. In other words, reads
* one row from the result set.</p>
*/
- protected abstract void init(java.sql.ResultSet rs, JMJdbcElement pElement)
- throws java.sql.SQLException, org.xml.sax.SAXException;
+ protected abstract void init(ResultSet rs, JMJdbcElement pElement)
+ throws SQLException, SAXException;
/** <p>Returns the field list to build an SQL SELECT statement.</p>
*/
@@ -363,27 +382,25 @@
/** <p>Returns an array of prepared statements, that are being
* performed to insert the element into the database.</p>
*/
- protected java.sql.PreparedStatement[] getInsertQueries(java.sql.Connection pConn,
+ protected PreparedStatement[] getInsertQueries(Connection pConn,
JMJdbcElement pElement)
- throws org.xml.sax.SAXException, java.sql.SQLException {
+ throws SAXException, SQLException {
throw new SAXException("Not implemented");
}
/** <p>Returns an array of prepared statements, that are being
* performed to update the element in the database.</p>
*/
- protected java.sql.PreparedStatement[] getUpdateQueries(java.sql.Connection pConn,
- JMJdbcElement pElement)
- throws org.xml.sax.SAXException, java.sql.SQLException {
+ protected PreparedStatement[] getUpdateQueries(Connection pConn,
+ JMJdbcElement pElement) throws SAXException, SQLException {
throw new SAXException("Not implemented");
}
/** <p>Returns an array of prepared statements, that are being
* performed to delete the element in the database.</p>
*/
- protected java.sql.PreparedStatement[] getDeleteQueries(java.sql.Connection pConn,
- JMJdbcElement pElement)
- throws org.xml.sax.SAXException, java.sql.SQLException {
+ protected PreparedStatement[] getDeleteQueries(Connection pConn,
+ JMJdbcElement pElement) throws SAXException, SQLException {
throw new SAXException("Not implemented");
}
@@ -399,9 +416,8 @@
/** <p>Executes the given statement.</p>
*/
- public void executeStatement(String pQuery,
- Object[] pPlaceHolderArgs)
- throws org.xml.sax.SAXException {
+ public void executeStatement(String pQuery, Object[] pPlaceHolderArgs)
+ throws SAXException {
Connection conn = null;
PreparedStatement stmt = null;
try {
@@ -414,8 +430,8 @@
Connection myconn = conn;
conn = null;
releaseConnection(myconn);
- } catch (java.sql.SQLException e) {
- throw new org.xml.sax.SAXException("SQLException: " + e.getMessage(), e);
+ } catch (SQLException e) {
+ throw new SAXException("SQLException: " + e.getMessage(), e);
} finally {
if (stmt != null) { try { stmt.close(); } catch (Exception e) {} }
if (conn != null) { try { releaseConnection(conn); } catch (Exception e) {} }
@@ -425,9 +441,7 @@
/** <p>Prepares the placeholders of the given statement.</p>
*/
protected PreparedStatement getPreparedStatement(Connection pConn,
- String pQuery,
- Object[] pPlaceHolderArgs)
- throws java.sql.SQLException {
+ String pQuery, Object[] pPlaceHolderArgs) throws SQLException {
PreparedStatement stmt = pConn.prepareStatement(pQuery);
if (pPlaceHolderArgs != null) {
int i = 1;
@@ -464,11 +478,11 @@
stmt.setString(i++, (String) o);
break;
case Types.TIMESTAMP:
- if (o instanceof java.sql.Timestamp) {
- stmt.setTimestamp(i++, (java.sql.Timestamp) o);
+ if (o instanceof Timestamp) {
+ stmt.setTimestamp(i++, (Timestamp) o);
} else {
- java.util.Date d = (java.util.Date) o;
- stmt.setTimestamp(i++, new java.sql.Timestamp(d.getTime()));
+ Date d = (Date) o;
+ stmt.setTimestamp(i++, new Timestamp(d.getTime()));
}
break;
case Types.BLOB:
|
|
From: <th...@us...> - 2003-12-08 09:59:06
|
Update of /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator
In directory sc8-pr-cvs1:/tmp/cvs-serv2263/src/generator/de/ispsoft/jaxme/generator
Modified Files:
JavaSourceWriter.java
Log Message:
fixes a bug if a non-jdbc aware element references a jdbc-view-aware
element, the jdbc manager class was not generated
Index: JavaSourceWriter.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/JavaSourceWriter.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- JavaSourceWriter.java 25 Apr 2003 19:57:54 -0000 1.8
+++ JavaSourceWriter.java 8 Dec 2003 09:59:02 -0000 1.9
@@ -1,6 +1,7 @@
package de.ispsoft.jaxme.generator;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
import org.apache.log4j.Category;
@@ -17,6 +18,7 @@
public class JavaSourceWriter extends SourceWriterImpl {
private static final Category cat = Category.getInstance(JavaSourceWriter.class.getName());
private static final Set writtenElements = new HashSet();
+ private static final Set writtenJdbcElements = new HashSet();
/** Creates a new instance of JavaSourceGenerator. */
public JavaSourceWriter() {}
@@ -38,35 +40,38 @@
JavaClassWriter jcw = getJavaClassWriter(pElement);
JavaSource js = jcw.getXmlClass();
+ String qName = null;
if (js != null) {
- String qName = js.getPackage();
+ qName = js.getPackage();
if (qName == null || qName.length() == 0) {
qName = js.getName();
} else {
qName += "." + js.getQName();
}
- if (writtenElements.contains(qName)) {
- return;
+ if (!writtenElements.contains(qName)) {
+ writtenElements.add(qName);
+ writeJavaSourceFile(getDirectory(), js);
+
+ js = jcw.getHandlerClass();
+ if (js != null) {
+ writeJavaSourceFile(getDirectory(), js);
+ }
}
- writtenElements.add(qName);
-
- writeJavaSourceFile(getDirectory(), js);
}
- js = jcw.getHandlerClass();
- if (js != null) {
- writeJavaSourceFile(getDirectory(), js);
- }
-
- js = jcw.getManagerClass();
- if (js != null) {
- writeJavaSourceFile(getDirectory(), js);
- }
+ js = jcw.getManagerClass();
+ if(qName != null && js != null && !writtenJdbcElements.contains(qName)) {
+ writtenJdbcElements.add(qName);
+ if (js != null) {
+ writeJavaSourceFile(getDirectory(), js);
+ }
+ }
- for (java.util.Iterator iter = ((SchemaComplexElement) pElement).getChilds();
+ SchemaElement child = null;
+ for (Iterator iter = ((SchemaComplexElement) pElement).getChilds();
iter.hasNext(); ) {
- SchemaElement child = (SchemaElement) iter.next();
+ child = (SchemaElement) iter.next();
cat.debug("Processing child " + child.getName() + " of " +
pElement.getName());
if (child.isComplex()) {
|
|
From: <th...@us...> - 2003-12-08 09:56:05
|
Update of /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/util
In directory sc8-pr-cvs1:/tmp/cvs-serv1886/src/generator/de/ispsoft/jaxme/generator/util
Added Files:
StringUtil.java
Log Message:
a util class for String handling, first correctly maps strings with backslashes correctly
--- NEW FILE: StringUtil.java ---
/*
* Created on 01.12.2003
*
*/
package de.ispsoft.jaxme.generator.util;
/**
* @author Thomas Haenel, ATC GmbH
* @version $Id: StringUtil.java,v 1.1 2003/12/08 09:56:01 thaenel Exp $
*/
public class StringUtil {
public static String getPrintablePattern(String pattern) {
if(pattern == null || pattern.length() == 0 || pattern.indexOf('\\') < 0)
return pattern;
StringBuffer buf = new StringBuffer("");
char c;
for(int i=0; i<pattern.length(); i++) {
c = pattern.charAt(i);
if(c != '\\')
buf.append(c);
else
buf.append("\\\\");
}
return buf.toString();
}
}
|
|
From: <th...@us...> - 2003-12-08 09:55:04
|
Update of /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/parselets
In directory sc8-pr-cvs1:/tmp/cvs-serv1748/src/generator/de/ispsoft/jaxme/generator/parselets
Modified Files:
ParseletWriter.java
Log Message:
inserted from a patched jaxme project (joe you know what it is)
Index: ParseletWriter.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe/src/generator/de/ispsoft/jaxme/generator/parselets/ParseletWriter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ParseletWriter.java 25 Apr 2003 19:57:50 -0000 1.7
+++ ParseletWriter.java 8 Dec 2003 09:54:57 -0000 1.8
@@ -1,5 +1,9 @@
package de.ispsoft.jaxme.generator.parselets;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
import org.apache.log4j.Category;
import de.ispsoft.jaxme.generator.SchemaAttribute;
import de.ispsoft.jaxme.generator.SchemaComplexElement;
@@ -214,7 +218,49 @@
JavaComment jc = new JavaComment();
jc.addLine("A Parselet for class " + pElement.getQClassName() + ".");
-
+ // inserted from patched (tcnew-)jaxme
+ Iterator iter = pElement.getAttributes();
+ Set parseletNames = new HashSet();
+ while(iter.hasNext()) {
+ Object o = iter.next();
+ SchemaAttribute attr = (SchemaAttribute)o;
+ ParseletDecorator pd2 = (ParseletDecorator) attr.getElementDecorator(pdf);
+
+ if (pd2 == null) {
+ continue;
+ }
+ String newParselet = pd2.getNewParseletForParse();
+ String parseletClass = pd2.getParseletPackageName()+"."+pd2.getParseletClassName();
+ if( !parseletNames.contains(parseletClass) ) {
+ parseletNames.add(parseletClass);
+ JavaField jf = new JavaField("m_"+pd2.getParseletClassName(),
+ parseletClass, "private");
+ jf.setValue(newParselet);
+ jf.setStatic(false);
+ jf.setFinal(false);
+ js.addField(jf);
+ }
+ }
+ for (iter = pElement.getChilds(); iter.hasNext(); ) {
+ SchemaElement child = (SchemaElement) iter.next();
+ ParseletDecorator pd3 = (ParseletDecorator) child.getElementDecorator(pdf);
+ if (pd3 == null) {
+ continue;
+ }
+ String newParselet = pd3.getNewParseletForParse();
+ String parseletClass = pd3.getParseletPackageName()+"."+
+ pd3.getParseletClassName();
+ if(!parseletNames.contains(parseletClass)) {
+ parseletNames.add(parseletClass);
+ JavaField jf = new JavaField("m_"+pd3.getParseletClassName(),
+ parseletClass, "private");
+ jf.setValue(newParselet);
+ jf.setStatic(false);
+ jf.setFinal(false);
+ js.addField(jf);
+ }
+ }
+ // end of insert
JavaConstructor jcon = getDefaultConstructor(js, pElement, pd);
if (jcon != null) {
js.addConstructor(jcon);
|