[jboss-cvs] JBossAS SVN: r58904 - in trunk/server/src: etc/deployers main/org/jboss/deployment
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 7 12:22:01 EST 2006
Author: anil.saldhana at jboss.com
Date: 2006-12-07 12:22:00 -0500 (Thu, 07 Dec 2006)
New Revision: 58904
Added:
trunk/server/src/main/org/jboss/deployment/EARInitializingDeployer.java
Modified:
trunk/server/src/etc/deployers/ear-deployer-beans.xml
Log:
an initializing ear deployer for jacc initialization
Modified: trunk/server/src/etc/deployers/ear-deployer-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/ear-deployer-beans.xml 2006-12-07 17:21:31 UTC (rev 58903)
+++ trunk/server/src/etc/deployers/ear-deployer-beans.xml 2006-12-07 17:22:00 UTC (rev 58904)
@@ -42,5 +42,17 @@
</parameter>
</uninstall>
</bean>
-
+
+ <bean name="EARInitializingDeployer" class="org.jboss.deployment.EARInitializingDeployer">
+ <install bean="MainDeployer" method="addDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </install>
+ <uninstall bean="MainDeployer" method="removeDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </uninstall>
+ </bean>
</deployment>
Added: trunk/server/src/main/org/jboss/deployment/EARInitializingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EARInitializingDeployer.java 2006-12-07 17:21:31 UTC (rev 58903)
+++ trunk/server/src/main/org/jboss/deployment/EARInitializingDeployer.java 2006-12-07 17:22:00 UTC (rev 58904)
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+package org.jboss.deployment;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.deployers.plugins.deployers.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+
+//$Id$
+
+/**
+ * EAR Deployer that can be used for initialization
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @since Dec 6, 2006
+ * @version $Revision$
+ */
+public class EARInitializingDeployer extends AbstractSimpleRealDeployer<J2eeApplicationMetaData>
+{
+ public EARInitializingDeployer()
+ {
+ super(J2eeApplicationMetaData.class);
+ }
+
+ public void deploy(DeploymentUnit unit, J2eeApplicationMetaData deployment) throws DeploymentException
+ {
+ //Perform JACC Policy Configuration
+ String contextID = shortNameFromDeploymentName(unit.getSimpleName());
+ PolicyConfigurationFactory pcFactory = null;
+ try
+ {
+ pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
+ unit.addAttachment(PolicyConfiguration.class, pc);
+ }
+ catch (PolicyContextException e)
+ {
+ throw new DeploymentException("PolicyContextException generated in deploy", e);
+ }
+ catch(Exception e)
+ {
+ throw new DeploymentException("Exception generated in deploy", e);
+ }
+
+ }
+
+ public void undeploy(DeploymentUnit unit, J2eeApplicationMetaData deployment)
+ {
+ //Perform JACC cleanup for the EAR
+ unit.removeAttachment(PolicyConfiguration.class);
+ }
+
+
+ /**
+ * A utility method that takes a deployment unit name and strips it down to the base ear
+ * name without the .ear suffix.
+ * @param name - the DeploymentUnit name.
+ */
+ public static String shortNameFromDeploymentName(String name)
+ {
+ String shortName = name.trim();
+ String[] parts = name.split("/|\\.|\\!");
+ if( parts.length > 1 )
+ {
+ // If it ends in .war, use the previous part
+ if( parts[parts.length-1].equals("ear") )
+ shortName = parts[parts.length-2];
+ // else use the last part
+ else
+ shortName = parts[parts.length-1];
+ }
+ return shortName;
+ }
+}
More information about the jboss-cvs-commits
mailing list