Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 6534 invoked from network); 17 Mar 2005 03:31:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 17 Mar 2005 03:31:05 -0000 Received: (qmail 8964 invoked by uid 500); 17 Mar 2005 03:31:04 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 8918 invoked by uid 500); 17 Mar 2005 03:31:03 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 8904 invoked by uid 99); 17 Mar 2005 03:31:03 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 16 Mar 2005 19:31:02 -0800 Received: (qmail 6471 invoked by uid 65534); 17 Mar 2005 03:31:01 -0000 Message-ID: <20050317033101.6467.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Thu, 17 Mar 2005 03:31:01 -0000 Subject: svn commit: r157878 - in webservices/axis/trunk/java/modules/deployment: maven.xml src/java/org/apache/axis/deployment/DeploymentEngine.java src/java/org/apache/axis/deployment/DeploymentParser.java src/java/org/apache/axis/deployment/repository/utill/HDFileItem.java To: axis-cvs@ws.apache.org From: deepal@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: deepal Date: Wed Mar 16 19:31:00 2005 New Revision: 157878 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D157878 Log: I have modified DeploymentEngine inorder to deploy a service using programa= tically . That is user can deploy service by giving classLoader , serviceNa= me and Inputstrem of service.xml Modified: webservices/axis/trunk/java/modules/deployment/maven.xml webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis= /deployment/DeploymentEngine.java webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis= /deployment/DeploymentParser.java webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis= /deployment/repository/utill/HDFileItem.java Modified: webservices/axis/trunk/java/modules/deployment/maven.xml URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/depl= oyment/maven.xml?view=3Ddiff&r1=3D157877&r2=3D157878 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- webservices/axis/trunk/java/modules/deployment/maven.xml (original) +++ webservices/axis/trunk/java/modules/deployment/maven.xml Wed Mar 16 19:= 31:00 2005 @@ -11,6 +11,7 @@ + Modified: webservices/axis/trunk/java/modules/deployment/src/java/org/apach= e/axis/deployment/DeploymentEngine.java URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/depl= oyment/src/java/org/apache/axis/deployment/DeploymentEngine.java?view=3Ddif= f&r1=3D157877&r2=3D157878 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis= /deployment/DeploymentEngine.java (original) +++ webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis= /deployment/DeploymentEngine.java Wed Mar 16 19:31:00 2005 @@ -23,17 +23,8 @@ import org.apache.axis.deployment.scheduler.DeploymentIterator; import org.apache.axis.deployment.scheduler.Scheduler; import org.apache.axis.deployment.scheduler.SchedulerTask; -import org.apache.axis.description.AxisGlobal; -import org.apache.axis.description.AxisModule; -import org.apache.axis.description.AxisService; -import org.apache.axis.description.Flow; -import org.apache.axis.description.HandlerMetadata; -import org.apache.axis.description.Parameter; -import org.apache.axis.engine.AxisFault; -import org.apache.axis.engine.EngineRegistry; -import org.apache.axis.engine.EngineRegistryImpl; -import org.apache.axis.engine.Handler; -import org.apache.axis.engine.Provider; +import org.apache.axis.description.*; +import org.apache.axis.engine.*; import org.apache.axis.phaseresolver.PhaseException; import org.apache.axis.phaseresolver.PhaseResolver; import org.apache.commons.logging.Log; @@ -41,19 +32,13 @@ =20 import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.HashMap; =20 =20 public class DeploymentEngine implements DeploymentConstants { @@ -111,6 +96,15 @@ this(RepositaryName,"server.xml"); =20 } + /** + * this constructor is used to deploy a web service programatically, by= using classLoader + * and InputStream + * @param engineRegistry + */ + public DeploymentEngine(EngineRegistry engineRegistry) { + this.engineRegistry =3D engineRegistry; + } + public DeploymentEngine(String RepositaryName, String serverXMLFile) t= hrows DeploymentException { this.folderName =3D RepositaryName; File repository =3D new File(RepositaryName); @@ -267,84 +261,74 @@ =20 =20 private void addnewService(AxisService serviceMetaData) throws AxisFau= lt, PhaseException { + currentFileItem.setClassLoader(); + serviceMetaData =3D getRunnerbleService(serviceMetaData); + engineRegistry.addService(serviceMetaData); + Parameter para =3D serviceMetaData.getParameter("OUTSERVICE"); + if(para !=3D null ){ + String value =3D (String) para.getValue(); + if("true".equals(value)){ + Class temp =3D serviceMetaData.getServiceClass(); =20 - ClassLoader classLoader =3D Thread.currentThread().getContextClass= Loader(); - - loadServiceClass(serviceMetaData,classLoader); - + } + } + } + /** + * This method is used to fill the axis service , it dose loading serv= ice class and also the provider class + * and it will also load the service handlers + * @param serviceMetaData + * @return + * @throws AxisFault + * @throws PhaseException + */ + private AxisService getRunnerbleService(AxisService serviceMetaData) t= hrows AxisFault, PhaseException { + loadServiceClass(serviceMetaData); Flow inflow =3D serviceMetaData.getInFlow(); if(inflow !=3D null ){ - addFlowHandlers(inflow,classLoader); + addFlowHandlers(inflow); } =20 Flow outFlow =3D serviceMetaData.getOutFlow(); if(outFlow !=3D null){ - addFlowHandlers(outFlow,classLoader); + addFlowHandlers(outFlow); } =20 Flow faultFlow =3D serviceMetaData.getFaultFlow(); if(faultFlow !=3D null) { - addFlowHandlers(faultFlow,classLoader); + addFlowHandlers(faultFlow); } PhaseResolver reolve =3D new PhaseResolver(engineRegistry,serviceM= etaData); reolve.buildchains(); - engineRegistry.addService(serviceMetaData); + serviceMetaData.setClassLoader(currentFileItem.getClassLoader()); + return serviceMetaData; } =20 - private void loadServiceClass(AxisService service, ClassLoader parent)= throws AxisFault{ - File file =3D currentFileItem.getFile(); - Class serviceclass =3D null; - URLClassLoader loader1 =3D null; - if (file !=3D null) { - URL[] urlsToLoadFrom =3D new URL[0]; - try { - if (!file.exists()) { - throw new RuntimeException("file not found !!!!!!!!!!!= !!!!"); - } - urlsToLoadFrom =3D new URL[]{file.toURL()}; - loader1 =3D new URLClassLoader(urlsToLoadFrom, parent); - service.setClassLoader(loader1); - - String readInClass =3D currentFileItem.getClassName(); - - if(readInClass !=3D null && !"".equals(readInClass)){ - serviceclass =3D Class.forName(currentFileItem.getClas= sName(), true, loader1); - } - service.setServiceClass(serviceclass); =20 - String readInProviderName =3D currentFileItem.getProvideNa= me(); - if(readInProviderName !=3D null && ! "".equals(readInProvi= derName)){ - Class provider =3DClass.forName(currentFileItem.getPro= videName(), true, loader1); - service.setProvider((Provider)provider.newInstance()); - } - } catch (MalformedURLException e) { - throw new AxisFault(e.getMessage(),e); - } catch (Exception e) { - throw new AxisFault(e.getMessage(),e); + private void loadServiceClass(AxisService service) throws AxisFault{ + Class serviceclass =3D null; + ClassLoader loader1 =3D currentFileItem.getClassLoader(); + try{ + service.setClassLoader(loader1); + String readInClass =3D currentFileItem.getClassName(); + if(readInClass !=3D null && !"".equals(readInClass)){ + serviceclass =3D Class.forName(currentFileItem.getClassNam= e(), true, loader1); } - + service.setServiceClass(serviceclass); + String readInProviderName =3D currentFileItem.getProvideName()= ; + if(readInProviderName !=3D null && ! "".equals(readInProviderN= ame)){ + Class provider =3DClass.forName(currentFileItem.getProvide= Name(), true, loader1); + service.setProvider((Provider)provider.newInstance()); + } + } catch (Exception e) { + throw new AxisFault(e.getMessage(),e); } =20 } =20 =20 - private void addFlowHandlers(Flow flow, ClassLoader parent) throws Axi= sFault { + private void addFlowHandlers(Flow flow) throws AxisFault { int count =3D flow.getHandlerCount(); - File file =3D currentFileItem.getFile(); - URLClassLoader loader1 =3D null; - if (file !=3D null) { - URL[] urlsToLoadFrom =3D new URL[0]; - try { - if (!file.exists()) { - throw new RuntimeException("file not found !!!!!!!!!!!= !!!!"); - } - urlsToLoadFrom =3D new URL[]{file.toURL()}; - } catch (MalformedURLException e) { - throw new AxisFault(e.getMessage()); - } - loader1 =3D new URLClassLoader(urlsToLoadFrom, parent); - } - + ClassLoader loader1 =3D currentFileItem.getClassLoader(); for (int j =3D 0; j < count; j++) { //todo handle exception in properway HandlerMetadata handlermd =3D flow.getHandler(j); @@ -366,7 +350,7 @@ } =20 =20 - public Class getHandlerClass(String className, URLClassLoader loader1)= throws AxisFault { + public Class getHandlerClass(String className, ClassLoader loader1) th= rows AxisFault { Class handlerClass =3D null; =20 try { @@ -379,17 +363,16 @@ =20 =20 private void addNewModule(AxisModule moduelmetada) throws AxisFault { - - ClassLoader classLoader =3D Thread.currentThread().getContextClass= Loader(); + currentFileItem.setClassLoader(); =20 Flow inflow =3D moduelmetada.getInFlow(); - addFlowHandlers(inflow,classLoader); + addFlowHandlers(inflow); =20 Flow outFlow =3D moduelmetada.getOutFlow(); - addFlowHandlers(outFlow,classLoader); + addFlowHandlers(outFlow); =20 Flow faultFlow =3D moduelmetada.getFaultFlow(); - addFlowHandlers(faultFlow,classLoader); + addFlowHandlers(faultFlow); =20 engineRegistry.addMdoule(moduelmetada); } @@ -439,7 +422,7 @@ serviceStatus =3D "Error:\n" + e.getMessage(); } finally { if(serviceStatus.startsWith("Error:")) { - engineRegistry.getFaulytServices().put(ge= tAxisServiceName(currentFileItem.getName()),serviceStatus); + engineRegistry.getFaulytServices().put(get= AxisServiceName(currentFileItem.getName()),serviceStatus); } currentFileItem =3D null; } @@ -479,7 +462,7 @@ engineRegistry.removeService(new QName(serviceName= )); log.info("UnDeployement WS Name " + wsInfo.getFil= ename()); } - engineRegistry.getFaulytServices().remove(serviceName= ); + engineRegistry.getFaulytServices().remove(serviceName)= ; } =20 } @@ -508,6 +491,25 @@ return value; } return fileName; + } + + public AxisService deployService(ClassLoader classLoder , InputStream = serviceStream ,String servieName) throws DeploymentException { + AxisService service =3D null; + try { + currentFileItem =3D new HDFileItem(SERVICE,servieName); + currentFileItem.setClassLoader(classLoder); + service =3D new AxisService(); + DeploymentParser schme =3D new DeploymentParser(serviceStream,= this, ""); + schme.parseServiceXML(service); + service =3D getRunnerbleService(service); + } catch (XMLStreamException e) { + throw new DeploymentException(e.getMessage()); + } catch (PhaseException e) { + throw new DeploymentException(e.getMessage()); + } catch (AxisFault axisFault) { + throw new DeploymentException(axisFault.getMessage()); + } + return service; } =20 =20 Modified: webservices/axis/trunk/java/modules/deployment/src/java/org/apach= e/axis/deployment/DeploymentParser.java URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/depl= oyment/src/java/org/apache/axis/deployment/DeploymentParser.java?view=3Ddif= f&r1=3D157877&r2=3D157878 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis= /deployment/DeploymentParser.java (original) +++ webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis= /deployment/DeploymentParser.java Wed Mar 16 19:31:00 2005 @@ -104,7 +104,7 @@ String ST =3D pullparser.getLocalName(); if (ST.equals(SERVICEXMLST)) { procesServiceXML(axisService); - axisService.setName(new QName(getAxisServiceName(d= pengine.getCurrentFileItem().getFile().getName()))); + axisService.setName(new QName(getAxisServiceName(d= pengine.getCurrentFileItem().getServiceName()))); } //processStartElement(); break;//todo this has to be chenfed only for testng Modified: webservices/axis/trunk/java/modules/deployment/src/java/org/apach= e/axis/deployment/repository/utill/HDFileItem.java URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/depl= oyment/src/java/org/apache/axis/deployment/repository/utill/HDFileItem.java= ?view=3Ddiff&r1=3D157877&r2=3D157878 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis= /deployment/repository/utill/HDFileItem.java (original) +++ webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis= /deployment/repository/utill/HDFileItem.java Wed Mar 16 19:31:00 2005 @@ -1,22 +1,28 @@ /* - * Copyright 2004,2005 The Apache Software Foundation. - *=20 - * 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 - *=20 - * http://www.apache.org/licenses/LICENSE-2.0 - *=20 - * 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. - */ -=20 +* Copyright 2004,2005 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.axis.deployment.repository.utill; =20 +import org.apache.axis.engine.Provider; +import org.apache.axis.engine.AxisFault; + import java.io.File; +import java.net.URLClassLoader; +import java.net.URL; +import java.net.MalformedURLException; =20 /** * HDFileItem =3D Hot Deployment File Item , to store infromation of the m= odule or servise @@ -24,10 +30,17 @@ */ public class HDFileItem { =20 - private File file; + private ClassLoader classLoader; + private File file =3D null; private int type; private String className; private String provideName; + private String name; + + public HDFileItem(int type , String name) { + this.type =3D type; + this.name =3D name ; + } =20 public String getClassName() { return className; @@ -54,6 +67,13 @@ return file.getName(); } =20 + public String getServiceName(){ + if(file!=3D null){ + return file.getName(); + } else + return name; + } + public String getAbsolutePath() { return file.getAbsolutePath(); } @@ -64,5 +84,32 @@ =20 public File getFile() { return file; + } + + public ClassLoader getClassLoader() { + return classLoader; + } + + public void setClassLoader(ClassLoader classLoader) { + this.classLoader =3D classLoader; + } + + public void setClassLoader() throws AxisFault { + ClassLoader parent =3D Thread.currentThread().getContextClassLoade= r(); + if (file !=3D null) { + URL[] urlsToLoadFrom =3D new URL[0]; + try { + if (!file.exists()) { + throw new RuntimeException("file not found !!!!!!!!!!!= !!!!"); + } + urlsToLoadFrom =3D new URL[]{file.toURL()}; + classLoader =3D new URLClassLoader(urlsToLoadFrom, parent)= ; + + } catch (MalformedURLException e) { + throw new AxisFault(e.getMessage(),e); + } catch (Exception e) { + throw new AxisFault(e.getMessage(),e); + } + } } }