From: Steve L. <st...@us...> - 2004-06-16 15:11:18
|
Update of /cvsroot/smartfrog/core/components/cddlm/src/org/smartfrog/services/axis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24358/components/cddlm/src/org/smartfrog/services/axis Modified Files: AxisImpl.java AxisService.java AxisServiceImpl.java components.sf Log Message: update for latest Axis version, added undeploy phase (and sync terminate switch) Index: AxisImpl.java =================================================================== RCS file: /cvsroot/smartfrog/core/components/cddlm/src/org/smartfrog/services/axis/AxisImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AxisImpl.java 15 Jun 2004 15:07:33 -0000 1.2 --- AxisImpl.java 16 Jun 2004 15:11:09 -0000 1.3 *************** *** 32,44 **** import org.jdom.output.DOMOutputter; import org.smartfrog.services.cddlm.DeploymentEndpoint; - import org.smartfrog.sfcore.common.SmartFrogCoreKeys; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogLifecycleException; import org.smartfrog.sfcore.common.SmartFrogLivenessException; import org.smartfrog.sfcore.logging.Log; - import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.prim.TerminationRecord; - import org.smartfrog.sfcore.security.SFClassLoader; import org.smartfrog.sfcore.utils.ComponentHelper; import org.w3c.dom.Document; --- 32,41 ---- *************** *** 143,153 **** log.info(" max threads=" + threads + " sessions=" + sessions); axis = new SimpleAxisServer(threads, sessions); ! String servicePath=DEFAULT_AXIS_SERVICE_PATH; ! sfReplaceAttribute(Axis.SERVICE_PATH,servicePath); try { //register the resouce ! wsddResource = sfResolve(Axis.WSDD_RESOURCE, (String)null, false); ! if(wsddResource!=null) { log.info("registering WSDD " + wsddResource); registerResource(wsddResource); --- 140,150 ---- log.info(" max threads=" + threads + " sessions=" + sessions); axis = new SimpleAxisServer(threads, sessions); ! String servicePath = DEFAULT_AXIS_SERVICE_PATH; ! sfReplaceAttribute(Axis.SERVICE_PATH, servicePath); try { //register the resouce ! wsddResource = sfResolve(Axis.WSDD_RESOURCE, (String) null, false); ! if (wsddResource != null) { log.info("registering WSDD " + wsddResource); registerResource(wsddResource); *************** *** 179,183 **** /** ! * Provides hook for subclasses to implement usefull termination behavior. * * @param status termination status --- 176,180 ---- /** ! * shut down axis * * @param status termination status *************** *** 251,254 **** --- 248,252 ---- /** * deploy or undeploy a WSDD doc to a local JVM + * * @param wsddDoc * @throws SmartFrogException if anything went wrong *************** *** 287,291 **** public void registerResource(String resourcename) throws SmartFrogException, RemoteException { ! ComponentHelper helper= new ComponentHelper(this); registerStream(helper.loadResource(resourcename)); } --- 285,289 ---- public void registerResource(String resourcename) throws SmartFrogException, RemoteException { ! ComponentHelper helper = new ComponentHelper(this); registerStream(helper.loadResource(resourcename)); } *************** *** 296,306 **** * depending on the payload. * Because the JDOM classes serialize, this is a remotable interface * @param wsdd */ public void registerWSDDDocument(org.jdom.Document wsdd) throws SmartFrogException { ! DOMOutputter outputter=new DOMOutputter(); try { ! Document DomDoc=outputter.output(wsdd); ! WSDDDocument wsddDoc=new WSDDDocument(DomDoc); deployOrUndeploy(wsddDoc); } catch (JDOMException e) { --- 294,305 ---- * depending on the payload. * Because the JDOM classes serialize, this is a remotable interface + * * @param wsdd */ public void registerWSDDDocument(org.jdom.Document wsdd) throws SmartFrogException { ! DOMOutputter outputter = new DOMOutputter(); try { ! Document DomDoc = outputter.output(wsdd); ! WSDDDocument wsddDoc = new WSDDDocument(DomDoc); deployOrUndeploy(wsddDoc); } catch (JDOMException e) { Index: AxisServiceImpl.java =================================================================== RCS file: /cvsroot/smartfrog/core/components/cddlm/src/org/smartfrog/services/axis/AxisServiceImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AxisServiceImpl.java 15 Jun 2004 15:07:33 -0000 1.2 --- AxisServiceImpl.java 16 Jun 2004 15:11:09 -0000 1.3 *************** *** 22,37 **** package org.smartfrog.services.axis; ! import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.logging.Log; import org.smartfrog.sfcore.utils.ComponentHelper; - import org.apache.axis.client.AdminClient; - import org.apache.axis.AxisFault; import javax.xml.rpc.ServiceException; - import java.rmi.RemoteException; - import java.net.URL; - import java.net.MalformedURLException; import java.io.InputStream; /** --- 22,37 ---- package org.smartfrog.services.axis; ! import org.apache.axis.client.AdminClient; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.logging.Log; + import org.smartfrog.sfcore.prim.PrimImpl; + import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.utils.ComponentHelper; import javax.xml.rpc.ServiceException; import java.io.InputStream; + import java.net.MalformedURLException; + import java.net.URL; + import java.rmi.RemoteException; /** *************** *** 39,43 **** * The service supports different modes of deployment: deploy local, and deploy remote * But that detail is hidden because the work is handed back up to the parent. ! * * Date: 14-Jun-2004 * Time: 14:27:26 --- 39,43 ---- * The service supports different modes of deployment: deploy local, and deploy remote * But that detail is hidden because the work is handed back up to the parent. ! * <p/> * Date: 14-Jun-2004 * Time: 14:27:26 *************** *** 72,76 **** private String adminService; private String wsdlPath; ! private String descriptorResource; private int port; private String adminPath; --- 72,77 ---- private String adminService; private String wsdlPath; ! private String deployResource; ! private String undeployResource; private int port; private String adminPath; *************** *** 83,87 **** - /** * Can be called to start components. Subclasses should override to provide --- 84,87 ---- *************** *** 94,115 **** public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); ! log=sfGetApplicationLog(); protocol = sfResolve(AxisService.PROTOCOL, protocol, true); hostname = sfResolve(AxisService.HOSTNAME, hostname, true); ! port=sfResolve(AxisService.PORT,port,true); ! webapp=sfResolve(AxisService.WEBAPP,webapp,true); ! serviceName = sfResolve(AxisService.SERVICE_NAME,serviceName,true); ! servicePath = sfResolve(AxisService.SERVICE_PATH,servicePath,true); ! adminService= sfResolve(AxisService.ADMIN_SERVICE, adminService, true); ! transport = sfResolve(AxisService.TRANSPORT,transport,false); ! username = sfResolve(AxisService.USERNAME,username,false); //password only matters if username is set ! password = sfResolve(AxisService.PASSWORD,password,username!=null); ! String path="/"+webapp+"/"+servicePath+"/"+adminService; try { ! adminURL=new URL(protocol,hostname,port,path); ! log.info("Admin url is "+adminURL); ! adminClient=new AdminClient(""); if (username != null) { adminClient.setLogin(username, password); --- 94,115 ---- public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); ! log = sfGetApplicationLog(); protocol = sfResolve(AxisService.PROTOCOL, protocol, true); hostname = sfResolve(AxisService.HOSTNAME, hostname, true); ! port = sfResolve(AxisService.PORT, port, true); ! webapp = sfResolve(AxisService.WEBAPP, webapp, true); ! serviceName = sfResolve(AxisService.SERVICE_NAME, serviceName, true); ! servicePath = sfResolve(AxisService.SERVICE_PATH, servicePath, true); ! adminService = sfResolve(AxisService.ADMIN_SERVICE, adminService, true); ! transport = sfResolve(AxisService.TRANSPORT, transport, false); ! username = sfResolve(AxisService.USERNAME, username, false); //password only matters if username is set ! password = sfResolve(AxisService.PASSWORD, password, username != null); ! String path = "/" + webapp + "/" + servicePath + "/" + adminService; try { ! adminURL = new URL(protocol, hostname, port, path); ! log.info("Admin url is " + adminURL); ! adminClient = new AdminClient(false); if (username != null) { adminClient.setLogin(username, password); *************** *** 123,150 **** } //at this point we have the admin client. Now we can do things with it. ! descriptorResource=sfResolve(AxisService.DESCRIPTOR_RESOURCE,descriptorResource,false); ! if(descriptorResource!=null) { ! deployDescriptorResource(); } } /** ! * deploy the contents of the descriptor resource, which must not be null ! * @throws SmartFrogException ! * @throws RemoteException */ ! private void deployDescriptorResource() throws SmartFrogException, RemoteException { ! assert descriptorResource!=null; ! try { ! String results; ! results=deployResource(descriptorResource); ! postProcessResults(results); ! } catch (AxisFault fault) { ! throw SmartFrogException.forward(fault); ! } catch (RemoteException re) { ! throw re; ! } catch (Exception e) { ! throw SmartFrogException.forward(e); } } --- 123,151 ---- } //at this point we have the admin client. Now we can do things with it. ! deployResource = sfResolve(AxisService.DEPLOY_RESOURCE, deployResource, false); ! undeployResource = sfResolve(AxisService.UNDEPLOY_RESOURCE, undeployResource, deployResource != null); ! if (deployResource != null) { ! deployResource(deployResource); } } + /** ! * undeploy a component. Errors are logged but not thrown ! * ! * @param status termination status */ ! public synchronized void sfTerminateWith(TerminationRecord status) { ! super.sfTerminateWith(status); ! if (undeployResource != null) { ! try { ! deployResource(undeployResource); ! } catch (SmartFrogException e) { ! log.error("while undeploying " + serviceName, e); ! } catch (RemoteException e) { ! log.error("while undeploying " + serviceName, e); ! } } + } *************** *** 152,170 **** /** * deploy a named resource * @param resourcename ! * @return ! * @throws Exception * @throws RemoteException */ ! public String deployResource(String resourcename) throws Exception, RemoteException, AxisFault { ! ComponentHelper helper = new ComponentHelper(this); ! InputStream instream=helper.loadResource(resourcename); ! assert instream!=null; ! return adminClient.process(instream); } public void postProcessResults(String results) throws SmartFrogException { ! if(log.isDebugEnabled()) { ! log.debug("Received "+results); } } --- 153,183 ---- /** * deploy a named resource + * * @param resourcename ! * @throws SmartFrogException which may wrap an axis fault too * @throws RemoteException */ ! public void deployResource(String resourcename) throws SmartFrogException, RemoteException { ! try { ! ComponentHelper helper = new ComponentHelper(this); ! InputStream instream = helper.loadResource(resourcename); ! assert instream != null; ! String results = adminClient.process(instream); ! } catch (RemoteException re) { ! throw re; ! } catch (Exception e) { ! throw SmartFrogException.forward(e); ! } } + /** + * do any result postprocessing + * + * @param results + * @throws SmartFrogException + */ public void postProcessResults(String results) throws SmartFrogException { ! if (log.isDebugEnabled()) { ! log.debug("Received " + results); } } Index: components.sf =================================================================== RCS file: /cvsroot/smartfrog/core/components/cddlm/src/org/smartfrog/services/axis/components.sf,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** components.sf 15 Jun 2004 15:07:32 -0000 1.2 --- components.sf 16 Jun 2004 15:11:09 -0000 1.3 *************** *** 97,100 **** --- 97,106 ---- /** + * now define an axis service. this is a service that + * deploys and undeploys axis. + * + * Note that an Axis service does not by default include any liveness tests; + * it is the role of other components (such as the liveness page) to do so. + * * this is non instantiable, but * sets the defaults for things *************** *** 114,122 **** /** * now define an axis service. this is a service that ! * tells the system what to run */ AxisServiceResourceSchema extends AxisServiceSchema { //this is the axis configuration file for a service ! descriptorResource extends String; } --- 120,130 ---- /** * now define an axis service. this is a service that ! * deploys and undeploys axis */ AxisServiceResourceSchema extends AxisServiceSchema { //this is the axis configuration file for a service ! deployResource extends String; ! //and the undeployment resource ! undeployResource extends String; } Index: AxisService.java =================================================================== RCS file: /cvsroot/smartfrog/core/components/cddlm/src/org/smartfrog/services/axis/AxisService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AxisService.java 15 Jun 2004 15:07:33 -0000 1.2 --- AxisService.java 16 Jun 2004 15:11:09 -0000 1.3 *************** *** 22,27 **** package org.smartfrog.services.axis; - import org.smartfrog.sfcore.reference.Reference; - import java.rmi.Remote; --- 22,25 ---- *************** *** 43,47 **** * the name of a resource for the descriptor */ ! String DESCRIPTOR_RESOURCE ="descriptorResource"; /** --- 41,50 ---- * the name of a resource for the descriptor */ ! String DEPLOY_RESOURCE = "deployResource"; ! ! /** ! * undeployment resource ! */ ! String UNDEPLOY_RESOURCE = "undeployResource"; /** *************** *** 59,73 **** * pass for admin */ ! String PASSWORD="password"; ! String WEBAPP="webapp"; ! String ADMIN_SERVICE="adminService"; //serviceName extends String; ! String SERVICE_NAME="serviceName"; ! String PORT="port"; /** --- 62,76 ---- * pass for admin */ ! String PASSWORD = "password"; ! String WEBAPP = "webapp"; ! String ADMIN_SERVICE = "adminService"; //serviceName extends String; ! String SERVICE_NAME = "serviceName"; ! String PORT = "port"; /** *************** *** 79,84 **** String TRANSPORT = "transport"; ! String PROTOCOL ="protocol"; ! String HOSTNAME="hostname"; } --- 82,87 ---- String TRANSPORT = "transport"; ! String PROTOCOL = "protocol"; ! String HOSTNAME = "hostname"; } |