KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > component > context > ComponentContextForInstallation


1 /*
2  * PETALS: PETALS Services Platform
3  * Copyright (C) 2005 EBM WebSourcing
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  *
20  * Initial developer(s): Adrien LOUIS
21  * --------------------------------------------------------------------------
22  * $Id: ComponentContextForInstallation.java,v 1.2 2005/07/22 10:24:27 alouis Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.petals.jbi.component.context;
27
28 import java.util.MissingResourceException JavaDoc;
29 import java.util.logging.Logger JavaDoc;
30
31 import javax.jbi.JBIException;
32 import javax.jbi.component.ComponentContext;
33 import javax.jbi.management.MBeanNames;
34 import javax.jbi.messaging.DeliveryChannel;
35 import javax.jbi.messaging.MessagingException;
36 import javax.jbi.servicedesc.ServiceEndpoint;
37 import javax.management.MBeanServer JavaDoc;
38 import javax.naming.InitialContext JavaDoc;
39 import javax.xml.namespace.QName JavaDoc;
40
41 import org.w3c.dom.Document JavaDoc;
42 import org.w3c.dom.DocumentFragment JavaDoc;
43
44 /**
45  * Decorator class of <code>ComponentContext</code> for the use of
46  * <code>InstallationContext</code>. Only getMBeanNames, getMBeanServer,
47  * getNamingContext, getTransactionContext are allowed. Other methods throw a
48  * <code>NoSuchMethodError</code> exception
49  *
50  * @author Adrien LOUIS - EBM WebSourcing
51  */

52 public class ComponentContextForInstallation implements ComponentContext {
53     protected ComponentContext context;
54
55     /**
56      * Constructor
57      *
58      * @param context
59      * The real component context to decorate
60      */

61     public ComponentContextForInstallation(ComponentContext context) {
62         this.context = context;
63     }
64
65     /**
66      * @see javax.jbi.component.ComponentContext#activateEndpoint(javax.xml.namespace.QName,
67      * java.lang.String)
68      */

69     public ServiceEndpoint activateEndpoint(QName JavaDoc serviceName,
70             String JavaDoc endpointName) throws JBIException {
71         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
72     }
73
74     /**
75      * @see javax.jbi.component.ComponentContext#deactivateEndpoint(javax.jbi.servicedesc.ServiceEndpoint)
76      */

77     public void deactivateEndpoint(ServiceEndpoint endpoint)
78         throws JBIException {
79         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
80     }
81
82     /**
83      * @see javax.jbi.component.ComponentContext#deregisterExternalEndpoint(javax.jbi.servicedesc.ServiceEndpoint)
84      */

85     public void deregisterExternalEndpoint(ServiceEndpoint externalEndpoint)
86         throws JBIException {
87         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
88     }
89
90     /**
91      * @see javax.jbi.component.ComponentContext#getComponentName()
92      */

93     public String JavaDoc getComponentName() {
94         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
95     }
96
97     /**
98      * @see javax.jbi.component.ComponentContext#getDeliveryChannel()
99      */

100     public DeliveryChannel getDeliveryChannel() throws MessagingException {
101         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
102     }
103
104     /**
105      * @see javax.jbi.component.ComponentContext#getEndpoint(javax.xml.namespace.QName,
106      * java.lang.String)
107      */

108     public ServiceEndpoint getEndpoint(QName JavaDoc service, String JavaDoc name) {
109         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
110     }
111
112     /**
113      * @see javax.jbi.component.ComponentContext#getEndpointDescriptor(javax.jbi.servicedesc.ServiceEndpoint)
114      */

115     public Document JavaDoc getEndpointDescriptor(ServiceEndpoint endpoint)
116         throws JBIException {
117         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
118     }
119
120     /**
121      * @see javax.jbi.component.ComponentContext#getEndpoints(javax.xml.namespace.QName)
122      */

123     public ServiceEndpoint[] getEndpoints(QName JavaDoc interfaceName) {
124         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
125     }
126
127     /**
128      * @see javax.jbi.component.ComponentContext#getEndpointsForService(javax.xml.namespace.QName)
129      */

130     public ServiceEndpoint[] getEndpointsForService(QName JavaDoc serviceName) {
131         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
132     }
133
134     /**
135      * @see javax.jbi.component.ComponentContext#getExternalEndpoints(javax.xml.namespace.QName)
136      */

137     public ServiceEndpoint[] getExternalEndpoints(QName JavaDoc interfaceName) {
138         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
139     }
140
141     /**
142      * @see javax.jbi.component.ComponentContext#getExternalEndpointsForService(javax.xml.namespace.QName)
143      */

144     public ServiceEndpoint[] getExternalEndpointsForService(QName JavaDoc serviceName) {
145         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
146     }
147
148     /**
149      * TODO : not allowed in the specification but necessary to run SUN exemple
150      *
151      * @see javax.jbi.component.ComponentContext#getInstallRoot()
152      */

153     public String JavaDoc getInstallRoot() {
154         return context.getInstallRoot();
155         // throw new IllegalStateException("Not allowed in
156
// InstallationContext");
157
}
158
159     /**
160      * @see javax.jbi.component.ComponentContext#getLogger(java.lang.String,
161      * java.lang.String)
162      */

163     public Logger JavaDoc getLogger(String JavaDoc suffix, String JavaDoc resourceBundleName)
164         throws MissingResourceException JavaDoc, JBIException {
165         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
166     }
167
168     /**
169      * @see javax.jbi.component.ComponentContext#getMBeanNames()
170      */

171     public MBeanNames getMBeanNames() {
172         return context.getMBeanNames();
173     }
174
175     /**
176      * @see javax.jbi.component.ComponentContext#getMBeanServer()
177      */

178     public MBeanServer JavaDoc getMBeanServer() {
179         return context.getMBeanServer();
180     }
181
182     /**
183      * @see javax.jbi.component.ComponentContext#getNamingContext()
184      */

185     public InitialContext JavaDoc getNamingContext() {
186         return context.getNamingContext();
187     }
188
189     /**
190      * @see javax.jbi.component.ComponentContext#getTransactionManager()
191      */

192     public Object JavaDoc getTransactionManager() {
193         return context.getTransactionManager();
194     }
195
196     /**
197      * @see javax.jbi.component.ComponentContext#getWorkspaceRoot()
198      */

199     public String JavaDoc getWorkspaceRoot() {
200         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
201     }
202
203     /**
204      * @see javax.jbi.component.ComponentContext#registerExternalEndpoint(javax.jbi.servicedesc.ServiceEndpoint)
205      */

206     public void registerExternalEndpoint(ServiceEndpoint externalEndpoint) {
207         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
208     }
209
210     /**
211      * @see javax.jbi.component.ComponentContext#resolveEndpointReference(org.w3c.dom.DocumentFragment,
212      * javax.jbi.component.Capabilities)
213      */

214     public ServiceEndpoint resolveEndpointReference(DocumentFragment JavaDoc epr) {
215         throw new IllegalStateException JavaDoc("Not allowed in InstallationContext");
216     }
217
218 }
219
Popular Tags