KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > jsr181 > packaging > Jsr181ServiceUnitAnalyzer


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.servicemix.jsr181.packaging;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.MissingResourceException JavaDoc;
22 import java.util.logging.Logger JavaDoc;
23
24 import javax.jbi.JBIException;
25 import javax.jbi.component.ComponentContext;
26 import javax.jbi.management.MBeanNames;
27 import javax.jbi.messaging.DeliveryChannel;
28 import javax.jbi.messaging.MessagingException;
29 import javax.jbi.servicedesc.ServiceEndpoint;
30 import javax.management.MBeanServer JavaDoc;
31 import javax.naming.InitialContext JavaDoc;
32 import javax.xml.namespace.QName JavaDoc;
33
34 import org.apache.servicemix.common.Endpoint;
35 import org.apache.servicemix.common.xbean.AbstractXBeanServiceUnitAnalyzer;
36 import org.apache.servicemix.jsr181.Jsr181Endpoint;
37 import org.apache.servicemix.jsr181.Jsr181SpringComponent;
38 import org.w3c.dom.Document JavaDoc;
39 import org.w3c.dom.DocumentFragment JavaDoc;
40
41 public class Jsr181ServiceUnitAnalyzer extends AbstractXBeanServiceUnitAnalyzer {
42
43     protected List JavaDoc getConsumes(Endpoint endpoint) {
44         return new ArrayList JavaDoc();
45     }
46
47     protected List JavaDoc getProvides(Endpoint endpoint) {
48
49         // We need to generate the dummy component to register the services
50
Jsr181Endpoint jsr181Endpoint = (Jsr181Endpoint) endpoint;
51         try {
52             Jsr181SpringComponent componentDummy = new Jsr181SpringComponent();
53             componentDummy
54                     .setEndpoints(new Jsr181Endpoint[] { jsr181Endpoint });
55             componentDummy.getLifeCycle().init(new DummyComponentContext());
56         } catch (Exception JavaDoc e) {
57             throw new RuntimeException JavaDoc("Unable to register JSR-181 service, "
58                     + e.getMessage(), e);
59         }
60         return super.getProvides(endpoint);
61     }
62
63     protected String JavaDoc getXBeanFile() {
64         return "xbean.xml";
65     }
66
67     protected boolean isValidEndpoint(Object JavaDoc bean) {
68         if (bean instanceof Jsr181Endpoint)
69             return true;
70         else
71             return false;
72     }
73
74     public class DummyComponentContext implements ComponentContext {
75
76         public ServiceEndpoint activateEndpoint(QName JavaDoc serviceName,
77                 String JavaDoc endpointName) throws JBIException {
78             return null;
79         }
80
81         public void deactivateEndpoint(ServiceEndpoint endpoint)
82                 throws JBIException {
83         }
84
85         public void deregisterExternalEndpoint(ServiceEndpoint externalEndpoint)
86                 throws JBIException {
87
88         }
89
90         public String JavaDoc getComponentName() {
91             return null;
92         }
93
94         public DeliveryChannel getDeliveryChannel() throws MessagingException {
95             return null;
96         }
97
98         public ServiceEndpoint getEndpoint(QName JavaDoc service, String JavaDoc name) {
99             return null;
100         }
101
102         public Document JavaDoc getEndpointDescriptor(ServiceEndpoint endpoint)
103                 throws JBIException {
104             return null;
105         }
106
107         public ServiceEndpoint[] getEndpoints(QName JavaDoc interfaceName) {
108             return null;
109         }
110
111         public ServiceEndpoint[] getEndpointsForService(QName JavaDoc serviceName) {
112             return null;
113         }
114
115         public ServiceEndpoint[] getExternalEndpoints(QName JavaDoc interfaceName) {
116             return null;
117         }
118
119         public ServiceEndpoint[] getExternalEndpointsForService(
120                 QName JavaDoc serviceName) {
121             return null;
122         }
123
124         public String JavaDoc getInstallRoot() {
125             return null;
126         }
127
128         public Logger JavaDoc getLogger(String JavaDoc suffix, String JavaDoc resourceBundleName)
129                 throws MissingResourceException JavaDoc, JBIException {
130             return null;
131         }
132
133         public MBeanNames getMBeanNames() {
134             return null;
135         }
136
137         public MBeanServer JavaDoc getMBeanServer() {
138             return null;
139         }
140
141         public InitialContext JavaDoc getNamingContext() {
142             return null;
143         }
144
145         public Object JavaDoc getTransactionManager() {
146             return null;
147         }
148
149         public String JavaDoc getWorkspaceRoot() {
150             return null;
151         }
152
153         public void registerExternalEndpoint(ServiceEndpoint externalEndpoint)
154                 throws JBIException {
155         }
156
157         public ServiceEndpoint resolveEndpointReference(DocumentFragment JavaDoc epr) {
158             return null;
159         }
160
161     }
162
163 }
164
Popular Tags