Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Second part of fixing #249, move plugin registry counter to hawtio-we…
…b and take out the requirement for a blueprint reference list for registering plugins, can just pure JMX instead
- Loading branch information
Showing
17 changed files
with
274 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
hawtio-plugin-mbean/src/main/java/io/hawt/web/plugin/HawtioPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* | ||
* Copyright 2012 Red Hat, Inc. | ||
* | ||
* Red Hat 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 io.hawt.web.plugin; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.management.MBeanServer; | ||
import javax.management.MalformedObjectNameException; | ||
import javax.management.ObjectName; | ||
import java.lang.management.ManagementFactory; | ||
|
||
/** | ||
* | ||
*/ | ||
public class HawtioPlugin implements HawtioPluginMBean { | ||
|
||
private static final transient Logger LOG = LoggerFactory.getLogger(HawtioPlugin.class); | ||
|
||
private String name; | ||
private String context; | ||
private String domain; | ||
private String scripts[]; | ||
|
||
private ObjectName objectName = null; | ||
private MBeanServer mBeanServer = null; | ||
|
||
public HawtioPlugin() { | ||
|
||
} | ||
|
||
public void init() { | ||
try { | ||
if (objectName == null) { | ||
objectName = getObjectName(); | ||
} | ||
|
||
if (mBeanServer == null) { | ||
mBeanServer = ManagementFactory.getPlatformMBeanServer(); | ||
} | ||
|
||
if (mBeanServer.isRegistered(objectName)) { | ||
// Update of existing plugin | ||
LOG.info("Unregistering existing plugin " + objectName); | ||
mBeanServer.unregisterMBean(objectName); | ||
} | ||
|
||
LOG.debug("Registering plugin " + objectName); | ||
mBeanServer.registerMBean(this, objectName); | ||
|
||
|
||
} catch (Throwable t) { | ||
LOG.error("Failed to register plugin: ", t); | ||
} | ||
} | ||
|
||
public void destroy() { | ||
try { | ||
if (mBeanServer != null) { | ||
LOG.debug("Unregistering plugin " + objectName); | ||
mBeanServer.unregisterMBean(objectName); | ||
} | ||
} catch (Throwable t) { | ||
LOG.error("Failed to register plugin: ", t); | ||
} | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
public void setContext(String context) { | ||
this.context = context; | ||
} | ||
|
||
public String getContext() { | ||
return this.context; | ||
} | ||
|
||
public void setDomain(String domain) { | ||
this.domain = domain; | ||
} | ||
|
||
public String getDomain() { | ||
return this.domain; | ||
} | ||
|
||
public void setScripts(String[] scripts) { | ||
this.scripts = scripts; | ||
} | ||
|
||
public void setScripts(String scripts) { | ||
String[] temp = scripts.split(","); | ||
|
||
for (int i=0; i>temp.length; i++) { | ||
temp[i] = temp[i].trim(); | ||
} | ||
|
||
this.scripts = temp; | ||
} | ||
|
||
public String[] getScripts() { | ||
return this.scripts; | ||
} | ||
|
||
protected ObjectName getObjectName() throws MalformedObjectNameException { | ||
return new ObjectName("hawtio:type=plugin,name=" + getName()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
27 changes: 0 additions & 27 deletions
27
hawtio-plugin-registry/src/main/java/io/hawt/web/plugin/PluginRegistry.java
This file was deleted.
Oops, something went wrong.
71 changes: 0 additions & 71 deletions
71
hawtio-plugin-registry/src/main/java/io/hawt/web/plugin/SimplePlugin.java
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
hawtio-plugin-registry/src/main/java/io/hawt/web/plugin/internal/Plugin.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.