You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2006/07/04 02:50:47 UTC

svn commit: r418888 [2/7] - in /geronimo/branches/pluggable-jacc: ./ applications/console/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/ configs/ configs/activemq/ configs/client-deployer/src/plan/ configs/client/ configs/...

Modified: geronimo/branches/pluggable-jacc/applications/console/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/applications/console/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/applications/console/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java (original)
+++ geronimo/branches/pluggable-jacc/applications/console/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java Mon Jul  3 17:50:41 2006
@@ -29,6 +29,7 @@
 import org.apache.geronimo.deployment.xbeans.GbeanType;
 import org.apache.geronimo.deployment.xbeans.ReferenceType;
 import org.apache.geronimo.deployment.xbeans.XmlAttributeType;
+import org.apache.geronimo.deployment.xbeans.AbstractServiceType;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.proxy.GeronimoManagedBean;
@@ -70,6 +71,7 @@
 import javax.portlet.WindowState;
 import javax.security.auth.Subject;
 import javax.security.auth.spi.LoginModule;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileWriter;
@@ -103,26 +105,26 @@
 public class SecurityRealmPortlet extends BasePortlet {
     private final static Log log = LogFactory.getLog(SecurityRealmPortlet.class);
     private final static String[] SKIP_ENTRIES_WITH = new String[]{"geronimo", "tomcat", "tranql", "commons", "directory", "activemq"};
-    private static final String LIST_VIEW          = "/WEB-INF/view/realmwizard/list.jsp";
-    private static final String EDIT_VIEW          = "/WEB-INF/view/realmwizard/edit.jsp";
-    private static final String SELECT_TYPE_VIEW   = "/WEB-INF/view/realmwizard/selectType.jsp";
-    private static final String CONFIGURE_VIEW     = "/WEB-INF/view/realmwizard/configure.jsp";
-    private static final String ADVANCED_VIEW      = "/WEB-INF/view/realmwizard/advanced.jsp";
-    private static final String TEST_LOGIN_VIEW    = "/WEB-INF/view/realmwizard/testLogin.jsp";
-    private static final String TEST_RESULTS_VIEW  = "/WEB-INF/view/realmwizard/testResults.jsp";
-    private static final String SHOW_PLAN_VIEW     = "/WEB-INF/view/realmwizard/showPlan.jsp";
-    private static final String USAGE_VIEW         = "/WEB-INF/view/realmwizard/usage.jsp";
-    private static final String LIST_MODE          = "list";
-    private static final String EDIT_MODE          = "edit";
-    private static final String SELECT_TYPE_MODE   = "type";
-    private static final String CONFIGURE_MODE     = "configure";
-    private static final String ADVANCED_MODE      = "advanced";
-    private static final String TEST_LOGIN_MODE    = "test";
-    private static final String TEST_RESULTS_MODE  = "results";
-    private static final String SHOW_PLAN_MODE     = "plan";
+    private static final String LIST_VIEW = "/WEB-INF/view/realmwizard/list.jsp";
+    private static final String EDIT_VIEW = "/WEB-INF/view/realmwizard/edit.jsp";
+    private static final String SELECT_TYPE_VIEW = "/WEB-INF/view/realmwizard/selectType.jsp";
+    private static final String CONFIGURE_VIEW = "/WEB-INF/view/realmwizard/configure.jsp";
+    private static final String ADVANCED_VIEW = "/WEB-INF/view/realmwizard/advanced.jsp";
+    private static final String TEST_LOGIN_VIEW = "/WEB-INF/view/realmwizard/testLogin.jsp";
+    private static final String TEST_RESULTS_VIEW = "/WEB-INF/view/realmwizard/testResults.jsp";
+    private static final String SHOW_PLAN_VIEW = "/WEB-INF/view/realmwizard/showPlan.jsp";
+    private static final String USAGE_VIEW = "/WEB-INF/view/realmwizard/usage.jsp";
+    private static final String LIST_MODE = "list";
+    private static final String EDIT_MODE = "edit";
+    private static final String SELECT_TYPE_MODE = "type";
+    private static final String CONFIGURE_MODE = "configure";
+    private static final String ADVANCED_MODE = "advanced";
+    private static final String TEST_LOGIN_MODE = "test";
+    private static final String TEST_RESULTS_MODE = "results";
+    private static final String SHOW_PLAN_MODE = "plan";
     private static final String EDIT_EXISTING_MODE = "editExisting";
-    private static final String USAGE_MODE         = "usage";
-    private static final String SAVE_MODE          = "save";
+    private static final String USAGE_MODE = "usage";
+    private static final String SAVE_MODE = "save";
     private static final String MODE_KEY = "mode";
 
     private PortletRequestDispatcher listView;
@@ -165,13 +167,13 @@
         String mode = actionRequest.getParameter(MODE_KEY);
         RealmData data = new RealmData();
         data.load(actionRequest);
-        if(mode.equals(SELECT_TYPE_MODE)) {
-            data.realmType="Properties File Realm";
+        if (mode.equals(SELECT_TYPE_MODE)) {
+            data.realmType = "Properties File Realm";
             actionResponse.setRenderParameter(MODE_KEY, SELECT_TYPE_MODE);
-        } else if(mode.equals("process-"+SELECT_TYPE_MODE)) {
-            if(data.getName() != null && !data.getName().trim().equals("")) {
+        } else if (mode.equals("process-" + SELECT_TYPE_MODE)) {
+            if (data.getName() != null && !data.getName().trim().equals("")) {
                 // Config properties have to be set in render since they have values of null
-                if(data.getRealmType().equals("Other")) {
+                if (data.getRealmType().equals("Other")) {
                     actionResponse.setRenderParameter(MODE_KEY, EDIT_MODE);
                 } else {
                     actionResponse.setRenderParameter(MODE_KEY, CONFIGURE_MODE);
@@ -179,39 +181,40 @@
             } else {
                 actionResponse.setRenderParameter(MODE_KEY, SELECT_TYPE_MODE);
             }
-        } else if(mode.equals("process-"+CONFIGURE_MODE)) {
+        } else if (mode.equals("process-" + CONFIGURE_MODE)) {
             final String error = actionTestLoginModuleLoad(actionRequest, data);
-            if(error == null) {
+            if (error == null) {
                 actionResponse.setRenderParameter(MODE_KEY, ADVANCED_MODE);
             } else {
                 actionResponse.setRenderParameter("LoginModuleError", error);
                 actionResponse.setRenderParameter(MODE_KEY, CONFIGURE_MODE);
             }
-        } else if(mode.equals("process-"+ADVANCED_MODE)) {
+        } else if (mode.equals("process-" + ADVANCED_MODE)) {
             String test = actionRequest.getParameter("test");
-            if(test == null || test.equals("true")) {
+            if (test == null || test.equals("true")) {
                 actionResponse.setRenderParameter(MODE_KEY, TEST_LOGIN_MODE);
             } else {
                 actionSaveRealm(actionRequest, data);
                 actionResponse.setRenderParameter(MODE_KEY, LIST_MODE);
             }
-        } else if(mode.equals("process-"+TEST_LOGIN_MODE)) {
+        } else if (mode.equals("process-" + TEST_LOGIN_MODE)) {
             actionAttemptLogin(data, actionRequest, actionRequest.getPortletSession(true), actionRequest.getParameter("username"), actionRequest.getParameter("password"));
             actionResponse.setRenderParameter(MODE_KEY, TEST_RESULTS_MODE);
-        } else if(mode.equals(SHOW_PLAN_MODE)) {
+        } else if (mode.equals(SHOW_PLAN_MODE)) {
             XmlObject object = actionGeneratePlan(actionRequest, data);
             savePlanToSession(actionRequest.getPortletSession(true), object);
             actionResponse.setRenderParameter(MODE_KEY, SHOW_PLAN_MODE);
-        } else if(mode.equals(EDIT_EXISTING_MODE)) {
+        } else if (mode.equals(EDIT_EXISTING_MODE)) {
             actionLoadExistingRealm(actionRequest, data);
             actionResponse.setRenderParameter(MODE_KEY, EDIT_MODE);
-        } else if(mode.equals(CONFIGURE_MODE)) {
-            if(data.getAbstractName() != null || (data.getRealmType() != null && data.getRealmType().equals("Other"))) {
+        } else if (mode.equals(CONFIGURE_MODE)) {
+            if (data.getAbstractName() != null || (data.getRealmType() != null && data.getRealmType().equals("Other")))
+            {
                 actionResponse.setRenderParameter(MODE_KEY, EDIT_MODE);
             } else {
                 actionResponse.setRenderParameter(MODE_KEY, CONFIGURE_MODE);
             }
-        } else if(mode.equals(SAVE_MODE)) {
+        } else if (mode.equals(SAVE_MODE)) {
             actionSaveRealm(actionRequest, data);
             actionResponse.setRenderParameter(MODE_KEY, LIST_MODE);
         } else {
@@ -229,26 +232,26 @@
             RealmData data = new RealmData();
             data.load(renderRequest);
             renderRequest.setAttribute("realm", data);
-            if(mode == null || mode.equals("")) {
+            if (mode == null || mode.equals("")) {
                 mode = LIST_MODE;
             }
-            if(mode.equals(LIST_MODE)) {
+            if (mode.equals(LIST_MODE)) {
                 renderList(renderRequest, renderResponse);
-            } else if(mode.equals(EDIT_MODE)) {
+            } else if (mode.equals(EDIT_MODE)) {
                 renderEdit(renderRequest, renderResponse, data);
-            } else if(mode.equals(SELECT_TYPE_MODE)) {
+            } else if (mode.equals(SELECT_TYPE_MODE)) {
                 renderSelectType(renderRequest, renderResponse);
-            } else if(mode.equals(CONFIGURE_MODE)) {
+            } else if (mode.equals(CONFIGURE_MODE)) {
                 renderConfigure(renderRequest, renderResponse, data);
-            } else if(mode.equals(ADVANCED_MODE)) {
+            } else if (mode.equals(ADVANCED_MODE)) {
                 renderAdvanced(renderRequest, renderResponse, data);
-            } else if(mode.equals(TEST_LOGIN_MODE)) {
+            } else if (mode.equals(TEST_LOGIN_MODE)) {
                 renderTestLoginForm(renderRequest, renderResponse);
-            } else if(mode.equals(TEST_RESULTS_MODE)) {
+            } else if (mode.equals(TEST_RESULTS_MODE)) {
                 renderTestResults(renderRequest, renderResponse);
-            } else if(mode.equals(SHOW_PLAN_MODE)) {
+            } else if (mode.equals(SHOW_PLAN_MODE)) {
                 renderPlan(renderRequest, renderResponse);
-            } else if(mode.equals(USAGE_MODE)) {
+            } else if (mode.equals(USAGE_MODE)) {
                 renderUsage(renderRequest, renderResponse);
             }
         } catch (Throwable e) {
@@ -260,30 +263,30 @@
         Map options = new HashMap();
         try {
             LoginModule module = loadModule(request, data, options);
-            log.warn("Testing with options "+options);
+            log.warn("Testing with options " + options);
             try {
                 PortletManager.testLoginModule(request, module, options);
                 return null;
             } catch (Exception e) {
                 log.warn("Unable to initialize LoginModule", e);
-                return "Unable to initialize LoginModule: "+e.getMessage();
+                return "Unable to initialize LoginModule: " + e.getMessage();
             }
         } catch (Exception e) {
             log.warn("Unable to load LoginModule class", e);
-            return "Unable to load LoginModule class: "+e.getMessage();
+            return "Unable to load LoginModule class: " + e.getMessage();
         }
     }
 
     private LoginModule loadModule(PortletRequest request, RealmData data, Map options) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
         ClassLoader loader = getClass().getClassLoader();
-        if(data.jar != null && !data.jar.equals("")) {
+        if (data.jar != null && !data.jar.equals("")) {
             try {
                 Artifact one = Artifact.create(data.getJar());
                 ListableRepository[] repos = PortletManager.getCurrentServer(request).getRepositories();
                 for (int i = 0; i < repos.length; i++) {
                     ListableRepository repo = repos[i];
                     File file = repo.getLocation(one);
-                    if(file != null) {
+                    if (file != null) {
                         loader = new URLClassLoader(new URL[]{file.toURL()}, loader);
                         break;
                     }
@@ -297,7 +300,7 @@
         for (Iterator it = data.getOptions().keySet().iterator(); it.hasNext();) {
             String key = (String) it.next();
             final Object value = data.getOptions().get(key);
-            if(value != null && !value.equals("")) {
+            if (value != null && !value.equals("")) {
                 options.put(key, value);
             }
         }
@@ -315,7 +318,7 @@
             session.setAttribute("TestLoginPrincipals", sub.getPrincipals());
         } catch (Exception e) {
             log.warn("Test login failed", e);
-            session.setAttribute("TestLoginError", "Login Failed: "+(e.getMessage() == null ? "no message" : e.getMessage()));
+            session.setAttribute("TestLoginError", "Login Failed: " + (e.getMessage() == null ? "no message" : e.getMessage()));
         }
     }
 
@@ -326,7 +329,7 @@
         EnvironmentType environment = root.addNewEnvironment();
         ArtifactType configId = environment.addNewModuleId();
         configId.setGroupId("console");
-        configId.setArtifactId("realm-"+data.getName());
+        configId.setArtifactId("realm-" + data.getName());
         configId.setVersion("1.0");
         configId.setType("car");
 
@@ -338,7 +341,7 @@
         parent.setArtifactId("j2ee-security");
         parent.setType("car");
         // Dependencies
-        if(data.getJar() != null) {
+        if (data.getJar() != null) {
             ArtifactType artifactType = dependenciesType.addNewDependency();
             Artifact artifact = Artifact.create(data.getJar());
             artifactType.setGroupId(artifact.getGroupId());
@@ -347,7 +350,8 @@
             artifactType.setType(artifact.getType());
         }
         // Build the realm GBean
-        GbeanType realm = root.addNewGbean();
+        GbeanType realm = GbeanType.Factory.newInstance();
+        root.setServiceArray(new AbstractServiceType[]{realm});
         realm.setName(data.getName());
         realm.setClass1("org.apache.geronimo.security.realm.GenericSecurityRealm");
         AttributeType realmName = realm.addNewAttribute();
@@ -355,25 +359,25 @@
         realmName.setStringValue(data.getName());
         ReferenceType serverInfo = realm.addNewReference();
         serverInfo.setName2("ServerInfo");
-        serverInfo.setName((String)PortletManager.getNameFor(request, PortletManager.getCurrentServer(request).getServerInfo()).getName().get("name"));
+        serverInfo.setName((String) PortletManager.getNameFor(request, PortletManager.getCurrentServer(request).getServerInfo()).getName().get("name"));
         ReferenceType loginService = realm.addNewReference();
         loginService.setName2("LoginService");
-        loginService.setName((String)PortletManager.getNameFor(request, PortletManager.getCurrentServer(request).getLoginService()).getName().get("name"));
+        loginService.setName((String) PortletManager.getNameFor(request, PortletManager.getCurrentServer(request).getLoginService()).getName().get("name"));
         XmlAttributeType config = realm.addNewXmlReference();
         // Construct the content to put in the XmlAttributeType
         GerLoginConfigDocument lcDoc = GerLoginConfigDocument.Factory.newInstance();
         GerLoginConfigType login = lcDoc.addNewLoginConfig();
         for (int i = 0; i < data.getModules().length; i++) {
             LoginModuleDetails details = data.getModules()[i];
-            if(details.getLoginDomainName() == null || details.getLoginDomainName().equals("")) {
+            if (details.getLoginDomainName() == null || details.getLoginDomainName().equals("")) {
                 continue;
             }
             GerLoginModuleType module = login.addNewLoginModule();
             module.setControlFlag(details.getControlFlag().equals("OPTIONAL") ? GerControlFlagType.OPTIONAL :
                     details.getControlFlag().equals("REQUIRED") ? GerControlFlagType.REQUIRED :
-                    details.getControlFlag().equals("REQUISITE") ? GerControlFlagType.REQUISITE :
-                    details.getControlFlag().equals("SUFFICIENT") ? GerControlFlagType.SUFFICIENT :
-                    GerControlFlagType.OPTIONAL);
+                            details.getControlFlag().equals("REQUISITE") ? GerControlFlagType.REQUISITE :
+                                    details.getControlFlag().equals("SUFFICIENT") ? GerControlFlagType.SUFFICIENT :
+                                            GerControlFlagType.OPTIONAL);
             module.setServerSide(details.isServerSide());
             module.setLoginDomainName(details.getLoginDomainName());
             module.setLoginModuleClass(details.getClassName());
@@ -386,11 +390,11 @@
             }
 
             // bit of a hack -- to put the DataSource module in as a parent for SQL modules
-            if(details.getClassName().indexOf("SQL") > -1) {
+            if (details.getClassName().indexOf("SQL") > -1) {
                 String poolName = (String) details.getOptions().get("dataSourceName");
                 String appName = (String) details.getOptions().get("dataSourceApplication");
-                if(poolName != null) {
-                    if(appName == null) appName = "null";
+                if (poolName != null) {
+                    if (appName == null) appName = "null";
                     JCAManagedConnectionFactory[] factories = PortletManager.getOutboundFactoriesOfType(request, "javax.sql.DataSource");
                     for (int j = 0; j < factories.length; j++) {
                         JCAManagedConnectionFactory factory = factories[j];
@@ -398,7 +402,7 @@
                             ObjectName objectName = ObjectName.getInstance(factory.getObjectName());
                             final String testName = objectName.getKeyProperty(NameFactory.J2EE_NAME);
                             final String testApp = objectName.getKeyProperty(NameFactory.J2EE_APPLICATION);
-                            if(testName.equals(poolName) && testApp.equals(appName)) {
+                            if (testName.equals(poolName) && testApp.equals(appName)) {
                                 String moduleName = objectName.getKeyProperty(NameFactory.JCA_RESOURCE);
 
                                 ArtifactType artifactType = dependenciesType.addNewDependency();
@@ -434,7 +438,7 @@
         data.name = realm.getRealmName();
         List list = new ArrayList();
         JaasLoginModuleChain node = realm.getLoginModuleChain();
-        while(node != null) {
+        while (node != null) {
             LoginModuleDetails details = new LoginModuleDetails();
             details.setControlFlag(node.getControlFlag());
             LoginModuleSettings module = node.getLoginModule();
@@ -445,7 +449,7 @@
             details.setOptions(module.getOptions());
             list.add(details);
             node = node.getNext();
-            if(node == null) {
+            if (node == null) {
                 break;
             }
         }
@@ -454,14 +458,14 @@
 
     private void actionSaveRealm(PortletRequest request, RealmData data) {
         normalize(data);
-        if(data.getAbstractName() == null || data.getAbstractName().equals("")) { // we're creating a new realm
+        if (data.getAbstractName() == null || data.getAbstractName().equals("")) { // we're creating a new realm
             try {
                 XmlObject plan = actionGeneratePlan(request, data);
                 data.name = data.name.replaceAll("\\s", "");
                 DeploymentManager mgr = PortletManager.getDeploymentManager(request);
-                File tempFile = File.createTempFile("console-deployment",".xml");
+                File tempFile = File.createTempFile("console-deployment", ".xml");
                 tempFile.deleteOnExit();
-                log.debug("Writing security realm deployment plan to "+tempFile.getAbsolutePath());
+                log.debug("Writing security realm deployment plan to " + tempFile.getAbsolutePath());
                 PrintWriter out = new PrintWriter(new FileWriter(tempFile));
                 savePlanToStream(plan, out);
                 out.flush();
@@ -469,11 +473,11 @@
                 Target[] targets = mgr.getTargets();
                 ProgressObject po = mgr.distribute(targets, null, tempFile);
                 waitForProgress(po);
-                if(po.getDeploymentStatus().isCompleted()) {
+                if (po.getDeploymentStatus().isCompleted()) {
                     TargetModuleID[] ids = po.getResultTargetModuleIDs();
                     po = mgr.start(ids);
                     waitForProgress(po);
-                    if(po.getDeploymentStatus().isCompleted()) {
+                    if (po.getDeploymentStatus().isCompleted()) {
                         System.out.println("Deployment completed successfully!");
                     }
                 }
@@ -485,11 +489,11 @@
             // index existing modules
             Map nodes = new HashMap();
             JaasLoginModuleChain node = realm.getLoginModuleChain();
-            while(node != null) {
+            while (node != null) {
                 LoginModuleSettings module = node.getLoginModule();
                 nodes.put(module.getLoginDomainName(), node);
                 node = node.getNext();
-                if(node == null) {
+                if (node == null) {
                     break;
                 }
             }
@@ -514,7 +518,7 @@
         org.apache.geronimo.management.geronimo.SecurityRealm[] realms = PortletManager.getCurrentServer(request).getSecurityRealms();
         ExistingRealm[] results = new ExistingRealm[realms.length];
         for (int i = 0; i < results.length; i++) {
-            final GeronimoManagedBean managedBean = (GeronimoManagedBean)realms[i];
+            final GeronimoManagedBean managedBean = (GeronimoManagedBean) realms[i];
             results[i] = new ExistingRealm(realms[i].getRealmName(), PortletManager.getNameFor(request, realms[i]),
                     managedBean.getState());
         }
@@ -534,7 +538,7 @@
 
     private void renderConfigure(RenderRequest request, RenderResponse response, RealmData data) throws IOException, PortletException {
         // Pass errors through
-        if(request.getParameter("LoginModuleError") != null) {
+        if (request.getParameter("LoginModuleError") != null) {
             request.setAttribute("LoginModuleError", request.getParameter("LoginModuleError"));
         }
         // Clear out any cached modules
@@ -543,13 +547,13 @@
         MasterLoginModuleInfo info = getSelectedModule(data);
         for (int i = 0; i < info.getOptions().length; i++) {
             MasterLoginModuleInfo.OptionInfo option = info.getOptions()[i];
-            if(!data.getOptions().containsKey(option.getName())) {
+            if (!data.getOptions().containsKey(option.getName())) {
                 data.getOptions().put(option.getName(), null);
             }
         }
         data.reorderOptions(info.getOptions());
         request.setAttribute("optionMap", info.getOptionMap());
-        if(info.getName().indexOf("SQL") > -1) {
+        if (info.getName().indexOf("SQL") > -1) {
             loadDriverJARList(request);
             loadDatabasePoolList(request);
         }
@@ -570,9 +574,9 @@
     private void renderTestResults(RenderRequest request, RenderResponse response) throws IOException, PortletException {
         PortletSession session = request.getPortletSession();
         String status = (String) session.getAttribute("TestLoginError");
-        if(status == null) {
+        if (status == null) {
             Set principals = (Set) session.getAttribute("TestLoginPrincipals");
-            status = "Login succeeded with "+(principals == null ? 0 : principals.size())+" principals";
+            status = "Login succeeded with " + (principals == null ? 0 : principals.size()) + " principals";
             request.setAttribute("principals", principals);
         }
         request.setAttribute("LoginResults", status);
@@ -593,7 +597,7 @@
         MasterLoginModuleInfo[] all = MasterLoginModuleInfo.getAllModules();
         for (int i = 0; i < all.length; i++) {
             MasterLoginModuleInfo info = all[i];
-            if(info.getName().equals(data.getRealmType())) {
+            if (info.getName().equals(data.getRealmType())) {
                 return info;
             }
         }
@@ -610,8 +614,8 @@
                 final String name = objectName.getKeyProperty(NameFactory.J2EE_NAME);
                 String display = name;
                 final String appName = objectName.getKeyProperty(NameFactory.J2EE_APPLICATION);
-                if(appName != null && !appName.equals("null")) {
-                    display = display+" ("+appName+")";
+                if (appName != null && !appName.equals("null")) {
+                    display = display + " (" + appName + ")";
                 }
                 pools.add(new DatabasePool(name, display, appName, PortletManager.getNameFor(renderRequest, factory)));
             }
@@ -636,7 +640,7 @@
                 // todo should only test groupId and should check for long (org.apache.geronimo) and short form
                 for (int k = 0; k < SKIP_ENTRIES_WITH.length; k++) {
                     String skip = SKIP_ENTRIES_WITH[k];
-                    if(test.indexOf(skip) > -1) {
+                    if (test.indexOf(skip) > -1) {
                         continue outer;
                     }
                 }
@@ -667,7 +671,7 @@
     }
 
     private static void waitForProgress(ProgressObject po) {
-        while(po.getDeploymentStatus().isRunning()) {
+        while (po.getDeploymentStatus().isRunning()) {
             try {
                 Thread.sleep(100);
             } catch (InterruptedException e) {
@@ -678,7 +682,7 @@
 
     public static void normalize(RealmData data) {
         List list = new ArrayList();
-        if(data.modules == null) {
+        if (data.modules == null) {
             LoginModuleDetails module = new LoginModuleDetails();
             module.setClassName(getSelectedModule(data).getClassName());
             module.setControlFlag("REQUIRED");
@@ -687,32 +691,32 @@
             Properties props = module.getOptions();
             for (Iterator it = data.getOptions().entrySet().iterator(); it.hasNext();) {
                 Map.Entry entry = (Map.Entry) it.next();
-                props.setProperty((String)entry.getKey(), (String) entry.getValue());
+                props.setProperty((String) entry.getKey(), (String) entry.getValue());
             }
             list.add(module);
-            if(data.isStorePassword()) {
+            if (data.isStorePassword()) {
                 module = new LoginModuleDetails();
                 module.setClassName(GeronimoPasswordCredentialLoginModule.class.getName());
                 module.setControlFlag("OPTIONAL");
-                module.setLoginDomainName(data.getName()+"-Password");
+                module.setLoginDomainName(data.getName() + "-Password");
                 module.setServerSide(true);
                 list.add(module);
             }
-            if(data.getAuditPath() != null) {
+            if (data.getAuditPath() != null) {
                 module = new LoginModuleDetails();
                 module.setClassName(FileAuditLoginModule.class.getName());
                 module.setControlFlag("OPTIONAL");
-                module.setLoginDomainName(data.getName()+"-Audit");
+                module.setLoginDomainName(data.getName() + "-Audit");
                 module.setServerSide(true);
                 props = module.getOptions();
                 props.setProperty("file", data.getAuditPath());
                 list.add(module);
             }
-            if(data.isLockoutEnabled()) {
+            if (data.isLockoutEnabled()) {
                 module = new LoginModuleDetails();
                 module.setClassName(RepeatedFailureLockoutLoginModule.class.getName());
                 module.setControlFlag("REQUISITE");
-                module.setLoginDomainName(data.getName()+"-Lockout");
+                module.setLoginDomainName(data.getName() + "-Lockout");
                 module.setServerSide(true);
                 props = module.getOptions();
                 props.setProperty("failureCount", data.getLockoutCount());
@@ -723,8 +727,8 @@
         } else {
             list.addAll(Arrays.asList(data.modules));
         }
-        if(data.getAbstractName() == null) {
-            for(int i=list.size(); i<5; i++) {
+        if (data.getAbstractName() == null) {
+            for (int i = list.size(); i < 5; i++) {
                 LoginModuleDetails module = new LoginModuleDetails();
                 list.add(module);
             }
@@ -747,30 +751,31 @@
 
         public void load(PortletRequest request) {
             name = request.getParameter("name");
-            if(name != null && name.equals("")) name = null;
+            if (name != null && name.equals("")) name = null;
             realmType = request.getParameter("realmType");
-            if(realmType != null && realmType.equals("")) realmType = null;
+            if (realmType != null && realmType.equals("")) realmType = null;
             jar = request.getParameter("jar");
-            if(jar != null && jar.equals("")) jar = null;
+            if (jar != null && jar.equals("")) jar = null;
             auditPath = request.getParameter("auditPath");
-            if(auditPath != null && auditPath.equals("")) auditPath = null;
+            if (auditPath != null && auditPath.equals("")) auditPath = null;
             lockoutCount = request.getParameter("lockoutCount");
-            if(lockoutCount != null && lockoutCount.equals("")) lockoutCount = null;
+            if (lockoutCount != null && lockoutCount.equals("")) lockoutCount = null;
             lockoutWindow = request.getParameter("lockoutWindow");
-            if(lockoutWindow != null && lockoutWindow.equals("")) lockoutWindow = null;
+            if (lockoutWindow != null && lockoutWindow.equals("")) lockoutWindow = null;
             lockoutDuration = request.getParameter("lockoutDuration");
-            if(lockoutDuration != null && lockoutDuration.equals("")) lockoutDuration = null;
+            if (lockoutDuration != null && lockoutDuration.equals("")) lockoutDuration = null;
             abstractName = request.getParameter("objectName");
-            if(abstractName != null && abstractName.equals("")) abstractName = null;
+            if (abstractName != null && abstractName.equals("")) abstractName = null;
             String test = request.getParameter("storePassword");
             storePassword = test != null && !test.equals("") && !test.equals("false");
             Map map = request.getParameterMap();
             for (Iterator it = map.keySet().iterator(); it.hasNext();) {
                 String key = (String) it.next();
-                if(key.startsWith("option-")) {
-                    if(key.equals("option-databasePoolObjectName")) { // special handling for a data source, where there's one select corresponding to two properties
+                if (key.startsWith("option-")) {
+                    if (key.equals("option-databasePoolObjectName"))
+                    { // special handling for a data source, where there's one select corresponding to two properties
                         String nameString = request.getParameter(key);
-                        if(nameString != null && !nameString.equals("")) {
+                        if (nameString != null && !nameString.equals("")) {
                             try {
                                 ObjectName on = ObjectName.getInstance(nameString);
                                 options.put("dataSourceName", on.getKeyProperty(NameFactory.J2EE_NAME));
@@ -782,7 +787,7 @@
                     } else {
                         final String optionName = key.substring(7);
                         final String value = request.getParameter(key);
-                        if(value != null && !value.equals("")) {
+                        if (value != null && !value.equals("")) {
                             options.put(optionName, value);
                         }
                     }
@@ -790,57 +795,57 @@
             }
             int count = 0;
             List list = new ArrayList();
-            while(true) {
+            while (true) {
                 int index = count;
                 ++count;
-                String name = request.getParameter("module-domain-"+index);
-                if(name == null || name.equals("")) break;
+                String name = request.getParameter("module-domain-" + index);
+                if (name == null || name.equals("")) break;
                 LoginModuleDetails details = new LoginModuleDetails();
                 details.setLoginDomainName(name);
-                String cls = request.getParameter("module-class-"+index);
-                if(cls == null || cls.equals("")) continue;
+                String cls = request.getParameter("module-class-" + index);
+                if (cls == null || cls.equals("")) continue;
                 details.setClassName(cls);
-                String flag = request.getParameter("module-control-"+index);
-                if(flag == null || flag.equals("")) continue;
+                String flag = request.getParameter("module-control-" + index);
+                if (flag == null || flag.equals("")) continue;
                 details.setControlFlag(flag);
-                String wrap = request.getParameter("module-wrap-"+index);
-                if(wrap == null || wrap.equals("")) continue;
+                String wrap = request.getParameter("module-wrap-" + index);
+                if (wrap == null || wrap.equals("")) continue;
                 details.setWrapPrincipals(Boolean.valueOf(wrap).booleanValue());
-                String server = request.getParameter("module-server-"+index);
-                if(server == null || server.equals("")) continue;
+                String server = request.getParameter("module-server-" + index);
+                if (server == null || server.equals("")) continue;
                 details.setServerSide(Boolean.valueOf(server).booleanValue());
-                String options = request.getParameter("module-options-"+index);
-                if(options != null && !options.equals("")) {
+                String options = request.getParameter("module-options-" + index);
+                if (options != null && !options.equals("")) {
                     BufferedReader in = new BufferedReader(new StringReader(options));
                     String line;
                     try {
-                        while((line = in.readLine()) != null) {
-                            if(line.startsWith("#") || line.equals("")) {
+                        while ((line = in.readLine()) != null) {
+                            if (line.startsWith("#") || line.equals("")) {
                                 continue;
                             }
                             int pos = line.indexOf('=');
-                            if(pos > -1) {
-                                details.getOptions().setProperty(line.substring(0, pos), line.substring(pos+1));
+                            if (pos > -1) {
+                                details.getOptions().setProperty(line.substring(0, pos), line.substring(pos + 1));
                             }
                         }
                     } catch (IOException e) {
-                        log.error("Unable to read properties '"+options+"'", e);
+                        log.error("Unable to read properties '" + options + "'", e);
                     }
                 }
                 list.add(details);
             }
-            if(list.size() > 0) {
+            if (list.size() > 0) {
                 modules = (LoginModuleDetails[]) list.toArray(new LoginModuleDetails[list.size()]);
             }
         }
 
         public void reorderOptions(MasterLoginModuleInfo.OptionInfo[] info) {
-            if(info == null || info.length == 0) {
+            if (info == null || info.length == 0) {
                 return; // Probably SQL or something that handles this manually
             }
             Map map = new LinkedHashMap();
-            for(int i=0; i<info.length;i++) {
-                if(options.containsKey(info[i].getName())) {
+            for (int i = 0; i < info.length; i++) {
+                if (options.containsKey(info[i].getName())) {
                     map.put(info[i].getName(), options.get(info[i].getName()));
                 }
             }
@@ -848,31 +853,35 @@
         }
 
         public void store(ActionResponse response) {
-            if(name != null) response.setRenderParameter("name", name);
-            if(realmType != null) response.setRenderParameter("realmType", realmType);
-            if(jar != null) response.setRenderParameter("jar", jar);
-            if(auditPath != null) response.setRenderParameter("auditPath", auditPath);
-            if(lockoutCount != null) response.setRenderParameter("lockoutCount", lockoutCount);
-            if(lockoutWindow != null) response.setRenderParameter("lockoutWindow", lockoutWindow);
-            if(lockoutDuration != null) response.setRenderParameter("lockoutDuration", lockoutDuration);
-            if(abstractName != null) response.setRenderParameter("objectName", abstractName);
-            if(storePassword) response.setRenderParameter("storePassword", "true");
+            if (name != null) response.setRenderParameter("name", name);
+            if (realmType != null) response.setRenderParameter("realmType", realmType);
+            if (jar != null) response.setRenderParameter("jar", jar);
+            if (auditPath != null) response.setRenderParameter("auditPath", auditPath);
+            if (lockoutCount != null) response.setRenderParameter("lockoutCount", lockoutCount);
+            if (lockoutWindow != null) response.setRenderParameter("lockoutWindow", lockoutWindow);
+            if (lockoutDuration != null) response.setRenderParameter("lockoutDuration", lockoutDuration);
+            if (abstractName != null) response.setRenderParameter("objectName", abstractName);
+            if (storePassword) response.setRenderParameter("storePassword", "true");
             for (Iterator it = options.keySet().iterator(); it.hasNext();) {
                 String name = (String) it.next();
                 String value = (String) options.get(name);
-                if(value != null) {
-                    response.setRenderParameter("option-"+name, value);
+                if (value != null) {
+                    response.setRenderParameter("option-" + name, value);
                 }
             }
-            if(modules != null) {
+            if (modules != null) {
                 for (int i = 0; i < modules.length; i++) {
                     LoginModuleDetails module = modules[i];
-                    if(module.getLoginDomainName() != null) response.setRenderParameter("module-domain-"+i, module.getLoginDomainName());
-                    if(module.getClassName() != null) response.setRenderParameter("module-class-"+i, module.getClassName());
-                    if(module.getControlFlag() != null) response.setRenderParameter("module-control-"+i, module.getControlFlag());
-                    response.setRenderParameter("module-wrap-"+i, Boolean.toString(module.isWrapPrincipals()));
-                    response.setRenderParameter("module-server-"+i, Boolean.toString(module.isServerSide()));
-                    if(module.getOptions().size() > 0) response.setRenderParameter("module-options-"+i, module.getOptionString());
+                    if (module.getLoginDomainName() != null)
+                        response.setRenderParameter("module-domain-" + i, module.getLoginDomainName());
+                    if (module.getClassName() != null)
+                        response.setRenderParameter("module-class-" + i, module.getClassName());
+                    if (module.getControlFlag() != null)
+                        response.setRenderParameter("module-control-" + i, module.getControlFlag());
+                    response.setRenderParameter("module-wrap-" + i, Boolean.toString(module.isWrapPrincipals()));
+                    response.setRenderParameter("module-server-" + i, Boolean.toString(module.isServerSide()));
+                    if (module.getOptions().size() > 0)
+                        response.setRenderParameter("module-options-" + i, module.getOptionString());
                 }
             }
         }
@@ -1017,7 +1026,7 @@
             this.name = name;
             this.abstractName = objectName.toString();
             String parent = (String) objectName.getName().get(NameFactory.J2EE_APPLICATION);
-            if(parent != null && parent.equals("null")) {
+            if (parent != null && parent.equals("null")) {
                 parent = null;
             }
             parentName = parent;
@@ -1090,20 +1099,20 @@
         }
 
         public int compareTo(Object o) {
-            final DatabasePool pool = (DatabasePool)o;
+            final DatabasePool pool = (DatabasePool) o;
             int names = name.compareTo(pool.name);
-            if(applicationName == null) {
-                if(pool.applicationName == null) {
+            if (applicationName == null) {
+                if (pool.applicationName == null) {
                     return names;
                 } else {
                     return -1;
                 }
             } else {
-                if(pool.applicationName == null) {
+                if (pool.applicationName == null) {
                     return 1;
                 } else {
                     int test = applicationName.compareTo(pool.applicationName);
-                    if(test != 0) {
+                    if (test != 0) {
                         return test;
                     } else {
                         return names;

Modified: geronimo/branches/pluggable-jacc/configs/activemq/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/configs/activemq/pom.xml?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/configs/activemq/pom.xml (original)
+++ geronimo/branches/pluggable-jacc/configs/activemq/pom.xml Mon Jul  3 17:50:41 2006
@@ -63,11 +63,11 @@
             <type>car</type>
         </dependency>
         <!-- To enforce build order -->
-        <dependency>
-            <groupId>org.apache.geronimo.configs</groupId>
-            <artifactId>system-database</artifactId>
-            <type>car</type>
-        </dependency>
+        <!--<dependency>-->
+            <!--<groupId>org.apache.geronimo.configs</groupId>-->
+            <!--<artifactId>system-database</artifactId>-->
+            <!--<type>car</type>-->
+        <!--</dependency>-->
 
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>

Modified: geronimo/branches/pluggable-jacc/configs/client-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/configs/client-deployer/src/plan/plan.xml?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/configs/client-deployer/src/plan/plan.xml (original)
+++ geronimo/branches/pluggable-jacc/configs/client-deployer/src/plan/plan.xml Mon Jul  3 17:50:41 2006
@@ -24,6 +24,12 @@
         <attribute name="transactionContextManagerObjectName">?name=TransactionContextManager</attribute>
         <attribute name="connectionTrackerObjectName">?name=ConnectionTracker</attribute>
         <attribute name="corbaGBeanObjectName">?name=Server</attribute>
+        <reference name="SecurityBuilder">
+            <name>SecurityBuilder</name>
+        </reference>
+        <reference name="ServiceBuilders">
+            <name>GBeanBuilder</name>
+        </reference>
         <references name="EJBReferenceBuilder">
             <pattern>
                 <name>ClientEJBReferenceBuilder</name>

Modified: geronimo/branches/pluggable-jacc/configs/client/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/configs/client/pom.xml?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/configs/client/pom.xml (original)
+++ geronimo/branches/pluggable-jacc/configs/client/pom.xml Mon Jul  3 17:50:41 2006
@@ -94,9 +94,14 @@
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-j2ee</artifactId>
+        </dependency>
+        <!-- should be transitive dependency of geronimo-j2ee -->
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-management</artifactId>
         </dependency>
-        
+
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-transaction</artifactId>

Modified: geronimo/branches/pluggable-jacc/configs/geronimo-gbean-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/configs/geronimo-gbean-deployer/src/plan/plan.xml?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/configs/geronimo-gbean-deployer/src/plan/plan.xml (original)
+++ geronimo/branches/pluggable-jacc/configs/geronimo-gbean-deployer/src/plan/plan.xml Mon Jul  3 17:50:41 2006
@@ -35,6 +35,13 @@
             <!--<pattern><gbean-name>geronimo.maven:name=Repository</gbean-name></pattern>-->
             <!--<pattern><gbean-name>geronimo.server:name=Repository,*</gbean-name></pattern>-->
         </reference>
+        <reference name="ServiceBuilders">
+            <name>GBeanBuilder</name>
+        </reference>
+    </gbean>
+
+    <!-- NamespaceDriveBuilder for handling gbeans -->
+    <gbean name="GBeanBuilder" class="org.apache.geronimo.deployment.service.GBeanBuilder">
         <reference name="XmlAttributeBuilders">
             <!--<module>*</module>-->
             <!--<name>*</name>-->

Modified: geronimo/branches/pluggable-jacc/configs/j2ee-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/configs/j2ee-deployer/src/plan/plan.xml?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/configs/j2ee-deployer/src/plan/plan.xml (original)
+++ geronimo/branches/pluggable-jacc/configs/j2ee-deployer/src/plan/plan.xml Mon Jul  3 17:50:41 2006
@@ -20,8 +20,6 @@
 <module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
 
     <gbean name="EARBuilder" class="org.apache.geronimo.j2ee.deployment.EARConfigBuilder">
-        <!--domain set to wildcard so datasources may be deployed independently on client. -->
-        <!--a better solution is to get the domain and server from the parent module -->
         <attribute name="transactionManagerAbstractName">?name=TransactionManager</attribute>
         <attribute name="transactionContextManagerAbstractName">?name=TransactionContextManager</attribute>
         <attribute name="connectionTrackerAbstractName">?name=ConnectionTracker</attribute>
@@ -35,6 +33,12 @@
         <reference name="WebConfigBuilder">
             <name>WebBuilder</name>
         </reference>
+        <reference name="SecurityBuilders">
+            <name>SecurityBuilder</name>
+        </reference>
+        <reference name="ServiceBuilders">
+            <name>GBeanBuilder</name>
+        </reference>
         <references name="EJBConfigBuilder">
             <pattern>
                 <name>EJBBuilder</name>
@@ -107,6 +111,9 @@
         <attribute name="defaultIdleTimeoutMinutes">15</attribute>
         <attribute name="defaultXATransactionCaching">true</attribute>
         <attribute name="defaultXAThreadCaching">false</attribute>
+        <reference name="ServiceBuilders">
+            <name>GBeanBuilder</name>
+        </reference>
         <xml-attribute name="defaultEnvironment">
             <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
                 <dependencies>
@@ -121,11 +128,16 @@
         </xml-attribute>
     </gbean>
 
+    <gbean name="SecurityBuilder" class="org.apache.geronimo.security.deployment.GeronimoSecurityBuilderImpl"/>
+
     <gbean name="LoginConfigurationBuilder" class="org.apache.geronimo.security.deployment.LoginConfigBuilder"/>
+
     <gbean name="SecurityService" class="org.apache.geronimo.security.SecurityServiceImpl">
         <attribute name="policyConfigurationFactory">
             org.apache.geronimo.security.jacc.GeronimoPolicyConfigurationFactory</attribute>
         <attribute name="policyProvider">org.apache.geronimo.security.jacc.GeronimoPolicy</attribute>
     </gbean>
+
+
 
 </module>

Modified: geronimo/branches/pluggable-jacc/configs/jetty-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/configs/jetty-deployer/src/plan/plan.xml?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/configs/jetty-deployer/src/plan/plan.xml (original)
+++ geronimo/branches/pluggable-jacc/configs/jetty-deployer/src/plan/plan.xml Mon Jul  3 17:50:41 2006
@@ -33,6 +33,12 @@
         <reference name="PojoWebServiceTemplate">
             <name>POJOTemplate</name>
         </reference>
+        <reference name="SecurityBuilders">
+            <name>SecurityBuilder</name>
+        </reference>
+        <reference name="ServiceBuilders">
+            <name>GBeanBuilder</name>
+        </reference>
         <references name="WebServiceBuilder">
             <pattern>
                 <name>WebServiceBuilder</name>

Modified: geronimo/branches/pluggable-jacc/configs/openejb-deployer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/configs/openejb-deployer/pom.xml?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/configs/openejb-deployer/pom.xml (original)
+++ geronimo/branches/pluggable-jacc/configs/openejb-deployer/pom.xml Mon Jul  3 17:50:41 2006
@@ -86,19 +86,19 @@
         <dependency>
             <groupId>openejb</groupId>
             <artifactId>openejb-builder</artifactId>
-            <version>${openejbVersion}</version>
+            <!--<version>${openejbVersion}</version>-->
         </dependency>
 
         <dependency>
             <groupId>openejb</groupId>
             <artifactId>openejb-pkgen-builder</artifactId>
-            <version>${openejbVersion}</version>
+            <!--<version>${openejbVersion}</version>-->
         </dependency>
 
         <dependency>
             <groupId>openejb</groupId>
             <artifactId>openejb-core</artifactId>
-            <version>${openejbVersion}</version>
+            <!--<version>${openejbVersion}</version>-->
         </dependency>
 
         <dependency>

Modified: geronimo/branches/pluggable-jacc/configs/openejb-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/configs/openejb-deployer/src/plan/plan.xml?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/configs/openejb-deployer/src/plan/plan.xml (original)
+++ geronimo/branches/pluggable-jacc/configs/openejb-deployer/src/plan/plan.xml Mon Jul  3 17:50:41 2006
@@ -28,6 +28,12 @@
         <reference name="WebServiceLinkTemplate">
             <name>WebServiceEJBLinkTemplate</name>
         </reference>
+        <reference name="SecurityBuilders">
+            <name>SecurityBuilder</name>
+        </reference>
+        <reference name="ServiceBuilders">
+            <name>GBeanBuilder</name>
+        </reference>
         <references name="WebServiceBuilder">
             <pattern>
                 <name>WebServiceBuilder</name>

Modified: geronimo/branches/pluggable-jacc/configs/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/configs/pom.xml?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/configs/pom.xml (original)
+++ geronimo/branches/pluggable-jacc/configs/pom.xml Mon Jul  3 17:50:41 2006
@@ -69,8 +69,8 @@
                 <activeByDefault>true</activeByDefault>
             </activation>
             <modules>
-                <!-- <module>activemq</module> -->
-                <!-- <module>activemq-broker</module> -->
+                <!--<module>activemq-broker</module>-->
+                <!--<module>activemq</module>-->
                 <module>axis</module>
                 <module>axis-deployer</module>
                 <module>client</module>
@@ -78,10 +78,10 @@
                 <module>client-deployer</module>
                 <module>client-security</module>
                 <module>client-system</module>
-                <!-- <module>console-jetty</module> -->
-                <!-- <module>console-tomcat</module> -->
-                <!-- <module>daytrader-jetty</module> -->
-                <!-- <module>daytrader-tomcat</module> -->
+                 <module>console-jetty</module>
+                 <module>console-tomcat</module>
+                 <!--<module>daytrader-jetty</module>-->
+                 <!--<module>daytrader-tomcat</module>-->
                 <module>directory</module>
                 <module>geronimo-gbean-deployer</module>
                 <module>hot-deployer</module>
@@ -101,8 +101,8 @@
                 <module>online-deployer</module>
                 <module>openejb</module>
                 <module>openejb-deployer</module>
-                <!-- <module>remote-deploy-jetty</module> -->
-                <!-- <module>remote-deploy-tomcat</module> -->
+                 <!--<module>remote-deploy-jetty</module>-->
+                 <!--<module>remote-deploy-tomcat</module>-->
                 <module>rmi-naming</module>
                 <module>servlets-examples-jetty</module>
                 <module>servlets-examples-tomcat</module>
@@ -111,8 +111,8 @@
                 <module>system-database</module>
                 <module>tomcat</module>
                 <module>tomcat-deployer</module>
-                <!-- <module>uddi-jetty</module> -->
-                <!-- <module>uddi-tomcat</module> -->
+                 <!--<module>uddi-jetty</module>-->
+                 <!--<module>uddi-tomcat</module>-->
                 <module>unavailable-client-deployer</module>
                 <module>unavailable-ejb-deployer</module>
                 <module>unavailable-webservices-deployer</module>

Modified: geronimo/branches/pluggable-jacc/configs/tomcat-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/configs/tomcat-deployer/src/plan/plan.xml?rev=418888&r1=418657&r2=418888&view=diff
==============================================================================
--- geronimo/branches/pluggable-jacc/configs/tomcat-deployer/src/plan/plan.xml (original)
+++ geronimo/branches/pluggable-jacc/configs/tomcat-deployer/src/plan/plan.xml Mon Jul  3 17:50:41 2006
@@ -22,6 +22,12 @@
 
     <gbean name="TomcatWebBuilder" class="org.apache.geronimo.tomcat.deployment.TomcatModuleBuilder">
         <attribute name="tomcatContainerName">?name=TomcatWebContainer</attribute>
+        <reference name="SecurityBuilders">
+            <name>SecurityBuilder</name>
+        </reference>
+        <reference name="ServiceBuilders">
+            <name>GBeanBuilder</name>
+        </reference>
         <references name="WebServiceBuilder">
             <pattern>
                 <name>WebServiceBuilder</name>

Added: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/pom.xml?rev=418888&view=auto
==============================================================================
--- geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/pom.xml (added)
+++ geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/pom.xml Mon Jul  3 17:50:41 2006
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2006 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev:$ $Date:$ -->
+<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>org.apache.geronimo.plugins</groupId>
+    <artifactId>plugins-parent</artifactId>
+    <version>1.2-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>geronimo-deployment-plugin</artifactId>
+  <version>${geronimoVersion}</version>
+  <packaging>maven-plugin</packaging>
+  <name>Geronimo :: Maven 2 Deployment Plugin</name>
+ 
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.modules</groupId>
+      <artifactId>geronimo-deploy-jsr88</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <plugins>
+      <plugin>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <configuration>
+          <goalPrefix>deploy</goalPrefix>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+
+</project>

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java?rev=418888&view=auto
==============================================================================
--- geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java (added)
+++ geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java Mon Jul  3 17:50:41 2006
@@ -0,0 +1,261 @@
+/**
+ *
+ * Copyright 2004-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.plugins.deployment;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+
+import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public abstract class AbstractModuleMojo extends AbstractMojo {
+    
+    /**
+     * The uri to look up the JMXConnector.
+     * 
+     * @parameter default-value="jmx:rmi://localhost/jndi/rmi:/JMXConnector"
+     */
+    private String uri;
+
+
+    /**
+     * @parameter
+     */
+    protected String id;
+    
+
+    /**
+     * The uri to connect to the jmx connector with.
+     * 
+     * @parameter default-value="deployer:geronimo:jmx"
+     */
+    private String distributeURI;
+
+    /**
+     * The authentication user name.
+     * 
+     * @parameter default-value="system"
+     */
+    private String username;
+
+    /**
+     * The authentication password.
+     * 
+     * @parameter default-value="manager"
+     */
+    private String password;
+
+    /**
+     * The time between connect attempts.
+     * 
+     * @parameter default-value=0
+     */
+    private long sleepTimer;
+
+    /**
+     * @parameter default-value=100
+     */
+    private int maxTries;
+
+    /**
+     * @parameter default-value=2000
+     */
+    private int retryIntervalMilliseconds;
+
+    /**
+     * @parameter default-value=true
+     */
+    private boolean failOnError;
+
+    /**
+     * @parameter
+     */
+    private File outputDirectory;
+
+    /**
+     * @parameter default-value=null
+     */
+    private File resultsLog;
+
+    
+
+    protected final String lineSep = "===========================================";
+
+    public abstract void execute() throws MojoExecutionException;
+
+    protected DeploymentManager getDeploymentManager() throws IOException, DeploymentManagerCreationException {
+        if (getUsername() == null) {
+            throw new IllegalStateException("No user specified");
+        }
+        if (getPassword() == null) {
+            throw new IllegalStateException("No password specified");
+        }
+        if (getDistributeURI() == null) {
+            throw new IllegalStateException("No uri specified");
+        }
+        new DeploymentFactoryImpl();
+
+        ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+            DeploymentFactoryManager factoryManager = DeploymentFactoryManager.getInstance();
+            DeploymentManager manager = factoryManager.getDeploymentManager(getDistributeURI(), getUsername(), getPassword());
+            return manager;
+        }
+        finally {
+            Thread.currentThread().setContextClassLoader(oldcl);
+        }
+    }
+
+    /**
+     * @return Returns the maxTries.
+     */
+    public int getMaxTries() {
+        return maxTries;
+    }
+
+    /**
+     * @return Returns the retryIntervalMilliseconds.
+     */
+    public int getRetryIntervalMilliseconds() {
+        return retryIntervalMilliseconds;
+    }
+
+    /**
+     * @return Returns the sleepTimer.
+     */
+    public long getSleepTimer() {
+        return sleepTimer;
+    }
+
+    public String getUri() {
+        return uri;
+    }
+
+    public String getDistributeURI() {
+        return distributeURI;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public boolean isFailOnError() {
+        return failOnError;
+    }
+
+    public File getOutputDirectory() {
+        return outputDirectory;
+    }
+
+    public PrintStream getResultsStream() {
+        PrintStream resultStream = null;
+        if (this.resultsLog != null) {
+            try {
+                resultStream = new PrintStream(new FileOutputStream(this.resultsLog, true), true);
+            }
+            catch (FileNotFoundException e) {
+                //e.printStackTrace();
+                getLog().warn(e.toString());
+                getLog().warn("Results cannot be logged");
+            }
+        }
+        return resultStream;
+    }
+
+    public PrintStream getLogStream(String goalName) {
+        PrintStream stream = System.out;
+    
+        if (this.outputDirectory != null) {
+            if (!this.outputDirectory.exists())
+                this.outputDirectory.mkdirs();
+    
+            String fileName = this.outputDirectory.getAbsolutePath() + File.separator + goalName + ".log";
+    
+            try {
+                stream = new PrintStream(new FileOutputStream(fileName, true), true);
+            }
+            catch (FileNotFoundException e) {
+                //e.printStackTrace();
+                getLog().warn(e.toString());
+                getLog().warn("No logs will be available");
+            }
+        }
+        return stream;
+    }
+
+    public void logResults(PrintStream resultStream, String goalName, String result) {
+        if (resultStream != null)
+            getResultsStream().println(goalName + ":" + result);
+    }
+
+    /**
+     * Method is used to point to the log location for more errors.
+     */
+    protected void seeLog() {
+        if (this.outputDirectory != null)
+            getLog().error("See log at " + getOutputDirectory().getAbsolutePath() + " for more details");
+    }
+
+    public void debug(String debugString) {
+        System.out.println(debugString);
+    }
+
+    /**
+     * @param e
+     * @param logStream
+     * @throws MojoExecutionException
+     * @throws MojoFailureException
+     */
+    protected void handleError(Exception e, PrintStream logStream) throws MojoExecutionException {
+        seeLog();
+        e.printStackTrace(logStream);
+        logStream.println(lineSep);
+        if (isFailOnError()) {            
+            throw (MojoExecutionException) new MojoExecutionException(e.toString(), e);
+        }
+        else {            
+             try {
+                throw (MojoFailureException) new MojoFailureException(e, e.toString(), e.getMessage());
+            }
+            catch (MojoFailureException e1) {
+                e1.printStackTrace(logStream);
+                logStream.println(lineSep);
+            }            
+        }        
+    }
+    
+    
+}

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java?rev=418888&view=auto
==============================================================================
--- geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java (added)
+++ geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java Mon Jul  3 17:50:41 2006
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2004-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.plugins.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.plugins.util.DeploymentClient;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * 
+ * @goal distribute
+ * 
+ * @version $Rev:$ $Date:$
+ *  
+ */
+public class DistributeModuleMojo extends AbstractModuleMojo {
+
+    /**
+     * @parameter
+     */
+    private String module;
+
+    /**
+     * @parameter
+     */
+    private String plan;
+
+    private PrintStream logStream = System.out;    
+    private PrintStream resultStream;
+    
+    private final String goalName = "Deploy Module";
+
+    public void execute() throws MojoExecutionException {        
+        resultStream = getResultsStream();        
+        logStream = getLogStream(goalName);
+        
+        DeploymentManager manager;
+        try {
+            manager = getDeploymentManager();
+
+            Target[] targets = manager.getTargets();
+            File moduleFile = (this.module == null) ? null : getFile(this.module);
+            File planFile = (this.plan == null) ? null : getFile((this.plan));
+            ProgressObject progress = manager.distribute(targets, moduleFile, planFile);
+            DeploymentClient.waitFor(progress);
+        }
+        catch (Exception e) {
+            logResults(resultStream, goalName, "fail");
+            handleError(e, logStream);
+            return;
+        }
+        logResults(resultStream, goalName, "success");  
+    }
+
+    private File getFile(String location) throws MalformedURLException {
+        try {
+            File f = new File(location).getCanonicalFile();
+            if (!f.exists() || !f.canRead()) {
+                throw new MalformedURLException("Invalid location: " + location);
+            }
+            return f;
+        }
+        catch (IOException e) {
+            throw (MalformedURLException) new MalformedURLException("Invalid location: " + location).initCause(e);
+        }
+
+    }
+
+}

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java?rev=418888&view=auto
==============================================================================
--- geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java (added)
+++ geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java Mon Jul  3 17:50:41 2006
@@ -0,0 +1,81 @@
+/**
+ *
+ * Copyright 2004-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.plugins.deployment;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager;
+import org.apache.geronimo.plugins.util.DeploymentClient;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * 
+ * @goal start
+ * 
+ * @version $Rev:$ $Date:$
+ *  
+ */
+public class StartModuleMojo extends AbstractModuleMojo {
+
+    private PrintStream logStream = System.out;
+
+    private PrintStream resultStream;
+
+    private final String goalName = "Start Module";
+
+    public void execute() throws MojoExecutionException {
+        resultStream = getResultsStream();
+        logStream = getLogStream(goalName);
+        RemoteDeploymentManager manager;
+        try {
+            manager = (RemoteDeploymentManager) getDeploymentManager();
+            manager.setLogConfiguration(true, true);
+
+            Target[] targets = manager.getTargets();
+            TargetModuleID moduleIds[] = manager.getNonRunningModules(null, targets);
+            List toStart = new ArrayList(moduleIds.length);
+            for (int i = 0; i < moduleIds.length; i++) {
+                TargetModuleID moduleId = moduleIds[i];
+                if (this.id.equals(moduleId.getModuleID())) {
+                    toStart.add(moduleId);
+                }
+            }
+            if (toStart.size() == 0) {
+                logResults(resultStream, goalName, "fail");
+                handleError(new Exception("Module is already running or may not be deployed: " + this.id), logStream);
+                return;
+            }
+            moduleIds = (TargetModuleID[]) toStart.toArray(new TargetModuleID[toStart.size()]);
+            ProgressObject progress = manager.start(moduleIds);            
+            DeploymentClient.waitFor(progress);            
+        }
+        catch (Exception e) {
+            logResults(resultStream, goalName, "fail");
+            handleError(e, logStream);
+            return;
+        }
+        logResults(resultStream, goalName, "success");
+    }
+
+}

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java?rev=418888&view=auto
==============================================================================
--- geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java (added)
+++ geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java Mon Jul  3 17:50:41 2006
@@ -0,0 +1,189 @@
+/**
+ *
+ * Copyright 2004-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.plugins.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import org.apache.geronimo.plugins.util.ServerBehavior;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * @goal startRemoteServer
+ * 
+ * @version $Rev:$ $Date:$
+ */
+public class StartRemoteServerMojo extends AbstractModuleMojo {
+
+    /**
+     * @parameter
+     */
+    private String geronimoTarget;
+
+    /**
+     * @parameter default-value=""
+     */
+    private String vmArgs = "";
+
+    /**
+     * @parameter
+     */
+    private String[] configs;
+
+    /**
+     * @parameter
+     */
+    private String debugPort;
+    
+    
+
+    private PrintStream logStream = System.out;    
+    private PrintStream resultStream;
+    
+    private final String goalName = "Start Remote Server";
+
+    public void execute() throws MojoExecutionException {        
+        resultStream = getResultsStream();        
+        logStream = getLogStream(goalName);
+        
+        try {
+            startRemoteServer();
+        }
+        catch (Exception e) {
+            logResults(resultStream, goalName, "fail");
+            handleError(e, logStream);
+            return;
+        }
+        logResults(resultStream, goalName, "success");        
+    }    
+    
+    
+
+    /**
+     * @throws MojoExecutionException
+     */
+    private void startRemoteServer() throws Exception {
+        ArrayList cmd = new ArrayList();
+        File root = new File(this.geronimoTarget);
+        File systemFile = new File(root, "bin/server.jar");
+        String s = java.io.File.separator;
+        String java = System.getProperty("java.home") + s + "bin" + s + "java";
+
+        cmd.add(java);
+
+        if (debugPort != null) {
+            cmd.add("-Xdebug");
+            cmd.add("-Xnoagent");
+            cmd.add("-Djava.compiler=NONE");
+            cmd.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + debugPort);
+        }
+
+        for (StringTokenizer st = new StringTokenizer(this.vmArgs); st.hasMoreTokens();) {
+            cmd.add(st.nextToken());
+        }
+
+        cmd.add("-ea");
+        cmd.add("-jar");
+
+        if (systemFile.exists()) {
+            try {
+                cmd.add(systemFile.getCanonicalPath());
+            }
+            catch (IOException e) {
+            }
+        }
+        else {
+            throw new Exception(systemFile.getAbsolutePath() + " does not exist");                                 
+        }
+
+        cmd.add("--quiet");
+
+        if (this.configs != null && this.configs.length > 0) {
+            cmd.add("--override");
+            for (int i=0; i < this.configs.length; i++) {
+                cmd.add(this.configs[i]);
+            }
+        }
+        String[] command = (String[]) cmd.toArray(new String[0]);
+
+        Runtime runtime = Runtime.getRuntime();
+        Process server;
+        try {
+            server = runtime.exec(command);
+
+            // Pipe the processes STDOUT to ours
+            InputStream outStream = server.getInputStream();
+            Thread serverOut = new Thread(new Pipe(outStream, logStream));
+            serverOut.setDaemon(true);
+            serverOut.start();
+
+            // Pipe the processes STDERR to ours
+            InputStream errStream = server.getErrorStream();
+            Thread serverErr = new Thread(new Pipe(errStream, logStream));
+            serverErr.setDaemon(true);
+            serverErr.start();
+
+            ServerBehavior sb = new ServerBehavior(getUri(), getMaxTries(), getRetryIntervalMilliseconds());
+            sb.setLogStream(logStream);
+            if (!sb.isFullyStarted()) {
+                server.destroy();                                
+                throw new Exception("Server did not start");                
+            }
+        }
+        catch (Exception e1) {
+            throw new Exception(e1);            
+        }        
+    }
+
+
+
+    public void destroy() {
+        logStream.close();
+    }
+
+    private final class Pipe implements Runnable {
+
+        private final InputStream in;
+
+        private final OutputStream out;
+
+        public Pipe(InputStream in, OutputStream out) {
+            this.in = in;
+            this.out = out;
+        }
+
+        public void run() {
+            int i;
+            try {
+                do {
+                    i = in.read();
+                    out.write(i);
+                }
+                while (i != -1);
+            }
+            catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/branches/pluggable-jacc/m2-plugins/geronimo-deployment-plugin/src/main/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain