You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by pd...@apache.org on 2006/10/02 22:30:19 UTC
svn commit: r452198 -
/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultBootstrap.java
Author: pdodds
Date: Mon Oct 2 13:30:18 2006
New Revision: 452198
URL: http://svn.apache.org/viewvc?view=rev&rev=452198
Log:
Added missing DefaultBootstrap.java
Added:
incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultBootstrap.java
Added: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultBootstrap.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultBootstrap.java?view=auto&rev=452198
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultBootstrap.java (added)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultBootstrap.java Mon Oct 2 13:30:18 2006
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.common;
+
+import javax.jbi.JBIException;
+import javax.jbi.component.Bootstrap;
+import javax.jbi.component.InstallationContext;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Default Bootstrap class.
+ *
+ * This is a default implementation of the Bootstrap, it is used by the
+ * Maven JBI plugin to provide a standard implementation of a Bootstrap
+ * when a component does not provide one
+ *
+ */
+public class DefaultBootstrap implements Bootstrap
+{
+
+ protected InstallationContext context;
+ protected ObjectName mbeanName;
+
+ public DefaultBootstrap() {
+ }
+
+ public ObjectName getExtensionMBeanName() {
+ return mbeanName;
+ }
+
+ protected Object getExtensionMBean() throws Exception {
+ return null;
+ }
+
+ protected ObjectName createExtensionMBeanName() throws Exception {
+ return this.context.getContext().getMBeanNames().createCustomComponentMBeanName("bootstrap");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#init(javax.jbi.component.InstallationContext)
+ */
+ public void init(InstallationContext installContext) throws JBIException {
+ try {
+ this.context = installContext;
+ doInit();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling init", e);
+ }
+ }
+
+ protected void doInit() throws Exception {
+ Object mbean = getExtensionMBean();
+ if (mbean != null) {
+ this.mbeanName = createExtensionMBeanName();
+ MBeanServer server = this.context.getContext().getMBeanServer();
+ if (server == null) {
+ throw new JBIException("null mBeanServer");
+ }
+ if (server.isRegistered(this.mbeanName)) {
+ server.unregisterMBean(this.mbeanName);
+ }
+ server.registerMBean(mbean, this.mbeanName);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#cleanUp()
+ */
+ public void cleanUp() throws JBIException {
+ try {
+ doCleanUp();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling cleanUp", e);
+ }
+ }
+
+ protected void doCleanUp() throws Exception {
+ if (this.mbeanName != null) {
+ MBeanServer server = this.context.getContext().getMBeanServer();
+ if (server == null) {
+ throw new JBIException("null mBeanServer");
+ }
+ if (server.isRegistered(this.mbeanName)) {
+ server.unregisterMBean(this.mbeanName);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#onInstall()
+ */
+ public void onInstall() throws JBIException {
+ try {
+ doOnInstall();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling onInstall", e);
+ }
+ }
+
+ protected void doOnInstall() throws Exception {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#onUninstall()
+ */
+ public void onUninstall() throws JBIException {
+ try {
+ doOnUninstall();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling onUninstall", e);
+ }
+ }
+
+ protected void doOnUninstall() throws Exception {
+ }
+
+}