[jboss-cvs] JBossAS SVN: r81028 - in trunk/profileservice/src: main/org/jboss/profileservice/management and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 14 07:52:00 EST 2008
Author: dimitris at jboss.org
Date: 2008-11-14 07:52:00 -0500 (Fri, 14 Nov 2008)
New Revision: 81028
Modified:
trunk/profileservice/src/main/org/jboss/managed/plugins/advice/TraceAdvice.java
trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperAdvice.java
trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperIterator.java
trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperSet.java
trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java
trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java
trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java
Log:
JBAS-3916, use the right copyright header
Modified: trunk/profileservice/src/main/org/jboss/managed/plugins/advice/TraceAdvice.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/managed/plugins/advice/TraceAdvice.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/managed/plugins/advice/TraceAdvice.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,99 +1,99 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.managed.plugins.advice;
-
-import java.util.Arrays;
-
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.logging.Logger;
-
-/**
- * TraceAdvice.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class TraceAdvice
-{
- /** The log */
- private static final Logger log = Logger.getLogger(TraceAdvice.class);
-
- /**
- * Interceptor
- *
- * @param invocation the invocation
- * @return the result
- * @throws Throwable for any problem
- */
- public Object invoke(Invocation invocation) throws Throwable
- {
- boolean trace = log.isTraceEnabled();
- if (trace)
- logMethod(false, invocation, null, null);
-
- Throwable e = null;
- Object result = null;
- try
- {
- result = invocation.invokeNext();
- return result;
- }
- catch (Throwable t)
- {
- e = t;
- throw t;
- }
- finally
- {
- logMethod(true, invocation, result, e);
- }
- }
-
- private void logMethod(boolean beforeAfter, Invocation invocation, Object result, Throwable t)
- {
- MethodInvocation mi = (MethodInvocation) invocation;
- StringBuilder builder = new StringBuilder();
- Object target = mi.getTargetObject();
- builder.append(target.getClass().getSimpleName());
- builder.append('@');
- builder.append(System.identityHashCode(target));
- if (beforeAfter == false)
- builder.append(" before ");
- else
- builder.append(" after ");
- builder.append(mi.getActualMethod().getName());
- if (beforeAfter == false)
- {
- builder.append(" params=");
- builder.append(Arrays.asList(mi.getArguments()));
- }
- else if (t == null)
- {
- builder.append(" result=");
- builder.append(result);
- }
- if (t != null)
- builder.append(" ended in error:");
- log.trace(builder.toString(), t);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.managed.plugins.advice;
+
+import java.util.Arrays;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.logging.Logger;
+
+/**
+ * TraceAdvice.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TraceAdvice
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(TraceAdvice.class);
+
+ /**
+ * Interceptor
+ *
+ * @param invocation the invocation
+ * @return the result
+ * @throws Throwable for any problem
+ */
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ logMethod(false, invocation, null, null);
+
+ Throwable e = null;
+ Object result = null;
+ try
+ {
+ result = invocation.invokeNext();
+ return result;
+ }
+ catch (Throwable t)
+ {
+ e = t;
+ throw t;
+ }
+ finally
+ {
+ logMethod(true, invocation, result, e);
+ }
+ }
+
+ private void logMethod(boolean beforeAfter, Invocation invocation, Object result, Throwable t)
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ StringBuilder builder = new StringBuilder();
+ Object target = mi.getTargetObject();
+ builder.append(target.getClass().getSimpleName());
+ builder.append('@');
+ builder.append(System.identityHashCode(target));
+ if (beforeAfter == false)
+ builder.append(" before ");
+ else
+ builder.append(" after ");
+ builder.append(mi.getActualMethod().getName());
+ if (beforeAfter == false)
+ {
+ builder.append(" params=");
+ builder.append(Arrays.asList(mi.getArguments()));
+ }
+ else if (t == null)
+ {
+ builder.append(" result=");
+ builder.append(result);
+ }
+ if (t != null)
+ builder.append(" ended in error:");
+ log.trace(builder.toString(), t);
+ }
+}
Modified: trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperAdvice.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperAdvice.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperAdvice.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,139 +1,139 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.managed.plugins.advice;
-
-import java.util.Set;
-
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-
-/**
- * WrapperAdvice, intercepts methods that produce objects
- * that require proxies.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 63962 $
- */
-public class WrapperAdvice
-{
- /**
- * Wrap a managed object
- *
- * @param managedObject the managed object
- * @return the managed object wrapper
- */
- public static ManagedObject wrapManagedObject(ManagedObject managedObject)
- {
- return createProxy(managedObject, ManagedObject.class);
- }
-
- /**
- * Wrap a managed property
- *
- * @param managedProperty the managed property
- * @return the managed property wrapper
- */
- public static ManagedProperty wrapManagedProperty(ManagedProperty managedProperty)
- {
- return createProxy(managedProperty, ManagedProperty.class);
- }
-
- /**
- * Wrap fields
- *
- * @param fields the fields
- * @return the fields wrapper
- */
- public static Fields wrapFields(Fields fields)
- {
- return createProxy(fields, Fields.class);
- }
-
- /**
- * Wrap a returned managed object
- *
- * @param invocation the invocation
- * @return the wrapped managed object
- * @throws Throwable for any error
- */
- public ManagedObject wrapManagedObject(Invocation invocation) throws Throwable
- {
- ManagedObject result = (ManagedObject) invocation.invokeNext();
- return wrapManagedObject(result);
- }
-
- /**
- * Wrap a returned managed property
- *
- * @param invocation the invocation
- * @return the wrapped managed property
- * @throws Throwable for any error
- */
- public ManagedProperty wrapManagedProperty(Invocation invocation) throws Throwable
- {
- ManagedProperty result = (ManagedProperty) invocation.invokeNext();
- return wrapManagedProperty(result);
- }
-
- /**
- * Wrap a returned managed property set
- *
- * @param invocation the invocation
- * @return the wrapped managed property set
- * @throws Throwable for any error
- */
- @SuppressWarnings("unchecked")
- public Set<ManagedProperty> wrapManagedPropertySet(Invocation invocation) throws Throwable
- {
- Set<ManagedProperty> result = (Set<ManagedProperty>) invocation.invokeNext();
- return new WrapperSet<ManagedProperty>(result, ManagedProperty.class);
- }
-
- /**
- * Wrap fields
- *
- * @param invocation the invocation
- * @return the wrapped managed property
- * @throws Throwable for any error
- */
- public Fields wrapFields(Invocation invocation) throws Throwable
- {
- Fields result = (Fields) invocation.invokeNext();
- return wrapFields(result);
- }
-
- /**
- * Create a proxy
- *
- * @param <T> the expected type
- * @param target the target
- * @param interfaceClass the interface class
- * @return the proxy
- */
- static <T> T createProxy(T target, Class<T> interfaceClass)
- {
- return GeneratedAOPProxyFactory.createProxy(target, interfaceClass);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.managed.plugins.advice;
+
+import java.util.Set;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+
+/**
+ * WrapperAdvice, intercepts methods that produce objects
+ * that require proxies.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 63962 $
+ */
+public class WrapperAdvice
+{
+ /**
+ * Wrap a managed object
+ *
+ * @param managedObject the managed object
+ * @return the managed object wrapper
+ */
+ public static ManagedObject wrapManagedObject(ManagedObject managedObject)
+ {
+ return createProxy(managedObject, ManagedObject.class);
+ }
+
+ /**
+ * Wrap a managed property
+ *
+ * @param managedProperty the managed property
+ * @return the managed property wrapper
+ */
+ public static ManagedProperty wrapManagedProperty(ManagedProperty managedProperty)
+ {
+ return createProxy(managedProperty, ManagedProperty.class);
+ }
+
+ /**
+ * Wrap fields
+ *
+ * @param fields the fields
+ * @return the fields wrapper
+ */
+ public static Fields wrapFields(Fields fields)
+ {
+ return createProxy(fields, Fields.class);
+ }
+
+ /**
+ * Wrap a returned managed object
+ *
+ * @param invocation the invocation
+ * @return the wrapped managed object
+ * @throws Throwable for any error
+ */
+ public ManagedObject wrapManagedObject(Invocation invocation) throws Throwable
+ {
+ ManagedObject result = (ManagedObject) invocation.invokeNext();
+ return wrapManagedObject(result);
+ }
+
+ /**
+ * Wrap a returned managed property
+ *
+ * @param invocation the invocation
+ * @return the wrapped managed property
+ * @throws Throwable for any error
+ */
+ public ManagedProperty wrapManagedProperty(Invocation invocation) throws Throwable
+ {
+ ManagedProperty result = (ManagedProperty) invocation.invokeNext();
+ return wrapManagedProperty(result);
+ }
+
+ /**
+ * Wrap a returned managed property set
+ *
+ * @param invocation the invocation
+ * @return the wrapped managed property set
+ * @throws Throwable for any error
+ */
+ @SuppressWarnings("unchecked")
+ public Set<ManagedProperty> wrapManagedPropertySet(Invocation invocation) throws Throwable
+ {
+ Set<ManagedProperty> result = (Set<ManagedProperty>) invocation.invokeNext();
+ return new WrapperSet<ManagedProperty>(result, ManagedProperty.class);
+ }
+
+ /**
+ * Wrap fields
+ *
+ * @param invocation the invocation
+ * @return the wrapped managed property
+ * @throws Throwable for any error
+ */
+ public Fields wrapFields(Invocation invocation) throws Throwable
+ {
+ Fields result = (Fields) invocation.invokeNext();
+ return wrapFields(result);
+ }
+
+ /**
+ * Create a proxy
+ *
+ * @param <T> the expected type
+ * @param target the target
+ * @param interfaceClass the interface class
+ * @return the proxy
+ */
+ static <T> T createProxy(T target, Class<T> interfaceClass)
+ {
+ return GeneratedAOPProxyFactory.createProxy(target, interfaceClass);
+ }
+}
Modified: trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperIterator.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperIterator.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperIterator.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,73 +1,73 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.managed.plugins.advice;
-
-import java.util.Iterator;
-
-/**
- * WrapperIterator.
- *
- * @param <T> the interface
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class WrapperIterator<T> implements Iterator<T>
-{
- /** The delegate */
- private Iterator<T> delegate;
-
- /** The interface class */
- private Class<T> interfaceClass;
-
- /**
- * Create a new WrapperIterator.
- *
- * @param delegate the delegate
- * @param interfaceClass the interface class
- */
- public WrapperIterator(Iterator<T> delegate, Class<T> interfaceClass)
- {
- if (delegate == null)
- throw new IllegalArgumentException("Null delegate");
- if (interfaceClass == null)
- throw new IllegalArgumentException("Null interface class");
-
- this.delegate = delegate;
- this.interfaceClass = interfaceClass;
- }
-
- public boolean hasNext()
- {
- return delegate.hasNext();
- }
-
- public T next()
- {
- T next = delegate.next();
- return WrapperAdvice.createProxy(next, interfaceClass);
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.managed.plugins.advice;
+
+import java.util.Iterator;
+
+/**
+ * WrapperIterator.
+ *
+ * @param <T> the interface
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class WrapperIterator<T> implements Iterator<T>
+{
+ /** The delegate */
+ private Iterator<T> delegate;
+
+ /** The interface class */
+ private Class<T> interfaceClass;
+
+ /**
+ * Create a new WrapperIterator.
+ *
+ * @param delegate the delegate
+ * @param interfaceClass the interface class
+ */
+ public WrapperIterator(Iterator<T> delegate, Class<T> interfaceClass)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Null delegate");
+ if (interfaceClass == null)
+ throw new IllegalArgumentException("Null interface class");
+
+ this.delegate = delegate;
+ this.interfaceClass = interfaceClass;
+ }
+
+ public boolean hasNext()
+ {
+ return delegate.hasNext();
+ }
+
+ public T next()
+ {
+ T next = delegate.next();
+ return WrapperAdvice.createProxy(next, interfaceClass);
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Modified: trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperSet.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperSet.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/managed/plugins/advice/WrapperSet.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,73 +1,73 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.managed.plugins.advice;
-
-import java.io.Serializable;
-import java.util.AbstractSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * WrapperSet.
- *
- * @param <T> the interface type
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-class WrapperSet<T> extends AbstractSet<T> implements Serializable
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = -5588975054846538928L;
-
- /** The delegate */
- private Set<T> delegate;
-
- /** The interface class */
- private Class<T> interfaceClass;
-
- /**
- * Create a new WrapperSet.
- *
- * @param delegate the delegate
- * @param interfaceClass the interface class
- */
- public WrapperSet(Set<T> delegate, Class<T> interfaceClass)
- {
- if (delegate == null)
- throw new IllegalArgumentException("Null delegate");
- if (interfaceClass == null)
- throw new IllegalArgumentException("Null interface class");
-
- this.delegate = delegate;
- this.interfaceClass = interfaceClass;
- }
-
- public Iterator<T> iterator()
- {
- return new WrapperIterator<T>(delegate.iterator(), interfaceClass);
- }
-
- public int size()
- {
- return delegate.size();
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.managed.plugins.advice;
+
+import java.io.Serializable;
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * WrapperSet.
+ *
+ * @param <T> the interface type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+class WrapperSet<T> extends AbstractSet<T> implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -5588975054846538928L;
+
+ /** The delegate */
+ private Set<T> delegate;
+
+ /** The interface class */
+ private Class<T> interfaceClass;
+
+ /**
+ * Create a new WrapperSet.
+ *
+ * @param delegate the delegate
+ * @param interfaceClass the interface class
+ */
+ public WrapperSet(Set<T> delegate, Class<T> interfaceClass)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Null delegate");
+ if (interfaceClass == null)
+ throw new IllegalArgumentException("Null interface class");
+
+ this.delegate = delegate;
+ this.interfaceClass = interfaceClass;
+ }
+
+ public Iterator<T> iterator()
+ {
+ return new WrapperIterator<T>(delegate.iterator(), interfaceClass);
+ }
+
+ public int size()
+ {
+ return delegate.size();
+ }
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.profileservice.management;
import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.profileservice.management;
import java.lang.reflect.UndeclaredThrowableException;
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,8 +1,8 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.profileservice.management.templates;
import java.io.File;
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.profileservice.management.templates;
import java.lang.annotation.Annotation;
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,264 +1,264 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload;
-
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
-import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.management.upload.remoting.DeployHandler;
-import org.jboss.profileservice.management.upload.remoting.StreamingDeploymentTarget;
-import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
-import org.jboss.profileservice.spi.NoSuchProfileException;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.remoting.InvokerLocator;
-
-/**
- * The remoting base DeploymentManager implementation
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class DeploymentManagerImpl implements DeploymentManager
-{
- private static Logger log = Logger.getLogger(DeploymentManagerImpl.class);
- private static final String BUNDLE_NAME = "org.jboss.profileservice.management.upload.messages"; //$NON-NLS-1$
- /** */
- private ProfileService ps;
- /** The currently loaded profile */
- private Profile activeProfile;
- private DeploymentRepositoryFactory repositoryFactory;
- private DeployHandler deployHandler;
-
- /** */
- private ResourceBundle i18n;
- /** */
- private Locale currentLocale;
- /** */
- private MessageFormat formatter = new MessageFormat("");
- private InvokerLocator locator;
- private String remotingSubsystem = "DeploymentManager";
-
- public DeploymentManagerImpl()
- {
- currentLocale = Locale.getDefault();
- formatter.setLocale(currentLocale);
- i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
- }
-
-
- public ProfileService getProfileService()
- {
- return ps;
- }
- public void setProfileService(ProfileService ps)
- {
- this.ps = ps;
- }
-
- public DeploymentRepositoryFactory getRepositoryFactory()
- {
- return repositoryFactory;
- }
- public void setRepositoryFactory(DeploymentRepositoryFactory repositoryFactory)
- {
- this.repositoryFactory = repositoryFactory;
- }
-
- public DeployHandler getDeployHandler()
- {
- return deployHandler;
- }
- public void setDeployHandler(DeployHandler deployHandler)
- {
- this.deployHandler = deployHandler;
- }
-
- public InvokerLocator getLocator()
- {
- return locator;
- }
- public void setLocator(InvokerLocator locator)
- {
- this.locator = locator;
- }
-
- public String getRemotingSubsystem()
- {
- return remotingSubsystem;
- }
- public void setRemotingSubsystem(String remotingSubsystem)
- {
- this.remotingSubsystem = remotingSubsystem;
- }
-
- public DeploymentProgress distribute(String name, DeploymentPhase phase, URL contentURL)
- throws Exception
- {
- return distribute(name, phase, contentURL, true);
- }
-
- public DeploymentProgress distribute(String name, DeploymentPhase phase, URL contentURL, boolean copyContent)
- throws Exception
- {
- if(activeProfile == null)
- {
- formatter.applyPattern(i18n.getString("DeploymentManager.NoProfileLoadedException")); //$NON-NLS-1$
- Object[] args = {};
- String msg = formatter.format(args);
- throw new NoSuchProfileException(msg);
- }
-
- List<DeploymentTarget> targets = getDeploymentTargets();
- SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, contentURL.toString());
- deployment.setContentURL(contentURL);
- deployment.setCopyContent(copyContent);
- return new DeploymentProgressImpl(targets, deployment, CommandType.DISTRIBUTE);
- }
-
- public String[] getRepositoryNames(String[] names, DeploymentPhase phase) throws Exception
- {
- List<DeploymentTarget> targets = getDeploymentTargets();
- return targets.get(0).getRepositoryNames(names, phase);
- }
-
- public boolean isRedeploySupported()
- {
- return false;
- }
-
- public void loadProfile(ProfileKey key, boolean allowHotDeployments)
- throws Exception
- {
- activeProfile = ps.getProfile(key);
- if( activeProfile == null )
- {
- formatter.applyPattern(i18n.getString("DeploymentManager.NoSuchProfileException")); //$NON-NLS-1$
- Object[] args = {key};
- String msg = formatter.format(args);
- throw new NoSuchProfileException(msg);
- }
- log.debug("Loading profile, key: "+key+", allowHotDeployments: "+allowHotDeployments);
- activeProfile.enableModifiedDeploymentChecks(allowHotDeployments);
- // Set the deployment repository on the handler
- DeploymentRepository repository = repositoryFactory.getDeploymentRepository(key);
- log.debug("DeploymentRepository for profile: "+repository);
- deployHandler.setDeploymentRepository(repository);
- }
-
- public void releaseProfile(ProfileKey key, boolean allowHotDeployments)
- throws Exception
- {
- activeProfile = ps.getProfile(key);
- if( activeProfile == null )
- {
- formatter.applyPattern(i18n.getString("DeploymentManager.NoSuchProfileException")); //$NON-NLS-1$
- Object[] args = {key};
- String msg = formatter.format(args);
- throw new NoSuchProfileException(msg);
- }
- log.debug("Releasing profile, key: "+key);
- activeProfile.enableModifiedDeploymentChecks(allowHotDeployments);
- deployHandler.setDeploymentRepository(null);
- }
-
- public DeploymentProgress redeploy(String name, DeploymentPhase phase, URL contentURL)
- throws Exception
- {
- if(activeProfile == null)
- {
- formatter.applyPattern(i18n.getString("DeploymentManager.NoProfileLoadedException")); //$NON-NLS-1$
- Object[] args = {};
- String msg = formatter.format(args);
- throw new NoSuchProfileException(msg);
- }
-
- List<DeploymentTarget> targets = getDeploymentTargets();
- SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, null);
- return new DeploymentProgressImpl(targets, deployment, CommandType.REDEPLOY);
- }
-
- public DeploymentProgress prepare(DeploymentPhase phase, String... names) throws Exception
- {
- return doProgress(CommandType.PREPARE, phase, names);
- }
-
- public DeploymentProgress start(DeploymentPhase phase, String... names) throws Exception
- {
- return doProgress(CommandType.START, phase, names);
- }
-
- public DeploymentProgress stop(DeploymentPhase phase, String... names) throws Exception
- {
- return doProgress(CommandType.STOP, phase, names);
- }
-
- public DeploymentProgress undeploy(DeploymentPhase phase, String... names) throws Exception
- {
- return doProgress(CommandType.UNDEPLOY, phase, names);
- }
-
- protected DeploymentProgress doProgress(CommandType type, DeploymentPhase phase, String... names)
- throws Exception
- {
- if(activeProfile == null)
- {
- formatter.applyPattern(i18n.getString("DeploymentManager.NoProfileLoadedException")); //$NON-NLS-1$
- Object[] args = {};
- String msg = formatter.format(args);
- throw new NoSuchProfileException(msg);
- }
-
- if (names == null || names.length == 0)
- log.warn("Null or empty names.");
-
- List<DeploymentTarget> targets = getDeploymentTargets();
- SerializableDeploymentID deployment = new SerializableDeploymentID(names, phase, null);
- return new DeploymentProgressImpl(targets, deployment, type);
- }
-
- /**
- * TODO: should the targets include cluster info
- * @param name
- * @return
- */
- protected List<DeploymentTarget> getDeploymentTargets()
- {
- String targetName = locator.getHost();
- List<DeploymentTarget> targets = new ArrayList<DeploymentTarget>();
- StreamingDeploymentTarget hostTarget = new StreamingDeploymentTarget(locator, targetName, remotingSubsystem);
- targets.add(hostTarget);
- return targets;
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.upload;
+
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.management.upload.remoting.DeployHandler;
+import org.jboss.profileservice.management.upload.remoting.StreamingDeploymentTarget;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * The remoting base DeploymentManager implementation
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class DeploymentManagerImpl implements DeploymentManager
+{
+ private static Logger log = Logger.getLogger(DeploymentManagerImpl.class);
+ private static final String BUNDLE_NAME = "org.jboss.profileservice.management.upload.messages"; //$NON-NLS-1$
+ /** */
+ private ProfileService ps;
+ /** The currently loaded profile */
+ private Profile activeProfile;
+ private DeploymentRepositoryFactory repositoryFactory;
+ private DeployHandler deployHandler;
+
+ /** */
+ private ResourceBundle i18n;
+ /** */
+ private Locale currentLocale;
+ /** */
+ private MessageFormat formatter = new MessageFormat("");
+ private InvokerLocator locator;
+ private String remotingSubsystem = "DeploymentManager";
+
+ public DeploymentManagerImpl()
+ {
+ currentLocale = Locale.getDefault();
+ formatter.setLocale(currentLocale);
+ i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
+ }
+
+
+ public ProfileService getProfileService()
+ {
+ return ps;
+ }
+ public void setProfileService(ProfileService ps)
+ {
+ this.ps = ps;
+ }
+
+ public DeploymentRepositoryFactory getRepositoryFactory()
+ {
+ return repositoryFactory;
+ }
+ public void setRepositoryFactory(DeploymentRepositoryFactory repositoryFactory)
+ {
+ this.repositoryFactory = repositoryFactory;
+ }
+
+ public DeployHandler getDeployHandler()
+ {
+ return deployHandler;
+ }
+ public void setDeployHandler(DeployHandler deployHandler)
+ {
+ this.deployHandler = deployHandler;
+ }
+
+ public InvokerLocator getLocator()
+ {
+ return locator;
+ }
+ public void setLocator(InvokerLocator locator)
+ {
+ this.locator = locator;
+ }
+
+ public String getRemotingSubsystem()
+ {
+ return remotingSubsystem;
+ }
+ public void setRemotingSubsystem(String remotingSubsystem)
+ {
+ this.remotingSubsystem = remotingSubsystem;
+ }
+
+ public DeploymentProgress distribute(String name, DeploymentPhase phase, URL contentURL)
+ throws Exception
+ {
+ return distribute(name, phase, contentURL, true);
+ }
+
+ public DeploymentProgress distribute(String name, DeploymentPhase phase, URL contentURL, boolean copyContent)
+ throws Exception
+ {
+ if(activeProfile == null)
+ {
+ formatter.applyPattern(i18n.getString("DeploymentManager.NoProfileLoadedException")); //$NON-NLS-1$
+ Object[] args = {};
+ String msg = formatter.format(args);
+ throw new NoSuchProfileException(msg);
+ }
+
+ List<DeploymentTarget> targets = getDeploymentTargets();
+ SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, contentURL.toString());
+ deployment.setContentURL(contentURL);
+ deployment.setCopyContent(copyContent);
+ return new DeploymentProgressImpl(targets, deployment, CommandType.DISTRIBUTE);
+ }
+
+ public String[] getRepositoryNames(String[] names, DeploymentPhase phase) throws Exception
+ {
+ List<DeploymentTarget> targets = getDeploymentTargets();
+ return targets.get(0).getRepositoryNames(names, phase);
+ }
+
+ public boolean isRedeploySupported()
+ {
+ return false;
+ }
+
+ public void loadProfile(ProfileKey key, boolean allowHotDeployments)
+ throws Exception
+ {
+ activeProfile = ps.getProfile(key);
+ if( activeProfile == null )
+ {
+ formatter.applyPattern(i18n.getString("DeploymentManager.NoSuchProfileException")); //$NON-NLS-1$
+ Object[] args = {key};
+ String msg = formatter.format(args);
+ throw new NoSuchProfileException(msg);
+ }
+ log.debug("Loading profile, key: "+key+", allowHotDeployments: "+allowHotDeployments);
+ activeProfile.enableModifiedDeploymentChecks(allowHotDeployments);
+ // Set the deployment repository on the handler
+ DeploymentRepository repository = repositoryFactory.getDeploymentRepository(key);
+ log.debug("DeploymentRepository for profile: "+repository);
+ deployHandler.setDeploymentRepository(repository);
+ }
+
+ public void releaseProfile(ProfileKey key, boolean allowHotDeployments)
+ throws Exception
+ {
+ activeProfile = ps.getProfile(key);
+ if( activeProfile == null )
+ {
+ formatter.applyPattern(i18n.getString("DeploymentManager.NoSuchProfileException")); //$NON-NLS-1$
+ Object[] args = {key};
+ String msg = formatter.format(args);
+ throw new NoSuchProfileException(msg);
+ }
+ log.debug("Releasing profile, key: "+key);
+ activeProfile.enableModifiedDeploymentChecks(allowHotDeployments);
+ deployHandler.setDeploymentRepository(null);
+ }
+
+ public DeploymentProgress redeploy(String name, DeploymentPhase phase, URL contentURL)
+ throws Exception
+ {
+ if(activeProfile == null)
+ {
+ formatter.applyPattern(i18n.getString("DeploymentManager.NoProfileLoadedException")); //$NON-NLS-1$
+ Object[] args = {};
+ String msg = formatter.format(args);
+ throw new NoSuchProfileException(msg);
+ }
+
+ List<DeploymentTarget> targets = getDeploymentTargets();
+ SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, null);
+ return new DeploymentProgressImpl(targets, deployment, CommandType.REDEPLOY);
+ }
+
+ public DeploymentProgress prepare(DeploymentPhase phase, String... names) throws Exception
+ {
+ return doProgress(CommandType.PREPARE, phase, names);
+ }
+
+ public DeploymentProgress start(DeploymentPhase phase, String... names) throws Exception
+ {
+ return doProgress(CommandType.START, phase, names);
+ }
+
+ public DeploymentProgress stop(DeploymentPhase phase, String... names) throws Exception
+ {
+ return doProgress(CommandType.STOP, phase, names);
+ }
+
+ public DeploymentProgress undeploy(DeploymentPhase phase, String... names) throws Exception
+ {
+ return doProgress(CommandType.UNDEPLOY, phase, names);
+ }
+
+ protected DeploymentProgress doProgress(CommandType type, DeploymentPhase phase, String... names)
+ throws Exception
+ {
+ if(activeProfile == null)
+ {
+ formatter.applyPattern(i18n.getString("DeploymentManager.NoProfileLoadedException")); //$NON-NLS-1$
+ Object[] args = {};
+ String msg = formatter.format(args);
+ throw new NoSuchProfileException(msg);
+ }
+
+ if (names == null || names.length == 0)
+ log.warn("Null or empty names.");
+
+ List<DeploymentTarget> targets = getDeploymentTargets();
+ SerializableDeploymentID deployment = new SerializableDeploymentID(names, phase, null);
+ return new DeploymentProgressImpl(targets, deployment, type);
+ }
+
+ /**
+ * TODO: should the targets include cluster info
+ * @param name
+ * @return
+ */
+ protected List<DeploymentTarget> getDeploymentTargets()
+ {
+ String targetName = locator.getHost();
+ List<DeploymentTarget> targets = new ArrayList<DeploymentTarget>();
+ StreamingDeploymentTarget hostTarget = new StreamingDeploymentTarget(locator, targetName, remotingSubsystem);
+ targets.add(hostTarget);
+ return targets;
+ }
+
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,335 +1,335 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus.StateType;
-import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-import org.jboss.deployers.spi.management.deploy.ProgressEvent;
-import org.jboss.deployers.spi.management.deploy.ProgressListener;
-
-/**
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class DeploymentProgressImpl implements DeploymentProgress, Serializable
-{
- private static final long serialVersionUID = 1;
-
- /** The client side listeners */
- private transient CopyOnWriteArrayList<ProgressListener> listeners = new CopyOnWriteArrayList<ProgressListener>();
- private transient DeploymentStatus currentStatus;
- private transient boolean isCancelled;
- /** The targets to distribute to */
- private List<DeploymentTarget> targets;
- /** The deployment being distributed */
- private DeploymentID deployment;
- private CommandType command;
-
- public DeploymentProgressImpl(List<DeploymentTarget> targets, DeploymentID deployment, CommandType command)
- {
- this.targets = targets;
- this.deployment = deployment;
- this.command = command;
- }
-
- public synchronized void addProgressListener(ProgressListener listener)
- {
- if(listeners == null)
- listeners = new CopyOnWriteArrayList<ProgressListener>();
- listeners.add(listener);
- }
- public void removeProgressListener(ProgressListener listener)
- {
- listeners.remove(listener);
- }
-
- /**
- * Begins the deployment command process
- */
- public void run()
- {
- switch(command)
- {
- case DISTRIBUTE:
- distribute();
- break;
- case START:
- start();
- break;
- case STOP:
- stop();
- break;
- case UNDEPLOY:
- undeploy();
- break;
- default:
- throw new IllegalStateException(command+" is not currently handled");
- }
- }
-
- public void cancel()
- {
- isCancelled = true;
- }
-
- public DeploymentStatus getDeploymentStatus()
- {
- return currentStatus;
- }
-
- public DeploymentID getDeploymentID()
- {
- return deployment;
- }
-
- public List<DeploymentTarget> getDeploymentTargets()
- {
- return targets;
- }
-
- /**
- *
- * @param event
- */
- protected void notify(ProgressEvent event)
- {
- if(listeners == null)
- return;
-
- for(ProgressListener listener : listeners)
- {
- try
- {
- listener.progressEvent(event);
- }
- catch(Throwable ignore)
- {
- }
- }
- }
-
- protected void distribute()
- {
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
- status.setMessage("Running distribute to: "+targets);
- currentStatus = status;
- ProgressEvent event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- for(DeploymentTarget target : targets)
- {
- if(isCancelled)
- {
- status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
- status.setMessage("Distribute has been cancelled");
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- break;
- }
-
- try
- {
- // TODO, percent complete info in upload and overall distribute
- status = new SerializableDeploymentStatus(command, StateType.UPLOADING);
- status.setTarget(target);
- status.setMessage("Begining distribute to target: "+target);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
-
- // TODO, cancellation of in progress distribution
- target.distribute(deployment);
- status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
- status.setTarget(target);
- status.setMessage("Completed distribute to target: "+target);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- catch(Exception e)
- {
- status = new SerializableDeploymentStatus(command, StateType.FAILED);
- status.setTarget(target);
- status.setFailure(e);
- status.setFailed(true);
- currentStatus = status;
- ProgressEvent error = new ProgressEvent(deployment, currentStatus);
- notify(error);
- break;
- }
- }
-
- if(currentStatus.isFailed() == false)
- {
- status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
- status.setMessage("Completed distribute to all targets");
- status.setCompleted(true);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- }
-
- protected void start()
- {
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
- status.setMessage("Running start to: "+targets);
- currentStatus = status;
- ProgressEvent event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- for(DeploymentTarget target : targets)
- {
- if(isCancelled)
- {
- status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
- status.setMessage("Start has been cancelled");
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- break;
- }
-
- try
- {
- target.start(deployment);
- status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
- status.setTarget(target);
- status.setMessage("Completed start for target: "+target);
- status.setCompleted(true);
- status.setRunning(true);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- catch(Exception e)
- {
- status = new SerializableDeploymentStatus(command, StateType.FAILED);
- status.setTarget(target);
- status.setFailure(e);
- status.setFailed(true);
- currentStatus = status;
- ProgressEvent error = new ProgressEvent(deployment, currentStatus);
- notify(error);
- break;
- }
- }
- }
-
- protected void stop()
- {
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
- status.setMessage("Running stop to: "+targets);
- currentStatus = status;
- ProgressEvent event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- for(DeploymentTarget target : targets)
- {
- if(isCancelled)
- {
- status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
- status.setMessage("Stop has been cancelled");
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- break;
- }
-
- try
- {
- target.stop(deployment);
- status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
- status.setTarget(target);
- status.setMessage("Completed stop for target: "+target);
- status.setCompleted(true);
- status.setRunning(true);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- catch(Exception e)
- {
- status = new SerializableDeploymentStatus(command, StateType.FAILED);
- status.setTarget(target);
- status.setFailure(e);
- status.setFailed(true);
- currentStatus = status;
- ProgressEvent error = new ProgressEvent(deployment, currentStatus);
- notify(error);
- break;
- }
- }
- }
-
- protected void undeploy()
- {
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
- status.setMessage("Running undeploy to: "+targets);
- currentStatus = status;
- ProgressEvent event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- for(DeploymentTarget target : targets)
- {
- if(isCancelled)
- {
- status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
- status.setMessage("Undeploy has been cancelled");
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- break;
- }
-
- try
- {
- target.undeploy(deployment);
- status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
- status.setTarget(target);
- status.setMessage("Completed undeploy for target: "+target);
- status.setCompleted(true);
- status.setRunning(true);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- catch(Exception e)
- {
- status = new SerializableDeploymentStatus(command, StateType.FAILED);
- status.setTarget(target);
- status.setFailure(e);
- status.setFailed(true);
- currentStatus = status;
- ProgressEvent error = new ProgressEvent(deployment, currentStatus);
- notify(error);
- break;
- }
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.upload;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus.StateType;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.deployers.spi.management.deploy.ProgressEvent;
+import org.jboss.deployers.spi.management.deploy.ProgressListener;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DeploymentProgressImpl implements DeploymentProgress, Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ /** The client side listeners */
+ private transient CopyOnWriteArrayList<ProgressListener> listeners = new CopyOnWriteArrayList<ProgressListener>();
+ private transient DeploymentStatus currentStatus;
+ private transient boolean isCancelled;
+ /** The targets to distribute to */
+ private List<DeploymentTarget> targets;
+ /** The deployment being distributed */
+ private DeploymentID deployment;
+ private CommandType command;
+
+ public DeploymentProgressImpl(List<DeploymentTarget> targets, DeploymentID deployment, CommandType command)
+ {
+ this.targets = targets;
+ this.deployment = deployment;
+ this.command = command;
+ }
+
+ public synchronized void addProgressListener(ProgressListener listener)
+ {
+ if(listeners == null)
+ listeners = new CopyOnWriteArrayList<ProgressListener>();
+ listeners.add(listener);
+ }
+ public void removeProgressListener(ProgressListener listener)
+ {
+ listeners.remove(listener);
+ }
+
+ /**
+ * Begins the deployment command process
+ */
+ public void run()
+ {
+ switch(command)
+ {
+ case DISTRIBUTE:
+ distribute();
+ break;
+ case START:
+ start();
+ break;
+ case STOP:
+ stop();
+ break;
+ case UNDEPLOY:
+ undeploy();
+ break;
+ default:
+ throw new IllegalStateException(command+" is not currently handled");
+ }
+ }
+
+ public void cancel()
+ {
+ isCancelled = true;
+ }
+
+ public DeploymentStatus getDeploymentStatus()
+ {
+ return currentStatus;
+ }
+
+ public DeploymentID getDeploymentID()
+ {
+ return deployment;
+ }
+
+ public List<DeploymentTarget> getDeploymentTargets()
+ {
+ return targets;
+ }
+
+ /**
+ *
+ * @param event
+ */
+ protected void notify(ProgressEvent event)
+ {
+ if(listeners == null)
+ return;
+
+ for(ProgressListener listener : listeners)
+ {
+ try
+ {
+ listener.progressEvent(event);
+ }
+ catch(Throwable ignore)
+ {
+ }
+ }
+ }
+
+ protected void distribute()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
+ status.setMessage("Running distribute to: "+targets);
+ currentStatus = status;
+ ProgressEvent event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ for(DeploymentTarget target : targets)
+ {
+ if(isCancelled)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Distribute has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ // TODO, percent complete info in upload and overall distribute
+ status = new SerializableDeploymentStatus(command, StateType.UPLOADING);
+ status.setTarget(target);
+ status.setMessage("Begining distribute to target: "+target);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+
+ // TODO, cancellation of in progress distribution
+ target.distribute(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
+ status.setTarget(target);
+ status.setMessage("Completed distribute to target: "+target);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ catch(Exception e)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ status.setTarget(target);
+ status.setFailure(e);
+ status.setFailed(true);
+ currentStatus = status;
+ ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+ notify(error);
+ break;
+ }
+ }
+
+ if(currentStatus.isFailed() == false)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setMessage("Completed distribute to all targets");
+ status.setCompleted(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ }
+
+ protected void start()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+ status.setMessage("Running start to: "+targets);
+ currentStatus = status;
+ ProgressEvent event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ for(DeploymentTarget target : targets)
+ {
+ if(isCancelled)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Start has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ target.start(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setTarget(target);
+ status.setMessage("Completed start for target: "+target);
+ status.setCompleted(true);
+ status.setRunning(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ catch(Exception e)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ status.setTarget(target);
+ status.setFailure(e);
+ status.setFailed(true);
+ currentStatus = status;
+ ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+ notify(error);
+ break;
+ }
+ }
+ }
+
+ protected void stop()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+ status.setMessage("Running stop to: "+targets);
+ currentStatus = status;
+ ProgressEvent event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ for(DeploymentTarget target : targets)
+ {
+ if(isCancelled)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Stop has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ target.stop(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setTarget(target);
+ status.setMessage("Completed stop for target: "+target);
+ status.setCompleted(true);
+ status.setRunning(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ catch(Exception e)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ status.setTarget(target);
+ status.setFailure(e);
+ status.setFailed(true);
+ currentStatus = status;
+ ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+ notify(error);
+ break;
+ }
+ }
+ }
+
+ protected void undeploy()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+ status.setMessage("Running undeploy to: "+targets);
+ currentStatus = status;
+ ProgressEvent event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ for(DeploymentTarget target : targets)
+ {
+ if(isCancelled)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Undeploy has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ target.undeploy(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setTarget(target);
+ status.setMessage("Completed undeploy for target: "+target);
+ status.setCompleted(true);
+ status.setRunning(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ catch(Exception e)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ status.setTarget(target);
+ status.setFailure(e);
+ status.setFailed(true);
+ currentStatus = status;
+ ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+ notify(error);
+ break;
+ }
+ }
+ }
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,140 +1,140 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.Arrays;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class SerializableDeploymentID implements DeploymentID, Serializable
-{
- private static final long serialVersionUID = 1;
-
- /** An InputStream to use to copy the contents */
- private transient InputStream contentIS;
- private String[] deploymentNames;
- private String[] repositoryNames;
- private DeploymentPhase phase;
- private String description;
- private URL contentURL;
- private boolean copyContent;
-
- public SerializableDeploymentID(DeploymentID deployment)
- {
- this(deployment.getNames(), deployment.getPhase(), deployment.getDescription());
- }
- public SerializableDeploymentID(String name, DeploymentPhase phase, String description)
- {
- this(new String[]{name}, phase, description);
- }
- public SerializableDeploymentID(String[] names, DeploymentPhase phase, String description)
- {
- this.deploymentNames = names;
- this.phase = phase;
- this.description = description;
- this.copyContent = true; // by default we copy content
- }
-
- public String[] getNames()
- {
- return deploymentNames;
- }
-
- public String[] getRepositoryNames()
- {
- if(repositoryNames == null)
- repositoryNames = deploymentNames;
- return repositoryNames;
- }
- public void setRepositoryNames(String[] names)
- {
- this.repositoryNames = names;
- }
- public DeploymentPhase getPhase()
- {
- return phase;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public URL getContentURL()
- {
- return contentURL;
- }
- public void setContentURL(URL contentURL)
- {
- this.contentURL = contentURL;
- }
-
- public boolean isCopyContent()
- {
- return copyContent;
- }
-
- public void setCopyContent(boolean copyContent)
- {
- this.copyContent = copyContent;
- }
-
- /**
- * An optional deployment archive content stream for the top-level
- * deployment.
- *
- * @return the archive input stream if it exists
- */
- public InputStream getContentIS()
- {
- return contentIS;
- }
- /**
- *
- * @param contentIS
- */
- public void setContentIS(InputStream contentIS)
- {
- this.contentIS = contentIS;
- }
-
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("names=").append(Arrays.toString(getNames()));
- // Only add the repositoryNames if it differs from deploymentNames
- if(getRepositoryNames() != getNames())
- buffer.append("repositoryNames=").append(Arrays.toString(getRepositoryNames()));
- buffer.append("phase=").append(phase);
- buffer.append("copyContent=").append(copyContent);
- buffer.append("description=").append(description);
- return buffer.toString();
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.upload;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Arrays;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SerializableDeploymentID implements DeploymentID, Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ /** An InputStream to use to copy the contents */
+ private transient InputStream contentIS;
+ private String[] deploymentNames;
+ private String[] repositoryNames;
+ private DeploymentPhase phase;
+ private String description;
+ private URL contentURL;
+ private boolean copyContent;
+
+ public SerializableDeploymentID(DeploymentID deployment)
+ {
+ this(deployment.getNames(), deployment.getPhase(), deployment.getDescription());
+ }
+ public SerializableDeploymentID(String name, DeploymentPhase phase, String description)
+ {
+ this(new String[]{name}, phase, description);
+ }
+ public SerializableDeploymentID(String[] names, DeploymentPhase phase, String description)
+ {
+ this.deploymentNames = names;
+ this.phase = phase;
+ this.description = description;
+ this.copyContent = true; // by default we copy content
+ }
+
+ public String[] getNames()
+ {
+ return deploymentNames;
+ }
+
+ public String[] getRepositoryNames()
+ {
+ if(repositoryNames == null)
+ repositoryNames = deploymentNames;
+ return repositoryNames;
+ }
+ public void setRepositoryNames(String[] names)
+ {
+ this.repositoryNames = names;
+ }
+ public DeploymentPhase getPhase()
+ {
+ return phase;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public URL getContentURL()
+ {
+ return contentURL;
+ }
+ public void setContentURL(URL contentURL)
+ {
+ this.contentURL = contentURL;
+ }
+
+ public boolean isCopyContent()
+ {
+ return copyContent;
+ }
+
+ public void setCopyContent(boolean copyContent)
+ {
+ this.copyContent = copyContent;
+ }
+
+ /**
+ * An optional deployment archive content stream for the top-level
+ * deployment.
+ *
+ * @return the archive input stream if it exists
+ */
+ public InputStream getContentIS()
+ {
+ return contentIS;
+ }
+ /**
+ *
+ * @param contentIS
+ */
+ public void setContentIS(InputStream contentIS)
+ {
+ this.contentIS = contentIS;
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("names=").append(Arrays.toString(getNames()));
+ // Only add the repositoryNames if it differs from deploymentNames
+ if(getRepositoryNames() != getNames())
+ buffer.append("repositoryNames=").append(Arrays.toString(getRepositoryNames()));
+ buffer.append("phase=").append(phase);
+ buffer.append("copyContent=").append(copyContent);
+ buffer.append("description=").append(description);
+ return buffer.toString();
+ }
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,153 +1,153 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.io.StringWriter;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
-import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-
-/**
- * Simple javabean impl of DeploymentStatus
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class SerializableDeploymentStatus implements DeploymentStatus,
- Serializable
-{
- private static final long serialVersionUID = 1;
-
- private CommandType command;
- private Exception failure;
- private String message;
- private StateType state;
- private DeploymentTarget target;
- private boolean isCompleted;
- private boolean isFailed;
- private boolean isRunning;
-
- public SerializableDeploymentStatus(CommandType command, StateType state)
- {
- this.command = command;
- this.state = state;
- }
-
- public CommandType getCommand()
- {
- return command;
- }
- public void setCommand(CommandType command)
- {
- this.command = command;
- }
-
- public DeploymentTarget getTarget()
- {
- return target;
- }
- public void setTarget(DeploymentTarget target)
- {
- this.target = target;
- }
-
- public Exception getFailure()
- {
- return failure;
- }
- public void setFailure(Exception failure)
- {
- this.failure = failure;
- }
- public String getMessage()
- {
- return message;
- }
- public void setMessage(String message)
- {
- this.message = message;
- }
- public StateType getState()
- {
- return state;
- }
- public void setState(StateType state)
- {
- this.state = state;
- }
- public boolean isCompleted()
- {
- return isCompleted;
- }
- public void setCompleted(boolean isCompleted)
- {
- this.isCompleted = isCompleted;
- }
- public boolean isFailed()
- {
- return isFailed;
- }
- public void setFailed(boolean isFailed)
- {
- this.isFailed = isFailed;
- }
- public boolean isRunning()
- {
- return isRunning;
- }
- public void setRunning(boolean isRunning)
- {
- this.isRunning = isRunning;
- }
-
- @Override
- public String toString()
- {
- StringBuffer tmp = new StringBuffer("DeploymentStatus(");
- tmp.append("command=");
- tmp.append(command);
- tmp.append(",state=");
- tmp.append(state);
- tmp.append(",message=");
- tmp.append(message);
- tmp.append(",isCompleted=");
- tmp.append(isCompleted);
- tmp.append(",isRunning=");
- tmp.append(isRunning);
- tmp.append(",isFailed=");
- tmp.append(isFailed);
-
- if(failure != null)
- {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- failure.printStackTrace(pw);
- tmp.append(",failure:\n");
- tmp.append(sw.toString());
- }
- tmp.append(")");
- return tmp.toString();
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.upload;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+
+/**
+ * Simple javabean impl of DeploymentStatus
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SerializableDeploymentStatus implements DeploymentStatus,
+ Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ private CommandType command;
+ private Exception failure;
+ private String message;
+ private StateType state;
+ private DeploymentTarget target;
+ private boolean isCompleted;
+ private boolean isFailed;
+ private boolean isRunning;
+
+ public SerializableDeploymentStatus(CommandType command, StateType state)
+ {
+ this.command = command;
+ this.state = state;
+ }
+
+ public CommandType getCommand()
+ {
+ return command;
+ }
+ public void setCommand(CommandType command)
+ {
+ this.command = command;
+ }
+
+ public DeploymentTarget getTarget()
+ {
+ return target;
+ }
+ public void setTarget(DeploymentTarget target)
+ {
+ this.target = target;
+ }
+
+ public Exception getFailure()
+ {
+ return failure;
+ }
+ public void setFailure(Exception failure)
+ {
+ this.failure = failure;
+ }
+ public String getMessage()
+ {
+ return message;
+ }
+ public void setMessage(String message)
+ {
+ this.message = message;
+ }
+ public StateType getState()
+ {
+ return state;
+ }
+ public void setState(StateType state)
+ {
+ this.state = state;
+ }
+ public boolean isCompleted()
+ {
+ return isCompleted;
+ }
+ public void setCompleted(boolean isCompleted)
+ {
+ this.isCompleted = isCompleted;
+ }
+ public boolean isFailed()
+ {
+ return isFailed;
+ }
+ public void setFailed(boolean isFailed)
+ {
+ this.isFailed = isFailed;
+ }
+ public boolean isRunning()
+ {
+ return isRunning;
+ }
+ public void setRunning(boolean isRunning)
+ {
+ this.isRunning = isRunning;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer("DeploymentStatus(");
+ tmp.append("command=");
+ tmp.append(command);
+ tmp.append(",state=");
+ tmp.append(state);
+ tmp.append(",message=");
+ tmp.append(message);
+ tmp.append(",isCompleted=");
+ tmp.append(isCompleted);
+ tmp.append(",isRunning=");
+ tmp.append(isRunning);
+ tmp.append(",isFailed=");
+ tmp.append(isFailed);
+
+ if(failure != null)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ failure.printStackTrace(pw);
+ tmp.append(",failure:\n");
+ tmp.append(sw.toString());
+ }
+ tmp.append(")");
+ return tmp.toString();
+ }
+
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,291 +1,291 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload.remoting;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Map;
-import javax.management.MBeanServer;
-
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.InvocationResponse;
-import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
-import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.management.upload.SerializableDeploymentID;
-import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.stream.StreamInvocationHandler;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A remoting StreamInvocationHandler installed as the profile service subsystem
- * handler and used by the StreamingDeploymentTarget implementation.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class DeployHandler extends AOPRemotingInvocationHandler
- implements StreamInvocationHandler
-{
- static Logger log = Logger.getLogger(DeployHandler.class);
- private DeploymentRepository deploymentRepository;
- /** The deployment factory */
- private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
- private MainDeployer mainDeployer;
-
-
- public DeploymentRepository getDeploymentRepository()
- {
- return deploymentRepository;
- }
- public void setDeploymentRepository(DeploymentRepository deploymentRepository)
- {
- log.debug("setDeploymentRepository, "+deploymentRepository);
- this.deploymentRepository = deploymentRepository;
- }
-
-
- public VFSDeploymentFactory getDeploymentFactory()
- {
- return deploymentFactory;
- }
- public void setDeploymentFactory(VFSDeploymentFactory deploymentFactory)
- {
- this.deploymentFactory = deploymentFactory;
- }
-
- public MainDeployer getMainDeployer()
- {
- return mainDeployer;
- }
- public void setMainDeployer(MainDeployer mainDeployer)
- {
- this.mainDeployer = mainDeployer;
- }
- /**
- * Handle a DeploymentManager distribute invocation
- * @see DeploymentManager#distribute(String, DeploymentPhase, java.net.URL)
- * @param request - the remoting invocation
- */
- public Object handleStream(InputStream contentIS, InvocationRequest request) throws Throwable
- {
- SerializableDeploymentID deploymentTarget = (SerializableDeploymentID) request.getParameter();
- log.info("Handle stream, deploymentTarget: " + deploymentTarget);
- deploymentTarget.setContentIS(contentIS);
- DeploymentPhase phase = deploymentTarget.getPhase();
- String[] names = deploymentTarget.getNames();
- String repositoryName = deploymentRepository.addDeploymentContent(names[0], contentIS, phase);
- log.info("End handle stream, repositoryName: " + repositoryName);
- String[] rnames = {repositoryName};
- deploymentTarget.setRepositoryNames(rnames);
- return new InvocationResponse(repositoryName);
- }
-
- public void addListener(InvokerCallbackHandler arg0)
- {
- }
-
- /**
- * Handle a DeploymentManager invocation other than distribute
- * @param request - the remoting invocation
- * @return the result of the invocation
- */
- public Object invoke(InvocationRequest request) throws Throwable
- {
- Object parameter = request.getParameter();
- Object returnValue = null;
-
- if(parameter instanceof Invocation)
- {
- returnValue = super.invoke(request);
- }
- else
- {
- Map payload = request.getRequestPayload();
- DeploymentID dtID = (DeploymentID) payload.get("DeploymentTargetID");
- log.debug("invoke, payload: "+payload+", parameter: "+parameter);
- if( parameter.equals("getRepositoryNames"))
- {
- String[] names = (String[]) payload.get("names");
- DeploymentPhase phase = (DeploymentPhase) payload.get("phase");
- returnValue = getRepositoryNames(names, phase);
- }
- else if( parameter.equals("distribute") )
- {
- returnValue = distribute(dtID);
- }
- else if( parameter.equals("start") )
- {
- start(dtID);
- }
- else if( parameter.equals("stop") )
- {
- stop(dtID);
- }
- else if( parameter.equals("undeploy") )
- {
- undeploy(dtID);
- }
- }
- return returnValue;
- }
-
- public void removeListener(InvokerCallbackHandler arg0)
- {
- }
-
- public void setInvoker(ServerInvoker arg0)
- {
- }
-
- public void setMBeanServer(MBeanServer arg0)
- {
- }
-
- protected String[] getRepositoryNames(String[] names, DeploymentPhase phase)
- throws IOException
- {
- return deploymentRepository.getRepositoryNames(names, phase);
- }
-
- protected String[] distribute(DeploymentID dtID) throws Exception
- {
- URL contentURL = dtID.getContentURL();
- DeploymentPhase phase = dtID.getPhase();
- log.info("Begin distribute, content url: " + contentURL + ", phase: " + phase);
- // Prevent hot deployment scans from seeing in transition deployments
- deploymentRepository.acquireDeploymentContentLock();
- try
- {
- VirtualFile vf = VFS.getRoot(contentURL);
- VFSDeployment vfsd = createDeployment(vf);
- deploymentRepository.addDeployment(vfsd.getName(), vfsd, phase);
- mainDeployer.addDeployment(vfsd);
- mainDeployer.process();
- mainDeployer.checkComplete();
- String[] rnames = {vfsd.getName()};
- log.info("End distribute, " + contentURL);
- return rnames;
- }
- finally
- {
- deploymentRepository.releaseDeploymentContentLock();
- }
- }
-
- protected void start(DeploymentID dtID) throws Exception
- {
- String[] names = dtID.getNames();
- DeploymentPhase phase = dtID.getPhase();
- log.info("Begin start, "+Arrays.asList(names) + ", phase: " + phase);
- // Prevent hot deployment scans from seeing in transition deployments
- deploymentRepository.acquireDeploymentContentLock();
- try
- {
- for(String name : names)
- {
- VirtualFile vf = deploymentRepository.getDeploymentContent(name, phase);
- VFSDeployment vfsd = createDeployment(vf);
- deploymentRepository.addDeployment(vfsd.getName(), vfsd, phase);
- deploymentRepository.unlockDeploymentContent(vf.getPathName(), phase);
- mainDeployer.addDeployment(vfsd);
- log.info("Scheduling start for: "+vfsd);
- }
- mainDeployer.process();
- mainDeployer.checkComplete();
- }
- finally
- {
- deploymentRepository.releaseDeploymentContentLock();
- }
- log.info("End start, "+Arrays.asList(names));
- }
-
- protected void stop(DeploymentID dtID) throws Exception
- {
- String[] names = dtID.getNames();
- log.info("Stop, "+Arrays.asList(names));
- deploymentRepository.acquireDeploymentContentLock();
- try
- {
- for(String name : names)
- {
- // Obtain the
- VFSDeployment vfsd = deploymentRepository.getDeployment(name, dtID.getPhase());
- // Lock the content to make it unavailable to the deployment scanner
- String path = vfsd.getRoot().getPathName();
- deploymentRepository.lockDeploymentContent(path, dtID.getPhase());
- mainDeployer.removeDeployment(vfsd);
- log.info("Scheduling stop for: "+vfsd);
- }
- mainDeployer.process();
- mainDeployer.checkComplete();
- }
- finally
- {
- deploymentRepository.releaseDeploymentContentLock();
- }
- }
-
- protected void undeploy(DeploymentID dtID) throws Exception
- {
- String[] names = dtID.getNames();
- log.info("Undeploy, "+Arrays.asList(names));
- deploymentRepository.acquireDeploymentContentLock();
- try
- {
- for(String name : names)
- {
- deploymentRepository.removeDeployment(name, dtID.getPhase());
- log.info("Undeployed: "+name);
- }
- }
- finally
- {
- deploymentRepository.releaseDeploymentContentLock();
- }
- }
-
- /**
- * Create a deployment
- *
- * @param file the root file
- * @return the deployment
- */
- protected VFSDeployment createDeployment(VirtualFile file)
- {
- if (file == null)
- throw new IllegalArgumentException("Null file");
- return deploymentFactory.createVFSDeployment(file);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.upload.remoting;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Map;
+import javax.management.MBeanServer;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.management.upload.SerializableDeploymentID;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.stream.StreamInvocationHandler;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A remoting StreamInvocationHandler installed as the profile service subsystem
+ * handler and used by the StreamingDeploymentTarget implementation.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DeployHandler extends AOPRemotingInvocationHandler
+ implements StreamInvocationHandler
+{
+ static Logger log = Logger.getLogger(DeployHandler.class);
+ private DeploymentRepository deploymentRepository;
+ /** The deployment factory */
+ private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
+ private MainDeployer mainDeployer;
+
+
+ public DeploymentRepository getDeploymentRepository()
+ {
+ return deploymentRepository;
+ }
+ public void setDeploymentRepository(DeploymentRepository deploymentRepository)
+ {
+ log.debug("setDeploymentRepository, "+deploymentRepository);
+ this.deploymentRepository = deploymentRepository;
+ }
+
+
+ public VFSDeploymentFactory getDeploymentFactory()
+ {
+ return deploymentFactory;
+ }
+ public void setDeploymentFactory(VFSDeploymentFactory deploymentFactory)
+ {
+ this.deploymentFactory = deploymentFactory;
+ }
+
+ public MainDeployer getMainDeployer()
+ {
+ return mainDeployer;
+ }
+ public void setMainDeployer(MainDeployer mainDeployer)
+ {
+ this.mainDeployer = mainDeployer;
+ }
+ /**
+ * Handle a DeploymentManager distribute invocation
+ * @see DeploymentManager#distribute(String, DeploymentPhase, java.net.URL)
+ * @param request - the remoting invocation
+ */
+ public Object handleStream(InputStream contentIS, InvocationRequest request) throws Throwable
+ {
+ SerializableDeploymentID deploymentTarget = (SerializableDeploymentID) request.getParameter();
+ log.info("Handle stream, deploymentTarget: " + deploymentTarget);
+ deploymentTarget.setContentIS(contentIS);
+ DeploymentPhase phase = deploymentTarget.getPhase();
+ String[] names = deploymentTarget.getNames();
+ String repositoryName = deploymentRepository.addDeploymentContent(names[0], contentIS, phase);
+ log.info("End handle stream, repositoryName: " + repositoryName);
+ String[] rnames = {repositoryName};
+ deploymentTarget.setRepositoryNames(rnames);
+ return new InvocationResponse(repositoryName);
+ }
+
+ public void addListener(InvokerCallbackHandler arg0)
+ {
+ }
+
+ /**
+ * Handle a DeploymentManager invocation other than distribute
+ * @param request - the remoting invocation
+ * @return the result of the invocation
+ */
+ public Object invoke(InvocationRequest request) throws Throwable
+ {
+ Object parameter = request.getParameter();
+ Object returnValue = null;
+
+ if(parameter instanceof Invocation)
+ {
+ returnValue = super.invoke(request);
+ }
+ else
+ {
+ Map payload = request.getRequestPayload();
+ DeploymentID dtID = (DeploymentID) payload.get("DeploymentTargetID");
+ log.debug("invoke, payload: "+payload+", parameter: "+parameter);
+ if( parameter.equals("getRepositoryNames"))
+ {
+ String[] names = (String[]) payload.get("names");
+ DeploymentPhase phase = (DeploymentPhase) payload.get("phase");
+ returnValue = getRepositoryNames(names, phase);
+ }
+ else if( parameter.equals("distribute") )
+ {
+ returnValue = distribute(dtID);
+ }
+ else if( parameter.equals("start") )
+ {
+ start(dtID);
+ }
+ else if( parameter.equals("stop") )
+ {
+ stop(dtID);
+ }
+ else if( parameter.equals("undeploy") )
+ {
+ undeploy(dtID);
+ }
+ }
+ return returnValue;
+ }
+
+ public void removeListener(InvokerCallbackHandler arg0)
+ {
+ }
+
+ public void setInvoker(ServerInvoker arg0)
+ {
+ }
+
+ public void setMBeanServer(MBeanServer arg0)
+ {
+ }
+
+ protected String[] getRepositoryNames(String[] names, DeploymentPhase phase)
+ throws IOException
+ {
+ return deploymentRepository.getRepositoryNames(names, phase);
+ }
+
+ protected String[] distribute(DeploymentID dtID) throws Exception
+ {
+ URL contentURL = dtID.getContentURL();
+ DeploymentPhase phase = dtID.getPhase();
+ log.info("Begin distribute, content url: " + contentURL + ", phase: " + phase);
+ // Prevent hot deployment scans from seeing in transition deployments
+ deploymentRepository.acquireDeploymentContentLock();
+ try
+ {
+ VirtualFile vf = VFS.getRoot(contentURL);
+ VFSDeployment vfsd = createDeployment(vf);
+ deploymentRepository.addDeployment(vfsd.getName(), vfsd, phase);
+ mainDeployer.addDeployment(vfsd);
+ mainDeployer.process();
+ mainDeployer.checkComplete();
+ String[] rnames = {vfsd.getName()};
+ log.info("End distribute, " + contentURL);
+ return rnames;
+ }
+ finally
+ {
+ deploymentRepository.releaseDeploymentContentLock();
+ }
+ }
+
+ protected void start(DeploymentID dtID) throws Exception
+ {
+ String[] names = dtID.getNames();
+ DeploymentPhase phase = dtID.getPhase();
+ log.info("Begin start, "+Arrays.asList(names) + ", phase: " + phase);
+ // Prevent hot deployment scans from seeing in transition deployments
+ deploymentRepository.acquireDeploymentContentLock();
+ try
+ {
+ for(String name : names)
+ {
+ VirtualFile vf = deploymentRepository.getDeploymentContent(name, phase);
+ VFSDeployment vfsd = createDeployment(vf);
+ deploymentRepository.addDeployment(vfsd.getName(), vfsd, phase);
+ deploymentRepository.unlockDeploymentContent(vf.getPathName(), phase);
+ mainDeployer.addDeployment(vfsd);
+ log.info("Scheduling start for: "+vfsd);
+ }
+ mainDeployer.process();
+ mainDeployer.checkComplete();
+ }
+ finally
+ {
+ deploymentRepository.releaseDeploymentContentLock();
+ }
+ log.info("End start, "+Arrays.asList(names));
+ }
+
+ protected void stop(DeploymentID dtID) throws Exception
+ {
+ String[] names = dtID.getNames();
+ log.info("Stop, "+Arrays.asList(names));
+ deploymentRepository.acquireDeploymentContentLock();
+ try
+ {
+ for(String name : names)
+ {
+ // Obtain the
+ VFSDeployment vfsd = deploymentRepository.getDeployment(name, dtID.getPhase());
+ // Lock the content to make it unavailable to the deployment scanner
+ String path = vfsd.getRoot().getPathName();
+ deploymentRepository.lockDeploymentContent(path, dtID.getPhase());
+ mainDeployer.removeDeployment(vfsd);
+ log.info("Scheduling stop for: "+vfsd);
+ }
+ mainDeployer.process();
+ mainDeployer.checkComplete();
+ }
+ finally
+ {
+ deploymentRepository.releaseDeploymentContentLock();
+ }
+ }
+
+ protected void undeploy(DeploymentID dtID) throws Exception
+ {
+ String[] names = dtID.getNames();
+ log.info("Undeploy, "+Arrays.asList(names));
+ deploymentRepository.acquireDeploymentContentLock();
+ try
+ {
+ for(String name : names)
+ {
+ deploymentRepository.removeDeployment(name, dtID.getPhase());
+ log.info("Undeployed: "+name);
+ }
+ }
+ finally
+ {
+ deploymentRepository.releaseDeploymentContentLock();
+ }
+ }
+
+ /**
+ * Create a deployment
+ *
+ * @param file the root file
+ * @return the deployment
+ */
+ protected VFSDeployment createDeployment(VirtualFile file)
+ {
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+ return deploymentFactory.createVFSDeployment(file);
+ }
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,297 +1,297 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload.remoting;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.aop.joinpoint.InvocationResponse;
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.management.upload.SerializableDeploymentID;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-
-/**
- * An implementation of DeploymentTarget that uses remoting for streaming
- * content in distribute, and basic rpc for the other methods.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class StreamingDeploymentTarget
- implements DeploymentTarget, Serializable
-{
- private static final long serialVersionUID = 1;
- private static final Logger log = Logger.getLogger(StreamingDeploymentTarget.class);
-
- /** The deployment target locator */
- private InvokerLocator locator;
- private String name;
- private String subsystem;
-
- /**
- * Create a target given a remoting locator
- * @param locator -
- * @param name -
- * @param subsystem -
- */
- public StreamingDeploymentTarget(InvokerLocator locator, String name, String subsystem)
- {
- log.debug("new StreamingTarget: " + locator);
- this.name = name;
- this.subsystem = subsystem;
- this.locator = locator;
- }
-
- public String getDescription()
- {
- return name + "(" + locator + ")";
- }
-
- public String getName()
- {
- return name;
- }
-
- public InvokerLocator getInvokerLocator()
- {
- return locator;
- }
-
- /**
- * Distribute a deployment to the profile targets.
- *
- * @param deployment - the encapsulation of the deployment to distribute
- * @throws Exception for any error
- */
- public void distribute(DeploymentID deployment) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Begin distribute: " + deployment);
- String[] rnames;
- if (deployment.isCopyContent())
- {
- URL contentURL = deployment.getContentURL();
- SerializableDeploymentID sdtID = new SerializableDeploymentID(deployment);
- InputStream contentIS = contentURL.openStream();
- sdtID.setContentIS(contentIS);
- String repositoryName = transferDeployment(client, sdtID);
- rnames = new String[]{repositoryName};
- }
- else
- {
- rnames = (String[])invoke(client, "distribute", createArgs(deployment));
- }
- // Update the repository names on the deployment
- deployment.setRepositoryNames(rnames);
- log.debug("End distribute, repositoryNames: "+ Arrays.asList(rnames));
- }
- finally
- {
- client.disconnect();
- }
- }
-
- public String[] getRepositoryNames(String[] names, DeploymentPhase phase) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Begin getRepositoryNames: " + Arrays.asList(names));
- HashMap<Object, Object> args = new HashMap<Object, Object>();
- args.put("names", names);
- args.put("phase", phase);
- String[] rnames = (String[]) invoke(client, "getRepositoryNames", args);
- log.debug("End getRepositoryNames: " + Arrays.asList(rnames));
- return rnames;
- }
- finally
- {
- client.disconnect();
- }
- }
-
- public void redeploy(DeploymentID deployment) throws Exception
- {
- throw new IllegalStateException("redeploy is not yet implemented");
- }
-
- public void prepare(DeploymentID deployment) throws Exception
- {
- throw new IllegalStateException("prepare is not yet implemented");
- }
-
- /**
- * Create the client args.
- *
- * @param dtID the deployment id
- * @return args map
- */
- protected Map<?, ?> createArgs(DeploymentID dtID)
- {
- return new HashMap<Object, Object>(Collections.singletonMap("DeploymentTargetID", dtID));
- }
-
- /**
- * Start a given deployment(s)
- */
- public void start(DeploymentID dtID) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Start: " + dtID);
- invoke(client, "start", createArgs(dtID));
- log.debug("End start: "+dtID);
- }
- finally
- {
- client.disconnect();
- }
- }
-
- /**
- * Stop a given module
- */
- public void stop(DeploymentID dtID) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Begin stop: " + dtID);
- invoke(client, "stop", createArgs(dtID));
- log.debug("End stop");
- }
- finally
- {
- client.disconnect();
- }
- }
-
- /**
- * Undeploy a given module
- */
- public void undeploy(DeploymentID dtID) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Begin undeploy: " + dtID);
- invoke(client, "undeploy", createArgs(dtID));
- log.debug("End undeploy");
- }
- finally
- {
- client.disconnect();
- }
- }
-
- public String toString()
- {
- StringBuilder tmp = new StringBuilder();
- tmp.append("name=");
- tmp.append(name);
- tmp.append(",locator=");
- tmp.append(locator);
- tmp.append(",subsystem=");
- tmp.append(subsystem);
- return tmp.toString();
- }
-
- /**
- * Get the remoting client connection
- * @return
- * @throws Exception
- */
- private Client getClient() throws Exception
- {
- log.debug("Calling remoting server with locator of: " + locator);
-
- Client remotingClient = new Client(locator, subsystem);
- remotingClient.connect();
- return remotingClient;
- }
-
- /**
- * Stream a deployment to the server
- *
- * @param client - the remoting client
- * @param sdtID - the deployment content encapsulation
- * @return the profile service repository unique name
- * @throws Exception
- */
- private String transferDeployment(Client client, SerializableDeploymentID sdtID) throws Exception
- {
- InputStream is = sdtID.getContentIS();
- try
- {
- // This return value depends on the proxy type
- InvocationResponse response = (InvocationResponse) client.invoke(is, sdtID);
- return (String) response.getResponse();
- }
- catch(Error e)
- {
- throw new RuntimeException(e);
- }
- catch(Throwable e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- try
- {
- is.close();
- }
- catch (IOException ignored)
- {
- }
- }
- }
-
- private Object invoke(Client client, String name, Map<?, ?> args) throws Exception
- {
- try
- {
- return client.invoke(name, args);
- }
- catch(Error e)
- {
- throw new RuntimeException(e);
- }
- catch(Throwable e)
- {
- throw new RuntimeException(e);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.upload.remoting;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.management.upload.SerializableDeploymentID;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * An implementation of DeploymentTarget that uses remoting for streaming
+ * content in distribute, and basic rpc for the other methods.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class StreamingDeploymentTarget
+ implements DeploymentTarget, Serializable
+{
+ private static final long serialVersionUID = 1;
+ private static final Logger log = Logger.getLogger(StreamingDeploymentTarget.class);
+
+ /** The deployment target locator */
+ private InvokerLocator locator;
+ private String name;
+ private String subsystem;
+
+ /**
+ * Create a target given a remoting locator
+ * @param locator -
+ * @param name -
+ * @param subsystem -
+ */
+ public StreamingDeploymentTarget(InvokerLocator locator, String name, String subsystem)
+ {
+ log.debug("new StreamingTarget: " + locator);
+ this.name = name;
+ this.subsystem = subsystem;
+ this.locator = locator;
+ }
+
+ public String getDescription()
+ {
+ return name + "(" + locator + ")";
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public InvokerLocator getInvokerLocator()
+ {
+ return locator;
+ }
+
+ /**
+ * Distribute a deployment to the profile targets.
+ *
+ * @param deployment - the encapsulation of the deployment to distribute
+ * @throws Exception for any error
+ */
+ public void distribute(DeploymentID deployment) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin distribute: " + deployment);
+ String[] rnames;
+ if (deployment.isCopyContent())
+ {
+ URL contentURL = deployment.getContentURL();
+ SerializableDeploymentID sdtID = new SerializableDeploymentID(deployment);
+ InputStream contentIS = contentURL.openStream();
+ sdtID.setContentIS(contentIS);
+ String repositoryName = transferDeployment(client, sdtID);
+ rnames = new String[]{repositoryName};
+ }
+ else
+ {
+ rnames = (String[])invoke(client, "distribute", createArgs(deployment));
+ }
+ // Update the repository names on the deployment
+ deployment.setRepositoryNames(rnames);
+ log.debug("End distribute, repositoryNames: "+ Arrays.asList(rnames));
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ public String[] getRepositoryNames(String[] names, DeploymentPhase phase) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin getRepositoryNames: " + Arrays.asList(names));
+ HashMap<Object, Object> args = new HashMap<Object, Object>();
+ args.put("names", names);
+ args.put("phase", phase);
+ String[] rnames = (String[]) invoke(client, "getRepositoryNames", args);
+ log.debug("End getRepositoryNames: " + Arrays.asList(rnames));
+ return rnames;
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ public void redeploy(DeploymentID deployment) throws Exception
+ {
+ throw new IllegalStateException("redeploy is not yet implemented");
+ }
+
+ public void prepare(DeploymentID deployment) throws Exception
+ {
+ throw new IllegalStateException("prepare is not yet implemented");
+ }
+
+ /**
+ * Create the client args.
+ *
+ * @param dtID the deployment id
+ * @return args map
+ */
+ protected Map<?, ?> createArgs(DeploymentID dtID)
+ {
+ return new HashMap<Object, Object>(Collections.singletonMap("DeploymentTargetID", dtID));
+ }
+
+ /**
+ * Start a given deployment(s)
+ */
+ public void start(DeploymentID dtID) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Start: " + dtID);
+ invoke(client, "start", createArgs(dtID));
+ log.debug("End start: "+dtID);
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ /**
+ * Stop a given module
+ */
+ public void stop(DeploymentID dtID) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin stop: " + dtID);
+ invoke(client, "stop", createArgs(dtID));
+ log.debug("End stop");
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ /**
+ * Undeploy a given module
+ */
+ public void undeploy(DeploymentID dtID) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin undeploy: " + dtID);
+ invoke(client, "undeploy", createArgs(dtID));
+ log.debug("End undeploy");
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder();
+ tmp.append("name=");
+ tmp.append(name);
+ tmp.append(",locator=");
+ tmp.append(locator);
+ tmp.append(",subsystem=");
+ tmp.append(subsystem);
+ return tmp.toString();
+ }
+
+ /**
+ * Get the remoting client connection
+ * @return
+ * @throws Exception
+ */
+ private Client getClient() throws Exception
+ {
+ log.debug("Calling remoting server with locator of: " + locator);
+
+ Client remotingClient = new Client(locator, subsystem);
+ remotingClient.connect();
+ return remotingClient;
+ }
+
+ /**
+ * Stream a deployment to the server
+ *
+ * @param client - the remoting client
+ * @param sdtID - the deployment content encapsulation
+ * @return the profile service repository unique name
+ * @throws Exception
+ */
+ private String transferDeployment(Client client, SerializableDeploymentID sdtID) throws Exception
+ {
+ InputStream is = sdtID.getContentIS();
+ try
+ {
+ // This return value depends on the proxy type
+ InvocationResponse response = (InvocationResponse) client.invoke(is, sdtID);
+ return (String) response.getResponse();
+ }
+ catch(Error e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch(Throwable e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException ignored)
+ {
+ }
+ }
+ }
+
+ private Object invoke(Client client, String name, Map<?, ?> args) throws Exception
+ {
+ try
+ {
+ return client.invoke(name, args);
+ }
+ catch(Error e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch(Throwable e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Modified: trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java
===================================================================
--- trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java 2008-11-14 12:51:26 UTC (rev 81027)
+++ trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java 2008-11-14 12:52:00 UTC (rev 81028)
@@ -1,144 +1,144 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.ps;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.AttachmentsSerializer;
-import org.jboss.profileservice.spi.DeploymentContentFlags;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.system.server.profileservice.repository.JavaSerializationAttachmentsSerializer;
-import org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository;
-
-
-/**
- * Tests of the SerializableDeploymentRepository implementation details.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class SerializableDeploymentRepositoryUnitTest
- extends TestCase
-{
- private static Logger log = Logger.getLogger(SerializableDeploymentRepositoryUnitTest.class);
-
- public SerializableDeploymentRepositoryUnitTest(String name)
- {
- super(name);
- }
-
- /**
- * Test the behavior of the {@link DeploymentContentFlags#LOCKED} flag
- * @throws Exception
- */
- public void testDeploymentContentFlagsLocked()
- throws Exception
- {
- File root = getServerRoot();
- URI[] appURIs = {root.toURI().resolve("default/deploy")};
- ProfileKey key = new ProfileKey("default");
- log.info("Creating SDR with root: "+root+", appURI: "+appURIs[0]);
- SerializableDeploymentRepository sdr = new SerializableDeploymentRepository(root, appURIs, key);
- AttachmentsSerializer serializer = new JavaSerializationAttachmentsSerializer();
- sdr.setSerializer(serializer);
- sdr.load();
-
- log.info("DeploymentNames: "+sdr.getDeploymentNames());
- // Validate we can get the ROOT.war
- VFSDeployment rootWar = sdr.getDeployment("ROOT.war", DeploymentPhase.APPLICATION);
- assertNotNull("deploy/ROOT.war", rootWar);
-
- // Modify the ROOT.war
- URI warURI = rootWar.getRoot().toURI();
- File warFile = new File(warURI.getPath());
- warFile.setLastModified(System.currentTimeMillis());
- // Check its flags
- int flags = sdr.getDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION);
- assertEquals("ROOT.war flags", 0, flags);
-
- // Validate the ROOT.war is in the modified deployments
- Collection<ModificationInfo> mods = sdr.getModifiedDeployments();
- assertEquals("Collection<ModificationInfo> size is 1", 1, mods.size());
- ModificationInfo warMods = mods.iterator().next();
- assertEquals("ModificationInfo.status is MODIFIED", ModificationInfo.ModifyStatus.MODIFIED, warMods.getStatus());
- assertEquals("ModificationInfo.name is ROOT.war", "ROOT.war", warMods.getDeployment().getSimpleName());
-
- // lock the war
- flags = sdr.setDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION,
- DeploymentContentFlags.LOCKED);
- assertEquals(flags, DeploymentContentFlags.LOCKED);
- warFile.setLastModified(System.currentTimeMillis()+1000);
- // It should be modified, but not show up in the mods
- assertTrue("vfsfile ROOT.war hasBeenModified", rootWar.getRoot().hasBeenModified());
- mods = sdr.getModifiedDeployments();
- assertEquals("Collection<ModificationInfo> size is 0", 0, mods.size());
-
- // Validate that the locked flag overrides the modified flag
- assertFalse("vfsfile ROOT.war hasBeenModified", rootWar.getRoot().hasBeenModified());
- flags = DeploymentContentFlags.LOCKED | DeploymentContentFlags.MODIFIED;
- sdr.setDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION, flags);
- mods = sdr.getModifiedDeployments();
- assertEquals("Collection<ModificationInfo> size is 0", 0, mods.size());
-
- // Validate that the modified flag allows it to show
- flags = sdr.clearDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION,
- DeploymentContentFlags.LOCKED);
- assertEquals("ROOT.war has MODIFIED flag", flags, DeploymentContentFlags.MODIFIED);
- mods = sdr.getModifiedDeployments();
- assertEquals("Collection<ModificationInfo> size is 1", 1, mods.size());
- warMods = mods.iterator().next();
- assertEquals("ModificationInfo.status is MODIFIED", ModificationInfo.ModifyStatus.MODIFIED, warMods.getStatus());
- assertEquals("ModificationInfo.name is ROOT.war", "ROOT.war", warMods.getDeployment().getSimpleName());
- }
-
- /**
- * Get the file for the jboss server directory. Relies on one
- * of the following variables to be set:
- * JBOSS_HOME env variable
- * jboss.home system property
- *
- * @return
- * @throws IOException
- */
- protected File getServerRoot() throws IOException
- {
- String home = System.getenv("JBOSS_HOME");
- if(home == null)
- {
- home = System.getProperty("jboss.home");
- }
- File defaultDir = new File(home, "server");
- if(defaultDir.exists() == false)
- throw new FileNotFoundException(defaultDir.getAbsolutePath()+", check the JBOSS_HOME env variable or jboss.home system property");
- return defaultDir;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ps;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.spi.AttachmentsSerializer;
+import org.jboss.profileservice.spi.DeploymentContentFlags;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.system.server.profileservice.repository.JavaSerializationAttachmentsSerializer;
+import org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository;
+
+
+/**
+ * Tests of the SerializableDeploymentRepository implementation details.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SerializableDeploymentRepositoryUnitTest
+ extends TestCase
+{
+ private static Logger log = Logger.getLogger(SerializableDeploymentRepositoryUnitTest.class);
+
+ public SerializableDeploymentRepositoryUnitTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the behavior of the {@link DeploymentContentFlags#LOCKED} flag
+ * @throws Exception
+ */
+ public void testDeploymentContentFlagsLocked()
+ throws Exception
+ {
+ File root = getServerRoot();
+ URI[] appURIs = {root.toURI().resolve("default/deploy")};
+ ProfileKey key = new ProfileKey("default");
+ log.info("Creating SDR with root: "+root+", appURI: "+appURIs[0]);
+ SerializableDeploymentRepository sdr = new SerializableDeploymentRepository(root, appURIs, key);
+ AttachmentsSerializer serializer = new JavaSerializationAttachmentsSerializer();
+ sdr.setSerializer(serializer);
+ sdr.load();
+
+ log.info("DeploymentNames: "+sdr.getDeploymentNames());
+ // Validate we can get the ROOT.war
+ VFSDeployment rootWar = sdr.getDeployment("ROOT.war", DeploymentPhase.APPLICATION);
+ assertNotNull("deploy/ROOT.war", rootWar);
+
+ // Modify the ROOT.war
+ URI warURI = rootWar.getRoot().toURI();
+ File warFile = new File(warURI.getPath());
+ warFile.setLastModified(System.currentTimeMillis());
+ // Check its flags
+ int flags = sdr.getDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION);
+ assertEquals("ROOT.war flags", 0, flags);
+
+ // Validate the ROOT.war is in the modified deployments
+ Collection<ModificationInfo> mods = sdr.getModifiedDeployments();
+ assertEquals("Collection<ModificationInfo> size is 1", 1, mods.size());
+ ModificationInfo warMods = mods.iterator().next();
+ assertEquals("ModificationInfo.status is MODIFIED", ModificationInfo.ModifyStatus.MODIFIED, warMods.getStatus());
+ assertEquals("ModificationInfo.name is ROOT.war", "ROOT.war", warMods.getDeployment().getSimpleName());
+
+ // lock the war
+ flags = sdr.setDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION,
+ DeploymentContentFlags.LOCKED);
+ assertEquals(flags, DeploymentContentFlags.LOCKED);
+ warFile.setLastModified(System.currentTimeMillis()+1000);
+ // It should be modified, but not show up in the mods
+ assertTrue("vfsfile ROOT.war hasBeenModified", rootWar.getRoot().hasBeenModified());
+ mods = sdr.getModifiedDeployments();
+ assertEquals("Collection<ModificationInfo> size is 0", 0, mods.size());
+
+ // Validate that the locked flag overrides the modified flag
+ assertFalse("vfsfile ROOT.war hasBeenModified", rootWar.getRoot().hasBeenModified());
+ flags = DeploymentContentFlags.LOCKED | DeploymentContentFlags.MODIFIED;
+ sdr.setDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION, flags);
+ mods = sdr.getModifiedDeployments();
+ assertEquals("Collection<ModificationInfo> size is 0", 0, mods.size());
+
+ // Validate that the modified flag allows it to show
+ flags = sdr.clearDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION,
+ DeploymentContentFlags.LOCKED);
+ assertEquals("ROOT.war has MODIFIED flag", flags, DeploymentContentFlags.MODIFIED);
+ mods = sdr.getModifiedDeployments();
+ assertEquals("Collection<ModificationInfo> size is 1", 1, mods.size());
+ warMods = mods.iterator().next();
+ assertEquals("ModificationInfo.status is MODIFIED", ModificationInfo.ModifyStatus.MODIFIED, warMods.getStatus());
+ assertEquals("ModificationInfo.name is ROOT.war", "ROOT.war", warMods.getDeployment().getSimpleName());
+ }
+
+ /**
+ * Get the file for the jboss server directory. Relies on one
+ * of the following variables to be set:
+ * JBOSS_HOME env variable
+ * jboss.home system property
+ *
+ * @return
+ * @throws IOException
+ */
+ protected File getServerRoot() throws IOException
+ {
+ String home = System.getenv("JBOSS_HOME");
+ if(home == null)
+ {
+ home = System.getProperty("jboss.home");
+ }
+ File defaultDir = new File(home, "server");
+ if(defaultDir.exists() == false)
+ throw new FileNotFoundException(defaultDir.getAbsolutePath()+", check the JBOSS_HOME env variable or jboss.home system property");
+ return defaultDir;
+ }
+}
More information about the jboss-cvs-commits
mailing list