You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/08/09 22:33:52 UTC
svn commit: r564374 [6/7] - in
/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix:
./ client/ components/util/ components/util/xstream/
components/varscheduler/ expression/ jbi/ jbi/container/ jbi/deployment/
jbi/event...
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java Thu Aug 9 13:33:26 2007
@@ -50,12 +50,11 @@
*/
public class ComponentMBeanImpl extends BaseLifeCycle implements ComponentMBean {
- private static Log log = LogFactory.getLog(ComponentMBeanImpl.class);
+ private static final Log LOG = LogFactory.getLog(ComponentMBeanImpl.class);
private boolean exchangeThrottling;
private long throttlingTimeout = 100;
private int throttlingInterval = 1;
-
private Component component;
private ComponentLifeCycle lifeCycle;
private ServiceUnitManager suManager;
@@ -110,39 +109,39 @@
/**
* Register the MBeans for this Component
- * @param context
+ * @param ctx
* @return ObjectName
* @throws JBIException
*/
- public ObjectName registerMBeans(ManagementContext context) throws JBIException{
- try{
- mBeanName = context.createObjectName(this);
- context.registerMBean(mBeanName, this, ComponentMBean.class);
+ public ObjectName registerMBeans(ManagementContext ctx) throws JBIException {
+ try {
+ mBeanName = ctx.createObjectName(this);
+ ctx.registerMBean(mBeanName, this, ComponentMBean.class);
return mBeanName;
- }catch(Exception e){
- String errorStr="Failed to register MBeans";
- log.error(errorStr,e);
- throw new JBIException(errorStr,e);
+ } catch (Exception e) {
+ String errorStr = "Failed to register MBeans";
+ LOG.error(errorStr, e);
+ throw new JBIException(errorStr, e);
}
}
/**
* Unregister Component MBeans
- * @param context
+ * @param ctx
* @throws JBIException
*/
- public void unregisterMbeans(ManagementContext context) throws JBIException{
- context.unregisterMBean(mBeanName);
+ public void unregisterMbeans(ManagementContext ctx) throws JBIException {
+ ctx.unregisterMBean(mBeanName);
}
/**
* Set the Context
*
- * @param context
+ * @param ctx
*/
- public void setContext(ComponentContextImpl context) {
- this.context = context;
- this.stateFile = context.getEnvironment().getStateFile();
+ public void setContext(ComponentContextImpl ctx) {
+ this.context = ctx;
+ this.stateFile = ctx.getEnvironment().getStateFile();
}
/**
@@ -182,13 +181,13 @@
* Get the Description of the item
* @return the description
*/
- public String getDescription(){
+ public String getDescription() {
return description;
}
public void init() throws JBIException {
- log.info("Initializing component: " + getName());
+ LOG.info("Initializing component: " + getName());
if (context != null && component != null) {
DeliveryChannelImpl channel = new DeliveryChannelImpl(this);
channel.setContext(context);
@@ -211,19 +210,19 @@
* @exception javax.jbi.JBIException if the item fails to start.
*/
public void start() throws javax.jbi.JBIException {
- log.info("Starting component: " + getName());
+ LOG.info("Starting component: " + getName());
try {
doStart();
persistRunningState();
getContainer().getRegistry().checkPendingAssemblies();
} catch (JBIException e) {
- log.error("Could not start component", e);
+ LOG.error("Could not start component", e);
throw e;
} catch (RuntimeException e) {
- log.error("Could not start component", e);
+ LOG.error("Could not start component", e);
throw e;
} catch (Error e) {
- log.error("Could not start component", e);
+ LOG.error("Could not start component", e);
throw e;
}
}
@@ -234,18 +233,18 @@
* @exception javax.jbi.JBIException if the item fails to stop.
*/
public void stop() throws javax.jbi.JBIException {
- log.info("Stopping component: " + getName());
+ LOG.info("Stopping component: " + getName());
try {
doStop();
persistRunningState();
} catch (JBIException e) {
- log.error("Could not stop component", e);
+ LOG.error("Could not stop component", e);
throw e;
} catch (RuntimeException e) {
- log.error("Could not start component", e);
+ LOG.error("Could not start component", e);
throw e;
} catch (Error e) {
- log.error("Could not start component", e);
+ LOG.error("Could not start component", e);
throw e;
}
}
@@ -256,18 +255,18 @@
* @exception javax.jbi.JBIException if the item fails to shut down.
*/
public void shutDown() throws javax.jbi.JBIException {
- log.info("Shutting down component: " + getName());
+ LOG.info("Shutting down component: " + getName());
try {
doShutDown();
persistRunningState();
} catch (JBIException e) {
- log.error("Could not shutDown component", e);
+ LOG.error("Could not shutDown component", e);
throw e;
} catch (RuntimeException e) {
- log.error("Could not start component", e);
+ LOG.error("Could not start component", e);
throw e;
} catch (Error e) {
- log.error("Could not start component", e);
+ LOG.error("Could not start component", e);
throw e;
}
}
@@ -317,7 +316,7 @@
} finally {
Thread.currentThread().setContextClassLoader(loader);
}
- super.stop();
+ super.stop();
}
fireEvent(ComponentEvent.COMPONENT_STOPPED);
}
@@ -356,11 +355,11 @@
* Set the initial running state of the Component
* @throws JBIException
*/
- public void setInitialRunningState() throws JBIException{
+ public void setInitialRunningState() throws JBIException {
if (!isPojo()) {
- String componentName = getName();
+ String name = getName();
String runningState = getRunningStateFromStore();
- log.info("Setting running state for Component: " + componentName + " to " + runningState);
+ LOG.info("Setting running state for Component: " + name + " to " + runningState);
if (runningState != null) {
if (runningState.equals(LifeCycleMBean.STARTED)) {
doStart();
@@ -379,14 +378,14 @@
*/
public void persistRunningState() {
if (!isPojo()) {
- String componentName = getName();
+ String name = getName();
try {
String currentState = getCurrentState();
Properties props = new Properties();
props.setProperty("state", currentState);
XmlPersistenceSupport.write(stateFile, props);
} catch (IOException e) {
- log.error("Failed to write current running state for Component: " + componentName, e);
+ LOG.error("Failed to write current running state for Component: " + name, e);
}
}
}
@@ -396,12 +395,12 @@
*/
public String getRunningStateFromStore() {
String result = LifeCycleMBean.UNKNOWN;
- String componentName = getName();
+ String name = getName();
try {
Properties props = (Properties) XmlPersistenceSupport.read(stateFile);
result = props.getProperty("state", result);
} catch (Exception e) {
- log.error("Failed to read running state for Component: " + componentName, e);
+ LOG.error("Failed to read running state for Component: " + name, e);
}
return result;
}
@@ -409,7 +408,7 @@
/**
* @return the capacity of the inbound queue
*/
- public int getInboundQueueCapacity(){
+ public int getInboundQueueCapacity() {
return queueCapacity;
}
@@ -417,7 +416,7 @@
* Set the inbound queue capacity
* @param value
*/
- public void setInboundQueueCapacity(int value){
+ public void setInboundQueueCapacity(int value) {
if (getDeliveryChannel() != null) {
throw new IllegalStateException("The component must be shut down before changing queue capacity");
}
@@ -564,7 +563,7 @@
sa.stop(false, false);
registry.addPendingAssembly(sa);
} catch (Exception e) {
- log.error("Error stopping service assembly " + sas[i]);
+ LOG.error("Error stopping service assembly " + sas[i]);
}
}
}
@@ -580,7 +579,7 @@
sa.shutDown(false);
registry.addPendingAssembly(sa);
} catch (Exception e) {
- log.error("Error shutting down service assembly " + sas[i]);
+ LOG.error("Error shutting down service assembly " + sas[i]);
}
}
}
@@ -602,6 +601,8 @@
break;
case ComponentEvent.COMPONENT_SHUTDOWN:
listeners[i].componentShutDown(event);
+ break;
+ default:
break;
}
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentRegistry.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentRegistry.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentRegistry.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentRegistry.java Thu Aug 9 13:33:26 2007
@@ -21,6 +21,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import javax.jbi.JBIException;
@@ -34,11 +35,11 @@
public class ComponentRegistry {
private Map<ComponentNameSpace, ComponentMBeanImpl> idMap = new LinkedHashMap<ComponentNameSpace, ComponentMBeanImpl>();
- private boolean runningStateInitialized = false;
+ private boolean runningStateInitialized;
private Registry registry;
- protected ComponentRegistry(Registry reg){
+ protected ComponentRegistry(Registry reg) {
this.registry = reg;
}
/**
@@ -70,9 +71,9 @@
* start components
* @throws JBIException
*/
- public synchronized void start() throws JBIException{
+ public synchronized void start() throws JBIException {
if (!setInitialRunningStateFromStart()) {
- for(Iterator<ComponentMBeanImpl> i = getComponents().iterator(); i.hasNext();) {
+ for (Iterator<ComponentMBeanImpl> i = getComponents().iterator(); i.hasNext();) {
ComponentMBeanImpl lcc = i.next();
lcc.doStart();
}
@@ -86,7 +87,7 @@
* @throws JBIException
*/
public synchronized void stop() throws JBIException {
- for (Iterator<ComponentMBeanImpl> i = getReverseComponents(). iterator();i.hasNext();) {
+ for (Iterator<ComponentMBeanImpl> i = getReverseComponents().iterator(); i.hasNext();) {
ComponentMBeanImpl lcc = i.next();
lcc.doStop();
}
@@ -99,7 +100,7 @@
* @throws JBIException
*/
public synchronized void shutDown() throws JBIException {
- for (Iterator<ComponentMBeanImpl> i = getReverseComponents().iterator();i.hasNext();) {
+ for (Iterator<ComponentMBeanImpl> i = getReverseComponents().iterator(); i.hasNext();) {
ComponentMBeanImpl lcc = i.next();
lcc.persistRunningState();
lcc.doShutDown();
@@ -108,7 +109,7 @@
private Collection<ComponentMBeanImpl> getReverseComponents() {
synchronized (idMap) {
- ArrayList<ComponentMBeanImpl> l = new ArrayList<ComponentMBeanImpl>(idMap.values());
+ List<ComponentMBeanImpl> l = new ArrayList<ComponentMBeanImpl>(idMap.values());
Collections.reverse(l);
return l;
}
@@ -145,15 +146,15 @@
}
}
- private boolean setInitialRunningStateFromStart() throws JBIException{
+ private boolean setInitialRunningStateFromStart() throws JBIException {
boolean result = !runningStateInitialized;
- if (!runningStateInitialized){
+ if (!runningStateInitialized) {
runningStateInitialized = true;
- for (Iterator<ComponentMBeanImpl> i = getComponents().iterator();i.hasNext();) {
+ for (Iterator<ComponentMBeanImpl> i = getComponents().iterator(); i.hasNext();) {
ComponentMBeanImpl lcc = i.next();
- if(!lcc.isPojo() && !registry.isContainerEmbedded()){
+ if (!lcc.isPojo() && !registry.isContainerEmbedded()) {
lcc.setInitialRunningState();
- }else {
+ } else {
lcc.doStart();
}
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java Thu Aug 9 13:33:26 2007
@@ -34,6 +34,13 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.jbi.container.EnvironmentContext;
@@ -49,11 +56,6 @@
import org.apache.servicemix.jbi.management.ParameterHelper;
import org.apache.servicemix.jbi.util.DOMUtil;
import org.apache.servicemix.jbi.util.FileUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
/**
* The deployment service MBean allows administrative tools to manage service assembly deployments.
@@ -62,7 +64,8 @@
*/
public class DeploymentService extends BaseSystemService implements DeploymentServiceMBean {
- private static final Log log = LogFactory.getLog(DeploymentService.class);
+ private static final Log LOG = LogFactory.getLog(DeploymentService.class);
+
private EnvironmentContext environmentContext;
private Registry registry;
@@ -96,7 +99,7 @@
ServiceAssemblyLifeCycle sa = registry.getServiceAssembly(sas[i]);
sa.restore();
} catch (Exception e) {
- log.error("Unable to restore state for service assembly " + sas[i], e);
+ LOG.error("Unable to restore state for service assembly " + sas[i], e);
}
}
}
@@ -202,7 +205,7 @@
}
return deployServiceAssembly(tmpDir, sa);
} catch (Exception e) {
- log.error("Error deploying service assembly", e);
+ LOG.error("Error deploying service assembly", e);
throw e;
}
}
@@ -239,7 +242,7 @@
registry.unregisterServiceAssembly(assemblyName);
ServiceUnitLifeCycle[] sus = sa.getDeployedSUs();
if (sus != null) {
- for (int i = 0;i < sus.length; i++) {
+ for (int i = 0; i < sus.length; i++) {
undeployServiceUnit(sus[i]);
}
}
@@ -247,7 +250,7 @@
return result;
} catch (Exception e) {
- log.info("Unable to undeploy assembly", e);
+ LOG.info("Unable to undeploy assembly", e);
throw e;
}
}
@@ -267,7 +270,7 @@
}
return names;
} catch (Exception e) {
- log.info("Unable to get deployed service unit list", e);
+ LOG.info("Unable to get deployed service unit list", e);
throw e;
}
}
@@ -281,7 +284,7 @@
try {
return registry.getDeployedServiceAssemblies();
} catch (Exception e) {
- log.info("Unable to get deployed service assemblies", e);
+ LOG.info("Unable to get deployed service assemblies", e);
throw e;
}
}
@@ -312,7 +315,7 @@
try {
return registry.getDeployedServiceAssembliesForComponent(componentName);
} catch (Exception e) {
- log.info("Error in getDeployedServiceAssembliesForComponent", e);
+ LOG.info("Error in getDeployedServiceAssembliesForComponent", e);
throw e;
}
}
@@ -328,7 +331,7 @@
try {
return registry.getComponentsForDeployedServiceAssembly(saName);
} catch (Exception e) {
- log.info("Error in getComponentsForDeployedServiceAssembly", e);
+ LOG.info("Error in getComponentsForDeployedServiceAssembly", e);
throw e;
}
}
@@ -345,7 +348,7 @@
try {
return registry.isSADeployedServiceUnit(componentName, suName);
} catch (Exception e) {
- log.info("Error in isSADeployedServiceUnit", e);
+ LOG.info("Error in isSADeployedServiceUnit", e);
throw e;
}
}
@@ -373,7 +376,7 @@
ServiceAssemblyLifeCycle sa = registry.getServiceAssembly(serviceAssemblyName);
return sa.start(true);
} catch (Exception e) {
- log.info("Error in start", e);
+ LOG.info("Error in start", e);
throw e;
}
}
@@ -392,7 +395,7 @@
ServiceAssemblyLifeCycle sa = registry.getServiceAssembly(serviceAssemblyName);
return sa.stop(true, false);
} catch (Exception e) {
- log.info("Error in stop", e);
+ LOG.info("Error in stop", e);
throw e;
}
}
@@ -409,7 +412,7 @@
ServiceAssemblyLifeCycle sa = registry.getServiceAssembly(serviceAssemblyName);
return sa.shutDown(true);
} catch (Exception e) {
- log.info("Error in shutDown", e);
+ LOG.info("Error in shutDown", e);
throw e;
}
}
@@ -426,7 +429,7 @@
ServiceAssemblyLifeCycle sa = registry.getServiceAssembly(serviceAssemblyName);
return sa.getCurrentState();
} catch (Exception e) {
- log.info("Error in getState", e);
+ LOG.info("Error in getState", e);
throw e;
}
}
@@ -455,8 +458,8 @@
File saDirectory = env.getInstallDir();
// move the assembly to a well-named holding area
- if (log.isDebugEnabled()) {
- log.debug("Moving " + tmpDir.getAbsolutePath() + " to " + saDirectory.getAbsolutePath());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Moving " + tmpDir.getAbsolutePath() + " to " + saDirectory.getAbsolutePath());
}
saDirectory.getParentFile().mkdirs();
if (!tmpDir.renameTo(saDirectory)) {
@@ -475,17 +478,21 @@
}
ComponentMBeanImpl lcc = container.getComponent(componentName);
if (lcc == null) {
- throw ManagementSupport.failure("deploy", "Target component " + componentName + " for service unit " + suName + " is not installed");
+ throw ManagementSupport.failure("deploy", "Target component " + componentName
+ + " for service unit " + suName + " is not installed");
}
if (!lcc.isStarted()) {
- throw ManagementSupport.failure("deploy", "Target component " + componentName + " for service unit " + suName + " is not started");
+ throw ManagementSupport.failure("deploy", "Target component " + componentName
+ + " for service unit " + suName + " is not started");
}
if (lcc.getServiceUnitManager() == null) {
- throw ManagementSupport.failure("deploy", "Target component " + componentName + " for service unit " + suName + " does not accept deployments");
+ throw ManagementSupport.failure("deploy", "Target component " + componentName
+ + " for service unit " + suName + " does not accept deployments");
}
// TODO: check duplicates here ?
if (isDeployedServiceUnit(componentName, suName)) {
- throw ManagementSupport.failure("deploy", "Service unit " + suName + " is already deployed on component " + componentName);
+ throw ManagementSupport.failure("deploy", "Service unit " + suName
+ + " is already deployed on component " + componentName);
}
}
}
@@ -505,8 +512,8 @@
try {
File artifactFile = new File(saDirectory, artifact);
targetDir = env.getServiceUnitDirectory(componentName, suName);
- if (log.isDebugEnabled()) {
- log.debug("Unpack service unit archive " + artifactFile + " to " + targetDir);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Unpack service unit archive " + artifactFile + " to " + targetDir);
}
FileUtil.unpackArchive(artifactFile, targetDir);
} catch (IOException e) {
@@ -555,15 +562,14 @@
ServiceUnitLifeCycle su = registry.getServiceUnit(suName);
undeployServiceUnit(su);
} catch (Exception e) {
- log.warn("Error undeploying SU", e);
+ LOG.warn("Error undeploying SU", e);
}
}
// Delete SA deployment directory
FileUtil.deleteFile(saDirectory);
throw ManagementSupport.failure("deploy", componentResults);
- }
// Success
- else {
+ } else {
// Register SA
String[] deployedSUs = suKeys.toArray(new String[suKeys.size()]);
ServiceAssemblyLifeCycle salc = registry.registerServiceAssembly(sa, deployedSUs, env);
@@ -619,7 +625,7 @@
"Unable to parse result string", e);
}
} catch (Exception e2) {
- log.error(e2);
+ LOG.error(e2);
result = null;
}
}
@@ -670,38 +676,37 @@
}
FileUtil.deleteFile(targetDir);
}
- }
- else {
+ } else {
FileUtil.deleteFile(targetDir);
}
- log.info("UnDeployed ServiceUnit " + name + " from Component: " + componentName);
+ LOG.info("UnDeployed ServiceUnit " + name + " from Component: " + componentName);
}
/**
* Find runnning state and things deployed before shutdown
*/
protected void buildState() {
- log.info("Restoring service assemblies");
+ LOG.info("Restoring service assemblies");
// walk through deployed SA's
File top = environmentContext.getServiceAssembliesDir();
if (top != null && top.exists() && top.isDirectory()) {
File[] files = top.listFiles();
if (files != null) {
- // Initialize all assemblies
+ // Initialize all assemblies
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
String assemblyName = files[i].getName();
try {
ServiceAssemblyEnvironment env = environmentContext.getServiceAssemblyEnvironment(assemblyName);
- Descriptor root = DescriptorFactory.buildDescriptor(env.getInstallDir());
- if (root != null) {
- ServiceAssembly sa = root.getServiceAssembly();
- if (sa != null && sa.getIdentification() != null) {
- registry.registerServiceAssembly(sa, env);
- }
- }
- } catch(Exception e) {
- log.error("Failed to initialized service assembly: " + assemblyName,e);
+ Descriptor root = DescriptorFactory.buildDescriptor(env.getInstallDir());
+ if (root != null) {
+ ServiceAssembly sa = root.getServiceAssembly();
+ if (sa != null && sa.getIdentification() != null) {
+ registry.registerServiceAssembly(sa, env);
+ }
+ }
+ } catch (Exception e) {
+ LOG.error("Failed to initialized service assembly: " + assemblyName, e);
}
}
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Endpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Endpoint.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Endpoint.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Endpoint.java Thu Aug 9 13:33:26 2007
@@ -45,7 +45,7 @@
public class Endpoint implements EndpointMBean, MBeanInfoProvider {
- private static final Log log = LogFactory.getLog(Endpoint.class);
+ private static final Log LOG = LogFactory.getLog(Endpoint.class);
private AbstractServiceEndpoint endpoint;
private Registry registry;
@@ -164,7 +164,7 @@
}
return null;
} catch (Exception e) {
- log.debug("Error proces test exchange", e);
+ LOG.debug("Error proces test exchange", e);
throw new RuntimeException(e);
} finally {
if (client != null) {
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointMBean.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointMBean.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointMBean.java Thu Aug 9 13:33:26 2007
@@ -20,18 +20,18 @@
public interface EndpointMBean {
- public String getEndpointName();
+ String getEndpointName();
- public QName[] getInterfaces();
+ QName[] getInterfaces();
- public QName getServiceName();
+ QName getServiceName();
- public String getComponentName();
+ String getComponentName();
- public String loadReference();
+ String loadReference();
- public String loadWSDL();
+ String loadWSDL();
- public String send(String content, String operation, String mep);
+ String send(String content, String operation, String mep);
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointRegistry.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointRegistry.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointRegistry.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointRegistry.java Thu Aug 9 13:33:26 2007
@@ -49,7 +49,7 @@
*/
public class EndpointRegistry {
- private static final Log logger = LogFactory.getLog(EndpointRegistry.class);
+ private static final Log LOG = LogFactory.getLog(EndpointRegistry.class);
private Registry registry;
@@ -82,16 +82,16 @@
protected List<EndpointProcessor> getEndpointProcessors() {
List<EndpointProcessor> l = new ArrayList<EndpointProcessor>();
- String[] classes = { "org.apache.servicemix.jbi.framework.support.SUDescriptorProcessor",
- "org.apache.servicemix.jbi.framework.support.WSDL1Processor",
- "org.apache.servicemix.jbi.framework.support.WSDL2Processor" };
+ String[] classes = {"org.apache.servicemix.jbi.framework.support.SUDescriptorProcessor",
+ "org.apache.servicemix.jbi.framework.support.WSDL1Processor",
+ "org.apache.servicemix.jbi.framework.support.WSDL2Processor" };
for (int i = 0; i < classes.length; i++) {
try {
EndpointProcessor p = (EndpointProcessor) Class.forName(classes[i]).newInstance();
p.init(registry);
l.add(p);
} catch (Throwable e) {
- logger.warn("Disabled endpoint processor '" + classes[i] + "': " + e);
+ LOG.warn("Disabled endpoint processor '" + classes[i] + "': " + e);
}
}
return l;
@@ -160,10 +160,11 @@
String key = getKey(conn.service, conn.endpoint);
ServiceEndpoint ep = internalEndpoints.get(key);
if (ep == null) {
- logger.warn("Connection for interface " + interfaceName + " could not find target for service " + conn.service + " and endpoint " + conn.endpoint);
+ LOG.warn("Connection for interface " + interfaceName + " could not find target for service "
+ + conn.service + " and endpoint " + conn.endpoint);
return new ServiceEndpoint[0];
} else {
- return new ServiceEndpoint[] { ep };
+ return new ServiceEndpoint[] {ep };
}
}
Collection<ServiceEndpoint> result = getEndpointsByInterface(interfaceName, getInternalEndpoints());
@@ -179,13 +180,16 @@
* @return the endpoint
* @throws JBIException
*/
- public InternalEndpoint registerInternalEndpoint(ComponentContextImpl provider, QName serviceName, String endpointName) throws JBIException {
+ public InternalEndpoint registerInternalEndpoint(ComponentContextImpl provider,
+ QName serviceName,
+ String endpointName) throws JBIException {
// Create endpoint
String key = getKey(serviceName, endpointName);
InternalEndpoint registered = (InternalEndpoint) internalEndpoints.get(key);
// Check if the endpoint has already been activated by another component
if (registered != null && registered.isLocal()) {
- throw new JBIException("An internal endpoint for service " + serviceName + " and endpoint " + endpointName + " is already registered");
+ throw new JBIException("An internal endpoint for service " + serviceName
+ + " and endpoint " + endpointName + " is already registered");
}
// Create a new endpoint
InternalEndpoint serviceEndpoint = new InternalEndpoint(provider.getComponentNameSpace(), endpointName, serviceName);
@@ -298,7 +302,8 @@
public void registerExternalEndpoint(ComponentNameSpace cns, ServiceEndpoint externalEndpoint) throws JBIException {
ExternalEndpoint serviceEndpoint = new ExternalEndpoint(cns, externalEndpoint);
if (externalEndpoints.get(getKey(serviceEndpoint)) != null) {
- throw new JBIException("An external endpoint for service " + externalEndpoint.getServiceName() + " and endpoint " + externalEndpoint.getEndpointName() + " is already registered");
+ throw new JBIException("An external endpoint for service " + externalEndpoint.getServiceName()
+ + " and endpoint " + externalEndpoint.getEndpointName() + " is already registered");
}
registerEndpoint(serviceEndpoint);
externalEndpoints.put(getKey(serviceEndpoint), serviceEndpoint);
@@ -390,7 +395,7 @@
ServiceEndpoint endpoint = i.next();
QName[] interfaces = endpoint.getInterfaces();
if (interfaces != null) {
- for (int k = 0; k < interfaces.length;k ++) {
+ for (int k = 0; k < interfaces.length; k++) {
QName qn = interfaces[k];
if (qn != null && qn.equals(interfaceName)) {
answer.add(endpoint);
@@ -426,7 +431,8 @@
* @param link
* @throws JBIException
*/
- public void registerEndpointConnection(QName fromSvc, String fromEp, QName toSvc, String toEp, String link) throws JBIException {
+ public void registerEndpointConnection(QName fromSvc, String fromEp,
+ QName toSvc, String toEp, String link) throws JBIException {
LinkedEndpoint ep = new LinkedEndpoint(fromSvc, fromEp, toSvc, toEp, link);
if (linkedEndpoints.get(getKey(ep)) != null) {
throw new JBIException("An endpoint connection for service " + ep.getServiceName() + " and name " + ep.getEndpointName() + " is already registered");
@@ -480,7 +486,7 @@
registry.getContainer().getManagementContext().registerMBean(objectName, endpoint, EndpointMBean.class);
endpointMBeans.put(serviceEndpoint, endpoint);
} catch (JMException e) {
- logger.error("Could not register MBean for endpoint", e);
+ LOG.error("Could not register MBean for endpoint", e);
}
}
@@ -489,7 +495,7 @@
try {
registry.getContainer().getManagementContext().unregisterMBean(ep);
} catch (JBIException e) {
- logger.error("Could not unregister MBean for endpoint", e);
+ LOG.error("Could not unregister MBean for endpoint", e);
}
}
@@ -538,6 +544,8 @@
break;
case EndpointEvent.REMOTE_ENDPOINT_UNREGISTERED:
listeners[i].remoteEndpointUnregistered(event);
+ break;
+ default:
break;
}
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationContextImpl.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationContextImpl.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationContextImpl.java Thu Aug 9 13:33:26 2007
@@ -16,21 +16,22 @@
*/
package org.apache.servicemix.jbi.framework;
-import org.apache.servicemix.jbi.deployment.Component;
-import org.apache.servicemix.jbi.deployment.InstallationDescriptorExtension;
-import org.apache.servicemix.jbi.deployment.SharedLibraryList;
-import org.w3c.dom.DocumentFragment;
-
-import javax.jbi.component.Bootstrap;
-import javax.jbi.component.ComponentContext;
-import javax.jbi.component.InstallationContext;
-
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+
+import javax.jbi.component.Bootstrap;
+import javax.jbi.component.ComponentContext;
+import javax.jbi.component.InstallationContext;
+
+import org.w3c.dom.DocumentFragment;
+
+import org.apache.servicemix.jbi.deployment.Component;
+import org.apache.servicemix.jbi.deployment.InstallationDescriptorExtension;
+import org.apache.servicemix.jbi.deployment.SharedLibraryList;
/**
* This context contains information necessary for a JBI component to perform its installation/uninstallation
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java Thu Aug 9 13:33:26 2007
@@ -56,12 +56,15 @@
* @version $Revision$
*/
public class InstallationService extends BaseSystemService implements InstallationServiceMBean {
-
- private static final Log log=LogFactory.getLog(InstallationService.class);
-
+
+ private static final Log LOG = LogFactory.getLog(InstallationService.class);
+
private EnvironmentContext environmentContext;
+
private ManagementContext managementContext;
+
private Map<String, InstallerMBeanImpl> installers = new ConcurrentHashMap<String, InstallerMBeanImpl>();
+
private Map<String, InstallerMBeanImpl> nonLoadedInstallers = new ConcurrentHashMap<String, InstallerMBeanImpl>();
/**
@@ -69,53 +72,56 @@
*
* @return description of this item
*/
- public String getDescription(){
+ public String getDescription() {
return "installs/uninstalls Components";
}
/**
- * Load the installer for a new component from a component installation package.
+ * Load the installer for a new component from a component installation
+ * package.
*
* @param installJarURL -
- * URL locating a jar file containing a JBI Installable Component.
- * @return - the JMX ObjectName of the InstallerMBean loaded from installJarURL.
+ * URL locating a jar file containing a JBI Installable
+ * Component.
+ * @return - the JMX ObjectName of the InstallerMBean loaded from
+ * installJarURL.
*/
- public synchronized ObjectName loadNewInstaller(String installJarURL){
- try{
- ObjectName result=null;
- if(log.isDebugEnabled()){
- log.debug("Loading new installer from "+installJarURL);
- }
- File tmpDir=AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(),installJarURL);
- if(tmpDir!=null){
- Descriptor root=DescriptorFactory.buildDescriptor(tmpDir);
- if(root!=null&&root.getComponent()!=null){
+ public synchronized ObjectName loadNewInstaller(String installJarURL) {
+ try {
+ ObjectName result = null;
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Loading new installer from " + installJarURL);
+ }
+ File tmpDir = AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(), installJarURL);
+ if (tmpDir != null) {
+ Descriptor root = DescriptorFactory.buildDescriptor(tmpDir);
+ if (root != null && root.getComponent() != null) {
String componentName = root.getComponent().getIdentification().getName();
- if(!installers.containsKey(componentName)){
- InstallerMBeanImpl installer = doInstallArchive(tmpDir,root);
- if(installer!=null){
- result=installer.getObjectName();
+ if (!installers.containsKey(componentName)) {
+ InstallerMBeanImpl installer = doInstallArchive(tmpDir, root);
+ if (installer != null) {
+ result = installer.getObjectName();
installers.put(componentName, installer);
}
- }else{
- throw new RuntimeException("An installer already exists for "+componentName);
+ } else {
+ throw new RuntimeException("An installer already exists for " + componentName);
}
- }else{
- throw new RuntimeException("Could not find Component from: "+installJarURL);
+ } else {
+ throw new RuntimeException("Could not find Component from: " + installJarURL);
}
- }else{
- throw new RuntimeException("location: "+installJarURL+" isn't valid");
+ } else {
+ throw new RuntimeException("location: " + installJarURL + " isn't valid");
}
return result;
- }catch(Throwable t){
- log.error("Deployment failed",t);
- if(t instanceof Error){
+ } catch (Throwable t) {
+ LOG.error("Deployment failed", t);
+ if (t instanceof Error) {
throw (Error) t;
}
- if(t instanceof RuntimeException){
+ if (t instanceof RuntimeException) {
throw (RuntimeException) t;
- }else{
- throw new RuntimeException("Deployment failed: "+t.getMessage());
+ } else {
+ throw new RuntimeException("Deployment failed: " + t.getMessage());
}
}
}
@@ -125,7 +131,8 @@
*
* @param aComponentName -
* the component name identifying the installer to load.
- * @return - the JMX ObjectName of the InstallerMBean loaded from an existing installation context.
+ * @return - the JMX ObjectName of the InstallerMBean loaded from an
+ * existing installation context.
*/
public ObjectName loadInstaller(String aComponentName) {
InstallerMBeanImpl installer = installers.get(aComponentName);
@@ -136,9 +143,8 @@
// create an MBean for the installer
ObjectName objectName = managementContext.createCustomComponentMBeanName("Installer", aComponentName);
installer.setObjectName(objectName);
- managementContext.registerMBean(objectName, installer,
- InstallerMBean.class,
- "standard installation controls for a Component");
+ managementContext.registerMBean(objectName, installer, InstallerMBean.class,
+ "standard installation controls for a Component");
} catch (Exception e) {
throw new RuntimeException("Could not load installer", e);
}
@@ -147,7 +153,7 @@
}
return null;
}
-
+
private InstallerMBeanImpl createInstaller(String componentName) throws IOException, DeploymentException {
File installationDir = environmentContext.getComponentInstallationDir(componentName);
Descriptor root = DescriptorFactory.buildDescriptor(installationDir);
@@ -160,8 +166,7 @@
File componentRoot = environmentContext.getComponentRootDir(componentName);
ComponentContextImpl context = buildComponentContext(componentRoot, installationDir, componentName);
installationContext.setContext(context);
- InstallerMBeanImpl installer = new InstallerMBeanImpl(container,
- installationContext);
+ InstallerMBeanImpl installer = new InstallerMBeanImpl(container, installationContext);
return installer;
}
@@ -180,7 +185,7 @@
container.getBroker().suspend();
InstallerMBeanImpl installer = installers.remove(componentName);
result = installer != null;
- if(result) {
+ if (result) {
container.getManagementContext().unregisterMBean(installer);
if (isToBeDeleted) {
installer.uninstall();
@@ -188,9 +193,9 @@
nonLoadedInstallers.put(componentName, installer);
}
}
- } catch(JBIException e) {
+ } catch (JBIException e) {
String errStr = "Problem shutting down Component: " + componentName;
- log.error(errStr, e);
+ LOG.error(errStr, e);
} finally {
container.getBroker().resume();
}
@@ -204,26 +209,26 @@
* URI locating a jar file containing a shared library.
* @return - the name of the shared library loaded from aSharedLibURI.
*/
- public String installSharedLibrary(String aSharedLibURI){
- String result="";
- try{
- File tmpDir=AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(),aSharedLibURI);
- if(tmpDir!=null){
- Descriptor root=DescriptorFactory.buildDescriptor(tmpDir);
+ public String installSharedLibrary(String aSharedLibURI) {
+ String result = "";
+ try {
+ File tmpDir = AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(), aSharedLibURI);
+ if (tmpDir != null) {
+ Descriptor root = DescriptorFactory.buildDescriptor(tmpDir);
if (root == null) {
throw new DeploymentException("Could not find JBI descriptor");
}
- SharedLibrary sl=root.getSharedLibrary();
- if(sl!=null){
- result=doInstallSharedLibrary(tmpDir,sl);
+ SharedLibrary sl = root.getSharedLibrary();
+ if (sl != null) {
+ result = doInstallSharedLibrary(tmpDir, sl);
} else {
throw new DeploymentException("JBI descriptor is not a SharedLibrary descriptor");
}
- }else{
+ } else {
throw new DeploymentException("Could not find JBI descriptor");
}
- }catch(DeploymentException e){
- log.error("Deployment failed",e);
+ } catch (DeploymentException e) {
+ LOG.error("Deployment failed", e);
}
return result;
}
@@ -256,7 +261,7 @@
this.managementContext = container.getManagementContext();
buildState();
}
-
+
protected Class getServiceMBean() {
return InstallationServiceMBean.class;
}
@@ -270,7 +275,7 @@
* @throws DeploymentException
*/
public void install(String location, Properties props, boolean autoStart) throws DeploymentException {
- File tmpDir = AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(),location);
+ File tmpDir = AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(), location);
if (tmpDir != null) {
Descriptor root = DescriptorFactory.buildDescriptor(tmpDir);
if (root != null) {
@@ -300,13 +305,13 @@
if (installers.containsKey(componentName)) {
throw new DeploymentException("Component " + componentName + " is already installed");
}
- InstallerMBeanImpl installer = doInstallArchive(tmpDir,root);
+ InstallerMBeanImpl installer = doInstallArchive(tmpDir, root);
if (installer != null) {
try {
if (props != null && props.size() > 0) {
ObjectName on = installer.getInstallerConfigurationMBean();
- if (on == null ) {
- log.warn("Could not find installation configuration MBean. Installation properties will be ignored.");
+ if (on == null) {
+ LOG.warn("Could not find installation configuration MBean. Installation properties will be ignored.");
} else {
MBeanServer mbs = managementContext.getMBeanServer();
for (Iterator it = props.keySet().iterator(); it.hasNext();) {
@@ -321,24 +326,24 @@
}
}
installer.install();
- } catch(JBIException e) {
+ } catch (JBIException e) {
throw new DeploymentException(e);
}
if (autoStart) {
- try{
+ try {
ComponentMBeanImpl lcc = container.getComponent(componentName);
if (lcc != null) {
lcc.start();
- }else{
- log.warn("No ComponentConnector found for Component "+componentName);
+ } else {
+ LOG.warn("No ComponentConnector found for Component " + componentName);
}
- }catch(JBIException e){
- String errStr="Failed to start Component: "+componentName;
- log.error(errStr,e);
+ } catch (JBIException e) {
+ String errStr = "Failed to start Component: " + componentName;
+ LOG.error(errStr, e);
throw new DeploymentException(e);
}
}
- installers.put(componentName,installer);
+ installers.put(componentName, installer);
}
}
}
@@ -349,38 +354,37 @@
* @return array of OperationInfos
* @throws JMException
*/
- public MBeanOperationInfo[] getOperationInfos() throws JMException{
- OperationInfoHelper helper=new OperationInfoHelper();
- ParameterHelper ph=helper.addOperation(getObjectToManage(),"loadNewInstaller",1,"load a new Installer ");
- ph.setDescription(0,"installJarURL","URL locating the install Jar");
- ph=helper.addOperation(getObjectToManage(),"loadInstaller",1,
- "load installer for a previously installed component");
- ph.setDescription(0,"componentName","Name of the Component");
- ph=helper.addOperation(getObjectToManage(),"unloadInstaller",2,"unload an installer");
- ph.setDescription(0,"componentName","Name of the Component");
- ph.setDescription(1,"isToBeDeleted","true if component is to be deleted");
- ph=helper.addOperation(getObjectToManage(),"installSharedLibrary",1,"Install a shared library jar");
- ph.setDescription(0,"sharedLibURI","URI for the jar to be installed");
- ph=helper.addOperation(getObjectToManage(),"uninstallSharedLibrary",1,"Uninstall a shared library jar");
- ph.setDescription(0,"sharedLibName","name of the shared library");
- ph=helper.addOperation(getObjectToManage(),"install",1,"install and deplot an archive");
- ph.setDescription(0,"location","location of archive");
- ph=helper.addOperation(getObjectToManage(),"install",2,"install and deplot an archive");
- ph.setDescription(0,"location","location of archive");
- ph.setDescription(1,"autostart","automatically start the Component");
- return OperationInfoHelper.join(super.getOperationInfos(),helper.getOperationInfos());
- }
-
- protected InstallerMBeanImpl doInstallArchive(File tmpDirectory,Descriptor descriptor) throws DeploymentException{
- InstallerMBeanImpl installer=null;
- Component component=descriptor.getComponent();
- if(component!=null){
- installer=doInstallComponent(tmpDirectory,component);
+ public MBeanOperationInfo[] getOperationInfos() throws JMException {
+ OperationInfoHelper helper = new OperationInfoHelper();
+ ParameterHelper ph = helper.addOperation(getObjectToManage(), "loadNewInstaller", 1, "load a new Installer ");
+ ph.setDescription(0, "installJarURL", "URL locating the install Jar");
+ ph = helper.addOperation(getObjectToManage(), "loadInstaller", 1, "load installer for a previously installed component");
+ ph.setDescription(0, "componentName", "Name of the Component");
+ ph = helper.addOperation(getObjectToManage(), "unloadInstaller", 2, "unload an installer");
+ ph.setDescription(0, "componentName", "Name of the Component");
+ ph.setDescription(1, "isToBeDeleted", "true if component is to be deleted");
+ ph = helper.addOperation(getObjectToManage(), "installSharedLibrary", 1, "Install a shared library jar");
+ ph.setDescription(0, "sharedLibURI", "URI for the jar to be installed");
+ ph = helper.addOperation(getObjectToManage(), "uninstallSharedLibrary", 1, "Uninstall a shared library jar");
+ ph.setDescription(0, "sharedLibName", "name of the shared library");
+ ph = helper.addOperation(getObjectToManage(), "install", 1, "install and deplot an archive");
+ ph.setDescription(0, "location", "location of archive");
+ ph = helper.addOperation(getObjectToManage(), "install", 2, "install and deplot an archive");
+ ph.setDescription(0, "location", "location of archive");
+ ph.setDescription(1, "autostart", "automatically start the Component");
+ return OperationInfoHelper.join(super.getOperationInfos(), helper.getOperationInfos());
+ }
+
+ protected InstallerMBeanImpl doInstallArchive(File tmpDirectory, Descriptor descriptor) throws DeploymentException {
+ InstallerMBeanImpl installer = null;
+ Component component = descriptor.getComponent();
+ if (component != null) {
+ installer = doInstallComponent(tmpDirectory, component);
}
return installer;
}
- protected String doInstallSharedLibrary(File tmpDirectory, SharedLibrary descriptor) throws DeploymentException{
+ protected String doInstallSharedLibrary(File tmpDirectory, SharedLibrary descriptor) throws DeploymentException {
String result = null;
if (descriptor != null) {
File installationDir = null;
@@ -391,12 +395,12 @@
if (!tmpDirectory.renameTo(installationDir)) {
throw new DeploymentException("Unable to rename " + tmpDirectory + " to " + installationDir);
}
- if (log.isDebugEnabled()) {
- log.debug("Moved " + tmpDirectory + " to " + installationDir);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Moved " + tmpDirectory + " to " + installationDir);
}
container.getRegistry().registerSharedLibrary(descriptor, installationDir);
} catch (Exception e) {
- log.error("Deployment of Shared Library failed", e);
+ LOG.error("Deployment of Shared Library failed", e);
// remove any files created for installation
FileUtil.deleteFile(installationDir);
throw new DeploymentException(e);
@@ -407,50 +411,48 @@
return result;
}
- protected InstallerMBeanImpl doInstallComponent(File tmpDirectory,Component descriptor) throws DeploymentException{
+ protected InstallerMBeanImpl doInstallComponent(File tmpDirectory, Component descriptor) throws DeploymentException {
// move archive to Component directory
- InstallerMBeanImpl result=null;
- String name=descriptor.getIdentification().getName();
- try{
- File oldInstallationDir=environmentContext.getComponentInstallationDir(name);
+ InstallerMBeanImpl result = null;
+ String name = descriptor.getIdentification().getName();
+ try {
+ File oldInstallationDir = environmentContext.getComponentInstallationDir(name);
// try and delete the old version ? - maybe should leave around ??
- if(!FileUtil.deleteFile(oldInstallationDir)){
- log.warn("Failed to delete old installation directory: " + oldInstallationDir.getPath());
+ if (!FileUtil.deleteFile(oldInstallationDir)) {
+ LOG.warn("Failed to delete old installation directory: " + oldInstallationDir.getPath());
}
- File componentRoot=environmentContext.createComponentRootDir(name);
+ File componentRoot = environmentContext.createComponentRootDir(name);
// this will get the new one
- File installationDir=environmentContext.getNewComponentInstallationDir(name);
+ File installationDir = environmentContext.getNewComponentInstallationDir(name);
tmpDirectory.renameTo(installationDir);
- if (log.isDebugEnabled()) {
- log.debug("Moved " + tmpDirectory + " to " + installationDir);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Moved " + tmpDirectory + " to " + installationDir);
}
- result=initializeInstaller(installationDir,componentRoot,descriptor);
+ result = initializeInstaller(installationDir, componentRoot, descriptor);
return result;
- }catch(IOException e){
+ } catch (IOException e) {
throw new DeploymentException(e);
}
}
- private InstallerMBeanImpl initializeInstaller(File installationDir,File componentRoot,Component descriptor)
- throws DeploymentException{
- InstallerMBeanImpl result=null;
- try{
- String name=descriptor.getIdentification().getName();
- InstallationContextImpl installationContext=new InstallationContextImpl(descriptor);
+ private InstallerMBeanImpl initializeInstaller(File installationDir, File componentRoot, Component descriptor)
+ throws DeploymentException {
+ InstallerMBeanImpl result = null;
+ try {
+ String name = descriptor.getIdentification().getName();
+ InstallationContextImpl installationContext = new InstallationContextImpl(descriptor);
installationContext.setInstall(true);
installationContext.setInstallRoot(installationDir);
// now build the ComponentContext
ComponentContextImpl context = buildComponentContext(componentRoot, installationDir, name);
installationContext.setContext(context);
- result = new InstallerMBeanImpl(container,
- installationContext);
+ result = new InstallerMBeanImpl(container, installationContext);
// create an MBean for the installer
ObjectName objectName = managementContext.createCustomComponentMBeanName("Installer", name);
result.setObjectName(objectName);
- managementContext.registerMBean(objectName,result,InstallerMBean.class,
- "standard installation controls for a Component");
- }catch(Throwable e){
- log.error("Deployment of Component failed",e);
+ managementContext.registerMBean(objectName, result, InstallerMBean.class, "standard installation controls for a Component");
+ } catch (Throwable e) {
+ LOG.error("Deployment of Component failed", e);
// remove any files created for installation
environmentContext.removeComponentRootDirectory(descriptor.getIdentification().getName());
throw new DeploymentException(e);
@@ -458,7 +460,7 @@
return result;
}
- protected void buildState(){
+ protected void buildState() {
buildSharedLibs();
buildComponents();
}
@@ -469,15 +471,16 @@
* @param name
* @return true/false
*/
- protected boolean containsSharedLibrary(String name){
+ protected boolean containsSharedLibrary(String name) {
return container.getRegistry().getSharedLibrary(name) != null;
}
- protected void buildSharedLibs(){
+ protected void buildSharedLibs() {
// walk through shared libaries and add then to the ClassLoaderService
File top = environmentContext.getSharedLibDir();
if (top != null && top.exists() && top.isDirectory()) {
- // directory structure is sharedlibraries/<lib name>/version_x/stuff ...
+ // directory structure is sharedlibraries/<lib name>/version_x/stuff
+ // ...
File[] files = top.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
@@ -491,7 +494,7 @@
try {
container.getRegistry().registerSharedLibrary(sl, dir);
} catch (Exception e) {
- log.error("Failed to initialize sharted library", e);
+ LOG.error("Failed to initialize sharted library", e);
}
}
}
@@ -502,21 +505,22 @@
}
}
- protected void buildComponents(){
+ protected void buildComponents() {
// walk through components and add then to the ClassLoaderService
- File top=environmentContext.getComponentsDir();
- if(top!=null&&top.exists()&&top.isDirectory()){
- // directory structure is components/<component name>/installation ...
- File[] files=top.listFiles();
- if(files!=null){
- for(int i=0;i<files.length;i++){
- if(files[i].isDirectory()){
- final File directory=files[i];
- try{
+ File top = environmentContext.getComponentsDir();
+ if (top != null && top.exists() && top.isDirectory()) {
+ // directory structure is components/<component name>/installation
+ // ...
+ File[] files = top.listFiles();
+ if (files != null) {
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory()) {
+ final File directory = files[i];
+ try {
buildComponent(directory);
- }catch(DeploymentException e){
- log.error("Could not build Component: "+directory.getName(),e);
- log.warn("Deleting Component directory: "+directory);
+ } catch (DeploymentException e) {
+ LOG.error("Could not build Component: " + directory.getName(), e);
+ LOG.warn("Deleting Component directory: " + directory);
FileUtil.deleteFile(directory);
}
}
@@ -525,29 +529,27 @@
}
}
- protected void buildComponent(File componentDirectory)
- throws DeploymentException {
+ protected void buildComponent(File componentDirectory) throws DeploymentException {
try {
String componentName = componentDirectory.getName();
ComponentEnvironment env = container.getEnvironmentContext().getComponentEnvironment(componentName);
if (!env.getStateFile().exists()) {
- // An installer has been created but the component has not been installed
+ // An installer has been created but the component has not been
+ // installed
// So remove it
FileUtil.deleteFile(componentDirectory);
} else {
- InstallerMBeanImpl installer = createInstaller(componentName);
+ InstallerMBeanImpl installer = createInstaller(componentName);
installer.activateComponent();
nonLoadedInstallers.put(componentName, installer);
}
} catch (Throwable e) {
- log.error("Failed to deploy component: "
- + componentDirectory.getName(), e);
+ LOG.error("Failed to deploy component: " + componentDirectory.getName(), e);
throw new DeploymentException(e);
}
}
- protected ComponentContextImpl buildComponentContext(File componentRoot, File installRoot, String name)
- throws IOException {
+ protected ComponentContextImpl buildComponentContext(File componentRoot, File installRoot, String name) throws IOException {
ComponentNameSpace cns = new ComponentNameSpace(container.getName(), name);
ComponentContextImpl context = new ComponentContextImpl(container, cns);
ComponentEnvironment env = new ComponentEnvironment();
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java Thu Aug 9 13:33:26 2007
@@ -44,7 +44,9 @@
* @version $Revision$
*/
public class InstallerMBeanImpl implements InstallerMBean {
- private static final Log log = LogFactory.getLog(InstallerMBeanImpl.class);
+
+ private static final Log LOG = LogFactory.getLog(InstallerMBeanImpl.class);
+
private InstallationContextImpl context;
private JBIContainer container;
private ObjectName objectName;
@@ -89,7 +91,7 @@
initialized = true;
}
} catch (JBIException e) {
- log.error("Could not initialize bootstrap", e);
+ LOG.error("Could not initialize bootstrap", e);
throw new DeploymentException(e);
}
}
@@ -98,7 +100,7 @@
try {
bootstrap.cleanUp();
} catch (JBIException e) {
- log.error("Could not initialize bootstrap", e);
+ LOG.error("Could not initialize bootstrap", e);
throw new DeploymentException(e);
} finally {
initialized = false;
@@ -118,24 +120,19 @@
Class bootstrapClass = cl.loadClass(descriptor.getBootstrapClassName());
Bootstrap bootstrap = (Bootstrap) bootstrapClass.newInstance();
return bootstrap;
- }
- catch (MalformedURLException e) {
- log.error("Could not create class loader", e);
+ } catch (MalformedURLException e) {
+ LOG.error("Could not create class loader", e);
throw new DeploymentException(e);
- }
- catch (ClassNotFoundException e) {
- log.error("Class not found: " + descriptor.getBootstrapClassName(), e);
+ } catch (ClassNotFoundException e) {
+ LOG.error("Class not found: " + descriptor.getBootstrapClassName(), e);
throw new DeploymentException(e);
- }
- catch (InstantiationException e) {
- log.error("Could not instantiate : " + descriptor.getBootstrapClassName(), e);
+ } catch (InstantiationException e) {
+ LOG.error("Could not instantiate : " + descriptor.getBootstrapClassName(), e);
throw new DeploymentException(e);
- }
- catch (IllegalAccessException e) {
- log.error("Illegal access on: " + descriptor.getBootstrapClassName(), e);
+ } catch (IllegalAccessException e) {
+ LOG.error("Illegal access on: " + descriptor.getBootstrapClassName(), e);
throw new DeploymentException(e);
- }
- finally {
+ } finally {
Thread.currentThread().setContextClassLoader(oldCl);
}
}
@@ -197,32 +194,25 @@
context.isBinding(),
context.isEngine(),
context.getSharedLibraries());
- }
- catch (MalformedURLException e) {
- log.error("Could not create class loader", e);
+ } catch (MalformedURLException e) {
+ LOG.error("Could not create class loader", e);
throw new DeploymentException(e);
- }
- catch (NoClassDefFoundError e) {
- log.error("Class not found: " + descriptor.getBootstrapClassName(), e);
+ } catch (NoClassDefFoundError e) {
+ LOG.error("Class not found: " + descriptor.getBootstrapClassName(), e);
throw new DeploymentException(e);
- }
- catch (ClassNotFoundException e) {
- log.error("Class not found: " + descriptor.getBootstrapClassName(), e);
+ } catch (ClassNotFoundException e) {
+ LOG.error("Class not found: " + descriptor.getBootstrapClassName(), e);
throw new DeploymentException(e);
- }
- catch (InstantiationException e) {
- log.error("Could not instantiate : " + descriptor.getBootstrapClassName(), e);
+ } catch (InstantiationException e) {
+ LOG.error("Could not instantiate : " + descriptor.getBootstrapClassName(), e);
throw new DeploymentException(e);
- }
- catch (IllegalAccessException e) {
- log.error("Illegal access on: " + descriptor.getBootstrapClassName(), e);
+ } catch (IllegalAccessException e) {
+ LOG.error("Illegal access on: " + descriptor.getBootstrapClassName(), e);
throw new DeploymentException(e);
- }
- catch (JBIException e) {
- log.error("Could not initialize : " + descriptor.getBootstrapClassName(), e);
+ } catch (JBIException e) {
+ LOG.error("Could not initialize : " + descriptor.getBootstrapClassName(), e);
throw new DeploymentException(e);
- }
- finally {
+ } finally {
Thread.currentThread().setContextClassLoader(oldCl);
}
return result;
@@ -328,7 +318,7 @@
for (int i = 0; i < classPathNames.length; i++) {
File file = new File(dir, classPathNames[i]);
if (!file.exists()) {
- log.warn("Unable to add File " + file
+ LOG.warn("Unable to add File " + file
+ " to class path as it doesn't exist: "
+ file.getAbsolutePath());
}
@@ -342,8 +332,8 @@
!parentFirst,
new String[0],
new String[] { "java.", "javax." });
- if (log.isDebugEnabled()) {
- log.debug("Component class loader: " + cl);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Component class loader: " + cl);
}
return cl;
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ManagementSupport.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ManagementSupport.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ManagementSupport.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ManagementSupport.java Thu Aug 9 13:33:26 2007
@@ -16,13 +16,6 @@
*/
package org.apache.servicemix.jbi.framework;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.jbi.util.DOMUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Iterator;
@@ -31,6 +24,14 @@
import javax.jbi.management.DeploymentException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.util.DOMUtil;
/**
* ManagementMessageHelper is a class that ease the building of management messages.
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java Thu Aug 9 13:33:26 2007
@@ -96,7 +96,7 @@
* Get the description
* @return description
*/
- public String getDescription(){
+ public String getDescription() {
return "Registry of Components/SU's and Endpoints";
}
@@ -156,21 +156,21 @@
/**
* @return the EnvironmentContext
*/
- protected EnvironmentContext getEnvironmentContext(){
+ protected EnvironmentContext getEnvironmentContext() {
return container.getEnvironmentContext();
}
/**
* @return true if the container is embedded
*/
- protected boolean isContainerEmbedded(){
+ protected boolean isContainerEmbedded() {
return container.isEmbedded();
}
protected InternalEndpoint matchEndpointByName(ServiceEndpoint[] endpoints, String endpointName) {
InternalEndpoint result = null;
if (endpoints != null && endpointName != null && endpointName.length() > 0) {
- for (int i = 0;i < endpoints.length;i++) {
+ for (int i = 0; i < endpoints.length; i++) {
if (endpoints[i].getEndpointName().equals(endpointName)) {
result = (InternalEndpoint) endpoints[i];
break;
@@ -224,7 +224,7 @@
* @throws JBIException invalid endpoint reference.
*/
public Document getEndpointDescriptor(ServiceEndpoint endpoint) throws JBIException {
- if (endpoint instanceof AbstractServiceEndpoint == false) {
+ if (!(endpoint instanceof AbstractServiceEndpoint)) {
throw new JBIException("Descriptors can not be queried for external endpoints");
}
AbstractServiceEndpoint se = (AbstractServiceEndpoint) endpoint;
@@ -283,15 +283,15 @@
throw new NullPointerException("resolveInternalEPR(epr) called with null epr.");
}
NodeList nl = epr.getChildNodes();
- for (int i = 0 ; i < nl.getLength(); ++i) {
+ for (int i = 0; i < nl.getLength(); ++i) {
Node n = nl.item(i);
if (n.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element el = (Element) n;
// Namespace should be "http://java.sun.com/jbi/end-point-reference"
- if (el.getNamespaceURI() == null ||
- !el.getNamespaceURI().equals("http://java.sun.com/jbi/end-point-reference"))
+ if (el.getNamespaceURI() == null
+ || !el.getNamespaceURI().equals("http://java.sun.com/jbi/end-point-reference"))
{
continue;
}
@@ -347,16 +347,16 @@
public ServiceEndpoint resolveStandardEPR(DocumentFragment epr) {
try {
NodeList children = epr.getChildNodes();
- for (int i = 0 ; i < children.getLength(); ++i) {
+ for (int i = 0; i < children.getLength(); ++i) {
Node n = children.item(i);
if (n.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element elem = (Element) n;
- String[] namespaces = new String[] { WSAddressingConstants.WSA_NAMESPACE_200508,
- WSAddressingConstants.WSA_NAMESPACE_200408,
- WSAddressingConstants.WSA_NAMESPACE_200403,
- WSAddressingConstants.WSA_NAMESPACE_200303 };
+ String[] namespaces = new String[] {WSAddressingConstants.WSA_NAMESPACE_200508,
+ WSAddressingConstants.WSA_NAMESPACE_200408,
+ WSAddressingConstants.WSA_NAMESPACE_200403,
+ WSAddressingConstants.WSA_NAMESPACE_200303 };
NodeList nl = null;
for (int ns = 0; ns < namespaces.length; ns++) {
NodeList tnl = elem.getElementsByTagNameNS(namespaces[ns], WSAddressingConstants.EL_ADDRESS);
@@ -375,8 +375,7 @@
uri = uri.substring("endpoint:".length());
String[] parts = URIResolver.split3(uri);
return getInternalEndpoint(new QName(parts[0], parts[1]), parts[2]);
- }
- else if (uri.startsWith("service:")) {
+ } else if (uri.startsWith("service:")) {
uri = uri.substring("service:".length());
String[] parts = URIResolver.split2(uri);
return getEndpoint(new QName(parts[0], parts[1]), parts[1]);
@@ -463,8 +462,8 @@
Component component,
boolean binding,
boolean service,
- String[] sharedLibraries) throws JBIException {
- return componentRegistry.registerComponent(name,description, component, binding, service, sharedLibraries);
+ String[] sharedLibs) throws JBIException {
+ return componentRegistry.registerComponent(name, description, component, binding, service, sharedLibs);
}
/**
@@ -509,7 +508,7 @@
ObjectName[] result = null;
List<ObjectName> tmpList = new ArrayList<ObjectName>();
for (ComponentMBeanImpl lcc : getComponents()) {
- if (!lcc.isPojo() && lcc.isService() && lcc.getMBeanName() != null){
+ if (!lcc.isPojo() && lcc.isService() && lcc.getMBeanName() != null) {
tmpList.add(lcc.getMBeanName());
}
}
@@ -527,7 +526,7 @@
ObjectName[] result = null;
List<ObjectName> tmpList = new ArrayList<ObjectName>();
for (ComponentMBeanImpl lcc : getComponents()) {
- if (!lcc.isPojo() && lcc.isBinding() && lcc.getMBeanName() != null){
+ if (!lcc.isPojo() && lcc.isBinding() && lcc.getMBeanName() != null) {
tmpList.add(lcc.getMBeanName());
}
}
@@ -544,7 +543,7 @@
ObjectName[] result = null;
List<ObjectName> tmpList = new ArrayList<ObjectName>();
for (ComponentMBeanImpl lcc : getComponents()) {
- if (lcc.isPojo() && lcc.getMBeanName() != null){
+ if (lcc.isPojo() && lcc.getMBeanName() != null) {
tmpList.add(lcc.getMBeanName());
}
}
@@ -558,7 +557,7 @@
* @param context
* @param as
*/
- public void registerSubscriptions(ComponentContextImpl context,ActivationSpec as) {
+ public void registerSubscriptions(ComponentContextImpl context, ActivationSpec as) {
QName service = as.getService();
String endpointName = as.getEndpoint();
InternalEndpoint endpoint = new InternalEndpoint(context.getComponentNameSpace(), endpointName, service);
@@ -575,7 +574,7 @@
* @param context
* @param as
*/
- public void deregisterSubscriptions(ComponentContextImpl context,ActivationSpec as) {
+ public void deregisterSubscriptions(ComponentContextImpl context, ActivationSpec as) {
SubscriptionSpec[] specs = as.getSubscriptions();
if (specs != null) {
for (int i =0; i<specs.length; i++) {
@@ -589,7 +588,7 @@
* @param subscription
* @param endpoint
*/
- public void registerSubscription(ComponentContextImpl context,SubscriptionSpec subscription, ServiceEndpoint endpoint) {
+ public void registerSubscription(ComponentContextImpl context, SubscriptionSpec subscription, ServiceEndpoint endpoint) {
InternalEndpoint sei = (InternalEndpoint)endpoint;
subscription.setName(context.getComponentNameSpace());
subscriptionRegistry.registerSubscription(subscription,sei);
@@ -600,7 +599,7 @@
* @param subscription
* @return the ServiceEndpoint
*/
- public InternalEndpoint deregisterSubscription(ComponentContextImpl context,SubscriptionSpec subscription) {
+ public InternalEndpoint deregisterSubscription(ComponentContextImpl context, SubscriptionSpec subscription) {
subscription.setName(context.getComponentNameSpace());
InternalEndpoint result = subscriptionRegistry.deregisterSubscription(subscription);
return result;
@@ -622,7 +621,7 @@
* @throws DeploymentException
*/
public ServiceAssemblyLifeCycle registerServiceAssembly(ServiceAssembly sa,
- ServiceAssemblyEnvironment env) throws DeploymentException{
+ ServiceAssemblyEnvironment env) throws DeploymentException {
return serviceAssemblyRegistry.register(sa, env);
}
@@ -634,7 +633,7 @@
*/
public ServiceAssemblyLifeCycle registerServiceAssembly(ServiceAssembly sa,
String[] suKeys,
- ServiceAssemblyEnvironment env) throws DeploymentException{
+ ServiceAssemblyEnvironment env) throws DeploymentException {
return serviceAssemblyRegistry.register(sa, suKeys, env);
}