001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.console.jmsmanager;
017:
018: import java.util.Map;
019:
020: import javax.jms.Queue;
021: import javax.jms.Topic;
022:
023: import org.apache.geronimo.gbean.AbstractName;
024: import org.apache.geronimo.gbean.AbstractNameQuery;
025: import org.apache.geronimo.gbean.GBeanData;
026: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
027: import org.apache.geronimo.kernel.GBeanNotFoundException;
028: import org.apache.geronimo.kernel.Kernel;
029: import org.apache.geronimo.kernel.KernelRegistry;
030: import org.apache.geronimo.kernel.config.Configuration;
031: import org.apache.geronimo.kernel.config.ConfigurationManager;
032: import org.apache.geronimo.kernel.config.ConfigurationUtil;
033: import org.apache.geronimo.kernel.repository.Artifact;
034:
035: public abstract class AbstractJMSManager {
036:
037: protected static final Artifact ACTIVEMQ_BROKER_ARTIFACT = new Artifact(
038: "geronimo", "activemq-broker",
039: org.apache.geronimo.system.serverinfo.ServerConstants
040: .getVersion(), "car");
041: protected static final Artifact ACTIVEMQ_ARTIFACT = new Artifact(
042: "geronimo", "activemq",
043: org.apache.geronimo.system.serverinfo.ServerConstants
044: .getVersion(), "car");
045: protected static final Kernel kernel = KernelRegistry
046: .getSingleKernel();
047:
048: protected static final ConfigurationManager configurationManager = ConfigurationUtil
049: .getConfigurationManager(kernel);
050: protected final Configuration BROKER_CONFIGURATION = configurationManager
051: .getConfiguration(ACTIVEMQ_BROKER_ARTIFACT);
052: protected final Configuration CONNECTOR_CONFIGURATION = configurationManager
053: .getConfiguration(ACTIVEMQ_ARTIFACT);
054:
055: private static final AbstractName earName = kernel.getNaming()
056: .createRootName(ACTIVEMQ_ARTIFACT, NameFactory.NULL,
057: NameFactory.J2EE_APPLICATION);
058: protected static final AbstractName RESOURCE_ADAPTER_MODULE_NAME = kernel
059: .getNaming().createChildName(earName,
060: ACTIVEMQ_ARTIFACT.toString(),
061: NameFactory.RESOURCE_ADAPTER_MODULE);
062: protected static final AbstractName RESOURCE_ADAPTER_NAME = kernel
063: .getNaming().createChildName(RESOURCE_ADAPTER_MODULE_NAME,
064: ACTIVEMQ_ARTIFACT.toString(),
065: NameFactory.RESOURCE_ADAPTER);
066: protected static final AbstractName JCA_RESOURCE_NAME = kernel
067: .getNaming().createChildName(RESOURCE_ADAPTER_NAME,
068: ACTIVEMQ_ARTIFACT.toString(),
069: NameFactory.JCA_RESOURCE);
070: protected static final AbstractName JCA_CONNECTION_FACTORY_NAME = kernel
071: .getNaming().createChildName(JCA_RESOURCE_NAME,
072: "DefaultActiveMQConnectionFactory",
073: NameFactory.JCA_CONNECTION_FACTORY);
074: protected static final AbstractName JCA_MANAGED_CONNECTION_FACTORY_NAME = kernel
075: .getNaming().createChildName(JCA_CONNECTION_FACTORY_NAME,
076: "DefaultActiveMQConnectionFactory",
077: NameFactory.JCA_MANAGED_CONNECTION_FACTORY);
078:
079: protected static final String GET_BROKER_ADMIN_FUNCTION = "getBrokerAdmin";
080:
081: public static final String TOPIC_TYPE = "Topic";
082:
083: public static final String QUEUE_TYPE = "Queue";
084:
085: //ViewDestinations attribute names
086: protected static final String DESTINATION_LIST = "destinations";
087:
088: protected static final String DESTINATION_MSG = "destinationsMsg";
089:
090: //CreateDestinations attribute names
091: protected static final String DESTINATION_NAME = "destinationMessageDestinationName";
092:
093: protected static final String DESTINATION_PHYSICAL_NAME = "destinationPhysicalName";
094:
095: protected static final String DESTINATION_TYPE = "destinationType";
096:
097: protected static final String DESTINATION_APPLICATION_NAME = "destinationApplicationName";
098:
099: protected static final String DESTINATION_MODULE_NAME = "destinationModuleName";
100:
101: protected static final String DESTINATION_CONFIG_URI = "destinationConfigURI";
102:
103: protected static Object[] no_args = new Object[0];
104:
105: protected static String[] no_params = new String[0];
106:
107: protected static final String BASE_CONFIG_URI = "runtimedestination/";
108:
109: protected GBeanData getResourceAdapterModuleData()
110: throws GBeanNotFoundException {
111: return CONNECTOR_CONFIGURATION
112: .findGBeanData(new AbstractNameQuery(
113: RESOURCE_ADAPTER_MODULE_NAME));
114: }
115:
116: protected GBeanData getQueueGBeanData()
117: throws GBeanNotFoundException {
118: GBeanData moduleData = getResourceAdapterModuleData();
119: Map adminObjects = (Map) moduleData
120: .getAttribute("adminObjectInfoMap");
121: GBeanData queueData = (GBeanData) adminObjects.get(Queue.class
122: .getName());
123: return new GBeanData(queueData);
124: }
125:
126: protected GBeanData getTopicGBeanData()
127: throws GBeanNotFoundException {
128: GBeanData moduleData = getResourceAdapterModuleData();
129: Map adminObjects = (Map) moduleData
130: .getAttribute("adminObjectInfoMap");
131: GBeanData queueData = (GBeanData) adminObjects.get(Topic.class
132: .getName());
133: return new GBeanData(queueData);
134: }
135:
136: // protected ObjectName mBeanName;
137:
138: // public static final ObjectName DESTINATION_QUERY;
139:
140: // public static final ObjectName ACTIVEMQJCA_RESOURCE_QUERY;
141:
142: // public static final String ACTIVEMQJCA_RESOURCE;
143:
144: // static {
145: // try {
146: //
147: // DESTINATION_QUERY = ObjectName
148: // .getInstance("geronimo.server:j2eeType="
149: // + NameFactory.JCA_ADMIN_OBJECT + ",*");
150: // ACTIVEMQJCA_RESOURCE_QUERY = ObjectName
151: // .getInstance("*:j2eeType=JCAManagedConnectionFactory,name=DefaultActiveMQConnectionFactory,*");
152: // ACTIVEMQJCA_RESOURCE = getActiveMQJCA_RESOURCE(ACTIVEMQJCA_RESOURCE_QUERY);
153: //
154: // if (null == ACTIVEMQJCA_RESOURCE) {
155: // throw new RuntimeException(
156: // "No JCA resource was found for DefaultActiveMQConnectionFactory");
157: // }
158: //
159: // } catch (MalformedObjectNameException e) {
160: // throw new RuntimeException(e);
161: // }
162: // }
163: //
164: // public static final J2eeContext baseContext = new J2eeContextImpl(
165: // "geronimo.server", "geronimo", "null", ACTIVEMQJCA_RESOURCE, null,
166: // null, NameFactory.JCA_ADMIN_OBJECT);
167: //
168: /**
169: * Get the JCA resource name of the activemq bean.
170: *
171: * @return JCA resource name
172: */
173: // public static String getActiveMQJCA_RESOURCE(ObjectName obj) {
174: //
175: // Set modules = kernel.listGBeans(obj);
176: //
177: // String JCA_Resource = null;
178: //
179: // for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
180: // ObjectName activemqObject = (ObjectName) iterator.next();
181: // JCA_Resource = activemqObject
182: // .getKeyProperty(NameFactory.JCA_RESOURCE);
183: // }
184: //
185: // return JCA_Resource;
186: // }
187: }
|