KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > soap > glue > GlueInitialisationCallback


1 /*
2  * $Id: GlueInitialisationCallback.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.soap.glue;
12
13 import electric.glue.context.ServiceContext;
14 import electric.registry.Registry;
15 import electric.registry.RegistryException;
16 import electric.service.IService;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.mule.config.i18n.Message;
21 import org.mule.impl.InitialisationCallback;
22 import org.mule.umo.lifecycle.InitialisationException;
23
24 /**
25  * <code>GlueInitialisationCallback</code> is invoked when an Glue service
26  * component is created from its descriptor.
27  *
28  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
29  * @version $Revision: 3798 $
30  */

31 public class GlueInitialisationCallback implements InitialisationCallback
32 {
33     /**
34      * logger used by this class
35      */

36     protected static Log logger = LogFactory.getLog(GlueInitialisationCallback.class);
37
38     private IService service;
39     private ServiceContext context;
40     private String JavaDoc servicePath;
41     private boolean invoked = false;
42
43     public GlueInitialisationCallback(IService service, String JavaDoc path, ServiceContext context)
44     {
45         this.service = service;
46         this.servicePath = path;
47         this.context = context;
48         if (context == null)
49         {
50             this.context = new ServiceContext();
51         }
52     }
53
54     public void initialise(Object JavaDoc component) throws InitialisationException
55     {
56         // only call this once
57
if (invoked)
58         {
59             return;
60         }
61         if (component instanceof GlueInitialisable)
62         {
63             logger.debug("Calling Glue initialisation for component: " + component.getClass().getName());
64             ((GlueInitialisable)component).initialise(service, context);
65         }
66         invoked = true;
67         try
68         {
69             logger.debug("Publishing service " + servicePath + " to Glue registry.");
70             Registry.publish(servicePath, service, context);
71         }
72         catch (RegistryException e)
73         {
74             throw new InitialisationException(new Message("soap", 3, component.getClass().getName()), e, this);
75         }
76     }
77 }
78
Popular Tags