/*
*-**************************************************************************-*
*
* XOo°f - http://www.xooof.org
* A development and XML specification framework for documenting and
* developing the services layer of enterprise business applications.
* From the specifications, it generates WSDL, DocBook, client-side and
* server-side code for Java, C# and Python.
*
* Copyright (C) 2006 Software AG Belgium
*
* This file is part of XOo°f.
*
* XOo°f is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* XOo°f is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*-**************************************************************************-*
*/
package xdtestsuite.server;
import javax.ejb.ObjectNotFoundException;
import javax.ejb.RemoveException;
import org.apache.log4j.Category;
import xdtestsuite.msgs.SMyBO;
import org.xooof.xmldispatcher.interfaces.XMLDispatcherAppException;
import org.xooof.xmldispatcher.interfaces.XMLDispatcherUserException;
import org.xooof.xmldispatcher.servers.XMLDispatcherContext;
class MyBOImpl extends BaseBO implements MyBOImplSkeleton
{
protected Category logcat = Category.getInstance(MyBOImpl.class);
private static int counter = 0;
// EJBObject
public String ejbFindByPrimaryKey(String primKey)
throws javax.ejb.FinderException
{
logcat.debug("ejbFindByPrimaryKey " + primKey);
if (null == MyBOStore.load(primKey))
{
throw new ObjectNotFoundException(primKey);
}
else
{
return primKey;
}
}
public void ejbLoad()
{
String id = (String)entityContext.getPrimaryKey();
logcat.debug("ejbLoad " + id);
state = MyBOStore.load(id).state;
}
public void ejbStore()
{
MyBOData data = new MyBOData();
data.id = (String)entityContext.getPrimaryKey();
data.state = state;
logcat.debug("ejbStore " + data.id);
try
{
MyBOStore.store(data);
}
catch(Exception e)
{
logcat.error("store failed: " + data.id,e);
throw new javax.ejb.EJBException(e);
}
}
public void ejbRemove()
throws RemoveException
{
String id = (String)entityContext.getPrimaryKey();
logcat.debug("ejbRemove " + id);
try
{
MyBOStore.remove(id);
}
catch(Exception e)
{
throw new RemoveException(e.toString());
}
}
// class methods
// constructors
private void _checkState(String expectedState)
throws XMLDispatcherAppException
{
if (expectedState == null)
{
if (state != null)
{
throw new XMLDispatcherAppException("unexpected state '" + state + "'");
}
}
else
{
if (!state.equals(expectedState))
{
throw new XMLDispatcherAppException("unexpected state '" + state + "'");
}
}
}
public String ejbCreateCreate(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException, javax.ejb.CreateException
{
logcat.debug("ejbCreateImpl_postCreate "+entityContext.getPrimaryKey());
_checkState(null);
++counter;
return "PK1-"+counter;
}
public void ejbPostCreateCreate(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException, javax.ejb.CreateException
{
logcat.debug("ejbPostCreateImpl_postCreate "+entityContext.getPrimaryKey());
_checkState("created1");
((MyBO)entityContext.getEJBLocalObject()).load(xdCtx);
}
public String ejbCreateSomeConstructor(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException, javax.ejb.CreateException
{
logcat.debug("ejbCreateImpl_postSomeConstructor "+entityContext.getPrimaryKey());
_checkState(null);
++counter;
return "PK2-"+counter;
}
public void ejbPostCreateSomeConstructor(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException, javax.ejb.CreateException
{
logcat.debug("ejbPostCreateImpl_postSomeConstructor "+entityContext.getPrimaryKey());
_checkState("created3");
}
public String ejbCreateBaseConstructor(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException, javax.ejb.CreateException
{
logcat.debug("ejbCreateImpl_postBaseConstructor "+entityContext.getPrimaryKey());
_checkState(null);
++counter;
return "PK3-"+counter;
}
public void ejbPostCreateBaseConstructor(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException, javax.ejb.CreateException
{
logcat.debug("ejbPostCreateImpl_postBaseConstructor "+entityContext.getPrimaryKey());
_checkState("created2");
}
// instance methods
public SMyBO impl_load(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException
{
logcat.debug("impl_load "+entityContext.getPrimaryKey());
try
{
SMyBO rply = new SMyBO();
rply.objId = (String)entityContext.getEJBLocalObject().getPrimaryKey();
rply.objClass = "MyBO";
rply.state = state;
return rply;
}
catch(Exception e)
{
exceptionHandler(e); // never returns
return null;
}
}
public SMyBO impl_specificLoad(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException
{
logcat.debug("impl_specificLoad "+entityContext.getPrimaryKey());
return impl_load(xdCtx);
}
public void impl_someMethod(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException
{
}
public void impl_someMethod1(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException
{
}
public void impl_baseMethod(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException
{
}
public void impl_baseMethod1(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException
{
}
public void impl_destroy(XMLDispatcherContext xdCtx)
throws XMLDispatcherUserException, XMLDispatcherAppException
{
}
// interface XMLDispatcherState
private String state;
public String getState(XMLDispatcherContext xdCtx)
{
return this.state;
}
public void setState(XMLDispatcherContext xdCtx, String state)
{
this.state = state;
}
}