--- a/glassfish.javaee/nbproject/project.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/glassfish.javaee/nbproject/project.xml Mon Feb 15 22:36:23 2010 +0100 @@ -100,7 +100,7 @@ 4 - 1.59 + 1.65 --- a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2DeploymentFactory.java Mon Feb 15 11:23:51 2010 +0100 +++ a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2DeploymentFactory.java Mon Feb 15 22:36:23 2010 +0100 @@ -109,6 +109,7 @@ * @param uri * @return */ + // also check the urlPattern in layer.xml when changing this public boolean handlesURI(String uri) { if (uri == null) { return false; --- a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/layer.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/layer.xml Mon Feb 15 22:36:23 2010 +0100 @@ -25,6 +25,7 @@ + @@ -56,6 +57,7 @@ + --- a/ide.kit/test/qa-functional/data/whitelist_3.txt Mon Feb 15 11:23:51 2010 +0100 +++ a/ide.kit/test/qa-functional/data/whitelist_3.txt Mon Feb 15 22:36:23 2010 +0100 @@ -141,33 +141,14 @@ org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver -org.netbeans.modules.j2ee.genericserver.GSDeploymentFactory org.netbeans.modules.j2ee.genericserver.ide.GSOptionalDeploymentManagerFactory -org.netbeans.modules.j2ee.jboss4.JBDeploymentFactory org.netbeans.modules.j2ee.jboss4.ide.JBOptionalDeploymentManagerFactory -org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils -org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils$Version org.netbeans.modules.j2ee.sun.api.ServerLocationManager -org.netbeans.modules.j2ee.sun.ide.dm.Bundle -org.netbeans.modules.j2ee.sun.ide.dm.Bundle_en -org.netbeans.modules.j2ee.sun.ide.dm.Bundle_en_US -org.netbeans.modules.j2ee.sun.ide.dm.Constants -org.netbeans.modules.j2ee.sun.ide.dm.SunDeploymentFactory -org.netbeans.modules.j2ee.sun.ide.j2ee.Constants org.netbeans.modules.j2ee.sun.ide.j2ee.OptionalFactory -org.netbeans.modules.j2ee.sun.ide.j2ee.PluginProperties org.netbeans.modules.j2ee.sun.ide.j2ee.RunTimeDDCatalog -org.netbeans.modules.j2ee.sun.share.CharsetMapping -org.netbeans.modules.j2ee.sun.share.SecurityMasterListModel -org.netbeans.modules.j2ee.weblogic9.WLBaseDeploymentManager -org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory -org.netbeans.modules.j2ee.weblogic9.optional.WLOptionalDeploymentManagerFactory +org.netbeans.modules.j2ee.weblogic9.optional.WLOptionalFactory org.netbeans.modules.tomcat5.TomcatManager$TomcatVersion org.netbeans.modules.tomcat5.ide.OptionalFactory -org.netbeans.modules.glassfish.javaee.Hk2OptionalFactory -org.netbeans.modules.glassfish.javaee.Hk2DeploymentFactory -org.netbeans.modules.glassfish.javaee.Hk2OptionalFactory -org.netbeans.modules.tomcat5.TomcatFactory #IZ 177644 org.netbeans.modules.schema2beans.AttrProp --- a/j2ee.genericserver/nbproject/project.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/j2ee.genericserver/nbproject/project.xml Mon Feb 15 22:36:23 2010 +0100 @@ -84,7 +84,7 @@ 4 - 1.23 + 1.65 --- a/j2ee.genericserver/src/org/netbeans/modules/j2ee/genericserver/resources/layer.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/j2ee.genericserver/src/org/netbeans/modules/j2ee/genericserver/resources/layer.xml Mon Feb 15 22:36:23 2010 +0100 @@ -48,6 +48,7 @@ + --- a/j2ee.jboss4/nbproject/project.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/j2ee.jboss4/nbproject/project.xml Mon Feb 15 22:36:23 2010 +0100 @@ -122,7 +122,7 @@ 4 - 1.52 + 1.65 --- a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/resources/layer.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/resources/layer.xml Mon Feb 15 22:36:23 2010 +0100 @@ -49,6 +49,7 @@ + --- a/j2ee.sun.appsrv81/nbproject/project.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/j2ee.sun.appsrv81/nbproject/project.xml Mon Feb 15 22:36:23 2010 +0100 @@ -189,7 +189,7 @@ 4 - 1.51 + 1.65 --- a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/dm/SunDeploymentFactory.java Mon Feb 15 11:23:51 2010 +0100 +++ a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/dm/SunDeploymentFactory.java Mon Feb 15 22:36:23 2010 +0100 @@ -175,6 +175,7 @@ * @param uri * @return boolean value */ + // also check the urlPattern in layer.xml when changing this public boolean handlesURI(String uri) { if (uri==null){ return false; --- a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml Mon Feb 15 22:36:23 2010 +0100 @@ -54,6 +54,7 @@ + @@ -108,6 +109,7 @@ + @@ -162,6 +164,7 @@ + @@ -216,6 +219,7 @@ + --- a/j2ee.weblogic9/nbproject/project.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/j2ee.weblogic9/nbproject/project.xml Mon Feb 15 22:36:23 2010 +0100 @@ -110,7 +110,7 @@ 4 - 1.23 + 1.65 --- a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/resources/layer.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/resources/layer.xml Mon Feb 15 22:36:23 2010 +0100 @@ -60,6 +60,7 @@ plugin --> + --- a/j2eeserver/api/doc/org/netbeans/modules/j2ee/deployment/plugins/api/doc-files/plugin-layer-file.html Mon Feb 15 11:23:51 2010 +0100 +++ a/j2eeserver/api/doc/org/netbeans/modules/j2ee/deployment/plugins/api/doc-files/plugin-layer-file.html Mon Feb 15 22:36:23 2010 +0100 @@ -32,6 +32,8 @@ <file name="Factory.instance">
      +<attr name="urlPattern" stringvalue="^regexp$" />
+      <attr name="instanceClass"
        @@ -39,8 +41,12 @@ style="font-family: courier new,courier,monospace;">     </file>
-
+ style="font-family: courier new,courier,monospace;">
+ +Optional urlPattern attribute specifies the required format +for server instance URL checked before call to DeploymentFactory.handlesURI(). +
+
3.  NetBeans instance class declaration of RegistryNodeFactory:
    --- a/j2eeserver/apichanges.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/j2eeserver/apichanges.xml Mon Feb 15 22:36:23 2010 +0100 @@ -107,12 +107,31 @@ J2EE Server Common API - Server Integration Plugin SPI Support + Server Integration Plugin SPI Support + XML Layer interfaces for plugin registration + + + + Optional attribute urlPattern for Factory.instance to prefilter + server instances on which server plugin is queried for support. + + + + + + +

+ Optional attribute urlPattern for Factory.instance may contain + regexp which the server instance url has to have. +

+
+ +
--- a/j2eeserver/nbproject/project.properties Mon Feb 15 11:23:51 2010 +0100 +++ a/j2eeserver/nbproject/project.properties Mon Feb 15 22:36:23 2010 +0100 @@ -39,7 +39,7 @@ is.autoload=true javac.source=1.6 -spec.version.base=1.64.0 +spec.version.base=1.65.0 javadoc.overview=${basedir}/api/doc/overview.html javadoc.arch=${basedir}/arch.xml --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/Server.java Mon Feb 15 11:23:51 2010 +0100 +++ a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/Server.java Mon Feb 15 22:36:23 2010 +0100 @@ -56,11 +56,11 @@ import org.netbeans.modules.j2ee.deployment.impl.ui.RegistryNodeProvider; import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfigurationFactory; import org.openide.util.Lookup; -import org.openide.cookies.InstanceCookie; import org.openide.nodes.Node; import org.openide.util.NbBundle; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Pattern; import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; import javax.enterprise.deploy.spi.DeploymentManager; import javax.xml.parsers.ParserConfigurationException; @@ -73,7 +73,6 @@ import org.netbeans.modules.j2ee.deployment.plugins.spi.RegistryNodeFactory; import org.netbeans.modules.j2ee.deployment.plugins.spi.VerifierSupport; import org.openide.filesystems.FileObject; -import org.openide.loaders.DataObject; import org.openide.util.lookup.Lookups; import org.xml.sax.SAXException; @@ -85,18 +84,22 @@ private static final String ATTR_NEEDS_FIND_SERVER_UI = "needsFindServerUI"; private final NetbeansDeployment dep; - private final Class factoryCls; private final String name; private final Lookup lkp; private final boolean needsFindServerUI; + private final Pattern urlPattern; + /** GuardedBy("this") */ private DeploymentFactory factory = null; /** GuardedBy("this") */ + private Class factoryCls = null; + /** GuardedBy("this") */ private DeploymentManager manager = null; /** GuardedBy("this") */ private RegistryNodeProvider nodeProvider = null; - + /** GuardedBy("this") */ + private boolean failed; public Server(FileObject fo) throws IOException, ParserConfigurationException, SAXException, ClassNotFoundException { @@ -112,43 +115,68 @@ needsFindServerUI = getBooleanValue(descriptor.getAttribute(ATTR_NEEDS_FIND_SERVER_UI), false); dep = NetbeansDeployment.createGraph(descriptor.getInputStream()); + FileObject factoryinstance = fo.getFileObject("Factory.instance"); + if (factoryinstance != null) { + Object regex = factoryinstance.getAttribute("urlPattern"); + if (regex != null) { + urlPattern = Pattern.compile(regex.toString()); + } else { + urlPattern = null; + } + } else { + urlPattern = null; + } lkp = Lookups.forPath(fo.getPath()); + + if (factoryinstance == null) { + String msg = NbBundle.getMessage(Server.class, "MSG_NoFactoryInstanceClass", name); + LOGGER.log(Level.SEVERE, msg); + } + } + + // not really sure about this code + private synchronized void initFactory() { + if ((factory != null && factoryCls != null) || failed) { + return; + } + factory = lkp.lookup(DeploymentFactory.class); if (factory != null) { factoryCls = factory.getClass(); + return; } else { - FileObject factoryinstance = fo.getFileObject("Factory.instance"); - if (factoryinstance == null) { - String msg = NbBundle.getMessage(Server.class, "MSG_NoFactoryInstanceClass", name); - LOGGER.log(Level.SEVERE, msg); - factoryCls = null; - return; - } - DataObject dobj = DataObject.find(factoryinstance); - InstanceCookie cookie = (InstanceCookie) dobj.getCookie(InstanceCookie.class); - if (cookie == null) { - String msg = NbBundle.getMessage(Server.class, "MSG_FactoryFailed", name); - LOGGER.log(Level.SEVERE, msg); - factoryCls = null; - return; - } - factoryCls = cookie.instanceClass(); + String msg = NbBundle.getMessage(Server.class, "MSG_FactoryFailed", name); + LOGGER.log(Level.SEVERE, msg); + failed = true; + return; - // speculative code depending on the DF implementation and if it registers - // itself with DFM or not - - try { - factory = (DeploymentFactory) cookie.instanceCreate(); - } catch (Exception e) { - LOGGER.log(Level.INFO, null, e); - } +// FIXME what is this crap? +// DataObject dobj = DataObject.find(factoryinstance); +// InstanceCookie cookie = (InstanceCookie) dobj.getCookie(InstanceCookie.class); +// if (cookie == null) { +// String msg = NbBundle.getMessage(Server.class, "MSG_FactoryFailed", name); +// LOGGER.log(Level.SEVERE, msg); +// factoryCls = null; +// return; +// } +// factoryCls = cookie.instanceClass(); +// +// // speculative code depending on the DF implementation and if it registers +// // itself with DFM or not +// +// try { +// factory = (DeploymentFactory) cookie.instanceCreate(); +// } catch (Exception e) { +// LOGGER.log(Level.INFO, null, e); +// } } } private synchronized DeploymentFactory getFactory() { + initFactory(); + if (factory == null) { - DeploymentFactory[] factories = DeploymentFactoryManager.getInstance().getDeploymentFactories(); for (int i = 0; i < factories.length; i++) { if (factoryCls.isInstance(factories[i])) { @@ -166,7 +194,7 @@ public synchronized DeploymentManager getDisconnectedDeploymentManager() throws DeploymentManagerCreationException { - if(manager == null) { + if (manager == null) { manager = getDisconnectedDeploymentManager(dep.getDisconnectedString()); } return manager; @@ -177,6 +205,12 @@ } public boolean handlesUri(String uri) { + if (uri != null && urlPattern != null) { + if (!urlPattern.matcher(uri).matches()) { + return false; + } + } + try { return getFactory().handlesURI(uri); } catch (Exception e) { --- a/j2eeserver/test/unit/src/org/netbeans/modules/j2ee/deployment/plugins/api/InstancePropertiesTest.java Mon Feb 15 11:23:51 2010 +0100 +++ a/j2eeserver/test/unit/src/org/netbeans/modules/j2ee/deployment/plugins/api/InstancePropertiesTest.java Mon Feb 15 22:36:23 2010 +0100 @@ -197,9 +197,8 @@ private static class MockDF extends org.netbeans.tests.j2eeserver.plugin.jsr88.TestDeploymentFactory { - @Override - public boolean handlesURI(String arg0) { - return arg0.startsWith("unknown:"); + public MockDF() { + super("unknown:"); } } --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ 4aa2398980b6 Mon Feb 15 22:36:23 2010 +0100 @@ -0,0 +1,75 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2010 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.deployment.plugins.spi; + +import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry; +import org.netbeans.modules.j2ee.deployment.impl.ServerRegistryTestBase; +import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceCreationException; +import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; + +/** + * + * @author Petr Hejl + */ +public class UrlPatternTest extends ServerRegistryTestBase { + + private static final String TEST_URL_PREFIX_PERMITTED = "permittedfooservice:"; + + private static final String TEST_URL_PREFIX_FORBIDDEN = "forbiddenfooservice:"; + + public UrlPatternTest(String name) { + super(name); + } + + public void testPermittedPattern() throws InstanceCreationException { + InstanceProperties.createInstanceProperties( + TEST_URL_PREFIX_PERMITTED + "testPermitted", "test", "password", "Permitted instance"); + } + + public void testForbiddenPattern() throws InstanceCreationException { + try { + InstanceProperties.createInstanceProperties( + TEST_URL_PREFIX_FORBIDDEN + "testForbidden", "test", "password", "Forbidden instance"); + fail("Forbidden instance registered"); + } catch (InstanceCreationException ex) { + // expected + } + } +} --- a/j2eeserver/test/unit/src/org/netbeans/tests/j2eeserver/plugin/jsr88/TestDeploymentFactory.java Mon Feb 15 11:23:51 2010 +0100 +++ a/j2eeserver/test/unit/src/org/netbeans/tests/j2eeserver/plugin/jsr88/TestDeploymentFactory.java Mon Feb 15 22:36:23 2010 +0100 @@ -47,14 +47,22 @@ /** * - * @author gfink + * @author Petr Hejl */ public class TestDeploymentFactory implements DeploymentFactory { - + private Map managers = new HashMap(); + private final String prefix; + /** Creates a new instance of DepFactory */ - public TestDeploymentFactory() { + protected TestDeploymentFactory(String prefix) { + assert prefix != null; + this.prefix = prefix; + } + + public static TestDeploymentFactory create(Map map) { + return new TestDeploymentFactory((String) map.get("prefix")); } public synchronized javax.enterprise.deploy.spi.DeploymentManager getDeploymentManager(String str, String str1, String str2) throws javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException { @@ -84,7 +92,7 @@ } public boolean handlesURI(String str) { - return (str != null && str.startsWith("fooservice")); + return (str != null && str.startsWith(prefix)); } } --- a/j2eeserver/test/unit/src/org/netbeans/tests/j2eeserver/plugin/layer.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/j2eeserver/test/unit/src/org/netbeans/tests/j2eeserver/plugin/layer.xml Mon Feb 15 22:36:23 2010 +0100 @@ -52,7 +52,8 @@
- + + @@ -87,12 +88,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + --- a/tomcat5/nbproject/project.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/tomcat5/nbproject/project.xml Mon Feb 15 22:36:23 2010 +0100 @@ -155,7 +155,7 @@ 4 - 1.51 + 1.65
--- a/tomcat5/src/org/netbeans/modules/tomcat5/resources/layer.xml Mon Feb 15 11:23:51 2010 +0100 +++ a/tomcat5/src/org/netbeans/modules/tomcat5/resources/layer.xml Mon Feb 15 22:36:23 2010 +0100 @@ -48,6 +48,7 @@ + @@ -81,6 +82,7 @@ + @@ -114,6 +116,7 @@ +