
org.apache.ws.jaxme.PM Maven / Gradle / Ivy
/*
* Copyright 2003, 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ws.jaxme;
import javax.xml.bind.Element;
import javax.xml.bind.JAXBException;
/** The persistence manager
(or PM
* for short) is responsible for reading objects from the
* database or storing them into the database.
*
* @author Jochen Wiedmann
*/
public interface PM {
/** Initializes the PM. Called from the
* {@link org.apache.ws.jaxme.impl.JAXBContextImpl} upon initialization.
* @param pManager The manager being queried for configuration details.
*/
public void init(JMManager pManager) throws JAXBException;
/** Returns the manager being queried for configuration details.
*/
public JMManager getManager();
/** Reads documents matching the given query. For any document
* matching, the Observer's notify method is executed with the
* matching document as an argument.
*
* @param pObserver This Observer is notified for any matching document.
* The document is added as an argument.
* @param pQuery The query to perform.
*/
public void select(Observer pObserver, String pQuery) throws JAXBException;
/** Reads documents matching the given query. For any document
* matching, the Observer's notify method is executed with the
* matching document as an argument.
* The query may contain placeholders. If it does, you have
* to supply an instance of {@link PMParams} with the placeholder
* values. Example:
*
* manager.select("Name = ? and Id = ?",
* new PMParams().addString("Someone").addInt(4));
*
*
* @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.
*/
public void select(Observer pObserver, String pQuery,
PMParams pPlaceHolderArgs) throws JAXBException;
/** Returns an iterator to all documents matching the given query.
*
* @param pQuery The query to perform.
*/
public java.util.Iterator select(String pQuery) throws JAXBException;
/** Returns an iterator to all documents matching the given query.
* The query may contain placeholders. If it does, you have
* to supply an instance of {@link PMParams} with the placeholder
* values. Example:
*
* manager.select("Name = ? and Id = ?",
* new PMParams().addString("Someone").addInt(4));
*
*
* @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.
*/
public java.util.Iterator select(String pQuery,
PMParams pPlaceHolderArgs)
throws JAXBException;
/** Inserts the given document into the database.
*/
public void insert(Element element) throws JAXBException;
/** Updates the given document in the database.
*/
public void update(Element element) throws JAXBException;
/** Deletes the given document from the database.
*/
public void delete(Element element) throws JAXBException;
/** Creates a new, empty element.
*/
public Object create() throws JAXBException;
}