[jboss-cvs] JBossAS SVN: r63680 - in projects/microcontainer/trunk: deployers-core-spi and 12 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 27 11:56:40 EDT 2007
Author: adrian at jboss.org
Date: 2007-06-27 11:56:40 -0400 (Wed, 27 Jun 2007)
New Revision: 63680
Added:
projects/microcontainer/trunk/deployers-core-spi/
projects/microcontainer/trunk/deployers-core-spi/.classpath
projects/microcontainer/trunk/deployers-core-spi/.project
projects/microcontainer/trunk/deployers-core-spi/pom.xml
projects/microcontainer/trunk/deployers-core-spi/src/
projects/microcontainer/trunk/deployers-core-spi/src/main/
projects/microcontainer/trunk/deployers-core-spi/src/main/org/
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/DeploymentException.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/DeploymentState.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/Ordered.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/Attachments.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/AttachmentsBuilder.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/AttachmentsFactory.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/ManagedObjectAttachments.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/ManagedObjectsWithTransientAttachments.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/MutableAttachments.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/PredeterminedManagedObjectAttachments.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/AbstractAttachments.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/AbstractMutableAttachments.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/ManagedObjectAttachmentsImpl.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/ManagedObjectsWithTransientAttachmentsImpl.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/PredeterminedManagedObjectAttachmentsImpl.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ClassPathEntry.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ContextInfo.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaData.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaDataBuilder.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaDataFactory.java
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/util/
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/util/builder/
projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/util/builder/AbstractBuilder.java
projects/microcontainer/trunk/deployers-core-spi/src/resources/
projects/microcontainer/trunk/deployers-core-spi/src/resources/tests/
projects/microcontainer/trunk/deployers-core-spi/src/tests/
Log:
Import refactored deployers code
Added: projects/microcontainer/trunk/deployers-core-spi/.classpath
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/.classpath (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/.classpath 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="target/eclipse-classes"/>
+</classpath>
Added: projects/microcontainer/trunk/deployers-core-spi/.project
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/.project (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/.project 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jboss-deployers-core-spi</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: projects/microcontainer/trunk/deployers-core-spi/pom.xml
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/pom.xml (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/pom.xml 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,14 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-microcontainer</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-deployers-core-spi</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Deployers Core SPI</name>
+ <url>http://www.jboss.com/products/jbossmc</url>
+ <description>JBoss Deployers Core SPI</description>
+</project>
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/DeploymentException.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/DeploymentException.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/DeploymentException.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,101 @@
+/*
+* 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.deployers.spi;
+
+/**
+ * DeploymentException.
+ *
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentException extends Exception
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 4495361010574179178L;
+
+ /**
+ * Rethrow a throwable as a deployment exception if it isn't already.
+ *
+ * @param message the message
+ * @param t the throwable
+ * @return never
+ * @throws DeploymentException always
+ */
+ public static DeploymentException rethrowAsDeploymentException(String message, Throwable t) throws DeploymentException
+ {
+ if (t instanceof DeploymentException)
+ throw (DeploymentException) t;
+ else
+ throw new DeploymentException(message, t);
+ }
+
+ /**
+ * Constructs a <code>DeploymentException</code> with <code>null</code>
+ * as its error detail message.
+ */
+ public DeploymentException()
+ {
+ }
+
+ /**
+ * Constructs a <code>DeploymentException</code> with the specified detail
+ * message. The error message string <code>s</code> can later be
+ * retrieved by the <code>{@link java.lang.Throwable#getMessage}</code>
+ * method of class <code>java.lang.Throwable</code>.
+ *
+ * @param s the message
+ */
+ public DeploymentException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Constructs a <code>DeploymentException</code> with the specified detail message and
+ * cause. <p>Note that the detail message associated with
+ * <code>cause</code> is <i>not</i> automatically incorporated in
+ * this exception's detail message.
+ *
+ * @param s the message
+ * @param cause the underlying cause
+ */
+ public DeploymentException(String s, Throwable cause)
+ {
+ super(s, cause);
+ }
+
+ /**
+ * Constructs a <code>DeploymentException</code> with the specified cause and a detail
+ * message of <tt>(cause==null ? null : cause.toString())</tt> (which
+ * typically contains the class and detail message of <tt>cause</tt>).
+ * This constructor is useful for exceptions that are little more than
+ * wrappers for other throwables (for example, {@link
+ * java.security.PrivilegedActionException}).
+ *
+ * @param cause the underlying cause
+ */
+ public DeploymentException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/DeploymentState.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/DeploymentState.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/DeploymentState.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,46 @@
+/*
+* 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.deployers.spi;
+
+/**
+ * DeploymentState.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public enum DeploymentState
+{
+ /** Deploy the deployment */
+ DEPLOYING,
+
+ /** Deployed the deployment */
+ DEPLOYED,
+
+ /** Undeploy the deployment */
+ UNDEPLOYING,
+
+ /** Undeployed the deployment */
+ UNDEPLOYED,
+
+ /** Error */
+ ERROR
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/Ordered.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/Ordered.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/Ordered.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.deployers.spi;
+
+import java.util.Comparator;
+
+/**
+ * A base interface for that defines the ordering contract and comparator.<p>
+ *
+ * Things with a lower order are processed first
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface Ordered
+{
+ /**
+ * Get the relative order
+ *
+ * @return the relative order
+ */
+ int getRelativeOrder();
+
+ /**
+ * Set the relative order.
+ *
+ * @param order the order
+ */
+ public void setRelativeOrder(int order);
+
+ /** The comparator for relative ordering of deployers */
+ Comparator<Ordered> COMPARATOR = new OrderedComparator();
+
+ /**
+ * The comparator for relative ordering
+ */
+ public class OrderedComparator implements Comparator<Ordered>
+ {
+ public int compare(Ordered o1, Ordered o2)
+ {
+ int relative = o1.getRelativeOrder() - o2.getRelativeOrder();
+ if (relative != 0)
+ return relative;
+ return o1.toString().compareTo(o2.toString());
+ }
+ }
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/Attachments.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/Attachments.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/Attachments.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,108 @@
+/*
+* 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.deployers.spi.attachments;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Attachments
+ *
+ * Represents a set of attachments
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Attachments extends Serializable
+{
+ /**
+ * Get all the attachments
+ *
+ * @return the unmodifiable attachments
+ */
+ Map<String, Object> getAttachments();
+
+ /**
+ * Get attachment
+ *
+ * @param name the name of the attachment
+ * @return the attachment or null if not present
+ * @throws IllegalArgumentException for a null name
+ */
+ Object getAttachment(String name);
+
+ /**
+ * Get attachment
+ *
+ * @param <T> the expected type
+ * @param name the name of the attachment
+ * @param expectedType the expected type
+ * @return the attachment or null if not present
+ * @throws IllegalArgumentException for a null name or expectedType
+ */
+ <T> T getAttachment(String name, Class<T> expectedType);
+
+ /**
+ * Get attachment
+ *
+ * @param <T> the expected type
+ * @param type the type
+ * @return the attachment or null if not present
+ * @throws IllegalArgumentException for a null name or type
+ */
+ <T> T getAttachment(Class<T> type);
+
+ /**
+ * Is the attachment present
+ *
+ * @param name the name of the attachment
+ * @return true when the attachment is present
+ * @throws IllegalArgumentException for a null name
+ */
+ boolean isAttachmentPresent(String name);
+
+ /**
+ * Is the attachment present
+ *
+ * @param name the name of the attachment
+ * @param expectedType the expected type
+ * @return true when the attachment is present
+ * @throws IllegalArgumentException for a null name or expectedType
+ */
+ boolean isAttachmentPresent(String name, Class<?> expectedType);
+
+ /**
+ * Is the attachment present
+ *
+ * @param type the type
+ * @return true when the attachment is present
+ * @throws IllegalArgumentException for a null name or type
+ */
+ boolean isAttachmentPresent(Class<?> type);
+
+ /**
+ * Are there any attachments
+ *
+ * @return true if there are any attachments, false otherwise.
+ */
+ boolean hasAttachments();
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/AttachmentsBuilder.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/AttachmentsBuilder.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/AttachmentsBuilder.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.attachments;
+
+import java.security.AccessController;
+
+import org.jboss.util.builder.AbstractBuilder;
+
+/**
+ * AttachmentsBuilder.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+class AttachmentsBuilder
+{
+ /** The default attachments builder */
+ private static String DEFAULT_FACTORY = "org.jboss.deployers.plugins.attachments.DefaultAttachmentsFactory";
+
+ /** The singleton */
+ private static AttachmentsFactory singleton;
+
+ /**
+ * Get the instance
+ *
+ * @return the instance
+ */
+ static synchronized AttachmentsFactory getInstance()
+ {
+ if (singleton == null)
+ {
+ AbstractBuilder<AttachmentsFactory> builder = new AbstractBuilder<AttachmentsFactory>(AttachmentsFactory.class, DEFAULT_FACTORY);
+ singleton = AccessController.doPrivileged(builder);
+ }
+ return singleton;
+ }
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/AttachmentsFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/AttachmentsFactory.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/AttachmentsFactory.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.attachments;
+
+/**
+ * AttachmentsFactory.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AttachmentsFactory
+{
+ /**
+ * Create an attachments object
+ *
+ * @return the attachments
+ */
+ public static Attachments createAttachments()
+ {
+ return AttachmentsBuilder.getInstance().newAttachments();
+ }
+
+ /**
+ * Create a mutable attachments object
+ *
+ * @return the attachments
+ */
+ public static MutableAttachments createMutableAttachments()
+ {
+ return AttachmentsBuilder.getInstance().newMutableAttachments();
+ }
+
+ /**
+ * Create an attachments object
+ *
+ * @return the attachments
+ */
+ protected abstract Attachments newAttachments();
+
+ /**
+ * Create a mutable attachments object
+ *
+ * @return the attachments
+ */
+ protected abstract MutableAttachments newMutableAttachments();
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/ManagedObjectAttachments.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/ManagedObjectAttachments.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/ManagedObjectAttachments.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.attachments;
+
+/**
+ * ManagedObjectAttachments.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ManagedObjectAttachments extends PredeterminedManagedObjectAttachments
+{
+ /**
+ * Get the transient managed objects
+ *
+ * @return the managed objects
+ */
+ MutableAttachments getTransientManagedObjects();
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/ManagedObjectsWithTransientAttachments.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/ManagedObjectsWithTransientAttachments.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/ManagedObjectsWithTransientAttachments.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.attachments;
+
+/**
+ * ManagedObjectAttachments.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ManagedObjectsWithTransientAttachments extends ManagedObjectAttachments
+{
+ /**
+ * Get the transient attachments
+ *
+ * @return the managed objects
+ */
+ MutableAttachments getTransientAttachments();
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/MutableAttachments.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/MutableAttachments.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/MutableAttachments.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.attachments;
+
+import java.util.Map;
+
+/**
+ * MutableAttachments.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MutableAttachments extends Attachments
+{
+ /**
+ * Add attachment
+ *
+ * @param name the name of the attachment
+ * @param attachment the attachment
+ * @return any previous attachment
+ * @throws IllegalArgumentException for a null name or attachment
+ * @throws UnsupportedOperationException when not supported by the implementation
+ */
+ Object addAttachment(String name, Object attachment);
+
+ /**
+ * Add attachment
+ *
+ * @param <T> the expected type
+ * @param name the name of the attachment
+ * @param attachment the attachment
+ * @param expectedType the expected type
+ * @return any previous attachment
+ * @throws IllegalArgumentException for a null name, attachment or expectedType
+ * @throws UnsupportedOperationException when not supported by the implementation
+ */
+ <T> T addAttachment(String name, T attachment, Class<T> expectedType);
+
+ /**
+ * Add attachment
+ *
+ * @param <T> the expected type
+ * @param attachment the attachment
+ * @param type the type
+ * @return any previous attachment
+ * @throws IllegalArgumentException for a null name, attachment or type
+ * @throws UnsupportedOperationException when not supported by the implementation
+ */
+ <T> T addAttachment(Class<T> type, T attachment);
+
+ /**
+ * Remove attachment
+ *
+ * @param name the name of the attachment
+ * @return the attachment or null if not present
+ * @throws IllegalArgumentException for a null name
+ * @throws UnsupportedOperationException when not supported by the implementation
+ */
+ Object removeAttachment(String name);
+
+ /**
+ * Remove attachment
+ *
+ * @param <T> the expected type
+ * @param name the name of the attachment
+ * @return the attachment or null if not present
+ * @param expectedType the expected type
+ * @throws IllegalArgumentException for a null name or expectedType
+ * @throws UnsupportedOperationException when not supported by the implementation
+ */
+ <T> T removeAttachment(String name, Class<T> expectedType);
+
+ /**
+ * Remove attachment
+ *
+ * @param <T> the expected type
+ * @return the attachment or null if not present
+ * @param type the type
+ * @throws IllegalArgumentException for a null name or type
+ */
+ <T> T removeAttachment(Class<T> type);
+
+ /**
+ * Set the attachments
+ *
+ * @param map the new attachments a map of names to attachments
+ * @throws IllegalArgumentException for a null map
+ */
+ void setAttachments(Map<String, Object> map);
+
+ /**
+ * Clear the attachments
+ *
+ * @throws UnsupportedOperationException when not supported by the implementation
+ */
+ void clear();
+
+ /**
+ * Get the number of changes that have happened.
+ *
+ * @return number of adds/removes that have happened since creation or clearChangeCount.
+ */
+ int getChangeCount();
+
+ /**
+ * Reset the change count to zero.
+ */
+ void clearChangeCount();
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/PredeterminedManagedObjectAttachments.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/PredeterminedManagedObjectAttachments.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/PredeterminedManagedObjectAttachments.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.attachments;
+
+import java.io.Serializable;
+
+/**
+ * PredeterminedManagedObjectAttachments.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PredeterminedManagedObjectAttachments extends Serializable
+{
+ /**
+ * Get the predetermined managed objects
+ *
+ * @return the predetermined managed objects
+ */
+ Attachments getPredeterminedManagedObjects();
+
+ /**
+ * Set the predetermined managed objects
+ *
+ * @param predetermined the predetermined managed objects
+ * @throws IllegalArgumentException for a null parameter
+ */
+ void setPredeterminedManagedObjects(Attachments predetermined);
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/AbstractAttachments.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/AbstractAttachments.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/AbstractAttachments.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,91 @@
+/*
+* 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.deployers.spi.attachments.helpers;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.jboss.deployers.spi.attachments.Attachments;
+
+/**
+ * AbstractAttachments.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractAttachments implements Attachments, Externalizable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -4084792454892396925L;
+
+ public <T> T getAttachment(String name, Class<T> expectedType)
+ {
+ if (expectedType == null)
+ throw new IllegalArgumentException("Null expectedType");
+ Object result = getAttachment(name);
+ if (result == null)
+ return null;
+ return expectedType.cast(result);
+ }
+
+ public <T> T getAttachment(Class<T> type)
+ {
+ if (type == null)
+ throw new IllegalArgumentException("Null type");
+ return getAttachment(type.getName(), type);
+ }
+
+ public boolean isAttachmentPresent(String name, Class<?> expectedType)
+ {
+ if (expectedType == null)
+ throw new IllegalArgumentException("Null expectedType");
+ Object result = getAttachment(name);
+ if (result == null)
+ return false;
+ try
+ {
+ expectedType.cast(result);
+ }
+ catch (ClassCastException e)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean isAttachmentPresent(Class<?> type)
+ {
+ if (type == null)
+ throw new IllegalArgumentException("Null type");
+ return isAttachmentPresent(type.getName(), type);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ }
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/AbstractMutableAttachments.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/AbstractMutableAttachments.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/AbstractMutableAttachments.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.attachments.helpers;
+
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+
+/**
+ * AbstractMutableAttachments.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractMutableAttachments extends AbstractAttachments implements MutableAttachments
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1692116584854666016L;
+
+ public <T> T addAttachment(String name, T attachment, Class<T> expectedType)
+ {
+ if (expectedType == null)
+ throw new IllegalArgumentException("Null expectedType");
+ Object result = addAttachment(name, attachment);
+ if (result == null)
+ return null;
+ return expectedType.cast(result);
+ }
+
+ public void setAttachments(Map<String, Object> map)
+ {
+ if (map == null)
+ throw new IllegalArgumentException("Null map");
+
+ clear();
+
+ for (Entry<String, Object> entry : map.entrySet())
+ addAttachment(entry.getKey(), entry.getValue());
+ }
+
+ public <T> T addAttachment(Class<T> type, T attachment)
+ {
+ if (type == null)
+ throw new IllegalArgumentException("Null type");
+ return addAttachment(type.getName(), attachment, type);
+ }
+
+ public <T> T removeAttachment(String name, Class<T> expectedType)
+ {
+ if (expectedType == null)
+ throw new IllegalArgumentException("Null expectedType");
+ Object result = removeAttachment(name);
+ if (result == null)
+ return null;
+ return expectedType.cast(result);
+ }
+
+ public <T> T removeAttachment(Class<T> type)
+ {
+ if (type == null)
+ throw new IllegalArgumentException("Null type");
+ return removeAttachment(type.getName(), type);
+ }
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/ManagedObjectAttachmentsImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/ManagedObjectAttachmentsImpl.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/ManagedObjectAttachmentsImpl.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.attachments.helpers;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.jboss.deployers.spi.attachments.AttachmentsFactory;
+import org.jboss.deployers.spi.attachments.ManagedObjectAttachments;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+
+/**
+ * ManagedObjectAttachmentsImpl.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagedObjectAttachmentsImpl extends PredeterminedManagedObjectAttachmentsImpl implements ManagedObjectAttachments
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -195530143173768763L;
+
+ /** The transient managed objects */
+ private MutableAttachments transientManagedObjects = AttachmentsFactory.createMutableAttachments();
+
+ public MutableAttachments getTransientManagedObjects()
+ {
+ return transientManagedObjects;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ super.readExternal(in);
+ transientManagedObjects = (MutableAttachments) in.readObject();
+ }
+
+ /**
+ * @serialData attachments
+ * @param out the output
+ * @throws IOException for any error
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ super.writeExternal(out);
+ out.writeObject(transientManagedObjects);
+ }
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/ManagedObjectsWithTransientAttachmentsImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/ManagedObjectsWithTransientAttachmentsImpl.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/ManagedObjectsWithTransientAttachmentsImpl.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.attachments.helpers;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.jboss.deployers.spi.attachments.AttachmentsFactory;
+import org.jboss.deployers.spi.attachments.ManagedObjectsWithTransientAttachments;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+
+/**
+ * ManagedObjectsWithTransientAttachmentsImpl.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagedObjectsWithTransientAttachmentsImpl extends ManagedObjectAttachmentsImpl implements ManagedObjectsWithTransientAttachments
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -195530143173768763L;
+
+ /** The transient attachments */
+ private transient MutableAttachments transientAttachments;
+
+ /**
+ * Create a new ManagedObjectsWithTransientAttachmentsImpl.
+ */
+ public ManagedObjectsWithTransientAttachmentsImpl()
+ {
+ transientAttachments = AttachmentsFactory.createMutableAttachments();
+ }
+
+ public MutableAttachments getTransientAttachments()
+ {
+ return transientAttachments;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ super.readExternal(in);
+ }
+
+ /**
+ * @param out the output
+ * @throws IOException for any error
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ super.writeExternal(out);
+ }
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/PredeterminedManagedObjectAttachmentsImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/PredeterminedManagedObjectAttachmentsImpl.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/attachments/helpers/PredeterminedManagedObjectAttachmentsImpl.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.attachments.helpers;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.attachments.AttachmentsFactory;
+import org.jboss.deployers.spi.attachments.PredeterminedManagedObjectAttachments;
+
+/**
+ * PredeterminedManagedObjectAttachmentsImpl.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class PredeterminedManagedObjectAttachmentsImpl implements PredeterminedManagedObjectAttachments, Externalizable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -195530143173768763L;
+
+ /** The predetermined attachments */
+ private Attachments predetermined = AttachmentsFactory.createMutableAttachments();
+
+ public Attachments getPredeterminedManagedObjects()
+ {
+ return predetermined;
+ }
+
+ public void setPredeterminedManagedObjects(Attachments predetermined)
+ {
+ if (predetermined == null)
+ throw new IllegalArgumentException("Null predetermined");
+ this.predetermined = predetermined;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ predetermined = (Attachments) in.readObject();
+ }
+
+ /**
+ * @serialData attachments
+ * @param out the output
+ * @throws IOException for any error
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeObject(predetermined);
+ }
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ClassPathEntry.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ClassPathEntry.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ClassPathEntry.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.deployers.spi.structure;
+
+import java.io.Serializable;
+
+/**
+ * A classpath entry.
+ *
+ * TODO other stuff e.g. inclusion/exclusion filters, etc.
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision: 1.1$
+ */
+public interface ClassPathEntry extends Serializable
+{
+ /**
+ * Get the path relative to the context virtual file
+ *
+ * @return the path.
+ */
+ String getPath();
+
+ /**
+ * Get the suffixes
+ *
+ * @return the suffixes.
+ */
+ String getSuffixes();
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ContextInfo.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ContextInfo.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ContextInfo.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.deployers.spi.structure;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jboss.deployers.spi.attachments.PredeterminedManagedObjectAttachments;
+
+/**
+ * An encapsulation of context information
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision: 1.1$
+ */
+public interface ContextInfo extends PredeterminedManagedObjectAttachments, Serializable
+{
+ /** The default metadata path */
+ String DEFAULT_METADATA_PATH = "META-INF";
+
+ /**
+ * Get the logical path of the context
+ *
+ * @return the logical path
+ */
+ String getPath();
+
+ /**
+ * Get the logical path of the metdata location.
+ *
+ * @return the path of the metdata location.
+ */
+ String getMetaDataPath();
+
+ /**
+ * Get the classpath locations within the context
+ *
+ * @return the possibly null context classpath
+ */
+ List<ClassPathEntry> getClassPath();
+
+ /**
+ * Add a class path entry
+ *
+ * @param entry the entry to add
+ * @throws IllegalArgumentException for a null entry
+ */
+ void addClassPathEntry(ClassPathEntry entry);
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaData.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaData.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaData.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.deployers.spi.structure;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * A set of subdeployment contexts.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision: 1.1$
+ */
+public interface StructureMetaData extends Serializable
+{
+ /**
+ * Get a context by path
+ *
+ * @param path the path of the context
+ * @return the context or null if there is no such context
+ * @throws IllegalArgumentException for a null path
+ */
+ ContextInfo getContext(String path);
+
+ /**
+ * Add a context
+ *
+ * @param context the context to add
+ * @throws IllegalArgumentException for a null context or if the context has no path
+ * @throws IllegalStateException if a context is already present with that path
+ */
+ void addContext(ContextInfo context);
+
+ /**
+ * Remove a context
+ *
+ * @param context the context to remove
+ * @throws IllegalArgumentException for a null context
+ */
+ void removeContext(ContextInfo context);
+
+ /**
+ * Remove a context
+ *
+ * @param path the patch of the context to remove
+ * @throws IllegalArgumentException for a null path
+ */
+ void removeContext(String path);
+
+ /**
+ * Get the contexts
+ *
+ * @return an immutable set of contexts
+ */
+ List<ContextInfo> getContexts();
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaDataBuilder.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaDataBuilder.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaDataBuilder.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.structure;
+
+import java.security.AccessController;
+
+import org.jboss.util.builder.AbstractBuilder;
+
+/**
+ * StructureMetaDataBuilder.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+class StructureMetaDataBuilder
+{
+ /** The default attachments builder */
+ private static String DEFAULT_FACTORY = "org.jboss.deployers.plugins.structure.DefaultStructureMetaDataFactory";
+
+ /** The singleton */
+ private static StructureMetaDataFactory singleton;
+
+ /**
+ * Get the instance
+ *
+ * @return the instance
+ */
+ static synchronized StructureMetaDataFactory getInstance()
+ {
+ if (singleton == null)
+ {
+ AbstractBuilder<StructureMetaDataFactory> builder = new AbstractBuilder<StructureMetaDataFactory>(StructureMetaDataFactory.class, DEFAULT_FACTORY);
+ singleton = AccessController.doPrivileged(builder);
+ }
+ return singleton;
+ }
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaDataFactory.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/StructureMetaDataFactory.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.spi.structure;
+
+import java.util.List;
+
+/**
+ * StructureFactory.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class StructureMetaDataFactory
+{
+ /**
+ * Create a new StructureMetaData.
+ *
+ * @return the structure metadata
+ */
+ public static StructureMetaData createStructureMetaData()
+ {
+ return StructureMetaDataBuilder.getInstance().newStructureMetaData();
+ }
+
+ /**
+ * Create a new ContextInfo.
+ *
+ * @return the context info
+ * @throws IllegalArgumentException for a null path
+ */
+ public static ContextInfo createContextInfo()
+ {
+ return StructureMetaDataBuilder.getInstance().newContextInfo("");
+ }
+
+ /**
+ * Create a new ContextInfo.
+ *
+ * @param path the path
+ * @return the context info
+ * @throws IllegalArgumentException for a null path
+ */
+ public static ContextInfo createContextInfo(String path)
+ {
+ return StructureMetaDataBuilder.getInstance().newContextInfo(path);
+ }
+
+ /**
+ * Create a new ContextInfo.
+ *
+ * @param path the path
+ * @param classPath the classpath
+ * @return the context info
+ * @throws IllegalArgumentException for a null path
+ */
+ public static ContextInfo createContextInfo(String path, List<ClassPathEntry> classPath)
+ {
+ return StructureMetaDataBuilder.getInstance().newContextInfo(path, classPath);
+ }
+
+ /**
+ * Create a new ContextInfo.
+ *
+ * @param path the path
+ * @param metaDataPath the metadata path
+ * @param classPath the class path
+ * @return the context info
+ * @throws IllegalArgumentException for a null path or metadata path
+ */
+ public static ContextInfo createContextInfo(String path, String metaDataPath, List<ClassPathEntry> classPath)
+ {
+ return StructureMetaDataBuilder.getInstance().newContextInfo(path, metaDataPath, classPath);
+ }
+
+ /**
+ * Create a new classpath entry
+ *
+ * @return the classpath entry
+ */
+ public static ClassPathEntry createClassPathEntry()
+ {
+ return StructureMetaDataBuilder.getInstance().newClassPathEntry("", null);
+ }
+
+ /**
+ * Create a new classpath entry
+ *
+ * @param path the path
+ * @return the classpath entry
+ * @throws IllegalArgumentException for a null path
+ */
+ public static ClassPathEntry createClassPathEntry(String path)
+ {
+ return StructureMetaDataBuilder.getInstance().newClassPathEntry(path, null);
+ }
+
+ /**
+ * Create a new classpath entry
+ *
+ * @param path the path
+ * @param suffixes the suffixes
+ * @return the classpath entry
+ * @throws IllegalArgumentException for a null path
+ */
+ public static ClassPathEntry createClassPathEntry(String path, String suffixes)
+ {
+ return StructureMetaDataBuilder.getInstance().newClassPathEntry(path, suffixes);
+ }
+
+ /**
+ * Create a new StructureMetaData.
+ *
+ * @return the structure metadata
+ */
+ protected abstract StructureMetaData newStructureMetaData();
+
+ /**
+ * Create a new ContextInfo.
+ *
+ * @param path the path
+ * @return the context info
+ * @throws IllegalArgumentException for a null path
+ */
+ protected abstract ContextInfo newContextInfo(String path);
+
+ /**
+ * Create a new ContextInfo.
+ *
+ * @param path the path
+ * @param classPath the classpath
+ * @return the context info
+ * @throws IllegalArgumentException for a null path
+ */
+ protected abstract ContextInfo newContextInfo(String path, List<ClassPathEntry> classPath);
+
+ /**
+ * Create a new ContextInfo.
+ *
+ * @param path the path
+ * @param metaDataPath the metadata path
+ * @param classPath the class path
+ * @return the context info
+ * @throws IllegalArgumentException for a null path or metadata path
+ */
+ protected abstract ContextInfo newContextInfo(String path, String metaDataPath, List<ClassPathEntry> classPath);
+
+ /**
+ * Create a new classpath entry
+ *
+ * @param path the path
+ * @param suffixes the suffixes
+ * @return the classpath entry
+ * @throws IllegalArgumentException for a null path
+ */
+ protected abstract ClassPathEntry newClassPathEntry(String path, String suffixes);
+}
Added: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/util/builder/AbstractBuilder.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/util/builder/AbstractBuilder.java (rev 0)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/util/builder/AbstractBuilder.java 2007-06-27 15:56:40 UTC (rev 63680)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.util.builder;
+
+import java.security.PrivilegedAction;
+
+/**
+ * AbstractBuilder.
+ *
+ * @param <T> the type to be built
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractBuilder<T> implements PrivilegedAction<T>
+{
+ /** The factory class */
+ private Class<T> factoryClass;
+
+ /** The default factory */
+ private String defaultFactory;
+
+ /**
+ * Create a new AbstractBuilder.
+ *
+ * @param factoryClass the factory class
+ * @param defaultFactory the default factory
+ * @throws IllegalArgumentException for a null parameter
+ */
+ public AbstractBuilder(Class<T> factoryClass, String defaultFactory)
+ {
+ if (factoryClass == null)
+ throw new IllegalArgumentException("Null factory class");
+ if (defaultFactory == null)
+ throw new IllegalArgumentException("Null default factory");
+ this.factoryClass = factoryClass;
+ this.defaultFactory = defaultFactory;
+ }
+
+ public T run()
+ {
+ try
+ {
+ String className = System.getProperty(factoryClass.getName(), defaultFactory);
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+ Object object = clazz.newInstance();
+ return factoryClass.cast(object);
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error constructing " + factoryClass.getName(), t);
+ }
+ }
+}
More information about the jboss-cvs-commits
mailing list