Hi again, some more information: the destroy() method seems to work properly.
Thanks, Michele Michele Mazzucco wrote: > Hi all, > > I'm experiencing serious problems with the eager service initialization > features provided by the Service interface (the service is deployed in > application scope everything is correct in services.xml). I'm using the > latest nightly build. > > 1 - the 'init' method is called *only* if there's a static > initialization elsewhere (i.e. a static block) -- so I guess the init() > method is called *only* when the first request comes, and not at system > startup as described into the documentation (and a service instance is > created) > 2 - the startUp() method is *never* called, even if the > <parameter name="load-on-startup" locked="false">true</parameter> > parameter is set into services.xml. > Furthermore, if you set this argument, *2* service instances are created > at system startup!. Again, if a static block is not present, nothing > happens. > > > Please find attached the simple service file (it's the sample service > slightly modified) together with the configuration file. > > > > Thanks, > Michele > > > > ------------------------------------------------------------------------ > > /* > * Copyright 2001-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 userguide.example1; > > import java.net.URL; > > import org.apache.axiom.om.OMElement; > import org.apache.axis2.AxisFault; > import org.apache.axis2.context.ConfigurationContext; > import org.apache.axis2.context.MessageContext; > import org.apache.axis2.context.OperationContext; > import org.apache.axis2.context.ServiceContext; > import org.apache.axis2.description.AxisService; > import org.apache.axis2.engine.Service; > import org.apache.axis2.wsdl.WSDLConstants; > import org.apache.log4j.Logger; > import org.apache.log4j.PropertyConfigurator; > > > /** > * Created by IntelliJ IDEA. > * User: Jaliya > * Date: Jun 2, 2005 > * Time: 2:17:58 PM > */ > public class MyService implements Service { > > private static Logger log; > > @SuppressWarnings("unused") > private MessageContext ctx; > > private static int res; > > /* > static { > log = Logger.getLogger(MyService.class); > ClassLoader cl = MyService.class.getClassLoader(); > URL url = cl.getResource("/log4j.properties"); > PropertyConfigurator.configure(url); > > log.info("Static initialization"); > } > */ > > public MyService() { > log.warn("== Instance created =="); > } > > public OMElement echo(OMElement element) { > //Praparing the OMElement so that it can be attached to another OM > Tree. > //First the OMElement should be completely build in case it is not > fully built and still > //some of the xml is in the stream. > element.build(); > //Secondly the OMElement should be detached from the current OMTree > so that it can be attached > //some other OM Tree. Once detached the OmTree will remove its > connections to this OMElement. > element.detach(); > > res++; > element.addAttribute("result", String.valueOf(res), null); > > return element; > } > > public void ping(OMElement element) { > buildElement(element); > //Do some processing > } > public void pingF(OMElement element) throws AxisFault{ > buildElement(element); > throw new AxisFault("Fault being thrown"); > } > > private static void buildElement(OMElement element) { > element.build(); > element.detach(); > } > > > public void destroy(ServiceContext sc) { > log.warn("Service is going to be destroyed!!!"); > } > > public void init(ServiceContext sc) {/* > log = Logger.getLogger(MyService.class); > ClassLoader cl = MyService.class.getClassLoader(); > URL url = cl.getResource("/log4j.properties"); > PropertyConfigurator.configure(url); > > res = 0; > */ > log.info("init ==="); > } > > public void setOperationContext(OperationContext operationContext) { > try { > this.ctx = > operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); > } catch (AxisFault e) { > log.warn(e.getMessage()); > } > } > > public void startUp(ConfigurationContext configctx, AxisService service) { > > > log.info("Startup ===="); > } > } > > > ------------------------------------------------------------------------ > > <service name="MyService" scope="application"> > <description> > This is a sample Web Service with two operations,echo and ping. > </description> > <parameter name="ServiceClass" > locked="false">userguide.example1.MyService</parameter> > > <parameter name="load-on-startup" locked="false">true</parameter> > > <operation name="echo"> > <messageReceiver > class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> > <actionMapping>urn:echo</actionMapping> > </operation> > <operation name="ping"> > <messageReceiver > class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/> > <actionMapping>urn:ping</actionMapping> > </operation> > </service> > > <!-- <parameter name="load-on-startup" locked="false">true</parameter> --> > > > ------------------------------------------------------------------------ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
