You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ch...@apache.org on 2006/07/28 07:49:50 UTC
svn commit: r426392 [14/47] - in /incubator/servicemix/trunk:
apache-servicemix/src/main/assembly/ apache-servicemix/src/main/release/conf/
apache-servicemix/src/main/release/examples/basic/
apache-servicemix/src/main/release/examples/bpel-bpe/ apache-...
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Endpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Endpoint.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Endpoint.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Endpoint.java Thu Jul 27 22:49:32 2006
@@ -1,131 +1,131 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed 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.jbi.framework;
-
-import java.beans.PropertyChangeListener;
-
-import javax.management.JMException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanOperationInfo;
-import javax.xml.namespace.QName;
-import javax.xml.transform.TransformerException;
-
-import org.apache.servicemix.jbi.management.AttributeInfoHelper;
-import org.apache.servicemix.jbi.management.MBeanInfoProvider;
-import org.apache.servicemix.jbi.management.OperationInfoHelper;
-import org.apache.servicemix.jbi.servicedesc.AbstractServiceEndpoint;
-import org.apache.servicemix.jbi.servicedesc.ExternalEndpoint;
-import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
-import org.apache.servicemix.jbi.servicedesc.LinkedEndpoint;
-import org.apache.servicemix.jbi.util.DOMUtil;
-
-public class Endpoint implements EndpointMBean, MBeanInfoProvider {
-
- private AbstractServiceEndpoint endpoint;
- private Registry registry;
-
- public Endpoint(AbstractServiceEndpoint endpoint, Registry registry) {
- this.endpoint = endpoint;
- this.registry = registry;
- }
-
- public String getEndpointName() {
- return endpoint.getEndpointName();
- }
-
- public QName[] getInterfaces() {
- return endpoint.getInterfaces();
- }
-
- public QName getServiceName() {
- return endpoint.getServiceName();
- }
-
- public String getReference() {
- try {
- return DOMUtil.asIndentedXML(endpoint.getAsReference(null));
- } catch (TransformerException e) {
- return null;
- }
- }
-
- public String getWSDL() {
- try {
- return DOMUtil.asXML(registry.getEndpointDescriptor(endpoint));
- } catch (Exception e) {
- return null;
- }
- }
-
- public String getComponentName() {
- if (endpoint.getComponentNameSpace() != null) {
- return endpoint.getComponentNameSpace().getName();
- } else {
- return null;
- }
- }
-
- public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
- AttributeInfoHelper helper = new AttributeInfoHelper();
- helper.addAttribute(getObjectToManage(), "endpointName", "name of the endpoint");
- helper.addAttribute(getObjectToManage(), "serviceName", "name of the service");
- helper.addAttribute(getObjectToManage(), "componentName", "component name of the service unit");
- helper.addAttribute(getObjectToManage(), "interfaces", "interfaces implemented by this endpoint");
- return helper.getAttributeInfos();
- }
-
- public MBeanOperationInfo[] getOperationInfos() throws JMException {
- OperationInfoHelper helper = new OperationInfoHelper();
- helper.addOperation(getObjectToManage(), "getReference", "retrieve the endpoint reference");
- helper.addOperation(getObjectToManage(), "getWSDL", "retrieve the wsdl description of this endpoint");
- return helper.getOperationInfos();
- }
-
- public Object getObjectToManage() {
- return this;
- }
-
- public String getName() {
- return endpoint.getServiceName() + endpoint.getEndpointName();
- }
-
- public String getType() {
- return "Endpoint";
- }
-
- public String getSubType() {
- if (endpoint instanceof InternalEndpoint) {
- return "Internal";
- } else if (endpoint instanceof LinkedEndpoint) {
- return "Linked";
- } else if (endpoint instanceof ExternalEndpoint) {
- return "External";
- }
- return null;
- }
-
- public String getDescription() {
- return null;
- }
-
- public void setPropertyChangeListener(PropertyChangeListener l) {
- }
-
- protected AbstractServiceEndpoint getEndpoint() {
- return endpoint;
- }
-
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.jbi.framework;
+
+import java.beans.PropertyChangeListener;
+
+import javax.management.JMException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+import javax.xml.namespace.QName;
+import javax.xml.transform.TransformerException;
+
+import org.apache.servicemix.jbi.management.AttributeInfoHelper;
+import org.apache.servicemix.jbi.management.MBeanInfoProvider;
+import org.apache.servicemix.jbi.management.OperationInfoHelper;
+import org.apache.servicemix.jbi.servicedesc.AbstractServiceEndpoint;
+import org.apache.servicemix.jbi.servicedesc.ExternalEndpoint;
+import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
+import org.apache.servicemix.jbi.servicedesc.LinkedEndpoint;
+import org.apache.servicemix.jbi.util.DOMUtil;
+
+public class Endpoint implements EndpointMBean, MBeanInfoProvider {
+
+ private AbstractServiceEndpoint endpoint;
+ private Registry registry;
+
+ public Endpoint(AbstractServiceEndpoint endpoint, Registry registry) {
+ this.endpoint = endpoint;
+ this.registry = registry;
+ }
+
+ public String getEndpointName() {
+ return endpoint.getEndpointName();
+ }
+
+ public QName[] getInterfaces() {
+ return endpoint.getInterfaces();
+ }
+
+ public QName getServiceName() {
+ return endpoint.getServiceName();
+ }
+
+ public String getReference() {
+ try {
+ return DOMUtil.asIndentedXML(endpoint.getAsReference(null));
+ } catch (TransformerException e) {
+ return null;
+ }
+ }
+
+ public String getWSDL() {
+ try {
+ return DOMUtil.asXML(registry.getEndpointDescriptor(endpoint));
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public String getComponentName() {
+ if (endpoint.getComponentNameSpace() != null) {
+ return endpoint.getComponentNameSpace().getName();
+ } else {
+ return null;
+ }
+ }
+
+ public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
+ AttributeInfoHelper helper = new AttributeInfoHelper();
+ helper.addAttribute(getObjectToManage(), "endpointName", "name of the endpoint");
+ helper.addAttribute(getObjectToManage(), "serviceName", "name of the service");
+ helper.addAttribute(getObjectToManage(), "componentName", "component name of the service unit");
+ helper.addAttribute(getObjectToManage(), "interfaces", "interfaces implemented by this endpoint");
+ return helper.getAttributeInfos();
+ }
+
+ public MBeanOperationInfo[] getOperationInfos() throws JMException {
+ OperationInfoHelper helper = new OperationInfoHelper();
+ helper.addOperation(getObjectToManage(), "getReference", "retrieve the endpoint reference");
+ helper.addOperation(getObjectToManage(), "getWSDL", "retrieve the wsdl description of this endpoint");
+ return helper.getOperationInfos();
+ }
+
+ public Object getObjectToManage() {
+ return this;
+ }
+
+ public String getName() {
+ return endpoint.getServiceName() + endpoint.getEndpointName();
+ }
+
+ public String getType() {
+ return "Endpoint";
+ }
+
+ public String getSubType() {
+ if (endpoint instanceof InternalEndpoint) {
+ return "Internal";
+ } else if (endpoint instanceof LinkedEndpoint) {
+ return "Linked";
+ } else if (endpoint instanceof ExternalEndpoint) {
+ return "External";
+ }
+ return null;
+ }
+
+ public String getDescription() {
+ return null;
+ }
+
+ public void setPropertyChangeListener(PropertyChangeListener l) {
+ }
+
+ protected AbstractServiceEndpoint getEndpoint() {
+ return endpoint;
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Endpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointMBean.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointMBean.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointMBean.java Thu Jul 27 22:49:32 2006
@@ -1,34 +1,34 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed 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.jbi.framework;
-
-import javax.xml.namespace.QName;
-
-public interface EndpointMBean {
-
- public String getEndpointName();
-
- public QName[] getInterfaces();
-
- public QName getServiceName();
-
- public String getComponentName();
-
- public String getReference();
-
- public String getWSDL();
-
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.jbi.framework;
+
+import javax.xml.namespace.QName;
+
+public interface EndpointMBean {
+
+ public String getEndpointName();
+
+ public QName[] getInterfaces();
+
+ public QName getServiceName();
+
+ public String getComponentName();
+
+ public String getReference();
+
+ public String getWSDL();
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyMBean.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyMBean.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyMBean.java Thu Jul 27 22:49:32 2006
@@ -1,30 +1,30 @@
-package org.apache.servicemix.jbi.framework;
-
-import javax.jbi.management.DeploymentServiceMBean;
-import javax.management.ObjectName;
-
-
-public interface ServiceAssemblyMBean {
-
- public static final String STARTED = DeploymentServiceMBean.STARTED;
-
- public static final String SHUTDOWN = DeploymentServiceMBean.SHUTDOWN;
-
- public static final String STOPPED = DeploymentServiceMBean.STOPPED;
-
- public String getName();
-
- public String getDescription();
-
- public String getCurrentState();
-
- public String getDescriptor();
-
- public ObjectName[] getServiceUnits();
-
- public String start() throws Exception;
-
- public String stop() throws Exception;
-
- public String shutDown() throws Exception;
-}
+package org.apache.servicemix.jbi.framework;
+
+import javax.jbi.management.DeploymentServiceMBean;
+import javax.management.ObjectName;
+
+
+public interface ServiceAssemblyMBean {
+
+ public static final String STARTED = DeploymentServiceMBean.STARTED;
+
+ public static final String SHUTDOWN = DeploymentServiceMBean.SHUTDOWN;
+
+ public static final String STOPPED = DeploymentServiceMBean.STOPPED;
+
+ public String getName();
+
+ public String getDescription();
+
+ public String getCurrentState();
+
+ public String getDescriptor();
+
+ public ObjectName[] getServiceUnits();
+
+ public String start() throws Exception;
+
+ public String stop() throws Exception;
+
+ public String shutDown() throws Exception;
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitLifeCycle.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitLifeCycle.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitLifeCycle.java Thu Jul 27 22:49:32 2006
@@ -1,303 +1,303 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed 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.jbi.framework;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-
-import javax.jbi.component.ServiceUnitManager;
-import javax.jbi.management.DeploymentException;
-import javax.management.JMException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanOperationInfo;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.jbi.deployment.Descriptor;
-import org.apache.servicemix.jbi.deployment.DescriptorFactory;
-import org.apache.servicemix.jbi.deployment.ServiceUnit;
-import org.apache.servicemix.jbi.deployment.Services;
-import org.apache.servicemix.jbi.event.ServiceUnitEvent;
-import org.apache.servicemix.jbi.event.ServiceUnitListener;
-import org.apache.servicemix.jbi.management.AttributeInfoHelper;
-import org.apache.servicemix.jbi.management.MBeanInfoProvider;
-import org.apache.servicemix.jbi.management.OperationInfoHelper;
-
-public class ServiceUnitLifeCycle implements ServiceUnitMBean, MBeanInfoProvider {
-
- private static final Log log = LogFactory.getLog(ServiceUnitLifeCycle.class);
-
- private ServiceUnit serviceUnit;
-
- private String currentState = SHUTDOWN;
-
- private String serviceAssembly;
-
- private Registry registry;
-
- private PropertyChangeListener listener;
-
- private Services services;
-
- private File rootDir;
-
- public ServiceUnitLifeCycle(ServiceUnit serviceUnit,
- String serviceAssembly,
- Registry registry,
- File rootDir) {
- this.serviceUnit = serviceUnit;
- this.serviceAssembly = serviceAssembly;
- this.registry = registry;
- this.rootDir = rootDir;
- Descriptor d = DescriptorFactory.buildDescriptor(getServiceUnitRootPath());
- if (d != null) {
- services = d.getServices();
- }
- }
-
- /**
- * Initialize the service unit.
- * @throws DeploymentException
- */
- public void init() throws DeploymentException {
- log.info("Initializing service unit: " + getName());
- checkComponentStarted("init");
- ServiceUnitManager sum = getServiceUnitManager();
- File path = getServiceUnitRootPath();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(getComponentClassLoader());
- sum.init(getName(), path.getAbsolutePath());
- } finally {
- Thread.currentThread().setContextClassLoader(cl);
- }
- currentState = STOPPED;
- }
-
- /**
- * Start the service unit.
- * @throws DeploymentException
- */
- public void start() throws DeploymentException {
- log.info("Starting service unit: " + getName());
- checkComponentStarted("start");
- ServiceUnitManager sum = getServiceUnitManager();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(getComponentClassLoader());
- sum.start(getName());
- } finally {
- Thread.currentThread().setContextClassLoader(cl);
- }
- currentState = STARTED;
- }
-
- /**
- * Stop the service unit. This suspends current messaging activities.
- * @throws DeploymentException
- */
- public void stop() throws DeploymentException {
- log.info("Stopping service unit: " + getName());
- checkComponentStarted("stop");
- ServiceUnitManager sum = getServiceUnitManager();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(getComponentClassLoader());
- sum.stop(getName());
- } finally {
- Thread.currentThread().setContextClassLoader(cl);
- }
- currentState = STOPPED;
- }
-
- /**
- * Shut down the service unit.
- * This releases resources, preparatory to uninstallation.
- * @throws DeploymentException
- */
- public void shutDown() throws DeploymentException {
- log.info("Shutting down service unit: " + getName());
- checkComponentStartedOrStopped("shutDown");
- ServiceUnitManager sum = getServiceUnitManager();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(getComponentClassLoader());
- sum.shutDown(getName());
- } finally {
- Thread.currentThread().setContextClassLoader(cl);
- }
- currentState = SHUTDOWN;
- }
-
- /**
- * @return the currentState as a String
- */
- public String getCurrentState() {
- return currentState;
- }
-
- public boolean isShutDown() {
- return currentState.equals(SHUTDOWN);
- }
-
- public boolean isStopped() {
- return currentState.equals(STOPPED);
- }
-
- public boolean isStarted() {
- return currentState.equals(STARTED);
- }
-
- /**
- * @return the name of the ServiceAssembly
- */
- public String getName() {
- return serviceUnit.getIdentification().getName();
- }
-
- /**
- * @return the description of the ServiceAssembly
- */
- public String getDescription() {
- return serviceUnit.getIdentification().getDescription();
- }
-
- public String getComponentName() {
- return serviceUnit.getTarget().getComponentName();
- }
-
- public String getServiceAssembly() {
- return serviceAssembly;
- }
-
- public String getDescriptor() {
- File suDir = getServiceUnitRootPath();
- return DescriptorFactory.getDescriptorAsText(suDir);
- }
-
- public Services getServices() {
- return services;
- }
-
- protected void checkComponentStarted(String task) throws DeploymentException {
- String componentName = getComponentName();
- String suName = getName();
- ComponentMBeanImpl lcc = registry.getComponent(componentName);
- if (lcc == null) {
- throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not installed");
- }
- if (!lcc.isStarted()) {
- throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not started");
- }
- if (lcc.getServiceUnitManager() == null) {
- throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " does not accept deployments");
- }
- }
-
- protected void checkComponentStartedOrStopped(String task) throws DeploymentException {
- String componentName = getComponentName();
- String suName = getName();
- ComponentMBeanImpl lcc = registry.getComponent(componentName);
- if (lcc == null) {
- throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not installed");
- }
- if (!lcc.isStarted() && !lcc.isStopped()) {
- throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not started");
- }
- if (lcc.getServiceUnitManager() == null) {
- throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " does not accept deployments");
- }
- }
-
- protected File getServiceUnitRootPath() {
- return rootDir;
- }
-
- protected ServiceUnitManager getServiceUnitManager() {
- ComponentMBeanImpl lcc = registry.getComponent(getComponentName());
- return lcc.getServiceUnitManager();
- }
-
- protected ClassLoader getComponentClassLoader() {
- ComponentMBeanImpl lcc = registry.getComponent(getComponentName());
- // TODO: should retrieve the real component class loader
- return lcc.getComponent().getClass().getClassLoader();
- }
-
- public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
- AttributeInfoHelper helper = new AttributeInfoHelper();
- helper.addAttribute(getObjectToManage(), "currentState", "current state of the service unit");
- helper.addAttribute(getObjectToManage(), "name", "name of the service unit");
- helper.addAttribute(getObjectToManage(), "componentName", "component name of the service unit");
- helper.addAttribute(getObjectToManage(), "serviceAssembly", "service assembly name of the service unit");
- helper.addAttribute(getObjectToManage(), "description", "description of the service unit");
- return helper.getAttributeInfos();
- }
-
- public MBeanOperationInfo[] getOperationInfos() throws JMException {
- OperationInfoHelper helper = new OperationInfoHelper();
- helper.addOperation(getObjectToManage(), "getDescriptor", "retrieve the jbi descriptor for this unit");
- return helper.getOperationInfos();
- }
-
- public Object getObjectToManage() {
- return this;
- }
-
- public String getType() {
- return "ServiceUnit";
- }
-
- public String getSubType() {
- return getComponentName();
- }
-
- public void setPropertyChangeListener(PropertyChangeListener listener) {
- this.listener = listener;
- }
-
- protected void firePropertyChanged(String name,Object oldValue, Object newValue){
- PropertyChangeListener l = listener;
- if (l != null){
- PropertyChangeEvent event = new PropertyChangeEvent(this,name,oldValue,newValue);
- l.propertyChange(event);
- }
- }
-
- public String getKey() {
- return getComponentName() + "/" + getName();
- }
-
- protected void fireEvent(int type) {
- ServiceUnitEvent event = new ServiceUnitEvent(this, type);
- ServiceUnitListener[] listeners = (ServiceUnitListener[]) registry.getContainer().getListeners(ServiceUnitListener.class);
- for (int i = 0; i < listeners.length; i++) {
- switch (type) {
- case ServiceUnitEvent.UNIT_STARTED:
- listeners[i].unitStarted(event);
- break;
- case ServiceUnitEvent.UNIT_STOPPED:
- listeners[i].unitStopped(event);
- break;
- case ServiceUnitEvent.UNIT_SHUTDOWN:
- listeners[i].unitShutDown(event);
- break;
- }
- }
- }
-
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.jbi.framework;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+
+import javax.jbi.component.ServiceUnitManager;
+import javax.jbi.management.DeploymentException;
+import javax.management.JMException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.deployment.Descriptor;
+import org.apache.servicemix.jbi.deployment.DescriptorFactory;
+import org.apache.servicemix.jbi.deployment.ServiceUnit;
+import org.apache.servicemix.jbi.deployment.Services;
+import org.apache.servicemix.jbi.event.ServiceUnitEvent;
+import org.apache.servicemix.jbi.event.ServiceUnitListener;
+import org.apache.servicemix.jbi.management.AttributeInfoHelper;
+import org.apache.servicemix.jbi.management.MBeanInfoProvider;
+import org.apache.servicemix.jbi.management.OperationInfoHelper;
+
+public class ServiceUnitLifeCycle implements ServiceUnitMBean, MBeanInfoProvider {
+
+ private static final Log log = LogFactory.getLog(ServiceUnitLifeCycle.class);
+
+ private ServiceUnit serviceUnit;
+
+ private String currentState = SHUTDOWN;
+
+ private String serviceAssembly;
+
+ private Registry registry;
+
+ private PropertyChangeListener listener;
+
+ private Services services;
+
+ private File rootDir;
+
+ public ServiceUnitLifeCycle(ServiceUnit serviceUnit,
+ String serviceAssembly,
+ Registry registry,
+ File rootDir) {
+ this.serviceUnit = serviceUnit;
+ this.serviceAssembly = serviceAssembly;
+ this.registry = registry;
+ this.rootDir = rootDir;
+ Descriptor d = DescriptorFactory.buildDescriptor(getServiceUnitRootPath());
+ if (d != null) {
+ services = d.getServices();
+ }
+ }
+
+ /**
+ * Initialize the service unit.
+ * @throws DeploymentException
+ */
+ public void init() throws DeploymentException {
+ log.info("Initializing service unit: " + getName());
+ checkComponentStarted("init");
+ ServiceUnitManager sum = getServiceUnitManager();
+ File path = getServiceUnitRootPath();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getComponentClassLoader());
+ sum.init(getName(), path.getAbsolutePath());
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ currentState = STOPPED;
+ }
+
+ /**
+ * Start the service unit.
+ * @throws DeploymentException
+ */
+ public void start() throws DeploymentException {
+ log.info("Starting service unit: " + getName());
+ checkComponentStarted("start");
+ ServiceUnitManager sum = getServiceUnitManager();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getComponentClassLoader());
+ sum.start(getName());
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ currentState = STARTED;
+ }
+
+ /**
+ * Stop the service unit. This suspends current messaging activities.
+ * @throws DeploymentException
+ */
+ public void stop() throws DeploymentException {
+ log.info("Stopping service unit: " + getName());
+ checkComponentStarted("stop");
+ ServiceUnitManager sum = getServiceUnitManager();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getComponentClassLoader());
+ sum.stop(getName());
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ currentState = STOPPED;
+ }
+
+ /**
+ * Shut down the service unit.
+ * This releases resources, preparatory to uninstallation.
+ * @throws DeploymentException
+ */
+ public void shutDown() throws DeploymentException {
+ log.info("Shutting down service unit: " + getName());
+ checkComponentStartedOrStopped("shutDown");
+ ServiceUnitManager sum = getServiceUnitManager();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getComponentClassLoader());
+ sum.shutDown(getName());
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ currentState = SHUTDOWN;
+ }
+
+ /**
+ * @return the currentState as a String
+ */
+ public String getCurrentState() {
+ return currentState;
+ }
+
+ public boolean isShutDown() {
+ return currentState.equals(SHUTDOWN);
+ }
+
+ public boolean isStopped() {
+ return currentState.equals(STOPPED);
+ }
+
+ public boolean isStarted() {
+ return currentState.equals(STARTED);
+ }
+
+ /**
+ * @return the name of the ServiceAssembly
+ */
+ public String getName() {
+ return serviceUnit.getIdentification().getName();
+ }
+
+ /**
+ * @return the description of the ServiceAssembly
+ */
+ public String getDescription() {
+ return serviceUnit.getIdentification().getDescription();
+ }
+
+ public String getComponentName() {
+ return serviceUnit.getTarget().getComponentName();
+ }
+
+ public String getServiceAssembly() {
+ return serviceAssembly;
+ }
+
+ public String getDescriptor() {
+ File suDir = getServiceUnitRootPath();
+ return DescriptorFactory.getDescriptorAsText(suDir);
+ }
+
+ public Services getServices() {
+ return services;
+ }
+
+ protected void checkComponentStarted(String task) throws DeploymentException {
+ String componentName = getComponentName();
+ String suName = getName();
+ ComponentMBeanImpl lcc = registry.getComponent(componentName);
+ if (lcc == null) {
+ throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not installed");
+ }
+ if (!lcc.isStarted()) {
+ throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not started");
+ }
+ if (lcc.getServiceUnitManager() == null) {
+ throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " does not accept deployments");
+ }
+ }
+
+ protected void checkComponentStartedOrStopped(String task) throws DeploymentException {
+ String componentName = getComponentName();
+ String suName = getName();
+ ComponentMBeanImpl lcc = registry.getComponent(componentName);
+ if (lcc == null) {
+ throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not installed");
+ }
+ if (!lcc.isStarted() && !lcc.isStopped()) {
+ throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not started");
+ }
+ if (lcc.getServiceUnitManager() == null) {
+ throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " does not accept deployments");
+ }
+ }
+
+ protected File getServiceUnitRootPath() {
+ return rootDir;
+ }
+
+ protected ServiceUnitManager getServiceUnitManager() {
+ ComponentMBeanImpl lcc = registry.getComponent(getComponentName());
+ return lcc.getServiceUnitManager();
+ }
+
+ protected ClassLoader getComponentClassLoader() {
+ ComponentMBeanImpl lcc = registry.getComponent(getComponentName());
+ // TODO: should retrieve the real component class loader
+ return lcc.getComponent().getClass().getClassLoader();
+ }
+
+ public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
+ AttributeInfoHelper helper = new AttributeInfoHelper();
+ helper.addAttribute(getObjectToManage(), "currentState", "current state of the service unit");
+ helper.addAttribute(getObjectToManage(), "name", "name of the service unit");
+ helper.addAttribute(getObjectToManage(), "componentName", "component name of the service unit");
+ helper.addAttribute(getObjectToManage(), "serviceAssembly", "service assembly name of the service unit");
+ helper.addAttribute(getObjectToManage(), "description", "description of the service unit");
+ return helper.getAttributeInfos();
+ }
+
+ public MBeanOperationInfo[] getOperationInfos() throws JMException {
+ OperationInfoHelper helper = new OperationInfoHelper();
+ helper.addOperation(getObjectToManage(), "getDescriptor", "retrieve the jbi descriptor for this unit");
+ return helper.getOperationInfos();
+ }
+
+ public Object getObjectToManage() {
+ return this;
+ }
+
+ public String getType() {
+ return "ServiceUnit";
+ }
+
+ public String getSubType() {
+ return getComponentName();
+ }
+
+ public void setPropertyChangeListener(PropertyChangeListener listener) {
+ this.listener = listener;
+ }
+
+ protected void firePropertyChanged(String name,Object oldValue, Object newValue){
+ PropertyChangeListener l = listener;
+ if (l != null){
+ PropertyChangeEvent event = new PropertyChangeEvent(this,name,oldValue,newValue);
+ l.propertyChange(event);
+ }
+ }
+
+ public String getKey() {
+ return getComponentName() + "/" + getName();
+ }
+
+ protected void fireEvent(int type) {
+ ServiceUnitEvent event = new ServiceUnitEvent(this, type);
+ ServiceUnitListener[] listeners = (ServiceUnitListener[]) registry.getContainer().getListeners(ServiceUnitListener.class);
+ for (int i = 0; i < listeners.length; i++) {
+ switch (type) {
+ case ServiceUnitEvent.UNIT_STARTED:
+ listeners[i].unitStarted(event);
+ break;
+ case ServiceUnitEvent.UNIT_STOPPED:
+ listeners[i].unitStopped(event);
+ break;
+ case ServiceUnitEvent.UNIT_SHUTDOWN:
+ listeners[i].unitShutDown(event);
+ break;
+ }
+ }
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitLifeCycle.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitMBean.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitMBean.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitMBean.java Thu Jul 27 22:49:32 2006
@@ -1,24 +1,24 @@
-package org.apache.servicemix.jbi.framework;
-
-import javax.jbi.management.DeploymentServiceMBean;
-
-public interface ServiceUnitMBean {
-
- public String getName();
-
- public String getDescription();
-
- public String getComponentName();
-
- public String getCurrentState();
-
- public String getServiceAssembly();
-
- public String getDescriptor();
-
- public static final String STARTED = DeploymentServiceMBean.STARTED;
-
- public static final String SHUTDOWN = DeploymentServiceMBean.SHUTDOWN;
-
- public static final String STOPPED = DeploymentServiceMBean.STOPPED;
-}
+package org.apache.servicemix.jbi.framework;
+
+import javax.jbi.management.DeploymentServiceMBean;
+
+public interface ServiceUnitMBean {
+
+ public String getName();
+
+ public String getDescription();
+
+ public String getComponentName();
+
+ public String getCurrentState();
+
+ public String getServiceAssembly();
+
+ public String getDescriptor();
+
+ public static final String STARTED = DeploymentServiceMBean.STARTED;
+
+ public static final String SHUTDOWN = DeploymentServiceMBean.SHUTDOWN;
+
+ public static final String STOPPED = DeploymentServiceMBean.STOPPED;
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SharedLibrary.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SharedLibrary.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SharedLibrary.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SharedLibrary.java Thu Jul 27 22:49:32 2006
@@ -1,102 +1,102 @@
-package org.apache.servicemix.jbi.framework;
-
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.management.JMException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanOperationInfo;
-
-import org.apache.servicemix.jbi.deployment.ClassPath;
-import org.apache.servicemix.jbi.loaders.JarFileClassLoader;
-import org.apache.servicemix.jbi.management.AttributeInfoHelper;
-import org.apache.servicemix.jbi.management.MBeanInfoProvider;
-
-public class SharedLibrary implements SharedLibraryMBean, MBeanInfoProvider {
-
- private org.apache.servicemix.jbi.deployment.SharedLibrary library;
- private File installationDir;
- private ClassLoader classLoader;
-
- public SharedLibrary(org.apache.servicemix.jbi.deployment.SharedLibrary library,
- File installationDir) {
- this.library = library;
- this.installationDir = installationDir;
- this.classLoader = createClassLoader();
- }
-
- /**
- * @return the library
- */
- public org.apache.servicemix.jbi.deployment.SharedLibrary getLibrary() {
- return library;
- }
-
- public ClassLoader getClassLoader() {
- return this.classLoader;
- }
-
- protected ClassLoader createClassLoader() {
- boolean parentFirst = library.isParentFirstClassLoaderDelegation();
- // Make the current ClassLoader the parent
- ClassLoader parent = getClass().getClassLoader();
-
- ClassPath cp = library.getSharedLibraryClassPath();
- String[] classPathNames = cp.getPathElements();
- URL[] urls = new URL[classPathNames.length];
- for (int i = 0; i < classPathNames.length; i++) {
- File file = new File(installationDir, classPathNames[i]);
- try {
- urls[i] = file.toURL();
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException(classPathNames[i], e);
- }
- }
- return new JarFileClassLoader(
- getName(),
- urls,
- parent,
- !parentFirst,
- new String[0],
- new String[] { "java.", "javax." });
- }
-
- public String getDescription() {
- return library.getIdentification().getDescription();
- }
-
- public String getName() {
- return library.getIdentification().getName();
- }
-
- public Object getObjectToManage() {
- return this;
- }
-
- public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
- AttributeInfoHelper helper = new AttributeInfoHelper();
- helper.addAttribute(getObjectToManage(), "name", "name of the service unit");
- helper.addAttribute(getObjectToManage(), "description", "description of the service unit");
- return helper.getAttributeInfos();
- }
-
- public MBeanOperationInfo[] getOperationInfos() throws JMException {
- return null;
- }
-
- public String getSubType() {
- return null;
- }
-
- public String getType() {
- return "SharedLibrary";
- }
-
- public void setPropertyChangeListener(PropertyChangeListener l) {
- // We do not fire property events, so need to keep
- // a reference
- }
-
-}
+package org.apache.servicemix.jbi.framework;
+
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.management.JMException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+
+import org.apache.servicemix.jbi.deployment.ClassPath;
+import org.apache.servicemix.jbi.loaders.JarFileClassLoader;
+import org.apache.servicemix.jbi.management.AttributeInfoHelper;
+import org.apache.servicemix.jbi.management.MBeanInfoProvider;
+
+public class SharedLibrary implements SharedLibraryMBean, MBeanInfoProvider {
+
+ private org.apache.servicemix.jbi.deployment.SharedLibrary library;
+ private File installationDir;
+ private ClassLoader classLoader;
+
+ public SharedLibrary(org.apache.servicemix.jbi.deployment.SharedLibrary library,
+ File installationDir) {
+ this.library = library;
+ this.installationDir = installationDir;
+ this.classLoader = createClassLoader();
+ }
+
+ /**
+ * @return the library
+ */
+ public org.apache.servicemix.jbi.deployment.SharedLibrary getLibrary() {
+ return library;
+ }
+
+ public ClassLoader getClassLoader() {
+ return this.classLoader;
+ }
+
+ protected ClassLoader createClassLoader() {
+ boolean parentFirst = library.isParentFirstClassLoaderDelegation();
+ // Make the current ClassLoader the parent
+ ClassLoader parent = getClass().getClassLoader();
+
+ ClassPath cp = library.getSharedLibraryClassPath();
+ String[] classPathNames = cp.getPathElements();
+ URL[] urls = new URL[classPathNames.length];
+ for (int i = 0; i < classPathNames.length; i++) {
+ File file = new File(installationDir, classPathNames[i]);
+ try {
+ urls[i] = file.toURL();
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(classPathNames[i], e);
+ }
+ }
+ return new JarFileClassLoader(
+ getName(),
+ urls,
+ parent,
+ !parentFirst,
+ new String[0],
+ new String[] { "java.", "javax." });
+ }
+
+ public String getDescription() {
+ return library.getIdentification().getDescription();
+ }
+
+ public String getName() {
+ return library.getIdentification().getName();
+ }
+
+ public Object getObjectToManage() {
+ return this;
+ }
+
+ public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
+ AttributeInfoHelper helper = new AttributeInfoHelper();
+ helper.addAttribute(getObjectToManage(), "name", "name of the service unit");
+ helper.addAttribute(getObjectToManage(), "description", "description of the service unit");
+ return helper.getAttributeInfos();
+ }
+
+ public MBeanOperationInfo[] getOperationInfos() throws JMException {
+ return null;
+ }
+
+ public String getSubType() {
+ return null;
+ }
+
+ public String getType() {
+ return "SharedLibrary";
+ }
+
+ public void setPropertyChangeListener(PropertyChangeListener l) {
+ // We do not fire property events, so need to keep
+ // a reference
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SharedLibrary.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SharedLibraryMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SharedLibraryMBean.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SharedLibraryMBean.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SharedLibraryMBean.java Thu Jul 27 22:49:32 2006
@@ -1,5 +1,5 @@
-package org.apache.servicemix.jbi.framework;
-
-public interface SharedLibraryMBean {
-
-}
+package org.apache.servicemix.jbi.framework;
+
+public interface SharedLibraryMBean {
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SharedLibraryMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamWriter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamWriter.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamWriter.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamWriter.java Thu Jul 27 22:49:32 2006
@@ -1,22 +1,22 @@
-/*
- * This implementation comes from the XFire project
- * https://svn.codehaus.org/xfire/trunk/xfire/xfire-core/src/main/org/codehaus/xfire/util/stax/
- */
-package org.apache.servicemix.jbi.jaxp;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-public abstract class DOMStreamWriter implements XMLStreamWriter
-{
-
- public void close()
- throws XMLStreamException
- {
- }
-
- public void flush()
- throws XMLStreamException
- {
- }
-}
+/*
+ * This implementation comes from the XFire project
+ * https://svn.codehaus.org/xfire/trunk/xfire/xfire-core/src/main/org/codehaus/xfire/util/stax/
+ */
+package org.apache.servicemix.jbi.jaxp;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+public abstract class DOMStreamWriter implements XMLStreamWriter
+{
+
+ public void close()
+ throws XMLStreamException
+ {
+ }
+
+ public void flush()
+ throws XMLStreamException
+ {
+ }
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamWriter.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamWriter.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamWriter.java Thu Jul 27 22:49:32 2006
@@ -1,270 +1,270 @@
-/*
- * This implementation comes from the XFire project
- * https://svn.codehaus.org/xfire/trunk/xfire/xfire-core/src/main/org/codehaus/xfire/util/stax/
- */
-package org.apache.servicemix.jbi.jaxp;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.XMLStreamException;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class W3CDOMStreamWriter
- extends DOMStreamWriter
-{
- static final String XML_NS = "http://www.w3.org/2000/xmlns/";
- private Stack stack = new Stack();
- private Document document;
- private Element currentNode;
- private NamespaceContext context;
- private Map properties = new HashMap();
-
- public W3CDOMStreamWriter() throws ParserConfigurationException
- {
- this(DocumentBuilderFactory.newInstance().newDocumentBuilder());
- }
-
- public W3CDOMStreamWriter(DocumentBuilder builder)
- {
- document = builder.newDocument();
- }
-
- public W3CDOMStreamWriter(Document document)
- {
- this.document = document;
- }
-
- public Document getDocument()
- {
- return document;
- }
-
- public void writeStartElement(String local)
- throws XMLStreamException
- {
- newChild(document.createElement(local));
- }
-
- private void newChild(Element element)
- {
- if (currentNode != null)
- {
- stack.push(currentNode);
- currentNode.appendChild(element);
- }
- else
- {
- document.appendChild(element);
- }
-
- W3CNamespaceContext context = new W3CNamespaceContext();
- context.setElement(element);
- this.context = context;
-
- currentNode = element;
- }
-
- public void writeStartElement(String namespace, String local)
- throws XMLStreamException
- {
- newChild(document.createElementNS(namespace, local));
- }
-
- public void writeStartElement(String prefix, String local, String namespace)
- throws XMLStreamException
- {
- if (prefix == null || prefix.equals(""))
- {
- writeStartElement(namespace, local);
- }
- else
- {
- newChild(document.createElementNS(namespace, prefix + ":" + local));
- }
- }
-
- public void writeEmptyElement(String namespace, String local)
- throws XMLStreamException
- {
- writeStartElement(namespace, local);
- }
-
- public void writeEmptyElement(String prefix, String namespace, String local)
- throws XMLStreamException
- {
- writeStartElement(prefix, namespace, local);
- }
-
- public void writeEmptyElement(String local)
- throws XMLStreamException
- {
- writeStartElement(local);
- }
-
- public void writeEndElement()
- throws XMLStreamException
- {
- if (stack.size() > 0)
- currentNode = (Element) stack.pop();
- else
- currentNode = null;
- }
-
- public void writeEndDocument()
- throws XMLStreamException
- {
- }
-
- public void writeAttribute(String local, String value)
- throws XMLStreamException
- {
- Attr a = document.createAttribute(local);
- a.setValue(value);
- currentNode.setAttributeNode(a);
- }
-
- public void writeAttribute(String prefix, String namespace, String local, String value)
- throws XMLStreamException
- {
- if (prefix.length() > 0)
- local = prefix + ":" + local;
-
- Attr a = document.createAttributeNS(namespace, local);
- a.setValue(value);
- currentNode.setAttributeNodeNS(a);
- }
-
- public void writeAttribute(String namespace, String local, String value)
- throws XMLStreamException
- {
- Attr a = document.createAttributeNS(namespace, local);
- a.setValue(value);
- currentNode.setAttributeNodeNS(a);
- }
-
- public void writeNamespace(String prefix, String namespace)
- throws XMLStreamException
- {
- if (prefix.length() == 0)
- {
- writeDefaultNamespace(namespace);
- }
- else
- {
- currentNode.setAttributeNS(XML_NS, "xmlns:" + prefix, namespace);
- }
- }
-
- public void writeDefaultNamespace(String namespace)
- throws XMLStreamException
- {
- currentNode.setAttributeNS(XML_NS, "xmlns", namespace);
- }
-
- public void writeComment(String value)
- throws XMLStreamException
- {
- currentNode.appendChild(document.createComment(value));
- }
-
- public void writeProcessingInstruction(String target)
- throws XMLStreamException
- {
- currentNode.appendChild(document.createProcessingInstruction(target, null));
- }
-
- public void writeProcessingInstruction(String target, String data)
- throws XMLStreamException
- {
- currentNode.appendChild(document.createProcessingInstruction(target, data));
- }
-
- public void writeCData(String data)
- throws XMLStreamException
- {
- currentNode.appendChild(document.createCDATASection(data));
- }
-
- public void writeDTD(String arg0)
- throws XMLStreamException
- {
- throw new UnsupportedOperationException();
- }
-
- public void writeEntityRef(String ref)
- throws XMLStreamException
- {
- currentNode.appendChild(document.createEntityReference(ref));
- }
-
- public void writeStartDocument()
- throws XMLStreamException
- {
- }
-
- public void writeStartDocument(String version)
- throws XMLStreamException
- {
- writeStartDocument();
- }
-
- public void writeStartDocument(String encoding, String version)
- throws XMLStreamException
- {
- writeStartDocument();
- }
-
- public void writeCharacters(String text)
- throws XMLStreamException
- {
- currentNode.appendChild(document.createTextNode(text));
- }
-
- public void writeCharacters(char[] text, int start, int len)
- throws XMLStreamException
- {
- writeCharacters(new String(text, start, len));
- }
-
- public String getPrefix(String uri)
- throws XMLStreamException
- {
- return context.getPrefix(uri);
- }
-
- public void setPrefix(String arg0, String arg1)
- throws XMLStreamException
- {
- }
-
- public void setDefaultNamespace(String arg0)
- throws XMLStreamException
- {
- }
-
- public void setNamespaceContext(NamespaceContext context)
- throws XMLStreamException
- {
- this.context = context;
- }
-
- public NamespaceContext getNamespaceContext()
- {
- return context;
- }
-
- public Object getProperty(String prop)
- throws IllegalArgumentException
- {
- return properties.get(prop);
- }
-}
+/*
+ * This implementation comes from the XFire project
+ * https://svn.codehaus.org/xfire/trunk/xfire/xfire-core/src/main/org/codehaus/xfire/util/stax/
+ */
+package org.apache.servicemix.jbi.jaxp;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class W3CDOMStreamWriter
+ extends DOMStreamWriter
+{
+ static final String XML_NS = "http://www.w3.org/2000/xmlns/";
+ private Stack stack = new Stack();
+ private Document document;
+ private Element currentNode;
+ private NamespaceContext context;
+ private Map properties = new HashMap();
+
+ public W3CDOMStreamWriter() throws ParserConfigurationException
+ {
+ this(DocumentBuilderFactory.newInstance().newDocumentBuilder());
+ }
+
+ public W3CDOMStreamWriter(DocumentBuilder builder)
+ {
+ document = builder.newDocument();
+ }
+
+ public W3CDOMStreamWriter(Document document)
+ {
+ this.document = document;
+ }
+
+ public Document getDocument()
+ {
+ return document;
+ }
+
+ public void writeStartElement(String local)
+ throws XMLStreamException
+ {
+ newChild(document.createElement(local));
+ }
+
+ private void newChild(Element element)
+ {
+ if (currentNode != null)
+ {
+ stack.push(currentNode);
+ currentNode.appendChild(element);
+ }
+ else
+ {
+ document.appendChild(element);
+ }
+
+ W3CNamespaceContext context = new W3CNamespaceContext();
+ context.setElement(element);
+ this.context = context;
+
+ currentNode = element;
+ }
+
+ public void writeStartElement(String namespace, String local)
+ throws XMLStreamException
+ {
+ newChild(document.createElementNS(namespace, local));
+ }
+
+ public void writeStartElement(String prefix, String local, String namespace)
+ throws XMLStreamException
+ {
+ if (prefix == null || prefix.equals(""))
+ {
+ writeStartElement(namespace, local);
+ }
+ else
+ {
+ newChild(document.createElementNS(namespace, prefix + ":" + local));
+ }
+ }
+
+ public void writeEmptyElement(String namespace, String local)
+ throws XMLStreamException
+ {
+ writeStartElement(namespace, local);
+ }
+
+ public void writeEmptyElement(String prefix, String namespace, String local)
+ throws XMLStreamException
+ {
+ writeStartElement(prefix, namespace, local);
+ }
+
+ public void writeEmptyElement(String local)
+ throws XMLStreamException
+ {
+ writeStartElement(local);
+ }
+
+ public void writeEndElement()
+ throws XMLStreamException
+ {
+ if (stack.size() > 0)
+ currentNode = (Element) stack.pop();
+ else
+ currentNode = null;
+ }
+
+ public void writeEndDocument()
+ throws XMLStreamException
+ {
+ }
+
+ public void writeAttribute(String local, String value)
+ throws XMLStreamException
+ {
+ Attr a = document.createAttribute(local);
+ a.setValue(value);
+ currentNode.setAttributeNode(a);
+ }
+
+ public void writeAttribute(String prefix, String namespace, String local, String value)
+ throws XMLStreamException
+ {
+ if (prefix.length() > 0)
+ local = prefix + ":" + local;
+
+ Attr a = document.createAttributeNS(namespace, local);
+ a.setValue(value);
+ currentNode.setAttributeNodeNS(a);
+ }
+
+ public void writeAttribute(String namespace, String local, String value)
+ throws XMLStreamException
+ {
+ Attr a = document.createAttributeNS(namespace, local);
+ a.setValue(value);
+ currentNode.setAttributeNodeNS(a);
+ }
+
+ public void writeNamespace(String prefix, String namespace)
+ throws XMLStreamException
+ {
+ if (prefix.length() == 0)
+ {
+ writeDefaultNamespace(namespace);
+ }
+ else
+ {
+ currentNode.setAttributeNS(XML_NS, "xmlns:" + prefix, namespace);
+ }
+ }
+
+ public void writeDefaultNamespace(String namespace)
+ throws XMLStreamException
+ {
+ currentNode.setAttributeNS(XML_NS, "xmlns", namespace);
+ }
+
+ public void writeComment(String value)
+ throws XMLStreamException
+ {
+ currentNode.appendChild(document.createComment(value));
+ }
+
+ public void writeProcessingInstruction(String target)
+ throws XMLStreamException
+ {
+ currentNode.appendChild(document.createProcessingInstruction(target, null));
+ }
+
+ public void writeProcessingInstruction(String target, String data)
+ throws XMLStreamException
+ {
+ currentNode.appendChild(document.createProcessingInstruction(target, data));
+ }
+
+ public void writeCData(String data)
+ throws XMLStreamException
+ {
+ currentNode.appendChild(document.createCDATASection(data));
+ }
+
+ public void writeDTD(String arg0)
+ throws XMLStreamException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void writeEntityRef(String ref)
+ throws XMLStreamException
+ {
+ currentNode.appendChild(document.createEntityReference(ref));
+ }
+
+ public void writeStartDocument()
+ throws XMLStreamException
+ {
+ }
+
+ public void writeStartDocument(String version)
+ throws XMLStreamException
+ {
+ writeStartDocument();
+ }
+
+ public void writeStartDocument(String encoding, String version)
+ throws XMLStreamException
+ {
+ writeStartDocument();
+ }
+
+ public void writeCharacters(String text)
+ throws XMLStreamException
+ {
+ currentNode.appendChild(document.createTextNode(text));
+ }
+
+ public void writeCharacters(char[] text, int start, int len)
+ throws XMLStreamException
+ {
+ writeCharacters(new String(text, start, len));
+ }
+
+ public String getPrefix(String uri)
+ throws XMLStreamException
+ {
+ return context.getPrefix(uri);
+ }
+
+ public void setPrefix(String arg0, String arg1)
+ throws XMLStreamException
+ {
+ }
+
+ public void setDefaultNamespace(String arg0)
+ throws XMLStreamException
+ {
+ }
+
+ public void setNamespaceContext(NamespaceContext context)
+ throws XMLStreamException
+ {
+ this.context = context;
+ }
+
+ public NamespaceContext getNamespaceContext()
+ {
+ return context;
+ }
+
+ public Object getProperty(String prop)
+ throws IllegalArgumentException
+ {
+ return properties.get(prop);
+ }
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/W3CNamespaceContext.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/W3CNamespaceContext.java?rev=426392&r1=426391&r2=426392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/W3CNamespaceContext.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/W3CNamespaceContext.java Thu Jul 27 22:49:32 2006
@@ -1,98 +1,98 @@
-/**
- *
- */
-package org.apache.servicemix.jbi.jaxp;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.NamespaceContext;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-public class W3CNamespaceContext implements NamespaceContext
-{
- private Element currentNode;
-
- public String getNamespaceURI(String prefix)
- {
- String name = prefix;
- if (name.length() == 0) name = "xmlns";
- else name = "xmlns:" + prefix;
-
- return getNamespaceURI(currentNode, name);
- }
-
- private String getNamespaceURI(Element e, String name)
- {
- Attr attr = e.getAttributeNode(name);
- if (attr == null)
- {
- Node n = e.getParentNode();
- if (n instanceof Element && n != e)
- {
- return getNamespaceURI((Element) n, name);
- }
- }
- else
- {
- return attr.getValue();
- }
-
- return null;
- }
-
- public String getPrefix(String uri)
- {
- return getPrefix(currentNode, uri);
- }
-
- private String getPrefix(Element e, String uri)
- {
- NamedNodeMap attributes = e.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++)
- {
- Attr a = (Attr) attributes.item(i);
-
- String val = a.getValue();
- if (val != null && val.equals(uri))
- {
- String name = a.getNodeName();
- if (name.equals("xmlns")) return "";
- else return name.substring(6);
- }
- }
-
- Node n = e.getParentNode();
- if (n instanceof Element && n != e)
- {
- return getPrefix((Element) n, uri);
- }
-
- return null;
- }
-
- public Iterator getPrefixes(String uri)
- {
- List prefixes = new ArrayList();
-
- String prefix = getPrefix(uri);
- if (prefix != null) prefixes.add(prefix);
-
- return prefixes.iterator();
- }
-
- public Element getElement()
- {
- return currentNode;
- }
-
- public void setElement(Element currentNode)
- {
- this.currentNode = currentNode;
- }
+/**
+ *
+ */
+package org.apache.servicemix.jbi.jaxp;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.NamespaceContext;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+public class W3CNamespaceContext implements NamespaceContext
+{
+ private Element currentNode;
+
+ public String getNamespaceURI(String prefix)
+ {
+ String name = prefix;
+ if (name.length() == 0) name = "xmlns";
+ else name = "xmlns:" + prefix;
+
+ return getNamespaceURI(currentNode, name);
+ }
+
+ private String getNamespaceURI(Element e, String name)
+ {
+ Attr attr = e.getAttributeNode(name);
+ if (attr == null)
+ {
+ Node n = e.getParentNode();
+ if (n instanceof Element && n != e)
+ {
+ return getNamespaceURI((Element) n, name);
+ }
+ }
+ else
+ {
+ return attr.getValue();
+ }
+
+ return null;
+ }
+
+ public String getPrefix(String uri)
+ {
+ return getPrefix(currentNode, uri);
+ }
+
+ private String getPrefix(Element e, String uri)
+ {
+ NamedNodeMap attributes = e.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++)
+ {
+ Attr a = (Attr) attributes.item(i);
+
+ String val = a.getValue();
+ if (val != null && val.equals(uri))
+ {
+ String name = a.getNodeName();
+ if (name.equals("xmlns")) return "";
+ else return name.substring(6);
+ }
+ }
+
+ Node n = e.getParentNode();
+ if (n instanceof Element && n != e)
+ {
+ return getPrefix((Element) n, uri);
+ }
+
+ return null;
+ }
+
+ public Iterator getPrefixes(String uri)
+ {
+ List prefixes = new ArrayList();
+
+ String prefix = getPrefix(uri);
+ if (prefix != null) prefixes.add(prefix);
+
+ return prefixes.iterator();
+ }
+
+ public Element getElement()
+ {
+ return currentNode;
+ }
+
+ public void setElement(Element currentNode)
+ {
+ this.currentNode = currentNode;
+ }
}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/W3CNamespaceContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/AbstractResourceHandle.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/AbstractUrlResourceLocation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/DestroyableClassLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/DirectoryResourceHandle.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/DirectoryResourceLocation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/IoUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/JarFileClassLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/JarFileUrlConnection.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/JarFileUrlStreamHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/JarResourceHandle.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/loaders/JarResourceLocation.java
------------------------------------------------------------------------------
svn:eol-style = native